delegate !is null

Saaa empty at needmail.com
Tue Sep 8 09:40:13 PDT 2009


>> The problem lies more in that I'd like to point to something which is not
>> there yet.
>> In the code 'c.method()' is not there yet, as c is null.
>> Maybe I should create a dummy object for c to point to in stead of null ?
>> That way I point the delegate to the dummy method and ignore it as long 
>> as
>> it is pointing
>> to the dummy method :)
>> The only drawback to this is that all objects I want to point the 
>> delegate
>> to,
>> need to somehow be convertable to the dummy type (interface/abstract 
>> class),
>> meaning it will be less flexible.
>
> Hm... I'm still confused.  Why not just set the delegate to null?  Why do 
> you need to have the delegate set to something?
It is for the gui. I give it a list of things to display.
And some of these things don't yet exist or can be deleted at any time.
I'd like it to display the last valid value.

>
> There are ways to do it, without having a class instance, but it is messy.
how messy? :D

Kind of related:
If you delete an object and later create a new object, what are the chances 
they are located on the
same place (deleted.ptr is new.ptr) ?
Does the garbage collector try to reuse locations or is it the opposite (or 
random) ? 




More information about the Digitalmars-d-learn mailing list