[Bro-Dev] changing Notice::policy mechanism

Siwek, Jonathan Luke jsiwek at illinois.edu
Fri Nov 2 09:06:14 PDT 2012


>>> function foobar(a: count) &priority=5
>>> 	{
>>> 	local test = "nope";
>>> 	print test;
>>> 	}
>>> 
>>> function foobar(a: count) &priority=8
>>> 	{
>>> 	local test = "yup";
>>> 	print test;
>>> 	}

Adding the &multibody attribute to do this I think might work alright.  And I think it's not much to implement it -- I just did some quick hacks as a proof of concept and so far it didn't look like a problem.

> Those would inline into this…
> 
> function foobar(a: count)
>        {
>       	{
> 	local test = "nope";
> 	print test;
> 	}
> 	{
> 	local test = "yup";
> 	print test;
> 	}
> 	}
> 
> The only problem is that this doesn't currently work, but it begs the question… should it?

That probably should work, but it's also not related to implementing the proposed &multibody attribute for functions since the bodies are already parsed separately with different scopes and can then be internally stored as separate bodies/scopes, there's no need to do the mashing together under a common scope -- just keep them separate and iterate over the bodies according to priority.

This code already exists because of the similarity of functions and events, it's just that functions are only allowed multiple body definitions if they have &redef, and in that case, the later definition *replaces* earlier ones instead of being pushed on to the vector of bodies.

    Jon


More information about the bro-dev mailing list