Undefined values: Difference between revisions

Content added Content deleted
No edit summary
(Explained Oz.)
Line 48: Line 48:
{}.c == null
{}.c == null
</lang>
</lang>

=={{header|Oz}}==
A program that uses an undefined variable does not compile.
However, variables can be "unbound" or "free". If a program tries to read such a variable, the current thread will be suspended until the variable's value becomes determined.

<lang oz>declare X in

thread
if {IsFree X} then {System.showInfo "X is unbound."} end
{Wait X}
{System.showInfo "Now X is determined."}
end

{System.showInfo "Sleeping..."}
{Delay 1000}
{System.showInfo "Setting X."}
X = 42</lang>

Explicitly checking the status of a variable with <code>IsFree</code> is discouraged because it can introduce race conditions.


=={{header|Perl}}==
=={{header|Perl}}==