version 1.66, 2004/09/02 10:12:28
|
version 1.67, 2004/11/28 20:20:38
|
Line 486 DOES>
|
Line 486 DOES>
|
|
|
\ IS Defer What's Defers TO 24feb93py |
\ IS Defer What's Defers TO 24feb93py |
|
|
|
: defer-default ( -- ) \ gforth |
|
\ might change into a THROW in the future |
|
; \ >stderr ." uninitialized deferred word" ; |
|
|
doer? :dodefer [IF] |
doer? :dodefer [IF] |
|
|
: Defer ( "name" -- ) \ gforth |
: Defer ( "name" -- ) \ gforth |
\ !! shouldn't it be initialized with abort or something similar? |
\G Define a deferred word @i{name}; its execution semantics can be |
|
\G set with @code{defer!} or @code{is} (and they have to, before first |
|
\G executing @i{name}. |
Header Reveal dodefer: cfa, |
Header Reveal dodefer: cfa, |
['] noop A, ; |
['] defer-default A, ; |
|
|
[ELSE] |
[ELSE] |
|
|
: Defer ( "name" -- ) \ gforth |
: Defer ( "name" -- ) \ gforth |
Create ['] noop A, |
Create ['] defer-default A, |
DOES> @ execute ; |
DOES> @ execute ; |
|
|
[THEN] |
[THEN] |
|
|
|
: defer@ ( xt-deferred -- xt ) \ gforth defer-fetch |
|
\G @i{xt} represents the word currently associated with the deferred |
|
\G word @i{xt-deferred}. |
|
>body @ ; |
|
|
: Defers ( compilation "name" -- ; run-time ... -- ... ) \ gforth |
: Defers ( compilation "name" -- ; run-time ... -- ... ) \ gforth |
\G Compiles the present contents of the deferred word @i{name} |
\G Compiles the present contents of the deferred word @i{name} |
\G into the current definition. I.e., this produces static |
\G into the current definition. I.e., this produces static |
\G binding as if @i{name} was not deferred. |
\G binding as if @i{name} was not deferred. |
' >body @ compile, ; immediate |
' defer@ compile, ; immediate |
|
|
:noname |
:noname |
dodoes, here !does ] |
dodoes, here !does ] |
Line 518 DOES> @ execute ;
|
Line 529 DOES> @ execute ;
|
defstart :-hook ; |
defstart :-hook ; |
interpret/compile: DOES> ( compilation colon-sys1 -- colon-sys2 ; run-time nest-sys -- ) \ core does |
interpret/compile: DOES> ( compilation colon-sys1 -- colon-sys2 ; run-time nest-sys -- ) \ core does |
|
|
|
: defer! ( xt xt-deferred -- ) |
|
\G Changes the @code{defer}red word @var{xt-deferred} to execute @var{xt}. |
|
>body ! ; |
|
|
: <IS> ( "name" xt -- ) \ gforth |
: <IS> ( "name" xt -- ) \ gforth |
\g Changes the @code{defer}red word @var{name} to execute @var{xt}. |
\g Changes the @code{defer}red word @var{name} to execute @var{xt}. |
' >body ! ; |
' defer! ; |
|
|
: [IS] ( compilation "name" -- ; run-time xt -- ) \ gforth bracket-is |
: [IS] ( compilation "name" -- ; run-time xt -- ) \ gforth bracket-is |
\g At run-time, changes the @code{defer}red word @var{name} to |
\g At run-time, changes the @code{defer}red word @var{name} to |
\g execute @var{xt}. |
\g execute @var{xt}. |
' >body postpone ALiteral postpone ! ; immediate restrict |
' postpone ALiteral postpone defer! ; immediate restrict |
|
|
' <IS> |
' <IS> |
' [IS] |
' [IS] |
interpret/compile: IS ( xt "name" -- ) \ gforth |
interpret/compile: IS ( compilation/interpretation "name-deferred" -- ; run-time xt -- ) \ gforth |
\G A combined word made up from @code{<IS>} and @code{[IS]}. |
\G Changes the @code{defer}red word @var{name} to execute @var{xt}. |
|
\G Its compilation semantics parses at compile time. |
|
|
' <IS> |
' <IS> |
' [IS] |
' [IS] |
interpret/compile: TO ( w "name" -- ) \ core-ext |
interpret/compile: TO ( w "name" -- ) \ core-ext |
|
|
:noname ' >body @ ; |
|
:noname ' >body postpone ALiteral postpone @ ; |
|
interpret/compile: What's ( interpretation "name" -- xt; compilation "name" -- ; run-time -- xt ) \ gforth |
|
\G @i{Xt} is the XT that is currently assigned to @i{name}. |
|
|
|
: interpret/compile? ( xt -- flag ) |
: interpret/compile? ( xt -- flag ) |
>does-code ['] DOES> >does-code = ; |
>does-code ['] DOES> >does-code = ; |
|
|