Post Reply 
newRPL - Updated to build 1510 [official build remains at 1487]
08-11-2021, 02:31 PM
Post: #169
RE: newRPL - Updated to build 1487 [ including official build]
(08-10-2021 06:56 PM)Wes Loewer Wrote:  
(08-10-2021 06:29 PM)Claudio L. Wrote:  I think we'll settle for the following (unless there's any objections):
Code:

<start> <end> FORFWD <var> ... NEXT (or STEP)
<start> <end> FORREV <var> ... NEXT (or STEP)

<start> <end> STARTFWD ... NEXT (or STEP)
<start> <end> STARTREV ... NEXT (or STEP)

Seems very reasonable to me. Simple, clear, effective, easily understood.

I assume the FWD versions would require a positive STEP and the REV would require a negative STEP.

It wouldn't "require" anything, you are still free to use any STEP if you want to.
The logic of FOR is a little quirky:
FOR determines the direction of the loop from the start and end arguments: if start<end it assumes forward (positive) and vice versa. That implied direction determines the check that STEP uses, regardless of the actual value given to STEP.
For example, 1 3 FOR K ... n STEP will assume a forward loop, and the comparison to end the loop is K<=3, regardless of the value of n. This allows a loop to backtrack the variable by using a negative STEP whenever needed.
Is this automatic determination of the direction what prevents the loop from exiting early: it always does one run because (start <= end) or (start >= end) is always true for the chosen loop direction.

The new proposal, providing the loop direction explicitly is the best solution. FORFWD will always use var<=end, therefore upon entry you can exit if start>end. Same for FORREV.

Which name is best, FORFWD of FORUP, also FORREV or FORDN or FORDOWN?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: newRPL - Updated to build 1487 [ including official build] - Claudio L. - 08-11-2021 02:31 PM
Navigating through sub-menus - Gilles - 05-13-2023, 11:31 AM
It's a mystery to me... - Klaus - 11-27-2023, 12:24 PM



User(s) browsing this thread: 1 Guest(s)