[Bro-Dev] set and vector operators

Vern Paxson vern at icir.org
Mon Apr 30 07:10:36 PDT 2018

> It especially feels weird to me if v + e and
> v += e are operations that perform something completely different.

Yeah, I hear you.  OTOH, I *really* would like a succinct way to say "add
this to the end of this vector", it's such a common idiom.

Robin and I discussed this a bit.  Our ultimate thinking was along the
lines of:

(1) likely there's no significant use right now of "v op e" semantics,
    given how none of us initially remembered it

(2) down the line such semantics could be quite handy if we start pushing
    on vector operations for doing statistical or ML computations (that's why
    I added "v op e" in the first place, inspired by how easy R makes these),

(3) "v += e" really is a nice append-to-vector idiom

(4) so how about we change "v op e" into something else to avoid the
    conceptual clash w/ v += e, while still having  it available for
    the possible uses in (2) above?

The question then was what would be the new "v op e" syntax.
The best we could come up with (which we both found not-too-awful) is
"vector(v op e)".  Wrapped in "vector(...)", the operation becomes the
current semantics (apply "op e" separately to each element of v).
"v op e" by itself would now be an error (which could point the user
at the "vector(...)" syntax as possibly providing what they're looking
for).  "v += e" would be "append e to v".

Do you buy that?


More information about the bro-dev mailing list