Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Remove block argument from `loop` #6026
Introducing a block argument here was a mistake. Some people now want the loop index to be a different value. But the worse thing is that the loop index can silently overflow. And if we ever change the language to raise on overflow, this could eventually break some long running programs like servers (and that wouldn't be nice).
Apr 28, 2018
In the event anyone wants this feature back, I've put together a shard to replace this functionality. When the compiler eventually raises an exception on integer overflows, I'll patch my shard to handle that accordingly.
Sidenote: the ability for me to bring a small feature like this back is one of my favorite features of Crystal!
@Willamin I don't think this is helpful. That behaviour was removed for a reason. If you want to use a short cut to have looping block with an incrementing counter, it should have a different name at least.
What would that be? If there was a way to deal with that which would work for every use case, it could've stayed in the stdlib implementation.