[dmd-internals] Asserts

Walter Bright walter at digitalmars.com
Fri Nov 9 15:11:03 PST 2012


On 11/9/2012 12:52 AM, Alex Rønne Petersen wrote:
> I don't hack on DMD much, but here's my take on the matter: Asserting
> every function parameter (where applicable of course) is good practice
> because it helps you catch bugs as early as possible. If you don't do
> this, you could end up with null pointers far into the program where
> you then have to spend time figuring out where it came from. This is
> especially nasty when e.g. building tree-like data structures and you
> can't just look at the call stack to figure out where you got a null
> pointer from.

That is true for some programs. It isn't true for dmd, where tracking down the 
source of a null pointer has never been particularly difficult.

There are a lot of refactoring things that dmd would benefit from. Adding 
assert(p!=NULL) everywhere will not add much value.


More information about the dmd-internals mailing list