Re: NULL value anyone?
- Posted by petelomax Mar 28, 2015
- 1516 views
Just as a point of order, dll.e defines
global constant NULL = 0
which is muddying the waters a bit, so as jimcbrown already did we should be using NOVALUE to discuss this matter.
Phix also has an internal NOVALUE, aka h4, which has the slightly different value #40000000 or #4000000000000000, but it's the same idea, being +/-1 MININT/MAXINT, and (in Phix) you can use it in inline assembly:
integer i ... #ilASM {mov [i],h4}
Not that I am convinced that has any significant merit. Note that when dealing with non-integers you would want additional test/decref/dealloc code to avoid memory leaks.
Anyway, while x = NOVALUE feels like it might be useful, after 10+ years of using this language I have yet to see any compelling examples, and things like return NOVALUE, myproc(NOVALUE) and s = {1,NOVALUE,3} have the potential to introduce serious technical challenges as well as significant performance degradation, not to mention making things harder to code, debug, and maybe even understand.
Looking at the return case in a bit more detail, assuming that
a = b
ought to issue a (fatal/recoverable/catchable) error when b is unassigned, how exactly is
function f() return NOVALUE end function a = f()
supposed to do anything different? And what happens when f returns b when it is unassigned? Does this help explain why Eu does not have such?
having an option to un-initialize a variable would be nice (isn't that what delete does?)
No, to answer your question at the end,
After the cleanup routines are called, the value of the object is unchanged, though the cleanup routine will no longer be associated with the object.
Pete