Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #13998 > unrolled thread
| Started by | mhx@iae.nl (Marcel Hendrix) |
|---|---|
| First post | 2012-07-14 15:55 +0200 |
| Last post | 2012-07-25 03:55 +0400 |
| Articles | 20 on this page of 159 — 18 participants |
Back to article view | Back to comp.lang.forth
Quotations revisited mhx@iae.nl (Marcel Hendrix) - 2012-07-14 15:55 +0200
Re: Quotations revisited stephenXXX@mpeforth.com (Stephen Pelc) - 2012-07-15 19:26 +0000
Re: Quotations revisited Bernd Paysan <bernd.paysan@gmx.de> - 2012-07-15 23:53 +0200
Re: Quotations revisited mhx@iae.nl (Marcel Hendrix) - 2012-07-15 23:54 +0200
Re: Quotations revisited Bernd Paysan <bernd.paysan@gmx.de> - 2012-07-16 00:48 +0200
Re: Quotations revisited Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-07-22 15:01 +0000
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-23 16:49 +0000
Re: Quotations revisited Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-07-23 21:39 +0000
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-25 13:13 +0000
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-22 11:07 -0500
Re: Quotations revisited Paul Rubin <no.email@nospam.invalid> - 2012-07-22 10:21 -0700
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-22 12:35 -0500
Re: Quotations revisited Paul Rubin <no.email@nospam.invalid> - 2012-07-22 11:39 -0700
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-22 15:16 -0500
Re: Quotations revisited Paul Rubin <no.email@nospam.invalid> - 2012-07-22 14:35 -0700
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-23 04:18 -0500
Re: Quotations revisited Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-07-23 12:58 +0000
Re: Quotations revisited Paul Rubin <no.email@nospam.invalid> - 2012-07-23 11:55 -0700
Re: Quotations revisited BruceMcF <agila61@netscape.net> - 2012-07-23 05:45 -0700
Re: Quotations revisited Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-07-27 12:41 +0000
Re: Quotations revisited "Elizabeth D. Rather" <erather@forth.com> - 2012-07-15 14:11 -1000
Re: Quotations revisited "A. K." <akk@nospam.org> - 2012-07-16 07:47 +0200
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-16 13:56 +0000
Re: Quotations revisited "Elizabeth D. Rather" <erather@forth.com> - 2012-07-16 07:20 -1000
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-17 13:49 +0000
Re: Quotations revisited Mark Wills <markrobertwills@yahoo.co.uk> - 2012-07-16 02:32 -0700
Re: Quotations revisited Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-07-27 12:58 +0000
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-16 04:32 -0500
Re: Quotations revisited stephenXXX@mpeforth.com (Stephen Pelc) - 2012-07-16 11:41 +0000
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-16 07:40 -0500
Re: Quotations revisited stephenXXX@mpeforth.com (Stephen Pelc) - 2012-07-16 14:05 +0000
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-16 09:20 -0500
Re: Quotations revisited stephenXXX@mpeforth.com (Stephen Pelc) - 2012-07-16 15:46 +0000
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-16 11:33 -0500
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-16 15:32 +0000
Re: Quotations revisited stephenXXX@mpeforth.com (Stephen Pelc) - 2012-07-16 17:56 +0000
Re: Quotations revisited Bernd Paysan <bernd.paysan@gmx.de> - 2012-07-16 23:37 +0200
Re: Quotations revisited Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-07-27 13:05 +0000
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-27 08:21 -0500
Re: Quotations revisited Roelf Toxopeus <rt4all@notthis.hetnet.nl> - 2012-07-16 10:14 +0200
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-16 04:23 -0500
Re: Quotations revisited m.a.m.hendrix@tue.nl - 2012-07-16 03:39 -0700
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-16 07:09 -0500
Re: Quotations revisited mhx@iae.nl (Marcel Hendrix) - 2012-07-16 23:47 +0200
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-17 04:14 -0500
Re: Quotations revisited Coos Haak <chforth@hccnet.nl> - 2012-07-17 17:39 +0200
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-17 12:18 -0500
Re: Quotations revisited mhx@iae.nl (Marcel Hendrix) - 2012-07-17 20:26 +0200
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-19 16:21 +0000
Re: Quotations revisited Alex McDonald <blog@rivadpm.com> - 2012-07-19 15:58 -0700
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-16 14:05 +0000
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-16 12:47 +0000
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-16 08:56 -0500
Re: Quotations revisited Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2012-07-16 15:04 +0100
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-16 09:23 -0500
Re: Quotations revisited Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2012-07-16 17:38 +0100
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-16 12:58 -0500
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-16 14:56 +0000
Re: Quotations revisited Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-07-16 22:53 +0000
Re: Quotations revisited BruceMcF <agila61@netscape.net> - 2012-07-16 19:59 -0700
Re: Quotations revisited "Elizabeth D. Rather" <erather@forth.com> - 2012-07-16 17:04 -1000
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-17 06:51 +0000
Re: Quotations revisited "Elizabeth D. Rather" <erather@forth.com> - 2012-07-16 21:39 -1000
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-17 07:48 +0000
Re: Quotations revisited "Elizabeth D. Rather" <erather@forth.com> - 2012-07-16 22:24 -1000
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-17 10:48 +0000
Re: Quotations revisited "Elizabeth D. Rather" <erather@forth.com> - 2012-07-17 08:19 -1000
Re: Quotations revisited Aleksej Saushev <asau@inbox.ru> - 2012-07-18 01:31 +0400
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-19 16:11 +0000
Re: Quotations revisited "Elizabeth D. Rather" <erather@forth.com> - 2012-07-19 12:41 -1000
Re: Quotations revisited Aleksej Saushev <asau@inbox.ru> - 2012-07-21 01:24 +0400
Re: Quotations revisited "Elizabeth D. Rather" <erather@forth.com> - 2012-07-20 16:20 -1000
Re: Quotations revisited Alex McDonald <blog@rivadpm.com> - 2012-07-21 03:59 -0700
Re: Quotations revisited "Elizabeth D. Rather" <erather@forth.com> - 2012-07-21 21:33 -1000
Re: Quotations revisited Alex McDonald <blog@rivadpm.com> - 2012-07-22 01:35 -0700
Re: Quotations revisited Aleksej Saushev <asau@inbox.ru> - 2012-07-22 21:19 +0400
Re: Quotations revisited "Elizabeth D. Rather" <erather@forth.com> - 2012-07-22 08:15 -1000
Re: Quotations revisited Paul Rubin <no.email@nospam.invalid> - 2012-07-22 11:48 -0700
Re: Quotations revisited Coos Haak <chforth@hccnet.nl> - 2012-07-22 21:48 +0200
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-22 15:22 -0500
Re: Quotations revisited Paul Rubin <no.email@nospam.invalid> - 2012-07-22 14:50 -0700
Re: Quotations revisited Paul Rubin <no.email@nospam.invalid> - 2012-07-22 15:08 -0700
Re: Quotations revisited Alex McDonald <blog@rivadpm.com> - 2012-07-22 15:20 -0700
Re: Quotations revisited Aleksej Saushev <asau@inbox.ru> - 2012-07-23 03:29 +0400
Re: Quotations revisited "Elizabeth D. Rather" <erather@forth.com> - 2012-07-22 14:22 -1000
Re: Quotations revisited Aleksej Saushev <asau@inbox.ru> - 2012-07-23 05:46 +0400
Re: Quotations revisited "Elizabeth D. Rather" <erather@forth.com> - 2012-07-22 21:46 -1000
Re: Quotations revisited Aleksej Saushev <asau@inbox.ru> - 2012-07-25 03:31 +0400
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-23 16:50 +0000
Re: Quotations revisited "Elizabeth D. Rather" <erather@forth.com> - 2012-07-23 07:57 -1000
Re: Quotations revisited Aleksej Saushev <asau@inbox.ru> - 2012-07-25 03:38 +0400
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-26 13:01 +0000
Re: Quotations revisited Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-07-21 12:10 +0000
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-21 09:19 -0500
Re: Quotations revisited Bernd Paysan <bernd.paysan@gmx.de> - 2012-07-21 18:58 +0200
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-22 04:24 -0500
Re: Quotations revisited Bernd Paysan <bernd.paysan@gmx.de> - 2012-07-22 14:25 +0200
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-22 11:11 -0500
Re: Quotations revisited Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-07-21 19:29 +0000
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-23 16:31 +0000
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-23 12:21 -0500
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-23 17:32 +0000
Re: Quotations revisited Paul Rubin <no.email@nospam.invalid> - 2012-07-23 11:23 -0700
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-24 03:28 -0500
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-25 13:15 +0000
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-25 11:47 -0500
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-26 13:06 +0000
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-26 09:50 -0500
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-26 15:11 +0000
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-26 11:06 -0500
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-26 16:46 +0000
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-27 04:52 -0500
Re: Quotations revisited Paul Rubin <no.email@nospam.invalid> - 2012-07-26 09:48 -0700
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-27 14:51 +0000
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-28 08:29 -0500
Re: Quotations revisited Paul Rubin <no.email@nospam.invalid> - 2012-07-29 20:55 -0700
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-30 04:40 -0500
Re: Quotations revisited Paul Rubin <no.email@nospam.invalid> - 2012-07-31 23:46 -0700
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-08-01 04:30 -0500
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-23 16:17 +0000
Re: Quotations revisited "Rod Pemberton" <do_not_have@notemailnot.cmm> - 2012-07-22 18:41 -0400
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-23 16:53 +0000
Re: Quotations revisited Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-07-17 12:22 +0000
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-17 07:30 -0500
Re: Quotations revisited Alex McDonald <blog@rivadpm.com> - 2012-07-17 06:34 -0700
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-17 09:04 -0500
Re: Quotations revisited Alex McDonald <blog@rivadpm.com> - 2012-07-18 07:07 -0700
Re: Quotations revisited Coos Haak <chforth@hccnet.nl> - 2012-07-18 17:43 +0200
Re: Quotations revisited Alex McDonald <blog@rivadpm.com> - 2012-07-18 09:29 -0700
Re: Quotations revisited Coos Haak <chforth@hccnet.nl> - 2012-07-18 20:59 +0200
Re: Quotations revisited Coos Haak <chforth@hccnet.nl> - 2012-07-18 21:14 +0200
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-19 16:05 +0000
Re: Quotations revisited Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-07-20 14:50 +0000
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-20 15:08 +0000
Re: Quotations revisited Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-07-21 11:27 +0000
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-23 16:28 +0000
Re: Quotations revisited Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-07-23 19:41 +0000
Re: Quotations revisited Alex McDonald <blog@rivadpm.com> - 2012-07-18 10:18 -0700
Re: Quotations revisited anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-07-19 17:00 +0000
Re: Quotations revisited Alex McDonald <blog@rivadpm.com> - 2012-07-19 15:34 -0700
Re: Quotations revisited Alex McDonald <blog@rivadpm.com> - 2012-07-19 16:08 -0700
Re: Quotations revisited Bernd Paysan <bernd.paysan@gmx.de> - 2012-07-17 20:09 +0200
Re: Quotations revisited stephenXXX@mpeforth.com (Stephen Pelc) - 2012-07-16 12:01 +0000
Re: Quotations revisited Paul Rubin <no.email@nospam.invalid> - 2012-07-16 10:42 -0700
Re: Quotations revisited stephenXXX@mpeforth.com (Stephen Pelc) - 2012-07-16 18:06 +0000
Re: Quotations revisited "Elizabeth D. Rather" <erather@forth.com> - 2012-07-16 11:08 -1000
Re: Quotations revisited stephenXXX@mpeforth.com (Stephen Pelc) - 2012-07-16 21:38 +0000
Re: Quotations revisited Bernd Paysan <bernd.paysan@gmx.de> - 2012-07-17 00:29 +0200
Re: Quotations revisited "Elizabeth D. Rather" <erather@forth.com> - 2012-07-16 12:38 -1000
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-17 04:20 -0500
Re: Quotations revisited Alex McDonald <blog@rivadpm.com> - 2012-07-17 03:21 -0700
Re: Quotations revisited Alex McDonald <blog@rivadpm.com> - 2012-07-17 03:14 -0700
Re: Quotations revisited Bernd Paysan <bernd.paysan@gmx.de> - 2012-07-17 19:58 +0200
Re: Quotations revisited Andrew Haley <andrew29@littlepinkcloud.invalid> - 2012-07-17 13:05 -0500
Re: Quotations revisited stephenXXX@mpeforth.com (Stephen Pelc) - 2012-07-20 11:12 +0000
Re: Quotations revisited Alex McDonald <blog@rivadpm.com> - 2012-07-20 05:40 -0700
Re: Quotations revisited stephenXXX@mpeforth.com (Stephen Pelc) - 2012-07-20 15:55 +0000
Re: Quotations revisited Paul Rubin <no.email@nospam.invalid> - 2012-07-22 20:54 -0700
Re: Quotations revisited Aleksej Saushev <asau@inbox.ru> - 2012-07-25 03:55 +0400
Page 1 of 8 [1] 2 3 4 5 6 7 8 Next page →
| From | mhx@iae.nl (Marcel Hendrix) |
|---|---|
| Date | 2012-07-14 15:55 +0200 |
| Subject | Quotations revisited |
| Message-ID | <00808889968435@frunobulax.edu> |
Recently, the subject of quotations popped up again and I remembered
an unfinished project.
It proves that in iForth (a simple form of) quotations takes only three
lines of code. The main limitation is that LOCALS are not (yet) possible
inside a quotation.
You can use a quotation outside of the definition where it was created,
but it does not 'remember' any state.
-marcel
--
0 VALUE dict : myEXIT -R [ -OPT ] ;
: [: ( -- ) POSTPONE AHEAD HERE TO dict -OPT POSTPONE >R ; IMMEDIATE
: ;] ( -- xt ) POSTPONE myEXIT POSTPONE THEN dict POSTPONE LITERAL ; IMMEDIATE
: test PI FLOCAL p
[: F+ F+ ;]
[: F- F- ;]
[: F* F* ;] LOCALS| xt* xt- xt+ |
11e 2e 3e xt+ EXECUTE F.
11e 2e 3e xt- EXECUTE F.
11e 2e 3e xt* EXECUTE F.
p F. ;
defer do-this defer do-that : generic do-this do-that ;
: mode-1 [: ." x" ;] [is] do-this [: ." y" ;] [is] do-that ;
: mode-2 [: ." this " ;] [is] do-this [: ." that " ;] [is] do-that ;
: .ABOUT CR ." Try: test -- Prints `16.000000 12.000000 66.000000 3.141593`"
CR ." mode-1 generic -- Prints `xy`"
CR ." mode-2 generic -- Prints `this that`" ;
[toc] | [next] | [standalone]
| From | stephenXXX@mpeforth.com (Stephen Pelc) |
|---|---|
| Date | 2012-07-15 19:26 +0000 |
| Message-ID | <50031807.129829772@192.168.0.50> |
| In reply to | #13998 |
On Sat, 14 Jul 2012 15:55:03 +0200, mhx@iae.nl (Marcel Hendrix) wrote: >Recently, the subject of quotations popped up again and I remembered >an unfinished project. Given the increasing popularity of talking about "quotations" and "closures", would someone like to specify them in Forth terminology. Andrew provided an implementation that only made sense to people with carnal knowledge of SwiftForth. I have seen two or three sets of requirements dicussed, but for those of us who distinguish between hand-waving and specifications, would an interested party be prepared to specify what is required? Stephen P.S. "Go read this in WikiPedia" is inadequate. -- Stephen Pelc, stephenXXX@mpeforth.com MicroProcessor Engineering Ltd - More Real, Less Time 133 Hill Lane, Southampton SO15 5AF, England tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691 web: http://www.mpeforth.com - free VFX Forth downloads
[toc] | [prev] | [next] | [standalone]
| From | Bernd Paysan <bernd.paysan@gmx.de> |
|---|---|
| Date | 2012-07-15 23:53 +0200 |
| Message-ID | <jtve49$99d$1@online.de> |
| In reply to | #14020 |
Stephen Pelc wrote:
> On Sat, 14 Jul 2012 15:55:03 +0200, mhx@iae.nl (Marcel Hendrix) wrote:
>
>>Recently, the subject of quotations popped up again and I remembered
>>an unfinished project.
>
> Given the increasing popularity of talking about "quotations" and
> "closures", would someone like to specify them in Forth terminology.
> Andrew provided an implementation that only made sense to people
> with carnal knowledge of SwiftForth.
Ok, quotations are fairly trivial. The experession
: foo ... [: some words ;] ... ;
is equal to
:noname some words ; Constant #temp#
: foo ... #temp# ... ;
I.e.
[: ( -- nestd-sys )
Compilation: suspends compiling to the current definition, starts a new
nested definition, and compilation continues with this nested
definition.
;] ( nested-sys -- )
Compilation: Ends the current nested definition, and resumes compilation
to the previous current definition. It appends the following run-time to
the current definition:
run-time: ( -- xt )
xt is the execution token to execute the nested definition.
If it's just a quotation, it can have its own locals, but it can't
access the locals of the outer word. We have some boy compilers here
(iForth, it would be possible with Gforth, too), which could access
locals from the outer scope, but not as real closure or correctly nested
frame.
Boy compiler:
: foo { a b } ... [: ... a b ... ;] execute ;
Here, a and b referenced in the boy-closure are offsets into the locals
stack which are identical to code generated within foo, and when
executed from within foo directly, they access the same locals. These
are not real closures, not even correctly nested frames.
Algol 60 (with its famous man-or-boy-test) has nested frames, which
requires that the xt carries a reference to the scope it was created in,
i.e. [: would produce an xt at run-time, which sets the frame for access
to outer locals, and then runs the code defined within the [: ;]
boundaries. Algol-like compilers usually solve that by adding an
implicit paramenter to the nested function, which points to the
environment, and the compiler knows to insert the proper parameter, but
in Forth, we can't do this.
Full closures go even further, they make sure that the environment is
active as long as the closure (the xt returned after ;]) is alive. This
means that the locals would be allocated on the heap, an some sort of
garbage collection is necessary to free unused memory.
> I have seen two or three sets of requirements dicussed, but for
> those of us who distinguish between hand-waving and specifications,
> would an interested party be prepared to specify what is required?
>
> Stephen
> P.S. "Go read this in WikiPedia" is inadequate.
Read the source, Luke. There are quotations for VFX in the MINOS
harness.
This is [: ;] in VFX Forth, not taking into account locals, stripped
down to the actual requirement:
: [: ( compile-time: -- nest-sys )
<headerless> @ last @ POSTPONE AHEAD
postpone [ :noname ; immediate
: ;] ( compile-time: nest-sys -- ; run-time: -- xt )
discard-sinline POSTPONE ; ( xt ) >r
] POSTPONE THEN r> POSTPONE Literal
last ! <headerless> ! discard-sinline ; immediate
--
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://bernd-paysan.de/
[toc] | [prev] | [next] | [standalone]
| From | mhx@iae.nl (Marcel Hendrix) |
|---|---|
| Date | 2012-07-15 23:54 +0200 |
| Message-ID | <58811288968435@frunobulax.edu> |
| In reply to | #14020 |
stephenXXX@mpeforth.com (Stephen Pelc) writes Re: Quotations revisited > On Sat, 14 Jul 2012 15:55:03 +0200, mhx@iae.nl (Marcel Hendrix) wrote: >>Recently, the subject of quotations popped up again and I remembered >>an unfinished project. > Given the increasing popularity of talking about "quotations" and > "closures", would someone like to specify them in Forth terminology. > Andrew provided an implementation that only made sense to people > with carnal knowledge of SwiftForth. I'll answer in the hope to stand corrected :-) A "quotation" is :noname definition that can be nested in another definition. Note that so far it would only be semantics; obviously :noname ( -- ) ." yeah" ; constant a : test ( -- ) a execute ; does the same as : test ( -- ) [: ." yeah" ;] execute ; Technically, some systems may have problems allowing locals in a quotation, i.e. : test ( -- ) 8 locals| x | 5 [: locals| x | x 3 * . ;] execute x . ; A rather easy extension would be to let code access (not necessarily modify) the locals of the hosting definition (printing 24 here): : test ( -- ) 8 locals| x | [: x 3 * . ;] execute ; However, this is getting hairy: : test ( -- xt ) 8 locals| x | [: x 3 * . ;] ; test execute ( ? ) AFAIU, when the implementation is such that the quotation permanently 'remembers' the value of 'x' (prints 24), this is called a 'closure.' Knuth's Man-Or-Boy test creates a quotation that *modifies* the outer locals and then recursively calls its host, accessing outer locals that one might have expected to long gone out of scope. It forces the quotation implementation to store copies of *all imaginable* outer locals and make them permanently available. This can get even more interesting when a closure is required to remember not only locals, but things like BASE, >IN, arbitrary variables, file handles, buffer addresses, etc..(*) > I have seen two or three sets of requirements discussed, but for > those of us who distinguish between hand-waving and specifications, > would an interested party be prepared to specify what is required? Maybe we first need a convincing example of the usefulness of quotations and closures -- (*) would certainly be useful, but the cost seems to be a little excessive? -marcel
[toc] | [prev] | [next] | [standalone]
| From | Bernd Paysan <bernd.paysan@gmx.de> |
|---|---|
| Date | 2012-07-16 00:48 +0200 |
| Message-ID | <jtvhcc$sdm$1@online.de> |
| In reply to | #14026 |
Marcel Hendrix wrote:
> Maybe we first need a convincing example of the usefulness of
> quotations and closures -- (*) would certainly be useful, but
> the cost seems to be a little excessive?
Quotations are quite useful when you do higher-order functions. We have
discussed words like LIST>, which take a list as argument, and loop over
the rest of the word with each item. Having a MAP-LIST is easier to
implement (especially for compilers like VFX and iForth, others have no
problems ;-), and quotations make it easier to write code for this.
Closures are something different, they contain both a function *and*
data. We have something like that in Forth - with name and persistent
in the dictionary, it's defined by CREATE and DOES>. Having the same
available with anonymous definition is useful, but it doesn't
necessarily have to be a closure as implementation (a closure always
means access to outer locals).
IMHO the price for real closures are too high to be paid in Forth - real
closures mean that you can't have a stack for locals, you absolutly need
to allocate them from the heap and have garbage collection.
A compromise would be the [:{ I proposed - this is a "poor man's
closure": it would be freed explicitly (you say <xt> free throw), and it
would take arguments from the stack. IMHO it feels much more Forth-
like: It doesn't come with the cost of full closures, where you can't
know the lifetime of a local frame in advance, and therefore you have to
make them live on a heap by default.
It's far better to have only those things to live on the heap which
absolutely must live there.
--
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://bernd-paysan.de/
[toc] | [prev] | [next] | [standalone]
| From | Albert van der Horst <albert@spenarnc.xs4all.nl> |
|---|---|
| Date | 2012-07-22 15:01 +0000 |
| Message-ID | <m7khqu.g37@spenarnc.xs4all.nl> |
| In reply to | #14027 |
In article <jtvhcc$sdm$1@online.de>, Bernd Paysan <bernd.paysan@gmx.de> wrote:
>Marcel Hendrix wrote:
>> Maybe we first need a convincing example of the usefulness of
>> quotations and closures -- (*) would certainly be useful, but
>> the cost seems to be a little excessive?
>
>Quotations are quite useful when you do higher-order functions. We have
>discussed words like LIST>, which take a list as argument, and loop over
>the rest of the word with each item. Having a MAP-LIST is easier to
>implement (especially for compilers like VFX and iForth, others have no
>problems ;-), and quotations make it easier to write code for this.
>
>Closures are something different, they contain both a function *and*
>data. We have something like that in Forth - with name and persistent
>in the dictionary, it's defined by CREATE and DOES>. Having the same
>available with anonymous definition is useful, but it doesn't
>necessarily have to be a closure as implementation (a closure always
>means access to outer locals).
Real closures probably require to remember the search order.
I think that Forth collapses if the weight of closures is added.
>
>IMHO the price for real closures are too high to be paid in Forth - real
>closures mean that you can't have a stack for locals, you absolutly need
>to allocate them from the heap and have garbage collection.
Indeed.
>A compromise would be the [:{ I proposed - this is a "poor man's
>closure": it would be freed explicitly (you say <xt> free throw), and it
>would take arguments from the stack. IMHO it feels much more Forth-
>like: It doesn't come with the cost of full closures, where you can't
>know the lifetime of a local frame in advance, and therefore you have to
>make them live on a heap by default.
If we compare the situation with LISP then Forth lacks a rigorous
theoretical framework. In LISP you may define something general and
it may work in unexpected ways. In Forth we must restrict ourselves
or we get unexpected difficulties.
>
>It's far better to have only those things to live on the heap which
>absolutely must live there.
>
>--
>Bernd Paysan
Groetjes Albert
--
--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
[toc] | [prev] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2012-07-23 16:49 +0000 |
| Message-ID | <2012Jul23.184911@mips.complang.tuwien.ac.at> |
| In reply to | #14266 |
Albert van der Horst <albert@spenarnc.xs4all.nl> writes:
>Real closures probably require to remember the search order.
Why do you think so?
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2012: http://www.euroforth.org/ef12/
[toc] | [prev] | [next] | [standalone]
| From | Albert van der Horst <albert@spenarnc.xs4all.nl> |
|---|---|
| Date | 2012-07-23 21:39 +0000 |
| Message-ID | <m7mutd.auf@spenarnc.xs4all.nl> |
| In reply to | #14323 |
In article <2012Jul23.184911@mips.complang.tuwien.ac.at>, Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote: >Albert van der Horst <albert@spenarnc.xs4all.nl> writes: >>Real closures probably require to remember the search order. > >Why do you think so? Not that I pretend to be an expert on closures, i thought EVALUATE ? > >- anton >-- >M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
[toc] | [prev] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2012-07-25 13:13 +0000 |
| Message-ID | <2012Jul25.151347@mips.complang.tuwien.ac.at> |
| In reply to | #14334 |
Albert van der Horst <albert@spenarnc.xs4all.nl> writes:
>In article <2012Jul23.184911@mips.complang.tuwien.ac.at>,
>Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>>Albert van der Horst <albert@spenarnc.xs4all.nl> writes:
>>>Real closures probably require to remember the search order.
>>
>>Why do you think so?
>
>Not that I pretend to be an expert on closures, i thought
>EVALUATE ?
What about EVALUATE? Using it is usually a bad idea. Has nothing to
do with closures, though.
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2012: http://www.euroforth.org/ef12/
[toc] | [prev] | [next] | [standalone]
| From | Andrew Haley <andrew29@littlepinkcloud.invalid> |
|---|---|
| Date | 2012-07-22 11:07 -0500 |
| Message-ID | <GvKdnaDRrvOjuJHNnZ2dnUVZ8nidnZ2d@supernews.com> |
| In reply to | #14027 |
Bernd Paysan <bernd.paysan@gmx.de> wrote:
> IMHO the price for real closures are too high to be paid in Forth - real
> closures mean that you can't have a stack for locals, you absolutly need
> to allocate them from the heap and have garbage collection.
I don't think that's really true: only the closures themselves need to
be heap-allocated.
> A compromise would be the [:{ I proposed - this is a "poor man's
> closure": it would be freed explicitly (you say <xt> free throw),
> and it would take arguments from the stack. IMHO it feels much more
> Forth- like: It doesn't come with the cost of full closures, where
> you can't know the lifetime of a local frame in advance, and
> therefore you have to make them live on a heap by default.
>
> It's far better to have only those things to live on the heap which
> absolutely must live there.
Indeed.
Andrew.
[toc] | [prev] | [next] | [standalone]
| From | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Date | 2012-07-22 10:21 -0700 |
| Message-ID | <7xhaszpv8h.fsf@ruckus.brouhaha.com> |
| In reply to | #14268 |
Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
>> IMHO the price for real closures are too high to be paid in Forth - real
>> closures mean that you can't have a stack for locals, you absolutly need
>> to allocate them from the heap and have garbage collection.
>
> I don't think that's really true: only the closures themselves need to
> be heap-allocated.
The "hello world" of closures is a counter that increments when you call
it, something like:
: counter ( -- xt )
0 { k }
[: ( -- n ) k 1+ to k k ;]
;
That is supposed to be equivalent to the Scheme example:
(define (counter)
(let ((k 0))
(lambda () (set! k (1+ k)) k)))
Then you can have independent counters:
: e. ( xt -- ) execute . ; \ run xt ( -- n ) and print result
: foo ( -- )
counter { c1 } counter { c2 }
c1 e. c1 e. c1 e. c1 e. c1 e. \ prints 1 2 3 4 5
c2 e. c2 e. \ prints 1 2
c1 e. c1 e. \ prints 7 8
c2 e. c2 e. \ prints 3 4
;
So it seems to me that the local "k" in counter has to be heap
allocated.
[toc] | [prev] | [next] | [standalone]
| From | Andrew Haley <andrew29@littlepinkcloud.invalid> |
|---|---|
| Date | 2012-07-22 12:35 -0500 |
| Message-ID | <zuOdnQVa--hypJHNnZ2dnUVZ8uednZ2d@supernews.com> |
| In reply to | #14271 |
Paul Rubin <no.email@nospam.invalid> wrote:
> Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
>>> IMHO the price for real closures are too high to be paid in Forth - real
>>> closures mean that you can't have a stack for locals, you absolutly need
>>> to allocate them from the heap and have garbage collection.
>>
>> I don't think that's really true: only the closures themselves need to
>> be heap-allocated.
>
> The "hello world" of closures is a counter that increments when you call
> it, something like:
>
> : counter ( -- xt )
> 0 { k }
> [: ( -- n ) k 1+ to k k ;]
> ;
Sure, but we've been around this before, at some length: my preferred
form of Forth closures, should they ever exist, would capture the
values of locals in an enclosing scope, not references to them. I'm
not even convinced of the sanity of modifying the locals of some word,
let alone its utility. If you really need something you can modify,
it's easy enough to ALLOCATE it and put its address in a a local.
Andrew.
[toc] | [prev] | [next] | [standalone]
| From | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Date | 2012-07-22 11:39 -0700 |
| Message-ID | <7x7gtvr66e.fsf@ruckus.brouhaha.com> |
| In reply to | #14273 |
Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
> my preferred form of Forth closures, should they ever exist, would
> capture the values of locals in an enclosing scope, not references to
> them.
Do you mean the compiler should figure out what outer locals the closure
can possibly refer to, and copy those values into the closure? Hmm, ok.
> If you really need something you can modify, it's easy enough to
> ALLOCATE it and put its address in a a local.
If I understand what you're saying, the example becomes:
: counter ( -- xt )
1 cells allocate { k }
[: ( -- n ) 1 k @ +! k @ ;]
;
it still seems to me that you want to gc that word.
I think this closure stuff is pretty theoretical by Forth standards and
I'm a little bit surprised if anyone is actually considering it.
Besides probably introducing dependence on gc's, I see trouble debugging
closure code with not even runtime type checking, and limited usefulness
of the construct in the absence of pervasive gc'd data structures like
you'd find in Scheme. I guess Factor does this stuff (I haven't looked
at it) but I think it is sort of a stack-based Scheme dialect, not
really the same idea as Forth despite some surface similarity.
[toc] | [prev] | [next] | [standalone]
| From | Andrew Haley <andrew29@littlepinkcloud.invalid> |
|---|---|
| Date | 2012-07-22 15:16 -0500 |
| Message-ID | <UaqdnXgO1-ImwpHNnZ2dnUVZ8gCdnZ2d@supernews.com> |
| In reply to | #14275 |
Paul Rubin <no.email@nospam.invalid> wrote:
> Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
>> my preferred form of Forth closures, should they ever exist, would
>> capture the values of locals in an enclosing scope, not references to
>> them.
>
> Do you mean the compiler should figure out what outer locals the closure
> can possibly refer to, and copy those values into the closure? Hmm, ok.
Exactly.
>> If you really need something you can modify, it's easy enough to
>> ALLOCATE it and put its address in a a local.
>
> If I understand what you're saying, the example becomes:
>
> : counter ( -- xt )
> 1 cells allocate { k }
> [: ( -- n ) 1 k @ +! k @ ;]
> ;
>
> it still seems to me that you want to gc that word.
What for? Nothing in the closure refers to that word.
> I think this closure stuff is pretty theoretical by Forth standards
> and I'm a little bit surprised if anyone is actually considering it.
It'd be fairly easy to do: after all, GC in Forth isn't exactly
difficult.
Andrew.
[toc] | [prev] | [next] | [standalone]
| From | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Date | 2012-07-22 14:35 -0700 |
| Message-ID | <7xmx2rscmg.fsf@ruckus.brouhaha.com> |
| In reply to | #14278 |
Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
>> Do you mean the compiler should figure out what outer locals the closure
>> can possibly refer to, and copy those values into the closure? Hmm, ok.
> Exactly.
That sounds a little more complicated than the usual one-pass Forth
compilation approach, but I guess not too bad. It can probably be
handled similarly to locals.
>> : counter ( -- xt )
>> 1 cells allocate { k }
>> [: ( -- n ) 1 k @ +! k @ ;]
>> ;
>> it still seems to me that you want to gc that word.
> What for? Nothing in the closure refers to that word.
The "k" in the closure refers to the word, if I understand what we're
discussing, which I might not.
> It'd be fairly easy to do: after all, GC in Forth isn't exactly
> difficult.
I know of one implementation (Anton's) but I've thought of it as more of
a proof of concept than as something that has gotten any significant
traction. Maybe I'm wrong.
It still seems to me that once you've got a gc and the willingness to
use it in combination with closures and locals, you've basically got a
contorted and unsafe Lisp subset, and you may as well use a real Lisp
instead.
[toc] | [prev] | [next] | [standalone]
| From | Andrew Haley <andrew29@littlepinkcloud.invalid> |
|---|---|
| Date | 2012-07-23 04:18 -0500 |
| Message-ID | <qIudnXhC-ZRki5DNnZ2dnUVZ8sCdnZ2d@supernews.com> |
| In reply to | #14281 |
Paul Rubin <no.email@nospam.invalid> wrote:
> Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
>>> Do you mean the compiler should figure out what outer locals the closure
>>> can possibly refer to, and copy those values into the closure? Hmm, ok.
>> Exactly.
>
> That sounds a little more complicated than the usual one-pass Forth
> compilation approach, but I guess not too bad. It can probably be
> handled similarly to locals.
>
>>> : counter ( -- xt )
>>> 1 cells allocate { k }
>>> [: ( -- n ) 1 k @ +! k @ ;]
>>> ;
>>> it still seems to me that you want to gc that word.
>> What for? Nothing in the closure refers to that word.
>
> The "k" in the closure refers to the word,
No it doesn't: K is the address of a cell on the heap.
>> It'd be fairly easy to do: after all, GC in Forth isn't exactly
>> difficult.
>
> I know of one implementation (Anton's) but I've thought of it as more of
> a proof of concept than as something that has gotten any significant
> traction. Maybe I'm wrong.
>
> It still seems to me that once you've got a gc and the willingness to
> use it in combination with closures and locals, you've basically got a
> contorted and unsafe Lisp subset, and you may as well use a real Lisp
> instead.
Could be, but you need to think about application areas where Forth is
used. Forth is amazingly flexible, and you might want a really good
real-time lanuguage in an embedded with a GC'd language and GUI.
Andrew.
[toc] | [prev] | [next] | [standalone]
| From | Albert van der Horst <albert@spenarnc.xs4all.nl> |
|---|---|
| Date | 2012-07-23 12:58 +0000 |
| Message-ID | <m7m6p2.2yy@spenarnc.xs4all.nl> |
| In reply to | #14281 |
In article <7xmx2rscmg.fsf@ruckus.brouhaha.com>, Paul Rubin <no.email@nospam.invalid> wrote: >Andrew Haley <andrew29@littlepinkcloud.invalid> writes: > >> It'd be fairly easy to do: after all, GC in Forth isn't exactly >> difficult. > >I know of one implementation (Anton's) but I've thought of it as more of >a proof of concept than as something that has gotten any significant >traction. Maybe I'm wrong. > >It still seems to me that once you've got a gc and the willingness to >use it in combination with closures and locals, you've basically got a >contorted and unsafe Lisp subset, and you may as well use a real Lisp >instead. My thoughts exactly. However I arrived at a Forth with GC from the premis of a computer intelligence, a computer that boots into Forth and never stops investigating its environment and use a raw disk as background storage. To switch I need a normal PC that boots into Lisp and allows low level access. Do you know of such a beast? Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
[toc] | [prev] | [next] | [standalone]
| From | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Date | 2012-07-23 11:55 -0700 |
| Message-ID | <7xliia71f1.fsf@ruckus.brouhaha.com> |
| In reply to | #14311 |
Albert van der Horst <albert@spenarnc.xs4all.nl> writes: > To switch I need a normal PC that boots into Lisp and allows > low level access. Do you know of such a beast? I haven't tried either of these: http://common-lisp.net/project/movitz/ http://losak.sourceforge.net/ I think there are a few others too.
[toc] | [prev] | [next] | [standalone]
| From | BruceMcF <agila61@netscape.net> |
|---|---|
| Date | 2012-07-23 05:45 -0700 |
| Message-ID | <aad1bbc9-fecd-4752-8b85-c1bb84759f1b@googlegroups.com> |
| In reply to | #14275 |
On Sunday, July 22, 2012 2:39:53 PM UTC-4, Paul Rubin wrote:
> If I understand what you're saying, the example becomes:
>
> : counter ( -- xt )
> 1 cells allocate { k }
> [: ( -- n ) 1 k @ +! k @ ;]
> ;
>
> it still seems to me that you want to gc that word.
Is there an occasion for a closure as opposed to a quotation without the import of a heap local?
: counter ( -- xt )
1 cells allocate
[:{ k } ( -- n ) 1 k @ +! k @ ;] ;
With Bernd's xt that is a pointer to the executable with a method table sitting one cell behind, the method to free the heap locals could be included in method table pointer immediately preceding the executable that the extended-quotation xt is pointing to.
[toc] | [prev] | [next] | [standalone]
| From | Albert van der Horst <albert@spenarnc.xs4all.nl> |
|---|---|
| Date | 2012-07-27 12:41 +0000 |
| Message-ID | <m7tkll.ki7@spenarnc.xs4all.nl> |
| In reply to | #14271 |
In article <7xhaszpv8h.fsf@ruckus.brouhaha.com>,
Paul Rubin <no.email@nospam.invalid> wrote:
>Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
>>> IMHO the price for real closures are too high to be paid in Forth - real
>>> closures mean that you can't have a stack for locals, you absolutly need
>>> to allocate them from the heap and have garbage collection.
>>
>> I don't think that's really true: only the closures themselves need to
>> be heap-allocated.
>
>The "hello world" of closures is a counter that increments when you call
>it, something like:
>
> : counter ( -- xt )
> 0 { k }
> [: ( -- n ) k 1+ to k k ;]
> ;
>
In forth this would be
: counter CREATE-NONAME 0 , DOES> 1+ ;
Very simple, but indicating a certain lack of orthogonality in the
language, because there is no CREATE-NONAME that leaves an xt.
>That is supposed to be equivalent to the Scheme example:
>
> (define (counter)
> (let ((k 0))
> (lambda () (set! k (1+ k)) k)))
>
>
>Then you can have independent counters:
>
> : e. ( xt -- ) execute . ; \ run xt ( -- n ) and print result
> : foo ( -- )
> counter { c1 } counter { c2 }
> c1 e. c1 e. c1 e. c1 e. c1 e. \ prints 1 2 3 4 5
> c2 e. c2 e. \ prints 1 2
> c1 e. c1 e. \ prints 7 8
> c2 e. c2 e. \ prints 3 4
> ;
Interesting. You want anonymous thingies, and the first you do is
give a name to them. I can do the same in Forth.
Assuming CREATE-NONAME
: e. >BODY ? ;
counter VALUE c1 counter VALUE c2
: c1 c1 execute ;
: c2 c2 execute ;
c1 e. c1 e. c1 e. c1 e. c1 e. \ prints 1 2 3 4 5
c2 e. c2 e. \ prints 1 2
c1 e. c1 e. \ prints 7 8
c2 e. c2 e. \ prints 3 4
As I said it is silly to do
counter VALUE/LOCAL c1
because
: counter CREATE 0 , DOES> 1+ ;
is perfectly adequate if used as
counter c1
>
>So it seems to me that the local "k" in counter has to be heap
>allocated.
Of course for this kind of thing you need permanent allocation.
Fortunately we have had the dictionary for years.
Groetjes Albert
--
--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
[toc] | [prev] | [next] | [standalone]
Page 1 of 8 [1] 2 3 4 5 6 7 8 Next page →
Back to top | Article view | comp.lang.forth
csiph-web