Null object: Difference between revisions

Content added Content deleted
No edit summary
(Added BBC BASIC)
Line 92:
In this example, we place nil on the stack, then perform an if-then-else (ifte) based on the value returned by the 'nil?' operator which returns true if top-of-stack (TOS) is nil. If TOS is nil, then we can be relieved, otherwise, the interpreter has gone absolutely haywire. The '<<' operator prints the selected string to STDOUT.
<lang babel>{ nil { nil? } { "Whew!\n" } { "Something is terribly wrong!\n" } ifte << }</lang>
 
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
A null object has a zero-value pointer.
<lang bbcbasic> DIM a(123)
DIM s{a%, b#, c$}
IF !^a() PRINT "a() is defined" ELSE PRINT "a() is not defined"
IF !^b() PRINT "b() is defined" ELSE PRINT "b() is not defined"
IF !^s{} PRINT "s{} is defined" ELSE PRINT "s{} is not defined"
IF !^t{} PRINT "t{} is defined" ELSE PRINT "t{} is not defined"</lang>
'''Output:'''
<pre>
a() is defined
b() is not defined
s{} is defined
t{} is not defined
</pre>
 
=={{header|C}}==