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
{{ message }}
Repository navigation
[BUG] for loop don't allow several assignments in next #448
main: () = {
(copy a := 0, copy b := 0)
//for "abc" next a++ do (i) { //ok
for "abc" next { a++; b++; } do (i) { //error
//for "abc' next a do (i) { //unused a
std::cout << i << a << b << '\n';
}
}
main: () = {
(copy a := 0, copy b := 0, next :=:()={ a&$*++; b&$*++; })
for "abc" next next() do (c) {
std::cout << c << a << b << '\n';
}
}
First attempt
```
main: () = {
a:=0; b:=0;
l := :() = { a&$*++; b&$*++; };
for "abc" next l() do (c) {
std::cout << c << a << b << '\n';
}
}
```
Thanks for idea from here, https://github.com//issues/432 currently lambda cannot be declared inside `next`
main: () = {
(copy a: = 0, copy b: = 0)
for"abc"next (a++, b++) do (i) {
std::cout << i << a << b << '\n';
}
}
Cpp2 generates this:
automain() -> int{
{
auto a = 0;
auto b = 0;
{ autoconst& cpp2_range = "abc"; for ( autoconst& i : cpp2_range ) { do {
std::cout << i << a << b << '\n';
} while (false); (++a, ++b); }}
}
}
Activity
realgdman commentedon May 11, 2023
Temporary workaround was found
First attempt
``` main: () = { a:=0; b:=0; l := :() = { a&$*++; b&$*++; }; for "abc" next l() do (c) { std::cout << c << a << b << '\n'; } } ```msadeqhe commentedon May 11, 2023
The example should be written like this:
main: () = { (copy a: = 0, copy b: = 0) for "abc" next (a++, b++) do (i) { std::cout << i << a << b << '\n'; } }Cpp2 generates this:
realgdman commentedon May 11, 2023
Well I should have guessed. Even this works.
for "abc" next ( a++, b++, std::cout << a, foo()) do (c)
JohelEGP commentedon May 11, 2023
See #449 (comment). It may work by accident.