Undefined values: Difference between revisions
Content added Content deleted
(→{{header|Java}}: You can print a null type) |
|||
Line 1: | Line 1: | ||
{{task}}For languages which have an explicit notion of an undefined value, identify and exercise those language's mechanisms for identifying and manipulating a variable's value's status as being undefined |
{{task}}For languages which have an explicit notion of an undefined value, identify and exercise those language's mechanisms for identifying and manipulating a variable's value's status as being undefined |
||
=={{header|ALGOL 68}}== |
|||
{{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]}} |
|||
Note: Some implementations (eg [[ALGOL 68C]]) also have a procedure named ''undefined'' that is called to indicated that the behaviour at a particular point in a program is unexpected, undefined, or non-standard. |
|||
<lang algol68>MODE X = REAL; |
|||
REF X x := NIL; |
|||
MODE U = UNION(COMPL, VOID); |
|||
U u := EMPTY; |
|||
IF x IS REF X(NIL) THEN |
|||
print(("x IS NIL", new line)) |
|||
ELSE |
|||
print(("x ISNT NIL", new line)) |
|||
FI; |
|||
CASE u IN |
|||
(VOID):print(("u is EMPTY", new line)) |
|||
OUT print(("u isnt EMPTY", new line)) |
|||
ESAC</lang> |
|||
Output: |
|||
<pre> |
|||
x IS NIL |
|||
u is EMPTY |
|||
</pre> |
|||
=={{header|C sharp|C#}}== |
=={{header|C sharp|C#}}== |