Without this, any test like:
if (map[key]) ...;
would behave incorrectly when map[key] is present but is integer 0.
This is EXACTLY what zero_type is there to solve. I.e use:
if(zero_type(map[key])) { key not present in map } else if(map[key]) { key present but value is zero } else { key present with a non-zero value }
/ David Hedbor
Previous text:
2003-01-22 15:26: Subject: Re: zero_type() & UNDEFINED and _typeof()
On Wed, Jan 22, 2003 at 07:05:02AM +0100, David Hedbor @ Pike developers forum wrote:
I don't exactly understand what you want to have - do you want something that means "NULL" but which isn't zero and if you do NULL == <zero or variable with value zero> to always return false?
Exactly. A completely "undefined" or "void" value, which is unique and no other value (including integer 0) should give true when comparing to. It will allow to make comparisions like:
somevalue == NULL
which will give "true" when somevalue is uninitialized or explicitly set to NULL, but which will give "false" when somevalue assigned something different from NULL.
Without this, any test like:
if (map[key]) ...;
would behave incorrectly when map[key] is present but is integer 0.
Name "NULL" isn't good choice for this case, I guess, perhaps "NIL" or "VOID" would be better ("UNDEFINED" is more clear, of course, but a bit long :)
Regards, /Al
/ Brevbäraren