On Tue, Oct 13, 2015 at 4:35 PM, Nils Chr. Brause <nilschrbra...@gmail.com>
wrote:

> Hi,
>
> On Mon, Oct 12, 2015 at 11:08 AM, Pekka Paalanen <ppaala...@gmail.com>
> wrote:
> > On Mon, 12 Oct 2015 10:41:22 +0200
> > Erik De Rijcke <derijcke.e...@gmail.com> wrote:
> >
> >> Adding enum members is backward compatible for Java. If you compile
> against
> >> an enum with 2 members, and later on a new member is added, you can
> simply
> >> use the new version of the enum.
> >>
> >> Important however is that the order of old members do not change when
> new
> >> members are added.
> >
> > This is important. I don't think anyone has ever mentioned anything
> > like this before.
> >
> > We certainly have not expected the order to matter inside an <enum>
> > tag, since we require the value to be explicitly given. Not when you
> > are coming from C, anyway.
>
> In C++ the order doesn't matter either, since each entry has a defined
> value.
> I wonder why this is different in Java?
>
Because Java is not C/C++. In Java, enum values are unique by instance
alone. It does not have user 'defined' value(s) that make it unique. It
*can* have user defined properties (like any object) in addition to
 implicit compiler generated enum type specific properties. One of those
properties is it's "ordinal". Change the order of the enums and the ordinal
property will change, which can cause undefined behavior. Now you need to
wonder no more. :)
_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to