[PATCH wayland] Add "enum" attribute to "arg" elements
jbinero at gmail.com
Mon Apr 20 08:54:59 PDT 2015
On Mon, 20 Apr 2015 at 09:03 Pekka Paalanen <ppaalanen at gmail.com> wrote:
> Also, adding the strict type information to the XML spec has no benefit
> for C, which is the de facto language for Wayland core developers. A C
> compiler also does not raise errors if you violate the rules. This and
> all the above are the likely reasons why adding the strict type
> information is not interesting, at least for me.
> Making the enum rules more strict has a possibility to break existing
> users, but to me it is unclear if the benefit would outweigh that
> con or the freedom.
> On the wire, an enum or bitfield is still just an uint (or int), and a
> buggy client or server may cause the other to receive illegal values.
> Do the strongly typed languages have checks against that? Can you
> define what happens if the value is illegal for an enum? Or do you have
> to write that check manually in any case?
> So, the big question here is: do we even want to have strict enum types?
It does indeed not provide any benefit for C, but if C is the only language
to be targeted, there is not much use in there being an XML specification
at all. It could've just been written out in C. I do agree that any changes
should be compatible with C.
I know in Rust, conversion from the `uint` to the `enum` type would have to
be done manually, and error checking happens here. It does stop the user
from passing illegal values to other servers however. It also makes it more
clear what `enum`s are to be used with which arguments, and enforces this.
I don't really see why adding that to the specification is an issue. If
some `enum` types aren't complete, as in, they aren't the only valid
values, then I see little value in having the `enum` in the specification
in the first place.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the wayland-devel