Post Reply 
newRPL - build 1255 released! [updated to 1299]
06-11-2019, 10:59 PM
Post: #500
RE: newRPL - build 1255 released! [official and unofficial]
(06-11-2019 06:51 PM)Gilles Wrote:  
(06-11-2019 12:42 PM)Claudio L. Wrote:  EXIT will also return from the current program but it can only exit one program at a time. RPL has no function markers so there is no way to know how many secondaries RETURN is supposed to exit (…)
Quote:EXIT will also return from the current program but it can only exit one program at a time.

I'm not sure to understand your point. Perhaps I missed or misunderstand something. I thought that EXIT was something like BREAK in PPL, and my suggestion for RETURN was something like the RETURN in PPL.
For me EXIT dont return from the current program but exit the current loop (Or perhaps behind the scene a loop is a program in newRPL ?).
The idea of RETURN is different : stop the program (the subprogram) here and returns the stack "as it is" :

Exemple

Code:
«
 1 9 FOR 'a'
  1 9 FOR 'b'
   IF  a b + 4 == THEN a b RETURN END
  NEXT
 NEXT
»

-> 1 3

'a' loop is just executed once
'b' loop 3 times

But with EXIT

Code:
«
 1 9 FOR 'a'
  1 9 FOR 'b'
   IF  a b 4 + == THEN a b EXIT END
  NEXT
 NEXT
»
-> 1 3 2 2 3 1

The inner loop stops each time the condtion is true
The outer loop is executed 10 times

A program (secondary) during runtime is just an address pushed to the return stack. A loop is... also just an address pushed to the return stack. In my example I used all secondaries but it's all the same. If I wanted to distinguish them I'd have to do something special to "mark" which positions in the return stack are secondaries. I'll have to think if that is possible and how to implement it. EXIT simply pops that return address from the return stack and cleans up local vars as needed, but doesn't really know what exactly it is exiting. RETURN would have to basically EXIT multiple times until it (somehow) knows the next return address is outside the secondary.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: newRPL - build 1001 released! - pier4r - 12-16-2017, 08:03 AM
newRPL - on Hp 39gs - Martin Hepperle - 06-05-2019, 06:51 AM
RE: newRPL - build 1001 released! - pier4r - 12-23-2017, 10:16 AM
RE: newRPL - build 1001 released! - pier4r - 01-01-2018, 09:42 AM
t - Claudio L. - 01-01-2018, 03:06 PM
RE: newRPL - build 1001 released! - pier4r - 01-01-2018, 03:41 PM
RE: newRPL - build 1001 released! - pier4r - 01-02-2018, 04:54 PM
RE: newRPL - build 1001 released! - pier4r - 01-02-2018, 06:58 PM
newRPL - brickviking - 10-05-2018, 06:01 AM
RE: newRPL - build 1255 released! [official and unofficial] - Claudio L. - 06-11-2019 10:59 PM
How to participate? - erazor - 12-13-2019, 07:12 AM



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