On 06/02/2019 21:00, Jon Siwek wrote: > On Wed, Feb 6, 2019 at 1:30 PM Vlad Grigorescu <v...@es.net> wrote: > >> I _think_ I like Seth's idea of records, but I'm still thinking it through. >> It would formalize a growing trend towards moving more parameters into >> records anyway. If we're worried about backwards compatibility, then maybe >> we have a built in version number in each record. Whenever fields are >> added/removed, or there are more subtle contextual changes, the version >> number could increase. > > Explicit versioning is a neat idea to maybe try expanding on. I'm not > quite sure how it would look for the user to, when they write their > code, make it explicit that they expect the semantics of the record to > match version XYZ.
If I get that right, this would mean that every record type comes with an individual version number, independent from the package or zeek version. While I can see that this allows to achieve backwards compatibility I am quite sure it will end in a complete mess. I expect the resulting code to be harder to write and to read, assuming that most of the records come with versioning constraints. Actually, I like Jon's solution most. From a coder's perspective, the only thing I have to keep in mind is that parameters are matched by name. If I want to rename I can fallback to matching by order. That said, I would guess renaming a parameter is not a critical use case. I cannot imagine a situation where I rely on that feature. For me, renaming parameters makes code harder to read if I am familiar with the original definition. One could even think about introducing syntactically explicit renaming of parameters (which would probably break backwards compatibility again). On 06/02/2019 02:40, Robin Sommer wrote: > The following would be even worst in terms of confusion: > > global my_event: event(a: string, b: string); > event my_event(b: string) > > Now I need to know if the language goes by order of parameters or by > parameter name. I can see that this might be confusing at first but I would argue that this is a one-time confusion. Versioned records in contrast would require me to think about their history every time I try to use a type. Jan _______________________________________________ zeek-dev mailing list zeek-dev@zeek.org http://mailman.icsi.berkeley.edu/mailman/listinfo/zeek-dev