a tree structure with Bro records -- traversal w/ callback (FYI)

Thanks for the tip -- I have built my tree as you suggest, storing
nodes in a table and managing the hierarchy simply w/ non-recursive
key references stored in each node.

Now I would like to create a function to walk my tree that takes a
callback function to performn some arbitrary computation on each node
as the tree is traversed. What I'd like is the ability to do the
following:

function callback( i : count ) {
    print fmt("i: %d", i);
}

function caller( f : function(j:count) ) {
    f(13);
}

event bro_init() {
    caller( callback );
}

... but as you will see, lots of type clashing errors are generated
for this code. I have had success defining a global variable for the
callback function and using 'redef' to change its value, but that will
only allow one value for the callback per bro invocation.

AHA! While writing this message, I have discovered the problem -- the
function callback signature and its corresponding function argument
signatures must match *exactly* -- including the argument names. In
the above case, the "i" and "j" cannot be different, they must be the
same. The corrected version of the above would be

function callback( i : count ) {
    print fmt("i: %d", i);
}

function caller( f : function(i:count) ) {
    f(13);
}

event bro_init() {
    caller( callback );
}

.. which prints "i: 13" to stdout. Like I said in the subject, just an FYI.

Thanks,
Mike

signatures must match *exactly* -- including the argument names. In
the above case, the "i" and "j" cannot be different, they must be the
same. The corrected version of the above would be

Yeah, that's something stupid from day-one when I first introduced functions
that I've never gotten around to fixing. Sorry about the time spent puzzling
this out :-(.

    Vern