Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #39538
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Macros based [CONTEXT]-EVALUATE |
| Date | 2015-06-03 07:12 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2015Jun3.091211@mips.complang.tuwien.ac.at> (permalink) |
Using EVALUATE for macros is either buggy, because the EVALUATE
happens in a different context than the definition of the macro, or
cumbersome, because you have to set up the context for EVALUATE
manually.
I have thought about how setting up the context could be automated, at
least partially: for the dictionary and BASE:
One would define a macro as follows:
: foo s" 16 +" [context]-evaluate ; immediate
During compilation, [CONTEXT]-EVALUATE saves the BASE, the search
order, and HERE. During run-time, [CONTEXT]-EVALUATE sets the BASE
and the search order to the saved values, and sets the FIND limit to
HERE, then EVALUATEs, and then restores the previous values of BASE,
search order and FIND limit. The FIND limit influences dictionary
searches such that only words below the FIND limit are found (so that
later redefinitions of a word used inside the macro are not found).
The macro could also depend on more context (maybe some words access
some variables during compilation), and that additional context still
has to be set up manually, but at least the common and, for dictionary
searches, cumbersome cases would be covered.
What would be needed to implement [CONTEXT]-EVALUATE, that systems
don't have at the moment is the FIND limit. The rest can be defined
in standard Forth.
The question is if there is enough interest in these kinds of macros
to convince system implementors (including me) to implement at least
the FIND limit.
- 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 2015: http://www.mpeforth.com/euroforth2015/euroforth2015.htm
Back to comp.lang.forth | Previous | Next — Next in thread | Find similar | Unroll thread
Macros based [CONTEXT]-EVALUATE anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-06-03 07:12 +0000
Re: Macros based [CONTEXT]-EVALUATE "Alex McDonald" <blog@rivadpm.com> - 2015-06-03 14:50 +0100
Re: Macros based [CONTEXT]-EVALUATE anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-06-03 14:01 +0000
Re: Macros based [CONTEXT]-EVALUATE "Alex McDonald" <blog@rivadpm.com> - 2015-06-03 21:21 +0100
Re: Macros based [CONTEXT]-EVALUATE humptydumpty <ouatubi@gmail.com> - 2015-06-03 09:02 -0700
Re: Macros based [CONTEXT]-EVALUATE hughaguilar96@gmail.com - 2015-06-03 14:07 -0700
csiph-web