- From: Jason White <jason@jasonjgw.net>
- Date: Sat, 1 Jun 2013 11:11:57 +1000
- To: public-indie-ui <public-indie-ui@w3.org>
As currently drafted, the User Contexts spec offers a ValueForKey() operation that returns a value of type DOMString, which in turn is a string representation of a value of an underlying type. The type represented is specified in the description of each key. I see several potential problems with this arrangement. 1. The string representations are not defined anywhere in the spec (perhaps this could be done by referring to an appropriate standard). 2. The type of the return value can only be checked at run-time; there is no compile-time type checking available. 3. Every access to a return value requires a type conversion from DOMString to the appropriate type. Alternatives a. Use a union type as the return value. This avoids conversions, presumably, but it doesn't provide good type checking. It also constrains the available types in advance, of course. b. Define an operation for each key and group the different categories of keys into interfaces appropriately, i.e., each query would be a method call and a value of the appropriate type would be returned in each case. Other options? Error handling should also be considered, including the case in which the value isn't available because the user has denied permission to retrieve it. Perhaps the solution here is to define an exception (I've been looking at WebIDL, which provides for these).
Received on Saturday, 1 June 2013 01:12:27 UTC