Type safety could prevent nuclear war

Adam D. Ruppe via Digitalmars-d digitalmars-d at puremagic.com
Thu Feb 4 17:14:05 PST 2016


On Thursday, 4 February 2016 at 22:57:00 UTC, tsbockman wrote:
> The first place entry is particularly ridiculous; is there any 
> modern language that would make it so easy to commit such an 
> awful "mistake"?

D allows that. This is why I recommend putting `static 
assert(foo.sizeof == expectation);` in code that interfaces with 
external things, like C code, or D .di stuff.

#include <math.h> /* sqrt */

that line is an interesting one too: the trick is depending on 
namespace pollution by the include. In D, you might write `import 
core.stdc.math : sqrt;` and make that misleading comment part of 
the code.... though then you could perhaps exploit that module 
bug (314?).



More information about the Digitalmars-d mailing list