My Kingdom For ...

Janice Caron caron800 at googlemail.com
Thu Feb 21 15:10:45 PST 2008


On 21/02/2008, Ary Borenszweig <ary at esperanto.org.ar> wrote:
>  But programmers are used to use "==" for comparisons with null...
>  Another alternative would be for the compiler to rewrite "== null" as
>  "is null", always.

Yep. That works for me too.

Of course, what I'd /really/ prefer is a runtime check (in debug
builds only, of course) for all null dereferences. I see it as
basically the same as array bounds checking - for speed, you don't
want it in a final release, but during development, you sacrifice the
speed and let the compiler help out. That would be useful, because not
only would it catch ==null, but it would also catch .member and
.func(), and you'd get a nice error message telling what line of what
file threw the exception.

And while we're on the subject of random falling over, am I the only
one who gets infuriated by the occasional "Win32 Exception" halting a
program with no further explanation? They happen when the flow of
execution hits the bottom of a function without returning, when it's
supposed to return something. I'm surprised we can't catch those at
compile time, but even a nice D Exception throw at runtime (...again,
in a debug build only...) would be useful.



More information about the Digitalmars-d mailing list