Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #19454
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | ACTION-OF (was: On-the-fly updating of word definitions?) |
| Date | 2013-02-05 11:45 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2013Feb5.124510@mips.complang.tuwien.ac.at> (permalink) |
| References | <f4412dce-5396-42ce-8c87-0a6c7ab6f6f4@googlegroups.com> <7xfw1de7i8.fsf@ruckus.brouhaha.com> <2013Feb4.170741@mips.complang.tuwien.ac.at> <8578fce1-c6c6-4450-ab80-6f2e60f066fb@y8g2000vbb.googlegroups.com> |
Mark Wills <forthfreak@gmail.com> writes:
>What's the use case for ACTION-OF ?
>
>I'm struggling to see why/how it's useful.
>
>Okay, from the command line, I can say:
>
>HEX
>ACTION-OF PLUS .
>
>and I can see the XT of PLUS's action. So it's a bit of syntactic
>sugar to save you typing:
>
>' PLUS DEFER@ .
Yes.
>What's its utility in compilation state?
If guess your question also extends to DEFER@.
One example is the ~~ tracer in Gforth; the programmer plants it into
a word he wants to debug, and when it is executed, it prints the
position of the tracer and the stack contents. It does that with TYPE
and EMIT, but these are deferred words that the debugged word or its
callers may have changed to print to somewhere else. We don't want
the debugging output to go there, so we change TYPE and EMIT to do
what they do normally.
After having printed the debugging stuff, we need to change TYPE and
EMIT back to what they were. In order to do that, we need to know
what they were before, and that's where ACTION-OF or DEFER@ comes into
play: We first save the old actions of TYPE and EMIT, then change
them, do the printing, and restore TYPE and EMIT. The code is:
: .debugline-directed ( nfile nline -- )
action-of type action-of emit { oldtype oldemit }
try
['] (type) is type ['] (emit) is emit
['] .debugline debug-fid outfile-execute
0
restore
oldemit is emit oldtype is type
endtry
throw ;
- 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 2013: http://www.euroforth.org/ef13/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
On-the-fly updating of word definitions? AKE <assadebrahim2000@gmail.com> - 2013-02-03 06:18 -0800
Re: On-the-fly updating of word definitions? Mark Wills <forthfreak@gmail.com> - 2013-02-03 07:15 -0800
Re: On-the-fly updating of word definitions? AKE <assadebrahim2000@gmail.com> - 2013-02-03 07:25 -0800
Re: On-the-fly updating of word definitions? Bruno Gauthier <bgauthier@free.fr> - 2013-02-03 16:24 +0100
Re: On-the-fly updating of word definitions? AKE <assadebrahim2000@gmail.com> - 2013-02-03 07:33 -0800
Re: On-the-fly updating of word definitions? Mark Wills <forthfreak@gmail.com> - 2013-02-03 09:27 -0800
Re: On-the-fly updating of word definitions? Paul Rubin <no.email@nospam.invalid> - 2013-02-03 07:34 -0800
Re: On-the-fly updating of word definitions? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-02-03 10:32 -0600
Re: On-the-fly updating of word definitions? "Elizabeth D. Rather" <erather@forth.com> - 2013-02-03 08:44 -1000
Re: On-the-fly updating of word definitions? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-02-04 16:07 +0000
Re: On-the-fly updating of word definitions? Hugh Aguilar <hughaguilar96@yahoo.com> - 2013-02-04 17:27 -0800
Re: On-the-fly updating of word definitions? Mark Wills <forthfreak@gmail.com> - 2013-02-04 23:57 -0800
ACTION-OF (was: On-the-fly updating of word definitions?) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-02-05 11:45 +0000
Re: On-the-fly updating of word definitions? stephenXXX@mpeforth.com (Stephen Pelc) - 2013-02-05 12:58 +0000
Re: On-the-fly updating of word definitions? Mark Wills <forthfreak@gmail.com> - 2013-02-05 05:20 -0800
Re: On-the-fly updating of word definitions? Lars Brinkhoff <lars.spam@nocrew.org> - 2013-02-05 09:22 +0100
Re: On-the-fly updating of word definitions? mhx@iae.nl (Marcel Hendrix) - 2013-02-05 18:08 +0200
csiph-web