Const-does> ¶A frequent use of create...does> is for transferring
some values from definition-time to run-time. Other ways of achieving
this are closures (see Closures), and with colon definitions
(see User-defined defining words with colon definitions), but
another way of achieving this is to use
Defines name and returns.
name execution: pushes w*uw r*ur, then performs the
code following the const-does>.
A typical use of this word is:
Here the 1 0 means that 1 cell and 0 floats are transferred from
definition to run-time.
The advantages of using const-does> compared to
create}...@word{does> are:
does>, you have to introduce a @ that cannot
be optimized away automatically (because the system does not know
whether you allow to access the data with >body...!).
You can address this problem with set-optimizer
(see User-defined compile,), but const-does> avoids
it; however, the current implementation is still not particularly
efficient.
A Standard Forth implementation of const-does> is available in
compat/const-does.fs.