Anonymous user
Variadic function: Difference between revisions
m
→[[Varargs#ALGOL 68]]: removed printf, space and new page procedure as these are not in ELLA and can be moved without detracting from the code sample.
No edit summary |
m (→[[Varargs#ALGOL 68]]: removed printf, space and new page procedure as these are not in ELLA and can be moved without detracting from the code sample.) |
||
Line 15:
''However'' a flexible array of tagged types (union) <u>is</u> permitted. This effectively
allows the passing of strongly typed variable arguments to procedures.
{{works with|ALGOL 68|Standard - no extensions to language used}}
PROC print strint = (FLEX[]STRINT argv)VOID: (▼
{{works with|ALGOL 68G|Any - tested with release mk15-0.8b.fc9.i386}}
FOR i TO UPB argv DO▼
{{works with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release 1.8.8d.fc9.i386}}
<pre>
(INT i):printf(($d$,i)),▼
main:(
(STRING s):print(s),▼
MODE STRINT = UNION(STRING, INT,
(VOID):print(error char) # print a "*" #▼
ESAC;▼
OD▼
);▼
▲ (STRING s):print(s),
print strint((new page, "Mary", "had", 1, "little", EMPTY, "...", new line))▼
(PROC(REF FILE)VOID f):f(stand out),
▲ ESAC;
IF i NE UPB argv THEN print((" ")) FI
▲ OD
)
</pre>
Output:
<pre>
</pre>
Also note that EMPTY (of type VOID) can be used to indicate missing or optional arguments.
|