Page 1 of 1

R.N

Posted: Sat Jul 24, 2021 10:39 am
by Powersoft
I found in the FD-V05N1.PDF an intersting article “Add a Breapoint Tool”. (Leo Brodie)
There was one word I could not find back.

“N.R”

What is the meaning of this word?

Cheers,

Jan

Re: R.N

Posted: Sat Jul 24, 2021 12:06 pm
by Dr Jefyll
Wild guess: non-reentrant (??) :roll: But can you link us to that PDF, please? Also clarify -- is it RN or NR? You topic title is different from what's in the text. :wink:

-- Jeff

Re: R.N

Posted: Sat Jul 24, 2021 12:35 pm
by Powersoft
It’s came from:

Forth Dimensions
Volume 5
Number 1
Page 19

“Add a Break Point Tool”
Autor: Leo Brodie

Re: R.N

Posted: Sat Jul 24, 2021 12:42 pm
by BigEd
Here we are:
https://archive.org/details/Forth_Dimen ... 8/mode/1up
Screen60-Forth-R.N.png
(Looks to me like code rather than an annotation but perhaps I can't parse what I see!)

Re: R.N

Posted: Sat Jul 24, 2021 1:15 pm
by Powersoft
Could this be a word printing the return stack, because first is printing the stack contence!

Re: R.N

Posted: Sat Jul 24, 2021 3:02 pm
by Dr Jefyll
Powersoft wrote:
Could this be a word printing the return stack
I suspect you're right. There's a ." that tells the user to expect S to be printed; then the word S. apparently prints S. And there's a ." that tells the user to expect R to be printed, and the word R.N apparently prints R.

But I don't know why the word that prints S is called S. whereas the word that prints R is called S.N. <shrug> :roll:

-- Jeff

ps- thx, Ed!

Re: R.N

Posted: Sun Jul 25, 2021 8:06 pm
by JimBoyd

After reading the article, I agree that it is most likely the word BREAK displays the contents of the data and return stacks before going into a custom QUIT loop. It is possible R.N only displays some of the return stack, but that doesn't really matter.
As for the odd names, the article is from the Summer of 1983. Leo Brodie states that this technique was invented by Frank Seuberling , adapted by Kim Harris and brought to his attention by John Clark. I'm not sure when the name .S became widely used for the word which displays the contents of the data stack and I don't even know if there is a standard name for a word which displays the contents of the return stack. In Fleet Forth, I use the name .RS for that.

Here is a version of this tool which is smaller. It eliminates the return stack check by using a technique from Scott Ballantyne's Blazin' Forth for the Commodore 64.
BREAK switches off the variable CON before entering the loop. To exit the loop, use the word CONT to switch CON on.

Code: Select all

VARIABLE CON
: CONT   CON ON ;  ( CONTINUE)
: BREAK  ( -- ) ( COMPILE BREAK INTO : DEF)
   CR ." BREAK S= " .S CR ." R= " .RS
   BLK OFF CON OFF
   BEGIN
      QUERY INTERPRET ." AOK" CR
      CON @
   UNTIL ;


Re: R.N

Posted: Mon Jul 26, 2021 1:43 pm
by SamCoVT
The accompanying text for that article says:
Quote:
Another pleasant addition has been the stack dumps — both data stack and return stack — on line 6. BREAK will run fine without either of these if you haven't got them yet.
That confirms that R.N prints the return stack. My guess is that R.N is "Print Return Stack with Names". Articles in other issues of Forth Dimensions were discussing how to turn stack addresses into names, with this mention that seems pretty close in Volume 17,Number 3, page 15 talking about debugging:
Quote:
I added checks to INTERPRET, and used to add ?STACK in misbehaving definitions. The word R. that prints the trace of return addresses (using the R@ 2- @ >NAME .NAME principle) turned out to be very useful in ABORT diagnostics.
This shows a word named R. that is doing something similar. I didn't find a code listing for R.N directly.

Re: R.N

Posted: Mon Jul 26, 2021 2:16 pm
by IamRob
My extremely limited educated guess is that "S." is already defined in a lot of Forth's to print the data stack and was just used, whereas "R.N' is newly defined. Since ".R" and "D.R" and ">R, R>, R" are already used in FigForth, it seems to me that "R." can become confusing. If I saw "R.", I would take it as printing the top Return Stack value since "R" and "R>" already put the top address on the data stack, whereas "R.N" would print all the values on the Return Stack.

Re: R.N

Posted: Thu Jul 29, 2021 1:02 am
by JimBoyd
SamCoVT wrote:
The accompanying text for that article says:
Quote:
Another pleasant addition has been the stack dumps — both data stack and return stack — on line 6. BREAK will run fine without either of these if you haven't got them yet.
That confirms that R.N prints the return stack. My guess is that R.N is "Print Return Stack with Names". Articles in other issues of Forth Dimensions were discussing how to turn stack addresses into names, with this mention that seems pretty close in Volume 17,Number 3, page 15 talking about debugging:
Quote:
I added checks to INTERPRET, and used to add ?STACK in misbehaving definitions. The word R. that prints the trace of return addresses (using the R@ 2- @ >NAME .NAME principle) turned out to be very useful in ABORT diagnostics.
This shows a word named R. that is doing something similar. I didn't find a code listing for R.N directly.

Fleet Forth's word .RS displays the addresses on the return stack as well as the associated names. I thought it was the norm for a word which displays the return stack contents to display both addresses and associated names.
Using R@ 2- @ >NAME .NAME to display the names works well enough for a stack trace in most cases, but the name QUIT does not appear in the display of the return stack trace. This technique does not display the name of the word containing a given address, but the name of the word which caused that address to be placed on the return stack when it was executed. As I said, this works well for troubleshooting in most cases. I mentioned here that I needed a more accurate version of .RS for some experiments I was running in Fleet Forth.