Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #14009
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!postnews2.euro.net!news.wanadoo.nl!not-for-mail |
|---|---|
| From | mhx@iae.nl (Marcel Hendrix) |
| Subject | Re: Quotations revisited |
| Newsgroups | comp.lang.forth |
| Message-ID | <86839188968435@frunobulax.edu> (permalink) |
| Date | Sun, 15 Jul 2012 12:52:49 +0200 |
| References | <EO6dnTRcUKqmHp_NnZ2dnUVZ8v2dnZ2d@supernews.com> |
| X-Newsreader | iForth 2.0 console (October 21, 2006) |
| Lines | 30 |
| Organization | Wanadoo |
| NNTP-Posting-Date | 15 Jul 2012 10:52:07 GMT |
| NNTP-Posting-Host | s529d937f.adsl.wanadoo.nl |
| X-Trace | 1342349527 dr2.euro.net 236 82.157.147.127:64375 |
| X-Complaints-To | abuse@wanadoo.nl |
| Xref | csiph.com comp.lang.forth:14009 |
Show key headers only | View raw
Re: Andrew Haley <andrew29@littlepinkcloud.invalid> writes Re: Quotations revisited > Marcel Hendrix <mhx@iae.nl> wrote: >> Recently, the subject of quotations popped up again and I remembered >> an unfinished project. [..] > My first version of quotations for SwiftForth was much like this. > Then someone pointed out that RECURSE had to work. Then somone > pointed out that locals had to work... 0 value dict : MY-EXIT -R [ -OPT ] ; : [: ( -- ) POSTPONE AHEAD HERE TO dict -OPT POSTPONE >R ; immediate : ;] ( -- xt ) POSTPONE MY-EXIT POSTPONE THEN dict POSTPONE LITERAL ; IMMEDIATE : MYSELF ( -- ) dict POSTPONE LITERAL POSTPONE EXECUTE ; immediate : test-recursion ( flag -- u ) #10 SWAP IF [: ( n1 -- n2 ) DUP 1 > IF DUP 1- MYSELF SWAP 2- MYSELF + ENDIF ;] \ fib ELSE [: ( n1 -- n2 ) DUP IF DUP 1- MYSELF SWAP * ELSE 1+ ENDIF ;] \ fac ENDIF EXECUTE . ; FORTH> true test-recursion 55 ok FORTH> false test-recursion 3628800 ok When [: and ;] switch to some private wordlist, EXIT and RECURSE can be used instead of MY-EXIT and MYSELF. LOCALs are possible with a little extra effort. Was there anything else people wanted? -marcel
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Auotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-15 03:45 -0500
Re: Quotations revisited mhx@iae.nl (Marcel Hendrix) - 2012-07-15 12:52 +0200
Re: Quotations revisited mhx@iae.nl (Marcel Hendrix) - 2012-07-15 16:08 +0200
Re: Quotations revisited Bernd Paysan <bernd.paysan@gmx.de> - 2012-07-15 17:08 +0200
csiph-web