Proposal : allocations made easier with non nullable types.

Daniel Keep daniel.keep.lists at gmail.com
Mon Feb 9 08:02:36 PST 2009



Frits van Bommel wrote:
> Daniel Keep wrote:
>> One option is the "turn everything into an expression" route.  This is
>> what Nemerle (think a functional superset of C#) did, and it's just
>> BEAUTIFULLY expressive.
>>
>>> X x = if( someCondition ) new SomeX(); else new SomeOtherX();
>>
>> Failing that, there's always this (note: didn't do a syntax check on
>> this :P):
>>
>>> X x = ({if(someCondition)
>>>     return new SomeX();
>>>     else return new SomeOtherX();})();
>>
>> Or something to that effect.
> 
> Like this?
>     X x = (someCondition) ? new SomeX() : new SomeOtherX();
> 
> *Much* preferred to delegate trickery, I'd think...

Replace "new SomeX();" with two statements.

  -- Daniel



More information about the Digitalmars-d mailing list