Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在玩 Forth,我想看看它是否具有类似函数的结构。我试图从 OOP 背景中理解它。
我看到你可以有类似的东西:
: addition + . ; 4 2 addition 6 ok
有没有办法让你可以有这样的变量:
: addition ( a b ) a b + ; 4 2 addition . 6 ok
这样我就可以用这个词定义做更复杂的事情。
局部变量的常规语法使用{and }。您的示例将变为:
{
}
: addition { a b -- } a b + ;
标准使用{:and:}代替。
{:
:}
http://forth-standard.org/standard/locals/bColon