Jump to content

Null object: Difference between revisions

m
→‎[[Undefined values#ALGOL 68]]: add "works with", fixed gramma and formatting.
m (→‎[[Undefined values#ALGOL 68]]: add "works with", fixed gramma and formatting.)
Line 25:
In ALGOL 68 the NIL yields a name that does not refer to any value. NIL can never be
naturally coerced and can only appear where the context is [[ALGOL 68#strong|strong]].
 
{{works with|ALGOL 68|Revision 1 - no extensions to language used}}
 
{{works with|ALGOL 68G|Any - tested with release [http://sourceforge.net/projects/algol68/files/algol68g/algol68g-1.18.0/algol68g-1.18.0-9h.tiny.el5.centos.fc11.i386.rpm/download 1.18.0-9h.tiny]}}
 
{{works with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release [http://sourceforge.net/projects/algol68/files/algol68toc/algol68toc-1.8.8d/algol68toc-1.8-8d.fc9.i386.rpm/download 1.8-8d]}}
<lang algol68>REF STRING no result = NIL;
STRING result := "";
Line 41 ⟶ 47:
# Note the following gotcha: #
 
REF STRING var := NIL;
IF var ISNT NIL THEN print(("The address of var ISNT NIL",new line)) FI;
IF var IS REF STRING(NIL) THEN print(("The address of var IS REF STRING(NIL)",new line)) FI</lang>
</lang>
Output:
<pre>
Line 54 ⟶ 59:
The address of var IS REF STRING(NIL)
</pre>
NIL basically is an untypesuntyped REF'''ref''' (pointer) that does not refer anywhere.
 
ALGOL 68 also has EMPTY'''empty'''. This is a "constant" of size 0 and type VOID'''void'''.
c.f. [[Roots_of_a_function#ALGOL_68|Roots of a function]] for two different
examples of usage.
* EMPTY'''empty''' as an undefined argument to a routine.
* EMPTY'''empty''' as a routine return if no result is found.
EMPTY'''empty''' is typically used to refer to am empty leaf in a tree structure.
 
Basically:
* ALGOL 68's EMPTY'''empty''' is python's <code>None</code>,
* ALGOL 68's VOID'''void''' is python's <code>NoneType</code>, and
* ALGOL 68's NIL'''nil''' is python's <code>hash(None)</code>
 
=={{header|AmigaE}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.