3 ms·
Python has enough vararg functions to make this not doable without coming up with some special-case syntax. There's a reason you don't have varargs in the Haske
by koenigdavidmj 7y ago
Python has enough vararg functions to make this not doable without coming up with some special-case syntax. There's a reason you don't have varargs in the Haskell world--currying isn't a special case, but rather happens any time you have multiple arguments. A three-argument function with type (A -> B -> C -> D) is actually syntactic sugar for a function that takes an A and returns...
a function that takes a B and returns...
a function that takes a C and returns...
a value of type D.
This is determinable by just looking at the number of arguments provided. But a variadic function, in a world with currying, would be a function that takes an argument, and returns...well, it might be a function to take another argument, and it might be the actual computation.
Even if we didn't have currying, we can't just use whitespace in a Python-like language. We don't know if (print) is actually a function call, or just referencing the function object (perhaps to pass it to 'map' or something). Your syntax needs to distinguish between those two cases.
- ferzul 7y agoi thought i disagreed with you, but then i realised you're referring to the possibility of a unary procedure call in python. but there are strict impure languages with white space function application. i suppose they handle the issue by using an object of a type with only one value. in principle, you could handle the issue by contrasting (print) with (print ()), with () a pseudo value only existing at syntax level. i'm not sure if white space function application carries it's own weight once we abandon partial application, so this feels like a contrivance to save a bursted balloon.
- eru 7y agoThere are varargs in Haskell, but they aren't as natural as in Python; and usually rely on various amounts of type level trickery. Implementing a vararg printf in Haskell is a popular enough exercise. A relatively common examples in practice is the testing library QuickCheck: your properties (ie tests) can take any number of arguments that the library fills with samples inputs.