logoalt Hacker News

antonvstoday at 2:44 PM1 replyview on HN

A language which truly treats an argument list as a tuple can support this:

    args = (a, b, c)
    f args
…and that will have the effect of binding a, b, and c as arguments in the called function.

In fact many “scripting” languages, like Javascript and Python, support something close to this using their array type. If you squint, you can see them as languages whose functions take a single argument that is equivalent to an array. At an internal implementation level this equivalence can be messy, though.

Lower level languages like C and Rust tend not to support this.


Replies

Pay08today at 4:15 PM

Rust definitely should. C++s std::initializer_list is a great tool and you wouldn't need macros for variadic functions anymore.