Null object: Difference between revisions

Content added Content deleted
m (→‎[[Undefined values#ALGOL 68]]: add "works with", fixed gramma and formatting.)
Line 25: Line 25:
In ALGOL 68 the NIL yields a name that does not refer to any value. NIL can never be
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]].
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;
<lang algol68>REF STRING no result = NIL;
STRING result := "";
STRING result := "";
Line 41: Line 47:
# Note the following gotcha: #
# Note the following gotcha: #


REF STRING var := NIL;
REF STRING var := NIL;
IF var ISNT NIL THEN print(("The address of var ISNT NIL",new line)) FI;
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
IF var IS REF STRING(NIL) THEN print(("The address of var IS REF STRING(NIL)",new line)) FI</lang>
</lang>
Output:
Output:
<pre>
<pre>
Line 54: Line 59:
The address of var IS REF STRING(NIL)
The address of var IS REF STRING(NIL)
</pre>
</pre>
NIL basically is an untypes REF (pointer) that does not refer anywhere.
NIL basically is an untyped '''ref''' (pointer) that does not refer anywhere.


ALGOL 68 also has EMPTY. This is a "constant" of size 0 and type VOID.
ALGOL 68 also has '''empty'''. This is a "constant" of size 0 and type '''void'''.
c.f. [[Roots_of_a_function#ALGOL_68|Roots of a function]] for two different
c.f. [[Roots_of_a_function#ALGOL_68|Roots of a function]] for two different
examples of usage.
examples of usage.
* EMPTY as an undefined argument to a routine.
* '''empty''' as an undefined argument to a routine.
* EMPTY as a routine return if no result is found.
* '''empty''' as a routine return if no result is found.
EMPTY is typically used to refer to am empty leaf in a tree structure.
'''empty''' is typically used to refer to am empty leaf in a tree structure.


Basically:
Basically:
* ALGOL 68's EMPTY is python's <code>None</code>,
* ALGOL 68's '''empty''' is python's <code>None</code>,
* ALGOL 68's VOID is python's <code>NoneType</code>, and
* ALGOL 68's '''void''' is python's <code>NoneType</code>, and
* ALGOL 68's NIL is python's <code>hash(None)</code>
* ALGOL 68's '''nil''' is python's <code>hash(None)</code>


=={{header|AmigaE}}==
=={{header|AmigaE}}==