The problem with loops is that, with only a handful of exceptions, they necessitate operating on mutable logic. Many languages get by without them, and I think while operating in an expression context it can be good to not have access to them. Instead, functions such as .map()
, .filter()
, and .reduce()
can be used (though I'm not actually a fan of .reduce()
). Though, if we think loops are valuable as expressions, I'm open to discussing it.
And yes, do ... in
is indeed a hazard. I'm currently running with the following syntax instead:
const result = (
with x = getX()
with y = getY()
with z = x + y
do processZ(z)
)