Closed polluks closed 2 years ago
Out of curiosity, how do you like to use see
?
I do find this word entertaining, but I doubt I ever found any practical use for it.
I revived it now in a branch, but hesitate a bit to merge it back. Partially because I don't find the results are that nice, compared to the original source code.
Well, I was using it with OFW quite often. At least it helps if you don't have the source.
The Forth standard offers this rationale for SEE: "SEE acts as an on-line form of documentation of words, allowing modification of words by decompiling and regenerating with appropriate changes."
Clearly, Durexforth SEE is not good enough to satisfy the rationale. That is one reason why I think it is no great loss if it disappears. The other reason is that source code is anyway available (although not always on target system)
Considering things further, I think it makes sense to
This could require:
A Disassembler and/or A Name token lookup by execution token.
Xt>name lookup is already in place. The tricky part is reverse-compiling control structures like IF, BEGIN, and so on. As an example, BEGIN compiles to nothing, and AGAIN compiles to a back-jump. Reverse-compiling that is a bit of a challenge. I think it should be possible, though.
On Sat, 30 Jul 2022 at 13:05, Whammo @.***> wrote:
This could require:
A Disassembler and/or A Name token lookup by execution token.
— Reply to this email directly, view it on GitHub https://github.com/jkotlinski/durexforth/issues/441#issuecomment-1200137967, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAY34OZ4LA54OW2TQ3SYJN3VWUD7HANCNFSM54FIUMYA . You are receiving this because you commented.Message ID: @.***>
There's a problem that hasn't been mentioned from the original discussion of this, and the reason why SEE
was removed in the first place:
:noname
segments do not create dictionary entries, and are built contiguously with other words in the data space.
At best right now, SEE
determines the length of a word's code by the distance between two adjacent dictionary entries.
Therefore, the determined code space of any word that precedes a :noname
declaration will include the :noname
's code.
In order for SEE
to stop at the appropriate position, the length of the word's code or the position of the last byte would need to be added to the dictionary or a supplementary data structure at compile time.
Maybe it would be possible to come up with some smart heuristics that decompiles most words correctly! It could be a fun challenge.
On Sat, 30 Jul 2022 at 18:46, Poindexter Frink @.***> wrote:
There's a problem that hasn't been mentioned from the original discussion of this, and the reason why SEE was removed in the first place:
:noname segments do not create dictionary entries, and are built contiguously with other words in the data space.
At best right now, SEE determines the length of a word's code by the distance between two adjacent dictionary entries.
Therefore, the determined code space of any word that precedes a :noname declaration will include the :noname's code.
In order for SEE to stop at the appropriate position, the length of the word's code or the position of the last byte would need to be added to the dictionary or a supplementary data structure at compile time.
— Reply to this email directly, view it on GitHub https://github.com/jkotlinski/durexforth/issues/441#issuecomment-1200250067, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAY34O5V3J4VCPIEJPZ2P4LVWVL5NANCNFSM54FIUMYA . You are receiving this because you commented.Message ID: @.***>
Gforth SEE seems like a good example how it can be done. It seems like a tall task to get control structures right, but certainly not impossible.
Work in progress: https://github.com/jkotlinski/durexforth/pull/464
I do just a little every day, eventually it should get there.
@polluks I think it kind of works now. Would you like to test before I merge to master?
looks ok, thx
Preserve this word https://github.com/jkotlinski/durexforth/commit/ec1b2d28f6dc5c06e26663ffc1a92621d1f70b6b#commitcomment-78959093