Jump to content

Undefined values: Difference between revisions

m
→‎{{header|Phix}}: added syntax colouring the hard way, phix/basics
No edit summary
m (→‎{{header|Phix}}: added syntax colouring the hard way, phix/basics)
Line 956:
 
=={{header|Phix}}==
{{libheader|Phix/basics}}
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-->
<span style="color: #004080;">object</span> <span style="color: #000000;">x</span>
 
procedure test()
<span style="color: #008080;">procedure</span> <span style="color: #000000;">test</span><span style="color: #0000FF;">()</span>
if object(x) then
<span style="color: #008080;">if</span> <span style="color: #004080;">object</span><span style="color: #0000FF;">(</span><span style="color: #000000;">x</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">then</span>
puts(1,"x is an object\n")
<span style="color: #7060A8;">puts</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"x is an object\n"</span><span style="color: #0000FF;">)</span>
else
<span style="color: #008080;">else</span>
puts(1,"x is unassigned\n")
<span style="color: #7060A8;">puts</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"x is unassigned\n"</span><span style="color: #0000FF;">)</span>
end if
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
end procedure
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
 
test()
<span style="color: #000000;">test</span><span style="color: #0000FF;">()</span>
x = 1
<span style="color: #000000;">x</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1</span>
test()</lang>
<span style="color: #000000;">test</span><span style="color: #0000FF;">()</span>
test()<!--</lang>-->
{{out}}
<pre>
7,820

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.