4 ms·
I think it could be retroffited but would require a syntax to have a variable marked as being a tuple. If we look behind the curtains, go functions somehow ret
by aatd86 1y ago
I think it could be retroffited but would require a syntax to have a variable marked as being a tuple.
If we look behind the curtains, go functions somehow return tuples that are automatically unrolled into respective variables, sometimes.
That's why if you have f(a, b, c){} and g() (b,c){} you can't do f(a, g()) currently.
It does not unroll it automatically for some reason here. The result remains in "tuple" form ?
I think it may leave some space to have tuples if needed.
In any case, I don't see it as technically infeasible.
- dontlaugh 1y agoGo functions don’t actually semantically return tuples, multiple return is part of the calling convention. It can be changed more easily than in other languages because everyone statically links, but it’s not trivial.
- aatd86 1y agoThey are not first class in the language but I think I remember the compiler having them as a representation for some language objects. Maybe https://go.dev/src/go/types/tuple.go https://go.dev/src/go/types/tuple.go
- pjmlp 1y agoWhile it is the default, dynamic linking has been supported in Go for quite a while.
- eru 1y ago> I think it could be retroffited but would require a syntax to have a variable marked as a being tuple. Like Perl's sigils? Or PHP's distinction between 'normal' variables with a $ and variables of function type which have no marking but are case insensitive?