Dylan 'nullable' types [Was: Close review of Language Overview whitepaper]
P T Withington
ptw at pobox.com
Thu Nov 15 14:02:55 PST 2007
On 2007-11-14, at 19:22 EST, Graydon Hoare wrote:
> (As far as I can tell -- not being a dylan hacker -- dylan doesn't
> even
> go as far as having a global sentinel type like nil)
The Dylan equivalent of a nullable type is a union of your type with a
singleton that acts as the sentinel. Most often a singleton of the
boolean false value is used. So there is a macro `false-or(<type>)`
that expands to `type-union(<type>, singleton(#f))`. This works for
any type other than a nullable boolean. Because any value other than
#f coerces to true in a boolean context, #f is very similar to nil.
I've never known anyone to need a nullable boolean. (Although I have
seen whacky es3 code that uses true/false/null as a sloppy 3-valued
enumeration -- with attended bug reports when null is passed expecting
it to behave like false.)
I must say, coming from Dylan, es3's undefined _and_ null seem like
overkill... but we're stuck with them now!
More information about the Es4-discuss
mailing list