Node:CREATE..DOES> details, Next:Advanced does> usage example, Previous:CREATE..DOES> applications, Up:User-defined Defining Words
DOES>compilation colon-sys1 -- colon-sys2 ; run-time nest-sys -- core ``does''
This means that you need not use
DOES> in the
same definition; you can put the
DOES>-part in a separate
definition. This allows us to, e.g., select among different
: does1 DOES> ( ... -- ... ) ... ; : does2 DOES> ( ... -- ... ) ... ; : def-word ( ... -- ... ) create ... IF does1 ELSE does2 ENDIF ;
In this example, the selection of whether to use
does2 is made at definition-time; at the time that the child word is
In a standard program you can apply a
DOES>-part only if the last
word was defined with
CREATE. In Gforth, the
will override the behaviour of the last word defined in any case. In a
standard program, you can use
DOES> only in a colon
definition. In Gforth, you can also use it in interpretation state, in a
kind of one-shot mode; for example:
CREATE name ( ... -- ... ) initialization DOES> code ;
is equivalent to the standard:
:noname DOES> code ; CREATE name EXECUTE ( ... -- ... ) initialization
Get the address of the body of the word represented by xt (the address of the word's data field).
>bodyxt -- a_addr core ``>body''