Closed patricksurry closed 1 month ago
I'm not exactly sure about the use of that flag, as technically all of the words have a code field in an STC forth. The manual says:
| HC | Has CFA. Consider first three bytes of the word’s code the Code Field
Area (CFA) of the word. Used by words defined with create so >body returns
the correct value. |
Looking at >BODY
, it appears to add three to the xt for these items, and has a note about DOVAR, DOCONST, DODEFER, and DODOES. The comment for that word says:
; This is a
; difficult word for STC Forths, because most words don't actually
; have a Code Field Area (CFA) to skip. We solve this by having CREATE
; add a flag, "has CFA" (HC), in the header so >BODY know to skip
; the subroutine jumps to DOVAR, DOCONST, or DODOES
That would seem to imply that all words created with CREATE
should have HC set, but I can see how :
should not leave that bit set. I can't think of a situation where a :
defined word would need the flag, so I agree with you that this is a bug.
Learning about header bits: CREATE tags new words with the HC status bit.
:
uses CREATE to start new user words. It later deletes the defaultjsr dovar
but doesn't unset the HC bit, so all user words seem to collect that flag. Perhaps a side entry point to xt_create could track whether to include the HC/jsr or not, which would also save the effort of reverting it later.