Am 22.06.2012 12:52, schrieb Namespace:
On my machine it is the compiler that crashes => compiler bug.
Presumably it is having trouble with the circular alias this.

My first try to avoid this "circular" bug work with opDispatch. (As you
can read here on my blog: http://blog.rswhite.de/archives/741)
Now i had a new idea to save the Reference and call only these, it seems
that it works fine and with a lot less code.

(BTW, what is 'obj' in the invariant supposed to refer to?)
Just for testing. ;)

@Alex Rønne Petersen:
Thanks a lot, i use assert(obj); that seems to serve the purpose.
I hope in the next version "alias this" is more stable.
I am wondering why you wanna have Objects which will never be null. Use a contract which checks for null and you're done (another benefit, it get's removed if you compile with -release).

The only thing you gain from that is an Exception instead of a Segfault, where is the benefit, the app crashes in both cases and if you wanna handle those Exceptions, you can also check for null which is definitly faster and more readable (because it's clear to everyone).

There were a few discussion about adding a NullPointerException, personally I wouldn't care if there was one, but implementing this behaviour with a library is the wrong way imo. This spreads inconsistency over D, some use it others don't, beginners will be confused.

Btw. when developing, just start your program always with a debugger (shift+F9 instead of F9 for me, not a big deal), it will halt on a segfault and you can check why there is one.

Reply via email to