Hi Kent,
the idea with number of iterations instead of step for some cases is neat, the local variable as well!
But I have to add few insights regarding the syntax.
Functions with multiple parameters are confusing, especially those booleans. It is mentioned multiple times in Pragmatic Programmer and Code Complete - I would also vote to avoid such a designs, although I made similar mistakes in the past. Just have a look at TBGL_SetupLightSource... yikes!
Also - while I am the last person to insist on inheriting legacy BASIC syntax, I like to keep "basic" as the design rule to lead us to the future.
When you look at these:
... you are immediately oriented.for i = 2 to 8 step 4 print "Ciao" At 10, 5
When you see:
... you need to think twice.fFori 0.1, 0.9, 5, true
So for the local variable, I would go this route:
...and for the implied number of iterations:for single f = 1 to 10
(for example)for f = 1 to 10 in 5 steps
-
Do you remember? ThinBASIC had this implemented, not sure where it got lost (Eros?):
So... you see, the i gets declared as part of first cycle and can be recycled in second.for i as long = 1 to 10 next for i = 2 to 8 next
Advantages?
No variable deallocation at end of each cycle brings more performance.
Petr
Bookmarks