[OpenBIOS] name of current word

Stefan Reinauer stepan at openbios.org
Wed Mar 31 10:55:52 CEST 2010


On 3/31/10 10:42 AM, Mark Cave-Ayland wrote:
> Programmingkid wrote:
>
>> Is there a word that can tell me the name of the current word that is
>> executing?
>>
>> I want something like this:
>>
>> : myword
>> obtainWord
>> ;
>>
>> obtainWord would somehow return "myword". Any tips would be great.
>
> No, I don't think this is really possible because of the way in which
> Forth works (at least I ended up using a different solution for the
> debugger anyway).

Well, it is - to some extent:

: saymyname r@ begin cell - dup @ 1 <> while repeat cell - lfa2name type ;
: bar saymyname cr ;
bar

will say "bar"

But it only works reliably so far if it's very early in the word (before
any other cells that hold "1" which is the CFA for a colon definition.

Stefan



More information about the OpenBIOS mailing list