Re: RfD: SYNONYM
- From: anton@xxxxxxxxxxxxxxxxxxxxxxxxxx (Anton Ertl)
- Date: Sun, 27 Aug 2006 09:47:59 GMT
"Neal Bridges" <nbridges@xxxxxxxxxxxx> writes:
ALIAS is already demonstrably common-usage, and ideally will create an exact
duplicate of oldname, flags and semantics and all.
Such an ALIAS has a conflict with Gforth's ALIAS, which just produces
a word that has the execution/interpretation semantics specified by
the xt, but default compilation semantics. In particular, it is not
immediate, whether the ticked word is immediate or not.
So a least common denominator would make the compilation semantics of
an ALIAS undefined, unless the original had default cmpilation
semantics (then it has default compilation semantics), or unless
IMMEDIATE is applied (then it is immediate).
With such an ALIAS, we cannot do as easily what SYNONYM can do, but we
can combine it with other techniques to achieve the same
functionality:
For a word with default compilation semantics, use
' R@ alias my-r@
For an immediate word, use
' ( alias my-* immediate
For a word with non-default compilation semantics und undefined
interpretation semantics, use:
: endif POSTPONE then ; immediate
For a word with defined interpretation semantics and non-default,
non-immediate compilation semantics, you could define it in a
STATE-smart way (and it will fail when the original will also fail on
some system), or you could use the refined technique discussed in
http://www.complang.tuwien.ac.at/forth/dpans-html/comment-semantics.html;
for simplicity, here's the state-smart variant:
: my-s"
state @ if
postpone S"
else
['] S" execute
then ; immediate
So what SYNONYM offers above ALIAS is the convenience of not having to
make this case analysis.
- anton
--
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
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2006: http://www.complang.tuwien.ac.at/anton/euroforth2006/
.
- References:
- RfD: SYNONYM
- From: Stephen Pelc
- Re: RfD: SYNONYM
- From: George Hubert
- Re: RfD: SYNONYM
- From: Ed
- Re: RfD: SYNONYM
- From: Alex McDonald
- Re: RfD: SYNONYM
- From: George Hubert
- Re: RfD: SYNONYM
- From: Ed
- Re: RfD: SYNONYM
- From: Neal Bridges
- RfD: SYNONYM
- Prev by Date: Re: RfD - SYNONYM
- Next by Date: Re: RfD - SYNONYM
- Previous by thread: Re: RfD: SYNONYM
- Next by thread: Re: RfD: SYNONYM
- Index(es):
Relevant Pages
|
Loading