On Saturday, 11 August 2012 at 09:26:42 UTC, Walter Bright wrote:
On 8/11/2012 1:30 AM, Era Scarecrow wrote:
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)
Not so easy. Suppose you pass a pointer to the variable to
another function. Does that function set it?
I suppose there could be a second hidden pointer/bool as part of
calls, but then it's completely incompatible with any C calling
convention, meaning that is probably out of the question.
Either a) pointers are low level enough that like casting; At
which case it's all up to the programmer. or b) same as before
that unless it's an 'out' parameter is specified, it would likely
throw an exception at that point, (Since attempting to read/pass
the address of an uninitialized variable is the same as accessing
it directly). Afterall having a false positive is better than not
being involved at all right?
Of course with that in mind, specifying a variable to begin as
void (uninitialized) could be it's own form of initialization?
(Meaning it wouldn't be checking those even though they hold
known garbage)