Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #39542
| From | "Alex McDonald" <blog@rivadpm.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Macros based [CONTEXT]-EVALUATE |
| Date | 2015-06-03 14:50 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <mkn0kt$u50$1@dont-email.me> (permalink) |
| References | <2015Jun3.091211@mips.complang.tuwien.ac.at> |
on 03/06/2015 08:12:11, wrote: > 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). That won't work for systems where HERE (or a plurality of HEREs for multi section Forths) don't conform to a increments-thru-time model. For instance, the dictionary in Win32Forth and others may be external; a library, an SQL database and so on. It may be relocated, optimised, built out of non-ascending lumps, garbage collected or even poofed out of existence for turnkeys. As was made clear in the case of TRAVERSE-WORDLIST, about all we can reasonably ask is that definitions for the same name are returned in *time sequenced* order, not address order. "TRAVERSE- WORDLIST may visit words in any order, with one exception: words with the same name are called in the order newest-to-oldest (possibly with other words in between)." > > 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. I have not implemented FORGET or MARKER because of these difficulties; but then, I don't claim 100% ANS compliance either, so my interest is a moot point. > > - anton
Back to comp.lang.forth | Previous | Next — Previous in thread | 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