Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why languages do not allow multiple return values? [closed]

Tags:

return-value

In languages like C which supports pointer operation, you can easily get multiple values from a procedure. But in languages like Java, it is a pain if you actually need to get multiple return values. (Using an object to wrap multiple values is bad)

In my experience, allowing multiple values returned can help improve software engineering--more flexible to organise procedure invocation, etc. But why there are so many languages that do no allow returning multiple values? I am interested to know the reasons. Thank you very much.

like image 675
qinsoon Avatar asked Jun 19 '26 12:06

qinsoon


1 Answers

Could be because many of the designers of these languages have strong math backgrounds and in math a function can have multiple input parameters but (almost always) only a single output value.

Also, it keeps code understandable and standardized to some extent.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!