nit: What syntax for multiple returns?
For the definition site, things seems straightforward.
fun div(a, b: Int): Int, Int do
return (a/b, a%b)
end
The only question is about parentheses. In the current grammar, parentheses are mandatory in the return. But do we still force them to be mandatory in the signature foo(a,b:Int): (Int, Int)
?
For the client site, things become quite complex.
Do we force parenthesis in left-values?
(q, r) = div(7, 3) # or
q, r = div(7, 3)
Do we allow any kind of left-values? Especially when each left value in a multiple-return can have a distinct nature.
var q, var r = div(7,3)
var q
#...
q, var r = div(7,3)
x.foo.bar, y.baz["hello"] = div(7,3)
About this issue
- Original URL
- State: open
- Created 10 years ago
- Comments: 18 (18 by maintainers)
I don’t know if it’s to late but personally I prefer this syntax :
It seem very simple and intuitive to use! And I think this write is closer to the script syntax language.