Variadic function: Difference between revisions
Content added Content deleted
Line 21: | Line 21: | ||
''However'' a flexible array of tagged types (union) <u>is</u> permitted. This effectively |
''However'' a flexible array of tagged types (union) <u>is</u> permitted. This effectively |
||
allows the passing of strongly typed variable arguments to procedures. |
allows the passing of strongly typed variable arguments to procedures. |
||
⚫ | |||
main:( |
|||
PROC print strint = (FLEX[]STRINT argv)VOID: ( |
|||
⚫ | |||
FOR i TO UPB argv DO |
|||
CASE argv[i] IN |
|||
(INT i):printf(($d$,i)), |
|||
(STRING s):print(s), |
|||
(PROC(REF FILE)VOID f):f(stand out), |
|||
(VOID):print(error char) # print a "*" # |
|||
ESAC; |
|||
IF i NE UPB argv THEN print((space)) FI |
|||
OD |
|||
OD |
|||
⚫ | |||
print strint((new page, "Mary", "had", 1, "little", EMPTY, "...", new line)) |
|||
⚫ | |||
Output: |
Output: |
||
<newpage> |
<newpage> |
||
Mary had 1 little |
Mary had 1 little * ... |
||
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}}== |
=={{header|Common Lisp}}== |