[Bro] appending to a vector

David Mandelberg david at mandelberg.org
Wed Jun 19 15:13:11 PDT 2013

On 2013-06-19 18:00, Siwek, Jonathan Luke wrote:
> On Jun 19, 2013, at 11:14 AM, David Mandelberg <david at mandelberg.org> 
> wrote:
>> What's the recommended way to append to a vector? The documentation
>> says vectors are like tables, so I tried the below code, but it 
>> gives
>> some errors.
>> const foo: vector of double = vector() &redef;
>> redef foo += {
>>     [|foo|] = 42.0
>> };
> Appending to a vector can't currently be done w/ redef, but I don't
> think it would be difficult to implement if you want to add a ticket
> to the tracker.

I got number 1024 :D


>> Maybe there's a better way to do what I want without vectors. I have 
>> a
>> somewhat complex record type and I want to store multiple records of
>> that type in a container of some sort. I want to be able to iterate 
>> over
>> the container, but I don't care about order (vector) or uniqueness
>> (set). When I tried using sets, I got the error below, so I switched 
>> to
>> vectors.
>> internal error: over-ran key in CompositeHash::RecoverVals
>> Aborted
> Can you give an example script that reproduces that (create a
> bug/ticket for it) ?

If I can reproduce it, I'll file a bug.

>> I thought normal assignment to a const variable was supposed to 
>> fail. Isn't that a bug?
> I agree that it shouldn't be allowed, but just to explain how it's
> currently working:  the const applies to the variable, not the value
> bound it.  So you can't assign further values to the const variable,
> but its value may still be mutable depending on its type.


David Eric Mandelberg / dseomn

More information about the Bro mailing list