My Kingdom For ...

Dan murpsoft at hotmail.com
Thu Feb 21 16:18:50 PST 2008


Janice Caron Wrote:

> On 21/02/2008, Jarrett Billingsley <kb3ctd2 at yahoo.com> wrote:
> > "Janice Caron" <caron800 at googlemail.com> wrote in message
> >  God, have you even _used_ D?
> 
> I've written bits of Phobos, does that count?
> 
> D /does/ fall over in the circumstance I described. The only error
> message you see on the console is "Win32 Exception". No filename. No
> line number. It happened to me only yesterday, using D2.010.

Janice Caron Wrote:

> 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.

Yes it does do that.  Yes it's annoying.  Yes, there's a way to catch those exceptions using... try/catch or scope(error) or scope(exit) and figuring it out.

No, you're not the only one who finds the limited error messages annoying.  It's about the only time I get rage on the machine - when I get unidentified compiler errors.  I would much prefer a *real* debugger like IDA Pro if it had hooks to bind it to another program's GP faults and other such errors.

Lately I've been writing Walnut in assembler and leveraging some OS function to hook one of my functions as my error handler with the OS.  I use the function to dump all the registers - though it would be nice to see a few items of the stack too.

It makes debugging that kind of crap alot easier.  Assembler allows anything the machine can do - which means your code can screw up in more ways than a compiled language can.

It also means I can write a lexer in under 2.5kb of machine code that runs 8 times as fast as a D compiled switch-based lexer.  The next Walnut will blaze.  : )




More information about the Digitalmars-d mailing list