News for hackers. Stuff that matters.
Re:Learn Lua in 15 Minutes (2013) by Pelic4n on Tuesday June 30, 2020 @08:07PM (#23696293)
Re:Learn Lua in 15 Minutes (2013) by ufo on Tuesday June 30, 2020 @11:12PM (#23697372)
This always seems to pop up in these discussions but I don't think I am terribly convinced by his argument. For example, he doesn't mention that option (c) is better than option (a) if you need to iterate backwards. In that case option (a) becomes option (b), which everyone can agree objectively sucks :)
Re:Learn Lua in 15 Minutes (2013) by pansa2 on Tuesday June 30, 2020 @11:45PM (#23697548)
Yes! Reverse ranges in Python are awkward for this reason. The reverse of `range(0, 5)` (i.e. [0, 1, 2, 3, 4]) isn’t `range(5, 0, -1)`, it’s `range(4, -1, -1)`.

I think it would be better if the end-points were “low” and “high” rather than “start” and “stop”, so the reverse of `range(0, 5)` would simply be `range(0, 5, -1)`.

Re:Learn Lua in 15 Minutes (2013) by bad-apple on Wednesday July 01, 2020 @04:50AM (#23699342)
I think Rust has another good alternative to this, although it might be cheating a little: you can just write (lo..hi).rev(). That way, the common case of going forwards is nice, and the case of going backward isn't much worse.