Post Reply 
RPL equivalents to BREAK, CYCLE, EXIT, etc.?
06-09-2014, 09:34 PM
Post: #21
RE: RPL equivalents to BREAK, CYCLE, EXIT, etc.?
(06-07-2014 11:48 PM)DavidM Wrote:  RPL seems to have been conceived by those who were probably trained with traditional "structured programming" in mind.

Well, looking at how the same people handled sysRPL and how they coded in assembler, they were very pragmatic. I doubt they were trying to adhere to the structured programming paradigm, or any paradigm for that matter. They had very limited resources, and when that happens, the solution is usually "whatever paradigm as long as it fits".
I think it was difficult to implement properly, so they probably decided not to.
So what would it take to implement BREAK for example?
The "interpreter" would have to search for the next END, or NEXT word, depending on what loop type we are into. That's hard to do because there's no interpreter, there's no easy way to determine the loop type you are into at runtime.
Also, skipping to the next END is not trivial since END is used in so many other constructs, so it would have to track for nested occurrences of different types of constructs. In sysRPL, they provided ?SEMI and similar words that basically provide BREAK from a secondary. That's relatively easy to implement, since the secondary is encapsulated and there's an address in the return stack where you can "break" into.
Loops on the other hand, generally use the return stack to push the address to restart the loop, not to end it, which would make CYCLE easier to implement.
So why they didn't implement CYCLE? Loops with STEP have no marker indicating where the code that calculates the step increment begins. So when you find the word CYCLE, where do you jump? Restarting the loop without incrementing your variable is not the expected behavior in STEP loops... but for other types of loops, however, CYCLE could be implemented.
I think rather than having some loops with BREAK and some with CYCLE but not all of them consistently, they gave up.

If people really miss these two (I do BTW) I might give it a shot on newRPL, it could be a nice addition to the language.

Find all posts by this user
Quote this message in a reply
06-11-2014, 05:50 AM
Post: #22
RE: RPL equivalents to BREAK, CYCLE, EXIT, etc.?
My 2ยข (not really addressed at anybody in particular): BREAK, CONTINUE, and even the occasional GOTO are a hell of a lot less damaging to code clarity than the extensive stackrobatics and mental juggling that the RPL system encourages. It takes a lot of discipline to write RPL code that isn't totally opaque even coming back to it yourself later in the day, and it's often done at the expense of performance.

RPL is nice, but it certainly wouldn't have killed them to add some more branching.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 

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