j
: Next unread message k
: Previous unread message j a
: Jump to all threads
j l
: Jump to MailingList overview
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?
On 2010-3-31 4:07 PM, Programmingkid 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?
That's not how you want to be using does> (in my opinion, you don't want to be using does> at all, but that's just my dislike of the construct).
If you want to play games with what's done at compile vs runtime, you should be using the "compile" and "[compile]" tokens.
On 3/31/10 10:07 PM, Programmingkid 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 am trying to make a word that does one thing at compile time, and does another thing at runtime.
: my-weird-word [ do-stuff-at-compile-time ] do-stuff-at-run-time ;
Segher