logoalt Hacker News

briancrtoday at 5:48 PM0 repliesview on HN

Yeah this is why the syntax is customizable.. maybe it’s not optimal.

The example I gave was strange and I’ll have to change it. Not sure what I was trying to show there. The basic syntax is just:

for counter in <1, 5> print(counter)

backfor counter in <1, 5> print(counter)

It’s not overloaded because ‘for’ is basically a macro, expanding to ‘iterate, increment counter, break on counter > 5’ where ‘>’ is hard-coded. If ‘for’ was a fundamental operator then yes, there would be a step option and it would be factored into the exit condition.

You’ve got me thinking, there’s probably a way to overload it even as a macro.. hmmm…