RE: [WebIDL] enum

Hi Ian,

>>I'd be even happier to have a real enum, though, so that type-checked
>>languages could get real type checking there. It would have to translate
>>to constants in JS of course.
This would work for me as well.

Thanks,
Marcin

Marcin Hanclik
ACCESS Systems Germany GmbH
Tel: +49-208-8290-6452  |  Fax: +49-208-8290-6465
Mobile: +49-163-8290-646
E-Mail: marcin.hanclik@access-company.com

-----Original Message-----
From: Ian Hickson [mailto:ian@hixie.ch]
Sent: Tuesday, November 24, 2009 1:33 PM
To: Marcin Hanclik
Cc: public-script-coord@w3.org
Subject: Re: [WebIDL] enum

On Mon, 16 Nov 2009, Marcin Hanclik wrote:
>
> To facilitate the comprehension of the interfaces specified in WebIDL, I think we need to have some way of specifying enumerated values.
> At present we define constants and associate them with the attributes in the prose.
> E.g. in HTML5 we have:
>
>   const unsigned short NETWORK_EMPTY = 0;
>   const unsigned short NETWORK_IDLE = 1;
>   const unsigned short NETWORK_LOADING = 2;
>   const unsigned short NETWORK_NO_SOURCE = 3;
>   readonly attribute unsigned short networkState;
>
> media . networkState
> Returns the current state of network activity for the element, from the codes in the list below.
>
> To ease the process of comprehension of the interfaces, we could have e.g.
>   [EnumFor=networkState]
>   const unsigned short NETWORK_EMPTY = 0;
>   [EnumFor=networkState]
>   const unsigned short NETWORK_IDLE = 1;
>   [EnumFor=networkState]
>   const unsigned short NETWORK_LOADING = 2;
>   [EnumFor=networkState]
>   const unsigned short NETWORK_NO_SOURCE = 3;
>
>   readonly attribute unsigned short networkState;
>
> Alternatively WebIDL could have the "enum" keyword with some specific syntax.
> The realization of this functionality does not, however, matter as much as the need to have it specified.

Purely from a human-readability perspective, I find the current terse text
with the constant immediately before the attribute, possibly annotated
with a comment, to be clearer than having [EnumFor=...] before each
constant. The latter is a lot harder to read, at least as written above.

I'd be even happier to have a real enum, though, so that type-checked
languages could get real type checking there. It would have to translate
to constants in JS of course.

--
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

________________________________________

Access Systems Germany GmbH
Essener Strasse 5  |  D-46047 Oberhausen
HRB 13548 Amtsgericht Duisburg
Geschaeftsfuehrer: Michel Piquemal, Tomonori Watanabe, Yusuke Kanda

www.access-company.com

CONFIDENTIALITY NOTICE
This e-mail and any attachments hereto may contain information that is privileged or confidential, and is intended for use only by the
individual or entity to which it is addressed. Any disclosure, copying or distribution of the information by anyone else is strictly prohibited.
If you have received this document in error, please notify us promptly by responding to this e-mail. Thank you.

Received on Tuesday, 24 November 2009 12:52:29 UTC