- From: Boris Zbarsky <bzbarsky@MIT.EDU>
- Date: Wed, 27 Aug 2008 20:05:28 -0400
- To: Garrett Smith <dhtmlkitchen@gmail.com>
- CC: Web Applications Working Group WG <public-webapps@w3.org>
Garrett Smith wrote: > If I'm reading the right spec[1], OMG IDL defines the string type > string consisting of all possible 8-bit quantities except null. DOMString isn't an OMG IDL String. It's defined as [1]: valuetype DOMString sequence<unsigned short>; And no, I'm not sure you're looking at the right spec. The right thing would seem to be http://www.omg.org/docs/formal/02-06-39.pdf which says: <value_box_dcl> ::=“valuetype” <identifier> <type_spec> Section 3.9.2 of this document then says: It is often convenient to define a value type with no inheritance or operations and with a single state member. A shorthand IDL notation is used to simplify the use of value types for this kind of simple containment, referred to as a “value box.” In other words, the syntax above defines a kind of value type. Looking to http://www.omg.org/docs/formal/02-06-41.pdf to see what the semantics of value types are, we see the following (section 5.2): There are two kinds of value types, concrete (or stateful) value types, and abstract (stateless) ones. Note that DOMString is a concrete value type (since there is no "abstract" keyword in its definition). Section 5.2 goes on to say: Concrete (stateful) values add to the expressive power of (IDL) structs by supporting: ... * null value semantics Section 5.2.4.2 is even more explicit: In order to be expressive enough to describe arbitrary graphs, lattice, trees etc., value types support sharing and null semantics. Instances of a value type can be shared by others across or within other instances. They can also be null. This is unlike other IDL data types such as structs, unions, and sequences that can never be shared. Contrast this with the DOM1 DOMString definition, which is: typedef sequence<unsigned short> DOMString; This does not allow null values, since it's a sequence, not a new type. But again, the DOM2/3 definition is: valuetype DOMString sequence<unsigned short>; Which declares a new type which contains a sequence. The type is not _itself_ a sequence, but a container for a sequence. It can be null (which means doesn't contain any sequence, as far as I can tell from these specs). -Boris [1] http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#DOMString > Which languages include the value null in their string type? I already mentioned Java and C/C++ earlier. There are plenty of others. -Boris
Received on Thursday, 28 August 2008 00:06:13 UTC