[Bro-Dev] would a patch for #981 be accepted?
Robin Sommer
robin at icir.org
Fri Apr 19 12:02:40 PDT 2013
On Fri, Apr 19, 2013 at 18:15 +0000, you wrote:
> Provided that &default for tables is not supposed to modify table
> membership when accessing indices that don't exist,
I'm wondering if it should modify the table here. I can see how the
current behaviour is misleading, it violates the "principle of least
surprise". :)
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? The downside would be that if
somebody is relying on the current behaviour, he might access lots of
non-existing entries with the assumption that the table won't change
(i.e., he won't run into memory trouble).
An alternative would be to have the lookup return a copy of the
default, but not modify the table. With that "foo[0]$x = 0" would
still not work as expected, but at least it wouldn't have any
surprising side effects.
Robin
--
Robin Sommer * Phone +1 (510) 722-6541 * robin at icir.org
ICSI/LBNL * Fax +1 (510) 666-2956 * www.icir.org/robin
More information about the bro-dev
mailing list