3 ms·
This is a common problem in languages which allow the use of "not set" or "not found" indicators as an rvalue, which (sadly) is most of them. Put another way, P
by zbentley 8y ago
This is a common problem in languages which allow the use of "not set" or "not found" indicators as an rvalue, which (sadly) is most of them. Put another way, Python's 'None' or Perl's 'undef' conflate the notion of 'something which has never been set' with the bottom (null) value, aka. the notion of 'the thing here is empty or not useful/usable'. That's a sad conflation to make because it confuses temporal/procedural effects (what has previously been done to this variable?) with contents (does this variable contain a usable value?)
JavaScript takes this to an even more ludicrous place by having both 'null' and 'undefined', putting them close to each other in the truth table, and allowing them both as rvalues.
Does anyone know of any procedural programming languages (or at least languages that encourage mutation, initialization-without-assignment, and rebinding) that have a) a special value for 'never accessed' and b) do not allow that value to be set, only read?
- gvx 8y agoPython's None is exclusively for 'the thing here explicitly doesn't exist' ('the thing here is empty' would be an empty collection and 'something which has never been set' is signified by raising an exception). I think that's the closest you're gonna get to the language you asked for in your last paragraph, because not being able to delete or unset a variable seems to be a serious design flaw to me.