01 詞的構造

符式詞之基本構造如下:

每個詞均有頭部及身部.頭部主要功用,在於詞典之查尋.身部才是執行動作所必要者

Win32Forth 詞之基本構造如下:

\ Classify a word based on its CFA  

\ 由 CFA欄的內容  來分類  定義詞   

: .definition-class  ( cfa cfa -- )

    @ case

            docol       of .:           endof

            docon       of .constant    endof

            dooff       of .offset      endof

            dovar       of .variable    endof

            douser      of .user        endof

            dodefer     of .defer       endof

            dovalue     of .value       endof

            doClass     of .class       endof

            do|Class    of .class       endof

            dovoc       of .vocabulary  endof

            doObj       of .object      endof

            doPointer   of .pointer     endof

            doImport    of .import      endof

        swap .other

    endcase ;

也就是說,可以查看任何Forth定義的CFA的內容,評估那裡的內容,並確定它是什麼類型的定義。

variable cyn ok

INTERNAL ok

' cyn dup .definition-class 4494156 VARIABLE CYN Value = 0 ok

MODULE ok

' cyn dup .definition-class 

^^^^^^^^^^^^^^^^^

Error(-13): .DEFINITION-CLASS is undefined

cyn  ok.

例如

: Colon1 1 2 + ;    ok

: Colon2 3 4 * ;    ok

' colon1 @ . 4198400  ok

' colon2 @ . 4198400  ok

0 value value1  ok

2 value value2  ok

' value1 @ .  4198471  ok

' value2 @ .  4198471  ok

variable var1  ok

variable var2  ok

' var1 @ . 4198431  ok

' var2 @ . 4198431  ok

1 constant constant1  ok

  ok

1 constant constant2  ok

'  constant2 @ . 401037  ok

'  constant1 @ . 401037  ok

由CODE 定義的詞 CFA直指 PFA

see dup 

DUP IS CODE 

  ( $401320 53 )              push    ebx 

hex ' dup @ u.  401320  ok