IT ( -- xt ) return execution token of the last defined word
I want to add an entry for it to the comp.lang.forth repository http://forth.sf.net/word
I now that in gForth it is called lastxt, but I dislike the word lastxt
for the following reason: "execution token" is a word monster.
None of the standard Forth words includes "xt" in the name,
and no Forth word should include a mention of this auxiliary concept in its name.
The OTA standard renamed "execution tokens" to "execution pointers".
Should the programmer rename LASTXT to LASTXP on OTA? IMO, the name must
be chosen so that there would be no such problems.
In addition, it is quite possible that on the next revision the term "xt" will
be replaced in the standard by omething else, as it nearly happened with
"semantics", another word monster that almost has been renamed to "behavoiur".
So: auxiliary terms like "semantics" or "tokens" must not appear in the code.
1) Typical use
blah blah blah
IT IS foo
This word allows us to solve the :NONAME problem -- xt not accessible
till eexcution of ; (semi-colon).
:- DUP RSEMIT LCDEMIT ; IT IS EMIT
:NONAME DUP RSEMIT LCDEMIT ; IS EMIT
: M: ' method>offset >R :- IT ^virtual-function-table R> + ! ;
and there will be no need for ;M
It becomes easy to redefine ; to support : -like words:
0 VALUE my-latest
: my: : bla bla bla IT IS my-latest ;
: ; IT my-latest = IF bla bla bla THEN POSTPONE ; ; IMMEDIATE
I think that everyone has been thinking of using IT for something
really clever, it's a nice short word - and I'd say that we
should leave it for application usage.
I want to support that argument also with real life experience
in the telco world where there are a whole lot of abbreviations
for various services, signals, connectors around. All too often
now I see people making a SYNONYM at the file-start to get a
second name for an ANS forth word that is needed in the
implemenation but coincides with a common term of the application.
May be you would be okay with providing a long name for IT that
you could make an ALIAS for in your sources. As to your
questoin, should a programmer rename LASTXT and similar?
Hear my soundly answer - yes, he should.
What about a little survey of what modes exist around that
are usuable to get access to the last code-area, header-area
of the latest definition? Sometimes things can get really
confusing, ye know... and that's what your question might
really targetting at, isn't it.
-- cheers, guido
Michael L.Gassanenko schrieb:
_How_ often do you use it? How often do others use LASTXT? In the
Gforth sources it occurs 27 times (out of about 30000 lines of Forth
code). That low frequency calls for a word with a mnemonic name, not
something unspecific like it. LASTXT is mnemonic because it
piggybacks on the word LAST and adds XT, a widely-used abbreviation
(2380 clf postings according to google).
>The OTA standard renamed "execution tokens" to "execution pointers".
>Should the programmer rename LASTXT to LASTXP on OTA?
Why have they renamed XT? And should the programmer rename it into
her on OTA?
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
In Forth-83, as far as I remember we used LATEST NAME> for this
purpose. I liked the word LATEST :)
> >The OTA standard renamed "execution tokens" to "execution pointers".
> >Should the programmer rename LASTXT to LASTXP on OTA?
> Why have they renamed XT? And should the programmer rename it into
> her on OTA?
It was renamed because the OTA concept was technically different (though
analogous), and we thought it would prevent confusion.
But LATEST or LAST in some implementations points somewhere in the
header that might be absent in e.g. applications.
LASTXT points to the execution token, that's "always" present and is
faster because NAME> could take time, but less than >NAME ;-)
I agree with the motivation, but how about THAT ?
Julian V. Noble
Professor of Physics
"Science knows only one commandment: contribute to science."
-- Bertolt Brecht, "Galileo".
NAME> assumes that there is some access to the name field, which may
not be true on, say, a cross-compiler. (This is a part of the cost paid
for a better level of compatibility with taditional Forth)
IIRC about 50% of systems used LATEST while the other about 50% used LAST @ .
In addition, Larionov's (IIRC) Forth used LATEST to mean LAST or vice versa.
101% -- Central Administration of Statistics (of USSR)
THIS -- should be left for OOP
; that is bar -- no good
I would reserve THAT for the 2nd element on the stack of objects.
What about LATTER ?
; latter is bar
Grin, why not use LATEST or LAST ?
Coos Haak schrieb:
what about LAST-DEFINITION then :-)=)
1) Typical use
blah blah blah
LAST-DEFINITION IS foo
Yes, I wondered why ' returned CFA, and LATEST returned NFA (well,
>NAME is incorrect operation - you cannot find NFA given a CFA, can
you?), but I just wanted to tell that LATEST sounded very nice to me
>> >purpose. I liked the word LATEST :)
In my Forth, both >NAME and NAME> are correct operations, why not?
Just not in a headerless application.
Already in common use
VARIABLE LAST \ name field address (nfa) of the last word
: LATEST ( -- nfa )
> what about LAST-DEFINITION then :-)=)
So why not LATTER ?
: bar .. ;
PRIOR IS foo
( or, my preference )
WHICH IS foo
WHICH@ foo ( returns ' bar )
that Win32Forth implements as DEFER@. THAT, LATTER, PRIOR and LASTx's don't
lend themselves to this treatment.
you can create an ALIAS for it in your application.
The word is too specific anyway, so it won't be
given a short name anyway, not even the LATTER.
Most of the people are fine with
: what ... ;
LATEST NAME> IS foo
:noname ... ; IS foo
That's my main point about it.
See, if you want to have a shortname for such a
beast in your forth, well, go ahead, but don't put
it on forth.sf.net as no one else recommends it.
The only heritage is the LASTXT that you've pointed
to, but it didn't spread out in real life, it's a
helper definition and as such in can stay somewhat
technical in its naming policy. An application
should use one of the portable things as listed
above, it does actually cover all realworld case.
May be you want to have your own style, but I do
not like to see forth to get too much of TMTOWTDI
style, keep it clean and minimal. And don't pollute
the range of short names in forth even more than we
already have, keep it open for applications to
be exported as an application-specific user method.
We already have too many shortnames registered, and
it's a fact that it is not particularly useful to
redefine them for application needs even that such is
possible - it could easily be confusing for the next
programmer to get to work on that piece of software.
To summarize: do not register a shortname for a
thing that is already covered with existing
syntax parts of forth. That's my POV. -- guido
What do you mean by "helper definition"? LASTXT is essential in
combination with "NONAME":
5 noname constant
lastxt is ...
However, LASTXT should be called LATESTXT, since it is value-flavoured
like LATEST, not variable-flavoured like LAST.
Since F83 does not have it, I doubt that it is in Forth-83. However,
fig-Forth has it.