Replies: 6 comments 4 replies
-
|
Beta Was this translation helpful? Give feedback.
-
Thanks for flagging those others. My plan is to implement Even given that, I'd still rather that |
Beta Was this translation helpful? Give feedback.
-
Well, rats - I looked into the But I'd still like to get rid of |
Beta Was this translation helpful? Give feedback.
-
Note that, to my understanding, Specifically when a table has attributes, I think these are bound to the instance and will be wiped by assigning an empty table. To give an example, when running the following script...
no output will occur on stdout. When removing the table assignment, the expire_func is called. |
Beta Was this translation helpful? Give feedback.
-
Delete to remove all elements of a vector, table or set will be in Zeek 7.0. |
Beta Was this translation helpful? Give feedback.
-
That's the current semantics, as best as I can tell, and I'm fine with
that - but wanted to confirm before I fix this for this month's script
optimization.
I did not think about this :-/
Delete with an IndexExpr will remove the element, delete on a NameExpr will
clear it.. that's the implementation. But with your example and thinking
about the work-around, realize this is somewhat subtle/quirky/asymmetric.
```
# This can be used to clear the sub-table, while delete tbl[3] removes it.
local e = tbl[3];
delete e;
# ...this continues to work
clear_table(tbl[3]);
```
I don't think we can/should change the IndexExpr delete to be yield-type
dependent. Given past behavior, that would be more surprising. Only thought
is maybe special syntax like `delete tbl[]` and then `delete[3][]`? I see
that awk implements multi-dimensional array/table via string-concat of
indices, so can't use something from there as a model :-/
|
Beta Was this translation helpful? Give feedback.
-
We have a BiF,
clear_table()
, that clears the contents of a table in situ. Normally you can do this just by assigning an emptytable()
constructor to the table you want to clear, but the BiF is solving a problem where the table is available only by shallow-copy, as an argument. The one use in the standard scripts is here:zeek/scripts/base/protocols/dns/main.zeek
Line 200 in cc646f6
I'd like to deprecate the BiF and replace it with expanded semantics for the
delete
statement: if you give it an entiretable
orset
, e.g.delete tbl
, it clears it (keeping the attributes). This matches functionality thatawk
provides (FWIW, it was the inspiration behind Zeek having adelete
statement).Why do I care? Because I'm working on a fix/improvement for script optimization, for which it's very helpful to know that none of our BiFs alter script-level non-
opaque
state. AFAICT, this is the only BiF that does so.Beta Was this translation helpful? Give feedback.
All reactions