Jump to content

Variadic function: Difference between revisions

Modula-3
m (use <var> for placeholders)
(Modula-3)
Line 505:
print_arg("hello", x, 12, fullcircle, currentpicture, down, identity, false, pencircle);
end</lang>
 
=={{header|Modula-3}}==
Modula-3 provides the built ins <tt>FIRST</tt> and <tt>LAST</tt>, which can be used with <tt>FOR</tt> loops to cycle over all elements of an array. This, combined with open arrays allows Modula-3 to simulate variadic functions.
<lang modula3> MODULE Varargs EXPORTS Main;
 
IMPORT IO;
 
VAR strings := ARRAY [1..5] OF TEXT {"foo", "bar", "baz", "quux", "zeepf"};
 
PROCEDURE Variable(VAR arr: ARRAY OF TEXT) =
BEGIN
FOR i := FIRST(arr) TO LAST(arr) DO
IO.Put(arr[i] & "\n");
END;
END Variable;
BEGIN
Variable(strings);
END Varargs.</lang>
 
=={{header|Objective-C}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.