[Bro-Dev] Meta-programming
Seth Hall
seth at icir.org
Thu Mar 21 08:54:23 PDT 2013
Let me start by saying that I have an actual use case for this in the measurement framework and I'm not just messing around. :)
function add_x(x: count): function(a: count): count
{
local tmp = function(a: count): count
{
# The 'x' variable ends up receiving the value of the same arity as my inner
# defined function instead of the value of the outer scope where 'x' is.
return a+x;
};
return tmp;
}
event bro_init()
{
local my_adder = add_x(5);
print my_adder(1); # hopefully would print 6, but it prints 2
local your_adder = add_x(100);
print your_adder(2); # hopefully would print 102, but it prints 4
}
Would this functionality working like I wish it did be difficult? It would make a very nice usability feature for the measurement framework when setting thresholds.
.Seth
--
Seth Hall
International Computer Science Institute
(Bro) because everyone has a network
http://www.bro.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: Message signed with OpenPGP using GPGMail
Url : http://mailman.icsi.berkeley.edu/pipermail/bro-dev/attachments/20130321/a0b05f5a/attachment.bin
More information about the bro-dev
mailing list