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.
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). Is there a reason that you're not using the in-built debugger for this? I'm fairly sure it would make your life much easier. ATB, Mark. -- Mark Cave-Ayland - Senior Technical Architect PostgreSQL - PostGIS Sirius Corporation plc - control through freedom http://www.siriusit.co.uk t: +44 870 608 0063 Sirius Labs: http://www.siriusit.co.uk/labs
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
Stefan Reinauer wrote:
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.
That's true. The other problem I had with earlier versions of the debugger that used this approach, was that as soon as a word starting manipulating the r-stack then everything got totally confused :( ATB, Mark. -- Mark Cave-Ayland - Senior Technical Architect PostgreSQL - PostGIS Sirius Corporation plc - control through freedom http://www.siriusit.co.uk t: +44 870 608 0063 Sirius Labs: http://www.siriusit.co.uk/labs
participants (3)
-
Mark Cave-Ayland -
Programmingkid -
Stefan Reinauer