Null object: Difference between revisions
Content added Content deleted
m (→[[Undefined values/Check#ALGOL 68]]: fix pre tag) |
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; |
|||
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: |
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 |
NIL basically is an untyped '''ref''' (pointer) that does not refer anywhere. |
||
ALGOL 68 also has |
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 a routine return if no result is found. |
||
'''empty''' is typically used to refer to am empty leaf in a tree structure. |
|||
Basically: |
Basically: |
||
* ALGOL 68's |
* ALGOL 68's '''empty''' is python's <code>None</code>, |
||
* ALGOL 68's |
* ALGOL 68's '''void''' is python's <code>NoneType</code>, and |
||
* ALGOL 68's |
* ALGOL 68's '''nil''' is python's <code>hash(None)</code> |
||
=={{header|AmigaE}}== |
=={{header|AmigaE}}== |