Undefined values: Difference between revisions
Content added Content deleted
Line 844: | Line 844: | ||
Native storage types work under different rules, since most native types cannot represent failure, or even undefinedness. Any attempt to assign a value to a storage location that cannot represent a failure will cause an exception to be thrown. |
Native storage types work under different rules, since most native types cannot represent failure, or even undefinedness. Any attempt to assign a value to a storage location that cannot represent a failure will cause an exception to be thrown. |
||
=={{header|Phix}}== |
|||
Phix has a special unassigned value, that can be tested for using object(). (There is no offical way to "un-assign" a variable, though you could fairly easily do so with a bit of inline assembly.) |
|||
<lang Phix>object x |
|||
procedure test() |
|||
if object(x) then |
|||
puts(1,"x is an object\n") |
|||
else |
|||
puts(1,"x is unassigned\n") |
|||
end if |
|||
end procedure |
|||
test() |
|||
x = 1 |
|||
test()</lang> |
|||
{{out}} |
|||
<pre> |
|||
x is unassigned |
|||
x is an object |
|||
</pre> |
|||
=={{header|PHP}}== |
=={{header|PHP}}== |