Null object: Difference between revisions
Content added Content deleted
(→{{header|Delphi}}: Adds Déjà Vu example) |
(BASIC | Applesoft BASIC) |
||
Line 107: | Line 107: | ||
<lang babel>{ nil { nil? } { "Whew!\n" } { "Something is terribly wrong!\n" } ifte << }</lang> |
<lang babel>{ nil { nil? } { "Whew!\n" } { "Something is terribly wrong!\n" } ifte << }</lang> |
||
=={{header| |
=={{header|BASIC}}== |
||
==={{header|Applesoft BASIC}}=== |
|||
caveat: http://qconlondon.com/london-2009/presentation/Null+References%3A+The+Billion+Dollar+Mistake |
|||
Applesoft has no built-in object system. The closest values to NULL or nil for each of the types are 0 for integers and floating point numbers, and "" for strings. There is also the NUL character: CHR$(0). One could create an object system using global variables and include a special value for NULL, but this is probably a mistake. |
|||
<lang ApplesoftBasic>TRUE = 1 : FALSE = 0 |
|||
NULL = TRUE |
|||
IF NULL THEN PRINT "NULL" |
|||
NULL = FALSE |
|||
IF NOT NULL THEN PRINT "NOT NULL"</lang>'''Output:'''<pre>NULL |
|||
NOT NULL</pre> |
|||
==={{header|BBC BASIC}}=== |
|||
{{works with|BBC BASIC for Windows}} |
{{works with|BBC BASIC for Windows}} |
||
A null object has a pointer with a value of zero or one. |
A null object has a pointer with a value of zero or one. |