Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #20627
| From | Bernd Paysan <bernd.paysan@gmx.de> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Quotations revisited |
| Date | 2013-03-13 12:52 +0100 |
| Organization | 1&1 Internet AG |
| Message-ID | <khpp9q$2r0$1@online.de> (permalink) |
| References | <00808889968435@frunobulax.edu> <50040282.189860346@192.168.0.50> <771c3aa0-0b95-48af-b0fb-c6ae6269a266@googlegroups.com> |
Michael L Gassanenko wrote:
> 1. We need to decide what RECURSE means for quotations:
> call the quotation or call the enclosing named definition?
Call the quotation.
> 2. Closures (about which we sort of agreed to speak only
> theoretically), resemble CREATE-DOES> definitions in the
> same way as quotations resemble colon definitions.
> Quotations may reside in ROM; closures will need some RAM.
>
> 2.1. Closures assume run-time creation of execution tokens.
>
> 2.2. As to where the memory for data is allocated,
> I think, the best answer is: let the user choose, it may be
> ALLOCATE or HERE SWAP ALLOT .
Hm, this asks for some kind of vector. Use a deferred word for allocation,
or use some construct like <heap [:{ a b } ... ;] heap> to redirect
dictionary allocation temporarily to a heap object (or the other way round -
heap allocation to here).
However, I'm not convinced that we want closures as persistent objects - we
already have create does> for that. The only reason to use closures instead
of Create DOES> for persistent stuff is that they may be more comfortable to
write.
> 2.3. To create a closure, we will need to: allocate an area of
> memory with some room for the "code field"; fill the "data field"
> with the data; bind the closure with the desired behavior (writing
> to the "code field"); create an xt for that "code field".
>
> So we get something like:
> : foo
> ...
> {{ a b }} HERE SWAP ALLOT [DOES> DUP a SWAP b + ;]
> ...
> ;
Yes, that's sort of how you would do it.
--
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://bernd-paysan.de/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Quotations revisited Michael L Gassanenko <m_l_g3@yahoo.com> - 2013-03-13 01:54 -0700
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-13 04:21 -0500
Re: Quotations revisited Michael L Gassanenko <m_l_g3@yahoo.com> - 2013-03-13 03:36 -0700
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-13 07:14 -0500
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-03-13 11:55 +0000
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-13 07:20 -0500
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-03-13 14:36 +0000
Re: Quotations revisited albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-03-13 13:01 +0000
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-03-13 14:21 +0000
Re: Quotations revisited David Kuehling <dvdkhlng@gmx.de> - 2013-03-13 10:33 +0100
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-03-13 04:41 -0500
Re: Quotations revisited David Kuehling <dvdkhlng@gmx.de> - 2013-03-13 11:44 +0100
Re: Quotations revisited Lars Brinkhoff <lars.spam@nocrew.org> - 2013-03-13 11:23 +0100
Re: Quotations revisited Bernd Paysan <bernd.paysan@gmx.de> - 2013-03-13 12:52 +0100
Re: Quotations revisited Lars Brinkhoff <lars.spam@nocrew.org> - 2013-03-14 09:47 +0100
Re: Quotations revisited Sieur de Bienville <morrimichael@gmail.com> - 2013-03-14 10:45 -0700
Re: Quotations revisited Lars Brinkhoff <lars.spam@nocrew.org> - 2013-03-14 19:41 +0100
Re: Quotations revisited Sieur de Bienville <morrimichael@gmail.com> - 2013-03-14 12:58 -0700
Re: Quotations revisited Michael L Gassanenko <m_l_g3@yahoo.com> - 2013-03-14 23:09 -0700
csiph-web