From: the.beez.speaks@gmail.com   
      
   On 13-03-2024 08:20, Anton Ertl wrote:   
   > Concerning the name +DO, this is taken in Gforth since at least   
   > Gforth-0.2 (1996) for entering a loop only if index comparison), without providing a stride.   
      
   Don't worry, Anton - I have no intention to implement this one. About a   
   third of my loops are well behaved DO or ?DO .. LOOPs. I like   
   BEGIN..WHILE..REPEAT a lot more. I very, very rarely use UNLOOP and   
   LEAVE makes me feel uncomfortable as well. So I don't feel +DO adds a   
   whole lot.   
      
   I must say I'm quite in love with the FOR..NEXT I designed in uBasic/4tH:   
   - DO..LOOP executes the very same code ;   
   - All these are valid expressions:   
    FOR x=1 TO 5   
    FOR x=1 TO 5 STEP 2   
    FOR x=1   
    FOR x=1 STEP 2   
    FOR (equals DO)   
    FOR x=1 WHILE x<5   
    FOR x=1 UNTIL x=5   
    FOR x=1 TO 5 UNTIL y=3   
   - It supports BREAK and CONTINUE, like:   
    IF n=5 THEN BREAK   
    IF n>5 THEN CONTINUE   
   - You can place BREAK and CONTINUE everywhere - and they take effect   
   immediately   
   - "IF n=5 THEN BREAK" is equivalent to:   
    UNTIL n=5   
    WHILE n<>5   
   - It features UNLOOP as well, so you can safely GOTO or RETURN out of a   
   loop.   
      
   Note you can reuse a lot of the components, like UNLOOP in BREAK, like   
   BREAK in WHILE and UNTIL. I consider its design quite Forthy:   
      
   : exec_unloop fpop fscrap ;   
   : exec_break exec_unloop skip_next ;   
   : exec_while get_exp 0= if exec_break then ;   
   : exec_until get_exp if exec_break then ;   
      
   "One loop to rule them all!!" ;-)   
      
   Hans Bezemer   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|