What about set
? And what about moving it into the KW list at the end?
for i <- [1, 2, 3], set: sum = 0 do
{i * 2, sum + i}
end
That way if there is already a sum
, it would be
sum = 0
for i <- [1, 2, 3], set: sum = sum do
{i * 2, sum + i}
end
Also, as a separate issue, (while consistent since plenty of other things do this in the language) I feel like without any type system implicitly returning the iterator value combined with the sum joined in a tuple is not intuitive. It would be nice to see syntax specifically for this form so that the implementation of it being returned as a tuple is not a common bug new users trip on. Creating a macro something like using(i * 2, sum + i)
for the for
return value would be best for readability and writability.