W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2000

Usage of null

From: Martin v. Loewis <martin@loewis.home.cs.tu-berlin.de>
Date: Sun, 17 Sep 2000 16:33:39 -0400 (EDT)
Message-Id: <200009172033.WAA03513@loewis.home.cs.tu-berlin.de>
To: www-dom@w3c.org
In the DOM spec, many attributes are allowed to have a special value
'null', in addition to their normal values. This is an extension to
normal OMG IDL, where values normally cannot be null. Many programming
languages cannot properly represent

   readonly attribute long foo; // may be null

An object possessing the attribute foo typically can have only
integral numbers as values; the additional null value is not supported
eg. in C, C++, or Java. It *is* supported in languages where numbers
are objects (e.g. Python).

The only exception in CORBA are object references: Attributes of a
reference type may be null. Specifically, strings, or sequences,
cannot be null.

CORBA 2.3 adds the valuetype construct, which allows to wrap an object
around any value (called valuebox); this gives a null value to any
type. A string that may be null can be defined as

  valuetype DOMString sequence<unsigned short>;

In this type, the empty sequence (with zero elements) is different
from the null sequence.

I'd recommend that the DOM is carefully reviewed with that respect,
and as many occurences of null values are eliminated, possibly
suggesting use of empty strings instead.

For the remaining places, you may find that they are null objects,
which would be fine. Otherwise, the DOM should explicitly state the
intent behind null values, and leaving it up to the target language to
deal with it. Alternatively, value boxes may be used to indicate that
a specific type includes null.

If null values are allowed for string attributes, it should be stated
explicitly in which cases empty strings and in which cases null
strings are acceptable.

Received on Monday, 18 September 2000 10:20:03 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:07 UTC