A frequent use of
does> is for transferring some
values from definition-time to run-time. Gforth supports this use with
const-does>run-time: w*uw r*ur uw ur "name" – gforth “const-does>”
Defines name and returns.
name execution: pushes w*uw r*ur, then performs the
code following the
A typical use of this word is:
: curry+ ( n1 "name" -- ) 1 0 CONST-DOES> ( n2 -- n1+n2 ) + ; 3 curry+ 3+
1 0 means that 1 cell and 0 floats are transferred from
definition to run-time.
The advantages of using
does>, you have to introduce a
@that cannot be optimized away (because you could change the data using
const-does>avoids this problem.
A Standard Forth implementation of
const-does> is available in