The C-style FOR notation is important even if you don't program in C because you probably do program in one of its children (Java, JavaScript, Python, etc.) and they use the same notation:
for (i=1; i<11; i++) {do stuff}
and what it does is start with the initialization (i=1
) which can be any instructions, initializing multiple variables for example, then it computes the end test (i<11
), which can be any predicate, but it's not really an end test but rather a not-end test because True means to continue the loop, then if the test comes out True it runs the body of the loop, then it does the iteration command (i++
) then back to the end test. Note that this does FROM I = 1 TO 10, not TO 11, because 10 is the last value for which the end test is True.
Say what? It doesn't depend on recursion; it depends on giving RUN the iteration variable as an argument for the commands it runs. So I just changed RUN ACTION WITH INPUTS I to just RUN ACTION. Kicking and screaming.
Ooh this pushes a button for me. We are not in the business of preventing users from doing anything! Otherwise we'd be a purely functional language. We want to expand the ways users can think about their programs, so we give them iteration and recursion and HOFs and APL hyperblocks and object oriented programming. And someday we'll add logic programming. And users can create their own tools if ours aren't good enough for them. To this day, when we want to show off Snap! in a single picture, it's
➞even though FOR is now a primitive.
(How do I get the pictures to be vertically centered?)