gpt4 book ai didi

forth - Gforth、FORGET 和 LIST 词与原始 Forth 中的一样

转载 作者:行者123 更新时间:2023-12-03 21:12:51 24 4
gpt4 key购买 nike

是否有等效于 forget Gforth 中的 Forth 词?
我见过关于marker ,但它没有相同的行为。还有 list命令似乎没有给出程序的列表。
我想查看内存中程序的列表,就像旧的 list在 BASIC 中 - 我认为这也是原始 Forth 中的行为。

最佳答案

我不知道 Gforth,但下面显示了基于旧的 FIG Forth 列表的 FORGET。它对字典布局和词汇组织非常敏感。像 nfa(名称字段地址)和 lfa(链接字段地址)这样的词有更现代的等价物。当我运行它时,它崩溃了 ( VFX ) Forth,但它可能指向正确的方向。

variable FENCE

\ Per fig forth listing ( slightly modernised )
: forget \ "word-to-forget-from"
CURRENT @ CONTEXT @ - ABORT" Vocabulary error."
' DUP FENCE @ < ABORT" Word below FENCE."
DUP NFA DP ! LFA @ CURRENT ! ;

DP @ FENCE !

\ What was tested. WARNING crashed Forth!!
\ My guess is that CURRENT needs to be set to a different address
: forget \ "word-to-forget-from"
CURRENT @ CONTEXT @ - ABORT" Vocabulary error."
' DUP FENCE @ < ABORT" Word below FENCE."
>LINK DUP DP ! \ Set the top of the dictionary
@ CURRENT ! ; \ Point current to the last valid definition
可能有办法利用标记的实现。它必须存储一个可以访问的恢复指针,以便将其重置为某个定义的相关地址。

关于forth - Gforth、FORGET 和 LIST 词与原始 Forth 中的一样,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62561633/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com