W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2008

Re: [whatwg] WebIDL and HTML5

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Wed, 27 Aug 2008 20:05:28 -0400
Message-ID: <48B5EBC8.6000904@mit.edu>
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 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).



> Which languages include the value null in their string type?

I already mentioned Java and C/C++ earlier.  There are plenty of others.

Received on Thursday, 28 August 2008 00:06:13 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:26:11 UTC