4 ms·
NULL is certainly a mistake, but even more of a mistake is not allowing distinct states in variables. NULL is just another case of a state of a variable. Other
by axilmar 8y ago
NULL is certainly a mistake, but even more of a mistake is not allowing distinct states in variables.
NULL is just another case of a state of a variable. Other states are 1, 15, 0xffffffff, etc.
That mainstream languages don't handle this is the worst mistake of the computer industry.
- rusk 8y agoMost languages do. Java will always initialise a non-initialised value to NULL for instance (EDIT or 0 or false for primitives). It's simply a reality of how computers operate that when you allocate a piece of memory (a variable) it will have something in it that you'll need to clear or initialise. In this respect, NULL is doing you a favour.
- zxczxc111 8y agoOnly for field variables. Local variables most definitely have to be initialised by the programmer, otherwise it's a compiler error
- deleted 8y ago[deleted]