Skip to content

Comment on Orange: A simple systems programming languageparent

Comments

What do you consider a for loop to be? The loop constructs called "for" that existed prior to C all just iterated through a numeric sequence with an optional step parameter. This was present in BASIC, ALGOL68 and Pascal.

The C for loop was designed by looking at an ALGOL-style for loop:

    FOR i FROM 1 BY 2 TO 3 WHILE i≠4 DO ~ OD
and trying to make the construct not tied to integer sequences (because such a specific construct would be out of place in C). The typical for loop, like the one in your comment, has a begin, end and increment parameter, just like the ALGOL example.

I assume you mean that you'd prefer some kind of for-each kind of loop, but in order to support that, a language needs a formalized concept of iterators, which may be out of scope for the project.

The for in my example (which is directly from the linked page) is a while loop written in a compact form. My complaint is that a for loop should name a definite end number without a condition. I think the WHILE portion of the ALGOL-style for loop you give is problematic (and given the example unused). Having a condition as an end condition is error prone.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.