4 ms·
The same argument applies to functions with multiple parameters, and yet most languages support multiple arguments rather than requiring one to use tuples.
by plorkyeran 13y ago
The same argument applies to functions with multiple parameters, and yet most languages support multiple arguments rather than requiring one to use tuples.
- zanny 13y agoThough to some degree when you consider, say, python, the call syntax foo(x,y) and a tuple (x,y) look very similar, and behave like a map.
- deleted 13y ago[deleted]
- cafard 13y agoFor that matter, Ada used parentheses for array offset and for function calls, on the grounds that both map between values. Others, of course, say that this was really because DOD owned so many old keyboards without square braces.
- asolove 13y agoBut, that is a bit different. Function calls return one value because expressions evaluate to one value. Functions accept multiple arguments the same way any expression can be made up of multiple values. What the formal parameters allow is a kind of destructuring assignment to give new names to values. (This is especially clear in eg. Clojure.)
- shiro 13y agoReturning from a function is calling the caller's continuation. If functions take multiple parameters, why not continuations? Semantically I think it's a lot cleaner to make every function 1-in 1-out. Multiple parameters are just a disguise of passing a tuple. In dynamically typed languages, though, it's difficult to make it efficient.