[dmd-internals] Asserts

David Held dmd at wyntrmute.com
Thu Nov 8 23:40:40 PST 2012


My personal policy is to assert early and assert often.  I see many 
functions taking pointer args and dereferencing them without checking 
for NULL first.  I know Walter likes to claim that dmd doesn't have any 
NPEs because he is a careful coder; but the fact is, he is not the only 
coder, and most functions don't explicitly document which arguments are 
allowed to be NULL and/or when.  Of course, it would be better for 
non-null arguments to just pass by reference, but fixing that would be 
quite disruptive in most cases (and outright infeasible in others, like 
void*).

However, I also know that asserting in every function is a religious 
issue for some, so I thought I would ask the dev community about 
thoughts on this topic.

Dave



More information about the dmd-internals mailing list