On Thu, Jan 23, 2003 at 02:00:01AM +0100, Martin Stjernholm, Roxen IS @ Pike developers forum wrote:
It'd be even better to make the new zero type not equal to zero and add a new constant nil or null or NULL for it. An uninitialized() function wouldn't be necessary.
Exactly my point. A constant that means that value is not initialized or explicitly deinitialized. This constant must not equals to 0 or anything else but itself. It should be possible to assign this constant to variable of any type, thus "deinitializing" it.
This way, any expression like:
(val = map[key]) != NULL will give correct result when, and only when the element indexed by key has been set to anything but NULL (including integer 0).
Setting an element of mapping, multiset or array to NULL should delete this element (thus eleminating the need of m_delete()). As of me, the code like:
map[key] = NULL; seems logical and I expect that element will be deleted.
NULL by itself should be evaluated as "false" in any logical operation.
Pros: we don't need additional function; we can easily check if the result is defined; we can delete elements in natural way (just by undefining them).
Cons: none yet, or? :)
Regards, /Al