You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ bin/007 -e='for [1, 2, 3, 4] -> x, y { say(str(x) ~ " and " ~ str(y)) }'
1 and 2
3 and 4
I suggest we remove this feature. Naming a single variable as the loop variable will still be allowed.
Why? A couple of reasons:
The feature has not seen much use. In examples/ we currently have 3 for loops. All of them name one variable.
As we near v1.0, I'm getting increasingly aware of what features we're going to need to support long-term.
It's simpler code to do just one variable.
Making it 0-or-1 variables would make it identical to how the if statement works.
It's a smaller surface area to expose to APIs and the like to do just one variable.
There's the ever-present little glitch wherein if the elements don't come out even in the end, you get None for some of them. Not a big problem, just slightly inelegant.
The way I'd want this to work, on reflection, is using subsignature matching. Here's some hypothetical code: for [[1, 2], [3, 4]] -> [x, y] { say(str(x) ~ " and " ~ str(y)) }. Under something like Implement type checking, orthogonally to everything else #33, we could even get nice structural checking for that. We couldn't with the current implementation.
Lastly, .map doesn't do that trick in 007 (and I don't think it should):
$ bin/007 -e='[1, 2, 3, 4].map(sub (e1, e2) { say(e1 ~ " and " ~ e2) })'
Sub with 2 parameters called with 1 arguments
The text was updated successfully, but these errors were encountered:
This currently works in 007:
I suggest we remove this feature. Naming a single variable as the loop variable will still be allowed.
Why? A couple of reasons:
examples/
we currently have 3for
loops. All of them name one variable.if
statement works.None
for some of them. Not a big problem, just slightly inelegant.for [[1, 2], [3, 4]] -> [x, y] { say(str(x) ~ " and " ~ str(y)) }
. Under something like Implement type checking, orthogonally to everything else #33, we could even get nice structural checking for that. We couldn't with the current implementation.Lastly,
.map
doesn't do that trick in 007 (and I don't think it should):The text was updated successfully, but these errors were encountered: