Digest #209 2023-02-15

Contributions

[282] 2023-02-14 20:17:30 JohanKotlinski wrote:

requestClarification - Is data stack required?

Is it a requirement that SAVE-INPUT and RESTORE-INPUT saves the state on the data stack?

I would prefer if it was allowed to keep the state on some other stack. (my Forth has a very limited data stack space)

Replies

[r952] 2023-02-14 09:59:02 ruv replies:

comment - Bad Stack Notation?

  1. the user can not rely on what data format gets pushed onto the return stack, and 2) something gets pushed on to the return stack and should not be meddled with.

When i is unknown, the data type symbol i*x already meets these both goals.

What is wrong in the diagram is that it assumes to take i*n from the data stack.

A correct variant: ( i*x +n -- ) ( R: -- j*x +n )


[r953] 2023-02-14 20:37:42 JohanKotlinski replies:

requestClarification - Is data stack required?

Umm... given that N>R R>N are listed as related. Is the intended workflow like this?

SAVE-INPUT N>R ... R>N RESTORE-INPUT ?


[r954] 2023-02-14 21:58:26 ruv replies:

requestClarification - Is data stack required?

I would prefer if it was allowed to keep the state on some other stack.

Probably, you need other (system-specific) words for that. The words save-input and restore-input are not what they appear on the first glance — see my other comment.

Is the intended workflow like this? SAVE-INPUT N>R ... R>N RESTORE-INPUT ?

It's a possible workflow, but in a single found program that uses these words ("Lambda Expressions in ANS Forth" by Gerry Jackson), they are used in a totally different manner. See a discussion on ForthHub.