Banjo

52 thoughts
last posted Nov. 9, 2015, 7:13 p.m.

25 earlier thoughts

0

Variadic function/methods (aka varargs)

A variadic function may accept a varying number of arguments. A language that supports variadic functions typically provides a list or array or iterator style interface to the arguments.

Varargs is a necessity if you want to write a delegating wrapper function that can take all its arguments and pass them along to some other function, possibly modifying them in some way.

I think the way to go here isn't new syntax - just have an intrinsic function that takes a function accepting a list of arguments and returns a function that puts all its arguments into a list and passes it through to the original one.

And for the reverse, provide a function that takes a function and a list of arguments and calls the function with that list. So:

varargs(f) = (...) -> f([...])
apply(f, args) = f(args expanded)

These functions cannot be written in the language itself.

26 later thoughts