Open macabeus opened 6 years ago
I don't think it is feasble as this, and would require a LOT of plumbing.
In addition there is an ambiguity if you consider:
var a, b = [1, 2, 3]
what should be the value of b
? 2
or [2, 3]
then it make ambigus: var a, b = [1, 2]
since it should make b
equals to either 2
or [2]
Anyway if we consider var a = [1]
to still be valid then the only sane consideration is to make:
var a, b = [1, 2, 3]
with b = [2, 3]
which deafeat the purpose of your suggestion ...
I agree it is nice to have support for multiple return values, but not with this syntax.
Some languages, such Python, Swift, Lua and JS, support multiple assignment. For example:
In Wren, I think that
should be a syntax sugar for
It is useful to add it in Wren, especially to handle function with multiple returns:
instead of
Edge case
What to do if have a different mount on right and left side? Each language have a different behavior:
I don't know what the ideal behavior to use in Wren. Each way has a different advantage:
Assignment and Setter
Wren has assignment for variables and setter for property. What to do in this situation?