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

Kim Bruce kim at cs.pomona.edu
Mon Sep 26 15:16:28 PDT 2011


I would probably choose not to have an all-purpose "Nil" object, but instead create a new one for each type that needed one.  That way, each could be given any methods that we felt necessary (and those would be different for each application).  

I don't see any need for a special None type.  Can anyone enlighten me as to why we might need it?

Kim



On Sep 26, 2011, at 3:03 PM, James Noble wrote:

>> 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
> _______________________________________________
> Grace-core mailing list
> Grace-core at cecs.pdx.edu
> https://mailhost.cecs.pdx.edu/mailman/listinfo/grace-core



More information about the Grace-core mailing list