Remix.run Logo
9rx 7 months ago

> With conclusion I meant you claiming that go returns multiple values because a function also takes multiple values.

That remains the most reasonable explanation. There is no legitimate reason for functions that accept multiple arguments but only return one argument. That defies the very nature of what a function is.

C made a mistake, but that is not a good reason to copy it. It also made a mistake around memory management. You wouldn't copy that in a modern language either, would you?

> A map access is not even a function call.

Theoretically it is, albeit with unique syntax. However, importantly, it establishes the concept of multiple returns in the language. Once the syntax for multiple returns is worked out, there is no reason to not extend that to functions proper.

But the most likely reason it was added was not because of some specific reason, but because it would be strange without. It is not like Go is the only language that has that feature. It was already an accepted paradigm.

the_gipsy 7 months ago | parent [-]

Rust, and other modern languages, have tuples. So a single return value is effectively sufficient.

I refuse to believe that go added MRV for some esoteric reason. In practice it just makes up for the lack of tuples and sumtypes (errors mostly). It also would stand sharply against every other design decision (or accident) that go has made.

MRV also lacks functors in contrast to tuples.