Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #21364
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Anonymous code/data/create-does |
| References | <93571201998434@frunobulax.edu> <02591300998434@frunobulax.edu> |
| From | Lars Brinkhoff <lars.spam@nocrew.org> |
| Organization | nocrew |
| Date | Thu, 04 Apr 2013 12:42:32 +0200 |
| Message-ID | <85vc82shk7.fsf@junk.nocrew.org> (permalink) |
| User-Agent | Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) |
| Cancel-Lock | sha1:vpKDjXinkrDnWGytjRHtvAdTpCI= |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Lines | 23 |
| NNTP-Posting-Host | 85.229.87.73 |
| X-Trace | news.sunsite.dk DXC==ZkS7I[Pb318NX=BCM0\c1YSB=nbEKnk;8n:1ka8JI:0@ON7A^J=915:[KId_d;k;?ecS2QjHQi^7HL>PhDc7Db56G6812mT7E2 |
| X-Complaints-To | staff@sunsite.dk |
| Xref | csiph.com comp.lang.forth:21364 |
Show key headers only | View raw
mhx@iae.nl (Marcel Hendrix) writes:
> The new ^, word ( does-xt -- child-xt ) creates an anonymous child
> and returns it xt. The data for the child is supposed to be at
> HERE. When putting both [: ... ;], ^, and (e.g.) "," inside a
> definer-word, children can be dynamically created. Such children
> inherit the anonymous code and have a data field (at HERE) that can
> be initialized from the data passed to the definer word.
In my experiments with this, I arrived at a [does> ... ;] construction
which use is quite similar to create ... does>.
An example with three "closures" sharing some state:
: counter ( n -- xt1 xt2 xt3 )
here swap , dup [does> ! ;] over [does> @ ;] rot [does> +! ;] ;
This is equivalent with the following "nonymous" code:
: setter create , does> @ ! ;
: getter create , does> @ @ ;
: counter ( n "name1 name2 name3" -- )
here swap , dup setter dup getter create , does> @ +! ;
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar
Anonymous code/data/create-does mhx@iae.nl (Marcel Hendrix) - 2013-04-02 23:46 +0200
Re: Anonymous code/data/create-does "WJ" <w_a_x_man@yahoo.com> - 2013-04-02 22:51 +0000
Re: Anonymous code/data/create-does "WJ" <w_a_x_man@yahoo.com> - 2013-04-02 23:00 +0000
Re: Anonymous code/data/create-does Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2013-04-03 11:07 +0100
Re: Anonymous code/data/create-does m.a.m.hendrix@tue.nl - 2013-04-03 06:53 -0700
Re: Anonymous code/data/create-does Alex McDonald <blog@rivadpm.com> - 2013-04-03 13:43 -0700
Re: Anonymous code/data/create-does Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2013-04-04 18:07 +0100
Re: Anonymous code/data/create-does mhx@iae.nl (Marcel Hendrix) - 2013-04-04 00:38 +0200
Re: Anonymous code/data/create-does Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2013-04-04 18:18 +0100
Re: Anonymous code/data/create-does mhx@iae.nl (Marcel Hendrix) - 2013-04-04 20:29 +0200
Re: Anonymous code/data/create-does mhx@iae.nl (Marcel Hendrix) - 2013-04-06 20:40 +0200
Re: Anonymous code/data/create-does Alex McDonald <blog@rivadpm.com> - 2013-04-06 14:09 -0700
Re: Anonymous code/data/create-does mhx@iae.nl (Marcel Hendrix) - 2013-04-07 02:04 +0200
Re: Anonymous code/data/create-does Alex McDonald <blog@rivadpm.com> - 2013-04-06 20:34 -0700
Re: Anonymous code/data/create-does mhx@iae.nl (Marcel Hendrix) - 2013-04-07 14:00 +0200
Re: Anonymous code/data/create-does kenney@cix.compulink.co.uk - 2013-04-08 02:38 -0500
Re: Anonymous code/data/create-does Roelf Toxopeus <rt4all@notthis.hetnet.nl> - 2013-04-08 10:58 +0200
Re: Anonymous code/data/create-does Alex McDonald <blog@rivadpm.com> - 2013-04-08 14:57 -0700
Re: Anonymous code/data/create-does Bernd Paysan <bernd.paysan@gmx.de> - 2013-04-08 19:26 +0200
Re: Anonymous code/data/create-does kenney@cix.compulink.co.uk - 2013-04-09 02:07 -0500
Re: Anonymous code/data/create-does mhx@iae.nl (Marcel Hendrix) - 2013-04-03 22:44 +0200
Re: Anonymous code/data/create-does Lars Brinkhoff <lars.spam@nocrew.org> - 2013-04-04 12:42 +0200
Re: Anonymous code/data/create-does Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-04-04 07:04 -0500
Re: Anonymous code/data/create-does Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-04-04 07:07 -0500
csiph-web