Re: String enum pattern

On Tue, Nov 30, 2010 at 7:45 AM, Anne van Kesteren <annevk@opera.com> wrote:
> Quite a number of APIs use string values instead of enums as they are more
> flexible when changes occur and such. E.g. this happens in canPlayType,
> quite a few things on the canvas API, and responseType in XMLHttpRequest.
>
> Should this pattern be endorsed by giving it some type in Web IDL?

I think it should, in part to kill the tyranny of C-style enum integer
values when folks design new APIs.

> This
> could make it easier to see from the IDL what values are allowed. And for
> attributes that allow setting the behavior of ignoring unknown values and
> such could maybe be defined centrally so that everyone using this pattern
> uses it in the same way.
>
>
> --
> Anne van Kesteren
> http://annevankesteren.nl/
>
>

Received on Tuesday, 30 November 2010 22:15:46 UTC