On Apr 1, 2010, at 6:00 AM, openbios-request(a)openbios.org wrote:
>> I am trying to make a word that does one thing at compile time, and does another thing at runtime. I think this is how you do it:
>>
>> : myword
>> ." one"
>> does> ." two"
>> cr ;
>>
>> When I first use this word, I see "one". Then when I use this word again, I see "two", but it causes OpenBIOS to panic because of a segmentation violation at 3. Is this an OpenBIOS bug, or did I do something wrong?
>>
> you can also do
>
> : mywork
> state @ if
> ." compile"
> else
> ." interpret"
> then
> ; immediate
>
> or so
I have tried using this way, but when I use mywork in another word, it disappears from the definition after being compiled. This is what happens
: doSomething
mywork
;
see doSomething
: doSomething
;
ok
0 >
The immediate word appears to make the word mywork only be available at compile time. Is there a way to make a word both run at compile-time, and still be available at run-time? My word has to start running immediately at compile-time.