Enums, bitfields and wl_arrays

Erik De Rijcke derijcke.erik at gmail.com
Thu Oct 15 01:18:14 PDT 2015


On Tue, Oct 13, 2015 at 9:27 PM, Auke Booij <auke at tulcod.com> wrote:
>
> I really don't understand this discussion. Is the claim that the usage
> of enums in java is problematic, because inserting a new value in an
> existing enum might change the index of later values, thereby creating
> an inconsistency?
>

Correct.


> If so, all I can say that clearly the object you want to associate
> with wayland-style enums is not whatever Java has invented for an
> "enum". The values that are associated to names inside wayland enums
> are very clear-defined, and if a language cannot safely couple names
> back to values, then that is a language that does not understand the
> concept of a variable. If this is a fundamental problem about Java
> enums, you better find a way around it, but I don't see how this is in
> any way a problem on the wayland side: there are enums, and enums
> contain names, and those names have values.
>

If wayland enums would not explicitly declare values, you'd have the same
problem in C. However since wayland enums do explicitly declare their
value, *and* because C allows you to override an enum 'internal value', you
don't have that problem here. Unfortunately, Sun in all it's infinite
wisdom decided that Java enum 'internal values' can not be overridden. Only
new 'properties' can be attached.


> But if this is indeed the issue you are discussing, then this must
> have already been a problem before the introduction of additional XML
> attributes.
>

Correct. My current Java bindings create a Java enum with the wayland enum
value as an additional property. If the order would change, that would be a
potentially breaking change.

Can we agree on the following? Until there is any firm specification
> of open/closed enums, every enum should be considered open, and
> although some legal values might be listed, others might not be, and
> some might only be legal sometimes.


Ok for me but it would be very nice to have the open/closed information ;)


> New values may be added (but not
> changed or removed) to protocol specifications without introducing any
> compatibility issues.
>

This is not clear for me. Compatibility issues for the current C bindings
or for all language bindings? If it's for all language bindings than this
might introduce a whole explosion of derived implicit specifications for
each language. Eg. the enum order in Java. Better would be to specify a
goal "no compatibility issues" and a set of form specifications eg. "the
order of an enum shall not be changed".


> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20151015/5ab4a1f0/attachment.html>


More information about the wayland-devel mailing list