Which D features to emphasize for academic review article
Era Scarecrow
rtcvb32 at yahoo.com
Sat Aug 11 01:30:21 PDT 2012
On Saturday, 11 August 2012 at 04:33:38 UTC, Walter Bright wrote:
> It's too bad that ints don't have a NaN value, but
> interestingly enough, valgrind does default initialize them to
> some internal NaN, making it a most excellent bug detector.
The compiler could always have flags specifying if variables
were used, and if they are false they are as good as NaN. Only
downside is a performance hit unless you Mark it as a release
binary. It really comes down to if it's worth implementing or
considered a big change (unless it's a flag you have to specially
turn on)
example:
int a;
writeln(a++); //compile-time error, or throws an exception on
at runtime (read access before being set)
internally translated as:
int a;
bool _is_a_used = false;
if (!_a__is_a_used)
throw new exception("a not initialized before use!");
//passing to functions will throw the exception,
//unless the signature is 'out'
writeln(a);
++a;
_a__is_a_used= true;
> Sadly, D has to map onto imperfect hardware :-(
Not so much imperfect hardware, just the imperfect 'human'
variable.
> We do have NaN values for chars (0xFF) and pointers (the
> villified 'null'). Think how many bugs the latter has exposed,
> and then think of all the floating point code with no such
> obvious indicator of bad initialization.
More information about the Digitalmars-d
mailing list