Re: [WebIDL] Remove string constants

On Fri, 09 Dec 2011 03:16:06 +0100, Cameron McCormack <cam@mcc.id.au>  
wrote:
> On 20/10/11 1:25 PM, Anne van Kesteren wrote:
>> Strings are intrinsically meaningful and therefore have no need for
>> constants in APIs for the platform. See XMLHttpRequest.responseType and
>> the <canvas> 2D API for examples. We should remove string constants so
>> people (e.g. public-web-perf) will not use them and introduce
>> inconsistent APIs.
>
> This sounds like an argument against string constants used for enum-like  
> values.  (We already convinced the Web Perf folks not to use string  
> constants in this case.)  What about something like:
>
>    interface A {
>      const DOMString HTMLNS = "http://www.w3.org/1999/xhtml";
>    };
>
> There are no string constants currently like this (a convenience because  
> people have difficulty remembering such strings), so my question is  
> whether we want to disallow them.

I would expect if we ever decide on some API that needs to work with the  
HTML/SVG/MathML namespaces we would use simple prefixes for them. E.g.  
"svg:svg", "html:a", etc. I'm personally not convinced at least that  
namespaces are a good use case for string constants. And since there is no  
such API currently we can always add this feature later may the need arise.


-- 
Anne van Kesteren
http://annevankesteren.nl/

Received on Friday, 9 December 2011 10:13:36 UTC