[Grace-core] [A Graceful Blog] Comment: "From Lancaster to Portland"

James Noble kjx at ecs.vuw.ac.nz
Mon Sep 26 15:03:47 PDT 2011


> The type None is uninhabited (as it's name suggests it should be).

yep that's fine...

> That's right.  If there is an object of type None, where None is the Top of the type (operations) lattice, then None does indeed inhabit every type.  So None can be asssigend to any variable.

so let's not do that.

>> Grace's types will distinguish between types that include nil, and types that don't. 
> 
> In which case, nil can't be of type None.  instead, it must be a "non object", as in Eiffel.   

I don't see why it can't be a singleton that inhabits it's own type, but otherwise offers no methods

type NilType = {
   brand Nil
}

def nil : NilType = object {
   brand Nil 
}

Then if we want a "nullable" Foo we just make the type  "Foo | NilType"  
which we could abbreviate to ?Foo...

(we probably need a better name than NilType)

> Isn't it annoying when one realizes that Bertrand is right ;-)

yes - and it's fair that in this design process I'm having more of an appreciation of his being right!

but this Singleton nil design doesn't seem to have the "Million Dollar" problem - or am I missing something?	

James


More information about the Grace-core mailing list