A compromise would be a block:
accum session_counter <- 0, lesson_counter <- 0 do
...
end
It has benefits from both approaches:
- The block helps limit the scope of where the variables are used, so we worry less about large functions
- No additional syntax noise such as
@@(although that can be a cons as usage is less clear)
It also helps keep the theme that all of for, with, and then accum are actually monads (but let’s not call them that
).
Of course, the other option is to introduce the accumulators directly into comprehensions, as others suggestions:
list = [1, 2]
for val <- list, binding: [a: 0, b: 1] do
a = a + val
b = b + val
end
But the comprehension syntax is already quite overloaded, unfortunately, and different enough to add to the confusion (imo)






















