Re: dereferencing null - what about something like an check-scope?

2012-03-08 Thread dennis luehring
could it be a good idea to add something like an check-scope for 
modules,functions,etc. for typical fails to easy the detection?


wild-idea-and-syntax-list:
@CheckForNull
@CheckForNaN
@CheckForUnnormalFloat
...

 x.d

modul x

@CheckForNull // will introduce NullChecks for the complete module

..
..
..

-

int test()
{
@CheckForNull; // introduces Null-Checks on the function scope
@CheckForNaN; // introduces NaN-Checks on the function scope
   ...very long evil function...
}

total waste of compiler-developer time - or something to make D better 
in the end?








Re: dereferencing null - what about something like an check-scope?

2012-03-08 Thread David Eagen
I like the way Scala handles this with the Option class. None 
indicates no value which is equivalent to your null sentinal 
value but it is a value itself so it is always safe to use.


Combined with pattern matching and the orElse methods makes it 
very easy to use one variable that both stores the value and at 
the same time indicates whether it is valid or not. It's not two 
variables that could get out of sync.