[Bro-Dev] would a patch for #981 be accepted?

Vern Paxson vern at icir.org
Sun Apr 21 02:06:19 PDT 2013

> Can we change tables so that if &default is a non-constant, the first
> time one accesses a non-existing index, that slot gets assigned a
> deep-copy of the &default value?

I'm not a fan of this, as "&default is a non-constant" is a more nuanced
semantic notion (and could get messy for complicated constructors) than
the sort that I think language rules should draw upon.  Rather, my thinking
is that &default should apply to rvalues but not lvalues.  I believe (but
have not confirmed) that there's enough context in the parser to tell whether
the access is in an lvalue context or an rvalue context.  If so, then the
former shoud be a run-time error; if the user wants to update a value in the
table that's not already there, they need to first put the value in the table.

> An alternative would be to have the lookup return a copy of the
> default, but not modify the table.

That makes sense to me in any case.  In fact, I'm surprised this isn't
what already happens.


More information about the bro-dev mailing list