[M3devel] null type?

Rodney M. Bates rodney_bates at lcwb.coop
Wed Apr 24 20:59:40 CEST 2013


The main intended use for NULL in Modula-3 is not to declare variables
with it, but as an alternative label in a TYPECASE statement, for which
it is extremely convenient.  Otherwise, a NIL would always match the
first alternative, which is often not what you want.  Wrapping an
IF v = NIL THEN ... ELSE TYPECASE v OF ... around it would work, but be
more awkward to code.  Even more so if v were an expression involving
runtime computation that you really didn't want done twice, inviting
yet another wrapping by a WITH construct.

Somewhere in all the informal language description stuff, this is
spelled out, but it might take a lot of time to find it.

On 04/23/2013 10:09 PM, Hendrik Boom wrote:
> On Mon, Apr 22, 2013 at 04:29:06PM -0700, Darko Volaric wrote:
>> There's another aspect of the NULL type which should be considered here.
>> NULL is the complement of REFANY. Just as REFANY is the ultimate ancestor
>> of all reference types, NULL is the ultimate descendant of
>> all reference types. As a result any variable of a reference type can be
>> assigned NIL. Because of its unusual position, NIL is the only member of
>> type NULL, since no other value makes sense (which is why it's sometimes
>> called the "absurd" type).
>
> I think that terminology comes from the type lattice, and perhaps also
> from the propositions as types formalism.  The type that is properly
> "absurd" is the type with no elements at all, corresponding to the empty
> set.  A functino returning a value of this type can never return,
> because there are no values of that type.
>
> But since Modula 3 (as many other languages) has no truly empty type,
> the bottom of the type lattice is NULL, and I suppose its kind of
> plausible that it get called "absurd" for that reason.
>
> -- hendrik
>




More information about the M3devel mailing list