Variadic function: Difference between revisions

Line 21:
''However'' a flexible array of tagged types (union) <u>is</u> permitted. This effectively
allows the passing of strongly typed variable arguments to procedures.
MODE STRINT = UNION(STRING, INT, PROC(REF FILE)VOID, VOID);
main:(
PROC print strint = (FLEX[]STRINT argv)VOID: (
MODE STRINT = UNION(STRING, INT, PROC(REF FILE)VOID);
PROCFOR printi strintTO = (FLEX[]STRINTUPB argv)VOID: (DO
FORCASE argv[i] TO UPB argv DOIN
CASE(INT argv[i] IN):printf(($d$,i)),
(INTSTRING is):printfprint(($x1d$,i)s),
(STRINGPROC(REF sFILE)VOID f):printff(($xg$,s)stand out),
(PROC(REF FILE)VOID f):fprint(standerror outchar) # print a "*" #
ESAC;
IF i NE UPB argv THEN print((space)) FI
OD
);OD
);
print strint((new page, "Mary", "had", 1, "little", EMPTY, "lamb...", new line))
)
Output:
<newpage>
Mary had 1 little lamb* ...
Also note that EMPTY (of type VOID) can be used to indicate missing or optional arguments.
 
'''ALGOL 68''' does not have anything similar the keyword argument found in python.
 
=={{header|Common Lisp}}==