Calling members of null pointers-to-struct

Daniel Keep daniel.keep.lists at gmail.com
Sun May 6 16:20:08 PDT 2007



Tor Myklebust wrote:
> [...] (I still see no
> earthly reason why it *should* be invalid for nonvirtual functions --- 
> by extension, I see no earthly reason why it should be invalid for 
> methods in D structs.)
> 
> Tor Myklebust

I suppose one could argue that if it is allowable to call the method
with a non-existent instance for context, then there's no reason for
making it a member function in the first place.

Conversely, the vast majority of member functions are member functions
specifically *because* they require the context to be there, where the
assertion makes sense to have.

Of course, since all D ever gives is "ZOMG!  ASSERT ERRORZ!" and neither
tells you *where* it happened[1], or on what, it's not very useful for
more than telling you you screwed up somewhere.

Thank $DEITY for ddbg, though.

	-- Daniel

[1] Ok, it tells you the line of the function being called, but all
things considered, that isn't very useful.  Oh for the day we get
back-traces in the standard library :)

-- 
int getRandomNumber()
{
    return 4; // chosen by fair dice roll.
              // guaranteed to be random.
}

http://xkcd.com/

v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D
i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP  http://hackerkey.com/



More information about the Digitalmars-d mailing list