Re: Declaring and Checking Non-Null Types

Daniel Bonniot <[email protected]> Thu, 25 Mar 2004 02:14:07 +0100
Newsgroups gmane.comp.lang.nice.general
Message-ID <[email protected]>
>>If you want an instance of this class with finite memory usage, you
>>will need somebody who is their own ancestor... ;-)
>>    
>>
>
>Isn't that the usual alternative to using 'null'; create an Unknown PPP
>instance set to be their own parent and child?
>  
>
You can do that. I would find it cleaner to explicitely say that parent 
might not be known. The could be with using an option type (?PPP) or 
with an abstract class and a subclass UnknownPPP. But that's a design 
question for your program, unrelated to Nice's features...

>>But in general I agree that there is a need for recursive definitions
>>of values, which will have to be adressed. I would imagine something
>>like:
>>
>>  let papa = new Papa(child: bambino),
>>      bambino = new Child(parent: papa);
>>    
>>
>
>How would we instantiate self-referential objects without using option-types?
>  
>
In the same way:

  let x = new Thing(itself: x);

(at the bytecode level, the field 'itself' will initially be null. Only 
the language should guarantee that this is an implementation detail, 
without any visible effect, because the field cannot be used before it 
is properly initialized)

Daniel




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click