proposal: spec: direct access to tuple return values #60086
Labels
LanguageChange
Proposal
v2
A language change or incompatible library change
WaitingForInfo
Issue is not actionable because of missing required information, which needs to be provided.
Milestone
Currently, in Go, it is necessary to first assign the tuple returned by a function to a variable and then access the desired value from the variable. While this approach is readable and explicit, in some cases it may be convenient to directly access a specific return value from a function without having to assign it to a variable first.
For example, instead of writing:
It would be possible to write:
This more concise syntax would be especially useful when working with functions that return fixed-size tuples and whose return values are well-known. By allowing tuple values to be accessed directly from the function call, this change could improve the readability and clarity of Go code in some cases.
However, it is important to note that this change may make code less explicit in some cases, and may be harder to understand for developers less familiar with the Go language. Additionally, this proposal may be incompatible with the philosophy of the Go language to emphasize code readability and clarity over conciseness.
The text was updated successfully, but these errors were encountered: