jkotlinski / durexforth

Modern C64 Forth
Other
230 stars 28 forks source link

save-input/restore-input #525

Closed popeyeotaku closed 1 year ago

popeyeotaku commented 1 year ago

Could we make save-input/restore-input regular words the user could access? Maybe bump their stacks up a couple entries. They are in the standard, and you do have them implemented.

jkotlinski commented 1 year ago

If you have a use for these words, I think it should be fine to put them in dictionary. The only reason not to have them in dictionary is to save RAM.

Ideally, SAVE-INPUT should ABORT on stack overflow.

I am not sure if it is standard-compliant to save the state in a separate stack. But I think it should be.

jkotlinski commented 1 year ago

Actually, I read up a bit and I think some rework is needed to make these words standard compliant:

At least, this is what I imagine after reading https://forth-standard.org/standard/core/SAVE-INPUT I am not sure if those last two bullet points are feasible.

jkotlinski commented 1 year ago

For fun, implemented N>R NR> which is part of the solution.

The real tricky part is moving around code so that SAVE_INPUT/RESTORE_INPUT calls are in the same word. (I want this, so that N>R NR> can store data on the return stack)

jkotlinski commented 1 year ago

OK... I read up a bit further. This is what Forth standard says: "SAVE-INPUT and RESTORE-INPUT are intended for repositioning within a single input source"

So, it looks like durexForth SAVE-INPUT/RESTORE-INPUT have a completely different functionality than intended in the standard.

They should be renamed to something else, to avoid confusion.

jkotlinski commented 1 year ago

I now renamed SAVE/RESTORE_INPUT to PUSH/POP_INPUT_SOURCE, to avoid confusion with the standard words.