Post Reply 
newRPL - Updated to build 1510 [official build remains at 1487]
08-10-2021, 06:29 PM
Post: #166
RE: newRPL - Updated to build 1487 [ including official build]
(08-10-2021 03:09 PM)Wes Loewer Wrote:  
(08-09-2021 09:39 PM)Claudio L. Wrote:  I don't oppose to having an alias, but if it has more than 3 letters it's harder to type, so I would personally never use it!

I almost suggested CAT (à la unix)

Quote:So I'd keep FOR the way it is, but I agree with Sylvain nothing prevents creating a new loop structure.

Yes, that's an even better idea.

Quote:Maybe:
Code:
<start> <end> <step> STEPFOR ... NEXT

Of all the examples you showed, this one would get my vote. As you said, anything more starts to look the same as a WHILE-DO loop. Although, I would reverse the name to FORSTEP which indicates that it replaces the FOR-STEP loop and suggests the order of the arguments. (Likewise for STARTSTEP.)

For style, you could even have a command that would replace "1 STEPFOR" such as the FORIF suggested by Sylvain. Such commands could only be paired with a NEXT, not a STEP.

Code:
<start> <end> <step> FORSTEP <var> ... NEXT
<start> <end> <step> STARTSTEP ... NEXT

<start> <end> FORIF <var> ... NEXT
<start> <end> STARTIF ... NEXT

of some such appropriately named commands.

Of course, my suggestion could be viewed as unnecessary since the desired behavior could be produced with a FOR nested in an IF, but I figured, hey, if you're going to create a new product, now is the time to bring things like this up before things get set in stone.

-wes

Thinking some more about it: since the variable is not changed during the early check, we don't need the magnitude of the step, just the direction.
The early check then becomes:
If sign('step') > 0 ---> Loop if 'start' <= 'end' , otherwise exit
if sign('step') < 0 ---> Loop if 'start' >= 'end' , otherwise exit
if sign('step') == 0 ---> Loop if 'start' == 'end', otherwise exit

So, instead of taking an extra argument with the step, maybe we should include the direction in the command name, that way all new commands become "drop-in" replacements for the standard FOR when the user needs that early check.
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)
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-10-2021 06:29 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: 2 Guest(s)