null and type safety

Jarrett Billingsley jarrett.billingsley at gmail.com
Wed Nov 5 14:03:26 PST 2008


On Wed, Nov 5, 2008 at 9:33 AM, Bill Baxter <wbaxter at gmail.com> wrote:
> I didn't really get what you meant the first time either.  The thing
> about Delight's use of auto "to great effect" wasn't clear.   I
> assumed it was basically the same as D's auto inside an if, but I see
> now that it's not.  Looks like a run-time type deduction, even though
> its not really.  Kinda neat.

It's almost the same as D's variable-inside-an-if, with the addition
that you can use it to convert a nullable type to a non-null type.
Hence, in:

if(auto f = someFunctionThatCanReturnNull())

if someFunctionThatCanReturnNull returns an int*? (nullable pointer to
int), typeof(f) will just be int* (non-null pointer to int), since in
the scope of the if statement, f is provably non-null.



More information about the Digitalmars-d mailing list