4 ms·
What else would you want to do with them? Maybe in rare cases you'd want to structure them into an array or something, but the inverse isn't possible either [e.
by 9rx 1y ago
What else would you want to do with them? Maybe in rare cases you'd want to structure them into an array or something, but the inverse isn't possible either [e.g. func f(a, b, c int) -> f(<destructure array into arguments>)] so it isn't like it is inconsistent.
Perhaps what you are really trying to say is that multiple function arguments is insane full stop. You can pass in an array/tuple to the single input just the same. But pretty much every language has settled on them these days – so it would be utterly bizarre to not support them both in and out. We may not have known any better in the C days, but multiple input arguments with only one output argument is plain crazy in a modern language. You can't even write an identity function.
- throwawaymaths 1y agohave a single return value and if you really need MRV, return as a tuple type, which you could destructure. (this is what zig does)
- 9rx 1y agoBut then why accept multiple input arguments? Why not limit to a single argument, accepting a tuple where multiple arguments are necessary, for input too? Where multiple input arguments are present, not having multiple output arguments is just strange.
- throwawaymaths 1y agoExactly. Why not make multiple argument function call syntatic sugar over a ~single argument tuple call? https://ziglang.org/documentation/0.14.1/#call https://ziglang.org/documentation/0.14.1/#call
- 9rx 1y agoWhat would you need syntax sugar for? If you are going to support multiple arguments you may as well do it properly or don't do it at all. A poor bandaid because you fucked up tuples is not a quality that is to strive for.