Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #42709
| From | Marcos Cruz <use_the_contact_page@programandala.net> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: alternative implementation of `??` |
| Date | 2015-10-19 20:21 +0000 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <n03jcr$ql0$1@speranza.aioe.org> (permalink) |
| References | <mvqqs2$n2r$1@speranza.aioe.org> <2015Oct19.112941@mips.complang.tuwien.ac.at> |
En/Je/On 2015-10-19, Anton Ertl <anton@mips.complang.tuwien.ac.at> escribió/skribis/wrote: >>---- >>: ?? ( Compilation: "name" -- ) ( Runtime: f -- ) >> postpone if ' compile, postpone then >> ; immediate >>---- > This one does not deal with immediate words as intended. E.g., in > Gforth, > > ?? LEAVE > > would not work as intended. > > However, since you actually want to execute the compilation semantics, > you can write the following in Gforth to express this: > >: ?? ( Compilation: "name" -- ) ( Runtime: f -- ) > postpone if comp' execute postpone then ; immediate > > And the cool thing is that this works even for parsing words: > >: foo ?? ." bla bla" ; > true foo \ prints "bla bla" > false foo \ prints nothing Thank you for pointing out. This new version (for my system) works with immediate and parsing words as you say: ---- : ?? ( Compilation: "name" -- ) ( Runtime: f -- ) postpone if parse-name find-name ( x 0 | cfa 1 | cfa -1 ) dup 0= -13 ?throw 1 = if execute else compile, then postpone then ; immediate ---- >>---- >>: ?? ( f -- ) 0= if r> cell+ >r then ; >>---- > > This requires a classical threaded-code implementation. Yes, that's what it's for. >>---- >>: (??) ( f -- ) 0= if r> cell+ >r then ; >>: ?? ( -- ) ?compiling postpone (??) ; immediate >>---- > Why spoil an ok word with STATE-smartness? If you want it to be > compile-only, implement a proper COMPILE-ONLY in the system (where the > text-interpreter checks, not the word). Of course. `compile-only` is on the to-do list... Meanwhile, some words keep those checks. -- Marcos Cruz http://programandala.net
Back to comp.lang.forth | Previous | Next — Previous in thread | Find similar | Unroll thread
alternative implementation of `??` Marcos Cruz <use_the_contact_page@programandala.net> - 2015-10-16 12:34 +0000
Re: alternative implementation of `??` anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-10-19 09:29 +0000
Re: alternative implementation of `??` Marcos Cruz <use_the_contact_page@programandala.net> - 2015-10-19 20:21 +0000
csiph-web