Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #40544 > unrolled thread
| Started by | Tessa Bonting <tessa.bonting@gmail.com> |
|---|---|
| First post | 2015-07-12 06:48 -0700 |
| Last post | 2015-08-06 21:19 +0200 |
| Articles | 20 on this page of 126 — 22 participants |
Back to article view | Back to comp.lang.forth
How do quotation work, I can not foound them in 20xx Tessa Bonting <tessa.bonting@gmail.com> - 2015-07-12 06:48 -0700
Re: How do quotation work, I can not foound them in 20xx anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-12 15:10 +0000
Re: How do quotation work, I can not foound them in 20xx Tessa Bonting <tessa.bonting@gmail.com> - 2015-07-12 08:47 -0700
Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-13 01:15 -0700
Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-13 01:20 -0700
Re: How do quotation work, I can not foound them in 20xx Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-13 01:30 -0700
Re: How do quotation work, I can not foound them in 20xx Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-13 01:33 -0700
Re: How do quotation work, I can not foound them in 20xx Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-13 01:28 -0700
Re: How do quotation work, I can not foound them in 20xx Julian Fondren <julian.fondren@gmail.com> - 2015-07-12 08:23 -0700
Re: How do quotation work, I can not foound them in 20xx Coos Haak <chforth@hccnet.nl> - 2015-07-12 18:56 +0200
Re: How do quotation work, I can not foound them in 20xx Julian Fondren <julian.fondren@gmail.com> - 2015-07-13 20:24 -0700
Re: How do quotation work, I can not foound them in 20xx Coos Haak <chforth@hccnet.nl> - 2015-07-14 09:43 +0200
Re: How do quotation work, I can not foound them in 20xx "HAA" <someone@microsoft.com> - 2015-07-18 14:18 +1000
Re: How do quotation work, I can not foound them in 20xx "HAA" <someone@microsoft.com> - 2015-08-01 12:46 +1000
Re: How do quotation work, I can not foound them in 20xx mhx@iae.nl - 2015-08-01 00:52 -0700
Re: How do quotation work, I can not foound them in 20xx "HAA" <someone@microsoft.com> - 2015-08-02 18:16 +1000
Re: How do quotation work, I can not foound them in 20xx mhx@iae.nl - 2015-08-02 02:18 -0700
Re: How do quotation work, I can not foound them in 20xx "HAA" <someone@microsoft.com> - 2015-08-05 13:35 +1000
Re: How do quotation work, I can not foound them in 20xx Bernd Paysan <bernd.paysan@gmx.de> - 2015-08-01 21:37 +0200
Re: How do quotation work, I can not foound them in 20xx JennyB <jennybrien@googlemail.com> - 2015-08-05 06:00 -0700
Re: How do quotation work, I can not foound them in 20xx anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-08-05 13:16 +0000
Re: How do quotation work, I can not foound them in 20xx JennyB <jennybrien@googlemail.com> - 2015-08-05 09:40 -0700
Re: How do quotation work, I can not foound them in 20xx anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-08-06 14:34 +0000
Re: How do quotation work, I can not foound them in 20xx JennyB <jennybrien@googlemail.com> - 2015-08-07 00:33 -0700
Re: How do quotation work, I can not foound them in 20xx "HAA" <someone@microsoft.com> - 2015-08-15 12:37 +1000
Re: How do quotation work, I can not foound them in 20xx Bernd Paysan <bernd.paysan@gmx.de> - 2015-08-15 13:53 +0200
Re: How do quotation work, I can not foound them in 20xx "HAA" <someone@microsoft.com> - 2015-08-16 12:53 +1000
Re: How do quotation work, I can not foound them in 20xx "HAA" <someone@microsoft.com> - 2015-08-08 13:06 +1000
Re: How do quotation work, I can not foound them in 20xx "WJ" <w_a_x_man@yahoo.com> - 2015-09-15 03:23 +0000
Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-12 14:55 -0700
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-13 12:53 +0100
Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-13 06:13 -0700
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-13 16:00 +0100
Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-13 09:12 -0700
Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-13 09:26 -0700
Re: How do quotation work, I can not foound them in 20xx Coos Haak <chforth@hccnet.nl> - 2015-07-13 17:00 +0200
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-13 16:58 +0100
Re: How do quotation work, I can not foound them in 20xx Coos Haak <chforth@hccnet.nl> - 2015-07-13 20:53 +0200
Re: How do quotation work, I can not foound them in 20xx bettilyona@gmail.com - 2015-07-13 09:13 -0700
Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-13 09:15 -0700
Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-13 13:10 -0700
Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-13 14:24 -0700
Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-13 18:51 -0700
Re: How do quotation work, I can not foound them in 20xx Julian Fondren <julian.fondren@gmail.com> - 2015-07-13 20:19 -0700
Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-13 20:49 -0700
Re: How do quotation work, I can not foound them in 20xx Julian Fondren <julian.fondren@gmail.com> - 2015-07-13 21:48 -0700
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-14 09:38 +0100
Re: How do quotation work, I can not foound them in 20xx Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-13 21:44 -0700
Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-13 21:53 -0700
Re: How do quotation work, I can not foound them in 20xx Julian Fondren <julian.fondren@gmail.com> - 2015-07-13 22:04 -0700
Re: How do quotation work, I can not foound them in 20xx humptydumpty <ouatubi@gmail.com> - 2015-07-14 01:22 -0700
Re: How do quotation work, I can not foound them in 20xx humptydumpty <ouatubi@gmail.com> - 2015-07-14 01:47 -0700
Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-14 09:56 -0700
Re: How do quotation work, I can not foound them in 20xx Julian Fondren <julian.fondren@gmail.com> - 2015-07-14 10:45 -0700
Re: How do quotation work, I can not foound them in 20xx humptydumpty <ouatubi@gmail.com> - 2015-07-14 11:10 -0700
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-14 09:35 +0100
Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-14 02:17 -0700
Re: How do quotation work, I can not foound them in 20xx humptydumpty <ouatubi@gmail.com> - 2015-07-14 02:24 -0700
Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-14 02:25 -0700
Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-14 09:32 -0700
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-14 17:50 +0100
Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-14 10:48 -0700
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-14 18:59 +0100
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-14 20:49 +0100
Re: How do quotation work, I can not foound them in 20xx "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-15 00:52 -0400
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-15 12:09 +0100
Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-15 04:19 -0700
Re: How do quotation work, I can not foound them in 20xx "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-15 22:10 -0400
Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-16 00:42 -0700
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-16 14:29 +0100
Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-16 12:52 -0700
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-16 09:59 +0100
Re: How do quotation work, I can not foound them in 20xx Mike Mellen <mmellen@intellikey.com> - 2015-07-15 07:56 -0400
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-15 16:27 +0100
Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-15 10:47 -0700
Re: How do quotation work, I can not foound them in 20xx "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-15 21:50 -0400
Re: How do quotation work, I can not foound them in 20xx stephen@mpeforth.com (Stephen Pelc) - 2015-07-15 19:38 +0000
Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-15 12:58 -0700
Re: How do quotation work, I can not foound them in 20xx "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-15 22:20 -0400
Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-14 09:53 -0700
Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-14 10:12 -0700
Re: How do quotation work, I can not foound them in 20xx Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-14 10:53 -0700
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-14 20:06 +0100
Re: How do quotation work, I can not foound them in 20xx Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-14 12:18 -0700
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-14 20:52 +0100
Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-14 13:39 -0700
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-14 22:20 +0100
Re: How do quotation work, I can not foound them in 20xx Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-14 21:10 -0700
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-15 12:03 +0100
Re: How do quotation work, I can not foound them in 20xx Coos Haak <chforth@hccnet.nl> - 2015-07-15 14:16 +0200
Re: How do quotation work, I can not foound them in 20xx Coos Haak <chforth@hccnet.nl> - 2015-07-15 14:04 +0200
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-15 15:44 +0100
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-15 15:47 +0100
Re: How do quotation work, I can not foound them in 20xx anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-15 15:26 +0000
Re: How do quotation work, I can not foound them in 20xx JennyB <jennybrien@googlemail.com> - 2015-07-16 05:41 -0700
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-16 14:13 +0100
Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-14 14:18 -0700
Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-15 02:42 -0700
Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-15 01:26 -0700
Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-15 10:44 -0700
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-15 19:31 +0100
Re: How do quotation work, I can not foound them in 20xx Paul Rubin <no.email@nospam.invalid> - 2015-07-15 11:48 -0700
Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-15 12:13 -0700
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-15 20:18 +0100
Re: How do quotation work, I can not foound them in 20xx "WJ" <w_a_x_man@yahoo.com> - 2015-07-22 11:11 +0000
Re: How do quotation work, I can not foound them in 20xx Håkan Thörngren <hth313@gmail.com> - 2015-07-14 11:38 -0700
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-14 19:58 +0100
Re: How do quotation work, I can not foound them in 20xx anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-15 05:55 +0000
Re: How do quotation work, I can not foound them in 20xx Håkan Thörngren <hth313@gmail.com> - 2015-07-15 00:03 -0700
Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-15 01:41 -0700
Re: How do quotation work, I can not foound them in 20xx Paul Rubin <no.email@nospam.invalid> - 2015-07-13 22:05 -0700
Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-13 14:24 -0700
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-13 23:13 +0100
Re: How do quotation work, I can not foound them in 20xx "Elizabeth D. Rather" <erather@forth.com> - 2015-07-13 13:03 -1000
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-14 09:31 +0100
Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-15 13:24 -0700
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-15 22:04 +0100
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-13 22:52 +0100
Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-13 13:12 -0700
Re: How do lambdas work, I cannot find them in 20xx "WJ" <w_a_x_man@yahoo.com> - 2016-07-11 23:02 +0000
Re: How do lambdas work, I cannot find them in 20xx "WJ" <w_a_x_man@yahoo.com> - 2016-07-12 02:56 +0000
Re: How do quotation work, I can not foound them in 20xx stephen@mpeforth.com (Stephen Pelc) - 2015-07-13 13:16 +0000
Re: How do quotation work, I can not foound them in 20xx anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-13 16:00 +0000
Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-13 17:58 +0100
Re: How do quotation work, I can not foound them in 20xx Steve Graham <solitary.wanderer52@gmail.com> - 2015-08-06 09:54 -0700
Re: How do quotation work, I can not foound them in 20xx Coos Haak <chforth@hccnet.nl> - 2015-08-06 21:19 +0200
Page 1 of 7 [1] 2 3 4 5 6 7 Next page →
| From | Tessa Bonting <tessa.bonting@gmail.com> |
|---|---|
| Date | 2015-07-12 06:48 -0700 |
| Subject | How do quotation work, I can not foound them in 20xx |
| Message-ID | <b86cc539-45eb-433a-be9e-373efd8b373a@googlegroups.com> |
Hey to all, Can anyone tell me how qoutation work. Is the word being compiled temporary stopped or a forward branch inserted to skip the quotation? And where are they used for? As in : foo ( -- ) 0 [: 2 + ;] . ; foo 2
[toc] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2015-07-12 15:10 +0000 |
| Message-ID | <2015Jul12.171017@mips.complang.tuwien.ac.at> |
| In reply to | #40544 |
Tessa Bonting <tessa.bonting@gmail.com> writes:
>Hey to all,
>
>Can anyone tell me how qoutation work.
>Is the word being compiled temporary stopped or a forward branch
>inserted to skip the quotation?
Typically a branch around the quotation is inserted in the containing
definition.
- 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 2015: http://www.mpeforth.com/euroforth2015/euroforth2015.htm
[toc] | [prev] | [next] | [standalone]
| From | Tessa Bonting <tessa.bonting@gmail.com> |
|---|---|
| Date | 2015-07-12 08:47 -0700 |
| Message-ID | <238f0dc2-6714-44e0-ad7c-229702263daa@googlegroups.com> |
| In reply to | #40545 |
Op zondag 12 juli 2015 17:11:59 UTC+2 schreef Anton Ertl: > Tessa Bonting <tessa.bonting@gmail.com> writes: > >Hey to all, > > > >Can anyone tell me how qoutation work. > >Is the word being compiled temporary stopped or a forward branch > >inserted to skip the quotation? > > Typically a branch around the quotation is inserted in the containing > definition. > > - 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 2015: http://www.mpeforth.com/euroforth2015/euroforth2015.htm Thank you both, I forgotten the execute since I it was not clearly to me what the quation did. I like it allready and I will implment it.
[toc] | [prev] | [next] | [standalone]
| From | Mark Wills <markwills1970@gmail.com> |
|---|---|
| Date | 2015-07-13 01:15 -0700 |
| Message-ID | <00effa07-b7ec-4c5a-87dc-35696436c6e6@googlegroups.com> |
| In reply to | #40545 |
On Sunday, 12 July 2015 16:11:59 UTC+1, Anton Ertl wrote: > Tessa Bonting <tessa.bonting@gmail.com> writes: > >Hey to all, > > > >Can anyone tell me how qoutation work. > >Is the word being compiled temporary stopped or a forward branch > >inserted to skip the quotation? > > Typically a branch around the quotation is inserted in the containing > definition. > > - 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 2015: http://www.mpeforth.com/euroforth2015/euroforth2015.htm So, a quotation leaves it's XT on the stack, yes, to be consumed by EXECUTE later, yes?
[toc] | [prev] | [next] | [standalone]
| From | Mark Wills <markwills1970@gmail.com> |
|---|---|
| Date | 2015-07-13 01:20 -0700 |
| Message-ID | <e7ee3057-fd7b-4016-bf9a-46127b53a0df@googlegroups.com> |
| In reply to | #40559 |
On Monday, 13 July 2015 09:15:03 UTC+1, Mark Wills wrote: > On Sunday, 12 July 2015 16:11:59 UTC+1, Anton Ertl wrote: > > Tessa Bonting <tessa.bonting@gmail.com> writes: > > >Hey to all, > > > > > >Can anyone tell me how qoutation work. > > >Is the word being compiled temporary stopped or a forward branch > > >inserted to skip the quotation? > > > > Typically a branch around the quotation is inserted in the containing > > definition. > > > > - 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 2015: http://www.mpeforth.com/euroforth2015/euroforth2015.htm > > So, a quotation leaves it's XT on the stack, yes, to be consumed > by EXECUTE later, yes? And, furthermore, what happens at the end of the quotation? Does it EXIT, or does it run into the remaining definition. : foo a b [: c ;] d ; Presumably, when foo is executed, a nd b are executed, c is not, and d is? On exit from foo, the XT of the quotation c is on the stack?
[toc] | [prev] | [next] | [standalone]
| From | Raimond Dragomir <raimond.dragomir@gmail.com> |
|---|---|
| Date | 2015-07-13 01:30 -0700 |
| Message-ID | <c099813f-e7db-4b11-9e37-812791b3cc58@googlegroups.com> |
| In reply to | #40560 |
luni, 13 iulie 2015, 11:20:19 UTC+3, Mark Wills a scris: > On Monday, 13 July 2015 09:15:03 UTC+1, Mark Wills wrote: > > On Sunday, 12 July 2015 16:11:59 UTC+1, Anton Ertl wrote: > > > Tessa Bonting <tessa.bonting@gmail.com> writes: > > > >Hey to all, > > > > > > > >Can anyone tell me how qoutation work. > > > >Is the word being compiled temporary stopped or a forward branch > > > >inserted to skip the quotation? > > > > > > Typically a branch around the quotation is inserted in the containing > > > definition. > > > > > > - 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 2015: http://www.mpeforth.com/euroforth2015/euroforth2015.htm > > > > So, a quotation leaves it's XT on the stack, yes, to be consumed > > by EXECUTE later, yes? > > And, furthermore, what happens at the end of the quotation? Does > it EXIT, or does it run into the remaining definition. > > : foo a b [: c ;] d ; > > Presumably, when foo is executed, a nd b are executed, c is not, > and d is? On exit from foo, the XT of the quotation c is on the > stack? Yes, unless d consumes it first ...
[toc] | [prev] | [next] | [standalone]
| From | Raimond Dragomir <raimond.dragomir@gmail.com> |
|---|---|
| Date | 2015-07-13 01:33 -0700 |
| Message-ID | <857a4fa0-c983-4354-b513-e9c51f235705@googlegroups.com> |
| In reply to | #40562 |
> > And, furthermore, what happens at the end of the quotation? Does > > it EXIT, or does it run into the remaining definition. > > > > : foo a b [: c ;] d ; > > > > Presumably, when foo is executed, a nd b are executed, c is not, > > and d is? On exit from foo, the XT of the quotation c is on the > > stack? > > Yes, unless d consumes it first ... def foo 1 2 [ 3 ] 4 ; foo reDef ok foo hex .s 1 2 40D6BF 4 <S ok... swap execute .s 1 2 4 3 <S ok...
[toc] | [prev] | [next] | [standalone]
| From | Raimond Dragomir <raimond.dragomir@gmail.com> |
|---|---|
| Date | 2015-07-13 01:28 -0700 |
| Message-ID | <3a894524-99dd-4c12-b3bf-7c23cc47508d@googlegroups.com> |
| In reply to | #40559 |
luni, 13 iulie 2015, 11:15:03 UTC+3, Mark Wills a scris: > On Sunday, 12 July 2015 16:11:59 UTC+1, Anton Ertl wrote: > > Tessa Bonting <tessa.bonting@gmail.com> writes: > > >Hey to all, > > > > > >Can anyone tell me how qoutation work. > > >Is the word being compiled temporary stopped or a forward branch > > >inserted to skip the quotation? > > > > Typically a branch around the quotation is inserted in the containing > > definition. > > > > - 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 2015: http://www.mpeforth.com/euroforth2015/euroforth2015.htm > > So, a quotation leaves it's XT on the stack, yes, to be consumed > by EXECUTE later, yes? Yes. About the branch around the quotation, if you choose this implementation, a literal will be necessary also, to put the quotation's address on the data stack. I use a different implementation: a CALL around the quotation, and a simple R> instead of the literal.
[toc] | [prev] | [next] | [standalone]
| From | Julian Fondren <julian.fondren@gmail.com> |
|---|---|
| Date | 2015-07-12 08:23 -0700 |
| Message-ID | <12de19a8-a4b6-4f9e-b7c5-126bbb3e5fa0@googlegroups.com> |
| In reply to | #40544 |
On Sunday, July 12, 2015 at 8:48:30 AM UTC-5, Tessa Bonting wrote:
> Hey to all,
>
> Can anyone tell me how qoutation work.
> Is the word being compiled temporary stopped or a forward branch
> inserted to skip the quotation?
Sure? Either? Does it matter?
Have a limited implementation in ciforth, which branches over the
quotation:
: [: POSTPONE 0 POSTPONE IF HERE ; IMMEDIATE
: :] >R POSTPONE EXIT POSTPONE THEN R> POSTPONE LITERAL ; IMMEDIATE
: CALL >R ;
As used in:
: EACH-CHAR ( c-addr u qt -- ) LOCAL qt
BOUNDS ?DO I C@ qt CALL LOOP ;
: STARRY ( c-addr u -- )
[: &* EMIT EMIT :] EACH-CHAR &* EMIT ;
"hello" STARRY \ outputs: *h*e*l*l*o*
The limitation: you can't EXECUTE these quotations. Which means
you can't write code that is neutral as to whether it receives a
quotation or a quoted word -- an XT. An executable version would
I expect only require that [: construct a header, and that the
address put on the stack by :] refer to the part of it that a
normal XT would.
So you can easily add bad quotations to any Forth that respects
the return stack (or can be told to respect it), probably, and
can add better quotations after learning some details about
your Forth.
> And where are they used for?
They are anonymous definitions. They're used for code that
doesn't deserve a name that you would like to pass to a
higher-order word. What would you name the quotation above?
: STAR-THEN-CHAR ( c -- ) &* EMIT EMIT ;
: *EMIT ( c -- ) &* EMIT EMIT ;
: HELPER ( c -- ) &* EMIT EMIT ;
: AUX ( c -- ) &* EMIT EMIT ;
A particularly useful higher-order word to pass definitions to is
CATCH . For example if you have a mainloop for a game
: GO ( -- ) INIT
BEGIN do this do that do that other thing AGAIN ;
And you want to catch exceptions that reach it, you could write an outer word like
: SAFE-GO ( -- ) ['] GO CATCH ... ;
: WRAPPED-GO ( -- ) ['] GO CATCH ... ;
: GO ( -- ) ['] GO CATCH ... ;
Or you could just wrap the original mainloop in a quotation:
: GO ( -- ) INIT
[: BEGIN do this do that do that other thing AGAIN :]
CATCH ... ;
The way your code evolves, you might start early on with the
unwrapped GO , then realize later that you need to catch
exceptions at this point , and you might appreciate only having to
insert [: :] around part of it.
Speaking of 'part of it', you see that the original INIT doesn't
need exceptions caught - maybe it already handles exceptions in a
superior manner for initialization code, and further catches would
only mishandle errors at that level. Excepting INIT from the
CATCH in SAFE-GO however would require altering GO so that you
could move the INIT into SAFE-GO . Suddenly the logic that was
all in one place is now in two places. Quotations let you avoid
factoring when it's not appropriate.
Quotations might also be a more readable alternative to the
dark temptation of return stack magic. Some kinds of it.
> As in : foo ( -- ) 0 [: 2 + ;] . ;
> foo 2
You would need EXECUTE before the dot. Otherwise you're printing
the address of the quotation.
With limited CALL-requiring quotations:
: MAP-TEN ( qt -- ) LOCAL qt
10 0 ?DO I qt CALL LOOP ;
: foo ( -- )
[: 2 + . :] MAP-TEN ;
foo \ outputs: 2 3 4 5 6 7 8 9 10 11
For more reasonable higher-order words, take a look at the Forth
Foundation Library, which uses them all over the place with
various data structures. You can pass XTs to these words just
fine, but again, sometimes you might want to pass a very trivial
word like 2 + . to them, and you might appreciate not having to
come up with a name for such a thing, which you might rather
retype in full even if you happened to accidentally reuse it in a
second part of your program.
-- Julian
[toc] | [prev] | [next] | [standalone]
| From | Coos Haak <chforth@hccnet.nl> |
|---|---|
| Date | 2015-07-12 18:56 +0200 |
| Message-ID | <754c3711fl6x$.1vtfxw5kz6n49.dlg@40tude.net> |
| In reply to | #40547 |
Op Sun, 12 Jul 2015 08:23:42 -0700 (PDT) schreef Julian Fondren: > On Sunday, July 12, 2015 at 8:48:30 AM UTC-5, Tessa Bonting wrote: >> Hey to all, >> >> Can anyone tell me how qoutation work. >> Is the word being compiled temporary stopped or a forward branch >> inserted to skip the quotation? > > Sure? Either? Does it matter? > > Have a limited implementation in ciforth, which branches over the > quotation: > > : [: POSTPONE 0 POSTPONE IF HERE ; IMMEDIATE > : :] >R POSTPONE EXIT POSTPONE THEN R> POSTPONE LITERAL ; IMMEDIATE > : CALL >R ; > > As used in: > > : EACH-CHAR ( c-addr u qt -- ) LOCAL qt > BOUNDS ?DO I C@ qt CALL LOOP ; > > : STARRY ( c-addr u -- ) > [: &* EMIT EMIT :] EACH-CHAR &* EMIT ; > > "hello" STARRY \ outputs: *h*e*l*l*o* > > The limitation: you can't EXECUTE these quotations. Which means > you can't write code that is neutral as to whether it receives a > quotation or a quoted word -- an XT. An executable version would > I expect only require that [: construct a header, and that the > address put on the stack by :] refer to the part of it that a > normal XT would. > > So you can easily add bad quotations to any Forth that respects > the return stack (or can be told to respect it), probably, and > can add better quotations after learning some details about > your Forth. > >> And where are they used for? > > They are anonymous definitions. They're used for code that > doesn't deserve a name that you would like to pass to a > higher-order word. What would you name the quotation above? > > : STAR-THEN-CHAR ( c -- ) &* EMIT EMIT ; > : *EMIT ( c -- ) &* EMIT EMIT ; > : HELPER ( c -- ) &* EMIT EMIT ; > : AUX ( c -- ) &* EMIT EMIT ; > > A particularly useful higher-order word to pass definitions to is > CATCH . For example if you have a mainloop for a game > > : GO ( -- ) INIT > BEGIN do this do that do that other thing AGAIN ; > > And you want to catch exceptions that reach it, you could write an outer word like > > : SAFE-GO ( -- ) ['] GO CATCH ... ; > : WRAPPED-GO ( -- ) ['] GO CATCH ... ; > : GO ( -- ) ['] GO CATCH ... ; > > Or you could just wrap the original mainloop in a quotation: > > : GO ( -- ) INIT > [: BEGIN do this do that do that other thing AGAIN :] > CATCH ... ; > > The way your code evolves, you might start early on with the > unwrapped GO , then realize later that you need to catch > exceptions at this point , and you might appreciate only having to > insert [: :] around part of it. > > Speaking of 'part of it', you see that the original INIT doesn't > need exceptions caught - maybe it already handles exceptions in a > superior manner for initialization code, and further catches would > only mishandle errors at that level. Excepting INIT from the > CATCH in SAFE-GO however would require altering GO so that you > could move the INIT into SAFE-GO . Suddenly the logic that was > all in one place is now in two places. Quotations let you avoid > factoring when it's not appropriate. > > Quotations might also be a more readable alternative to the > dark temptation of return stack magic. Some kinds of it. > >> As in : foo ( -- ) 0 [: 2 + ;] . ; >> foo 2 > > You would need EXECUTE before the dot. Otherwise you're printing > the address of the quotation. > > With limited CALL-requiring quotations: > > : MAP-TEN ( qt -- ) LOCAL qt > 10 0 ?DO I qt CALL LOOP ; > > : foo ( -- ) > [: 2 + . :] MAP-TEN ; > > foo \ outputs: 2 3 4 5 6 7 8 9 10 11 > > For more reasonable higher-order words, take a look at the Forth > Foundation Library, which uses them all over the place with > various data structures. You can pass XTs to these words just > fine, but again, sometimes you might want to pass a very trivial > word like 2 + . to them, and you might appreciate not having to > come up with a name for such a thing, which you might rather > retype in full even if you happened to accidentally reuse it in a > second part of your program. > : > > -- Julian This allows EXECUTE: : [: POSTPONE 0 POSTPONE IF HERE 'QUIT @ , HERE CELL+ ; IMMEDIATE : ;] >R POSTPONE EXIT POSTPONE THEN R> POSTPONE LITERAL ; IMMEDIATE \ Note the semicolon instead of colon : COUNTING [: . ;] 11 1 DO I OVER EXECUTE LOOP DROP ; groet Coos
[toc] | [prev] | [next] | [standalone]
| From | Julian Fondren <julian.fondren@gmail.com> |
|---|---|
| Date | 2015-07-13 20:24 -0700 |
| Message-ID | <90743763-51d4-468c-8f06-e76f48f50ffe@googlegroups.com> |
| In reply to | #40552 |
On Sunday, July 12, 2015 at 12:14:13 PM UTC-5, Coos Haak wrote: > This allows EXECUTE: > : [: POSTPONE 0 POSTPONE IF HERE 'QUIT @ , HERE CELL+ ; IMMEDIATE > : ;] >R POSTPONE EXIT POSTPONE THEN R> POSTPONE LITERAL ; IMMEDIATE Thanks! I noted that there should be a comma at the end of [: : [: POSTPONE 0 POSTPONE IF HERE 'QUIT @ , HERE CELL+ , ; IMMEDIATE
[toc] | [prev] | [next] | [standalone]
| From | Coos Haak <chforth@hccnet.nl> |
|---|---|
| Date | 2015-07-14 09:43 +0200 |
| Message-ID | <wzh7jl0m0dq1$.i4is4w2yktt3$.dlg@40tude.net> |
| In reply to | #40593 |
Op Mon, 13 Jul 2015 20:24:22 -0700 (PDT) schreef Julian Fondren: > On Sunday, July 12, 2015 at 12:14:13 PM UTC-5, Coos Haak wrote: >> This allows EXECUTE: >>: [: POSTPONE 0 POSTPONE IF HERE 'QUIT @ , HERE CELL+ ; IMMEDIATE >>: ;] >R POSTPONE EXIT POSTPONE THEN R> POSTPONE LITERAL ; IMMEDIATE > > Thanks! I noted that there should be a comma at the end of [: > > : [: POSTPONE 0 POSTPONE IF HERE 'QUIT @ , HERE CELL+ , ; IMMEDIATE My bad, I typed the source into the newsreader instead of copying and pasting the working code. groet Coos
[toc] | [prev] | [next] | [standalone]
| From | "HAA" <someone@microsoft.com> |
|---|---|
| Date | 2015-07-18 14:18 +1000 |
| Message-ID | <mock2c$uhv$1@speranza.aioe.org> |
| In reply to | #40547 |
Julian Fondren wrote: > ... > A particularly useful higher-order word to pass definitions to is > CATCH . > ... > : GO ( -- ) INIT > [: BEGIN do this do that do that other thing AGAIN :] > CATCH ... ; Quotations in Forth reminds me of C and its shortcuts. Needlessly confusing.
[toc] | [prev] | [next] | [standalone]
| From | "HAA" <someone@microsoft.com> |
|---|---|
| Date | 2015-08-01 12:46 +1000 |
| Message-ID | <mphbtd$1km$1@speranza.aioe.org> |
| In reply to | #40698 |
HAA wrote: > ... > Quotations in Forth reminds me of C and its shortcuts. Needlessly > confusing. Browsing Thinking Forth I came across Brodie's DOER MAKE and noted the similarity to quotations. Not a fan of DOER MAKE but it does appear to support the concept of quotations. Brodie's examples are the closest I've seen to a credible use for quotations. Notably these quotations are linked to a name which makes them testable. \ DOER/MAKE example from 'Thinking Forth' p.225 doer .unit ( a -- increment) \ display byte or cell : <dump> ( a # ) 0 do i 16 mod 0= if cr dup i + 5 u.r 2 spaces then dup i + .unit +loop drop ; : DUMP ( a #) make .unit @ 6 u.r 2 ;and <dump> ; : CDUMP ( a #) make .unit c@ 4 u.r 1 ;and <dump> ; \ Same as above but using quotations defer .unit ( a -- increment) \ display byte or cell : <dump> ( a # ) 0 do i 16 mod 0= if cr dup i + 5 u.r 2 spaces then dup i + .unit +loop drop ; : DUMP ( a #) [: @ 6 u.r 2 ;] is .unit <dump> ; : CDUMP ( a #) [: c@ 4 u.r 1 ;] is .unit <dump> ;
[toc] | [prev] | [next] | [standalone]
| From | mhx@iae.nl |
|---|---|
| Date | 2015-08-01 00:52 -0700 |
| Message-ID | <28f6498d-e866-45bc-8486-3a8683c5d33f@googlegroups.com> |
| In reply to | #41032 |
On Saturday, August 1, 2015 at 4:46:11 AM UTC+2, HAA wrote:
> HAA wrote:
> > ...
> > Quotations in Forth reminds me of C and its shortcuts. Needlessly
> > confusing.
>
> Browsing Thinking Forth I came across Brodie's DOER MAKE and
> noted the similarity to quotations. Not a fan of DOER MAKE but it
> does appear to support the concept of quotations. Brodie's examples
> are the closest I've seen to a credible use for quotations. Notably
> these quotations are linked to a name which makes them testable.
>
> \ DOER/MAKE example from 'Thinking Forth' p.225
> doer .unit ( a -- increment) \ display byte or cell
>
> : <dump> ( a # )
> 0 do i 16 mod 0= if cr dup i + 5 u.r 2 spaces then
> dup i + .unit +loop drop ;
>
> : DUMP ( a #) make .unit @ 6 u.r 2 ;and <dump> ;
>
> : CDUMP ( a #) make .unit c@ 4 u.r 1 ;and <dump> ;
>
> \ Same as above but using quotations
> defer .unit ( a -- increment) \ display byte or cell
>
> : <dump> ( a # )
> 0 do i 16 mod 0= if cr dup i + 5 u.r 2 spaces then
> dup i + .unit +loop drop ;
>
> : DUMP ( a #) [: @ 6 u.r 2 ;] is .unit <dump> ;
>
> : CDUMP ( a #) [: c@ 4 u.r 1 ;] is .unit <dump> ;
I think you meant to write:
needs -anons
ANEW -dumps
: <dump> ( addr #items xt -- )
ROT LOCALS| addr xt |
0 ?DO I #16 MOD 0= IF CR addr H. 2 SPACES ENDIF
addr ( addr -- bytesize ) xt EXECUTE +TO addr
LOOP ;
: DUMP ( addr #items -- ) [: ( a -- bsz ) @ U. SPACE 1 CELLS ;] <dump> ;
: CDUMP ( addr #items -- ) [: ( a -- bsz ) C@ U. SPACE 1 ;] <dump> ;
: FDUMP ( addr #items -- ) [: ( a -- bsz ) F@ F. SPACE 1 FLOATS ;] <dump> ;
: $DUMP ( addr #items -- ) [: ( a -- bsz ) COUNT TUCK TYPE SPACE CHAR+ ;] <dump> ;
CREATE fbuffer 3e f, pi f, ln2 f, 2e fsqrt f, 77.1133e f, 123e f, -2e f,
CREATE $buffer ," aap" ," noot" ," mies" ," maniac"
DOC
(*
FORTH> fbuffer 4 hex dump
$01229B40 C000000000000000 4000 C90FDAA22168C235 4000 ok
FORTH> fbuffer 4 fdump
$01229B40 3.000000 3.141593 0.693147 1.414214 ok
FORTH> fbuffer #14 decimal cdump
$01229B40 0 0 0 0 0 0 0 192 0 64 0 0 0 0 0 0
$01229B50 53 194 104 33 ok
FORTH> $buffer 4 $dump
$01229BC0 aap noot mies maniac ok
*)
ENDDOC
[toc] | [prev] | [next] | [standalone]
| From | "HAA" <someone@microsoft.com> |
|---|---|
| Date | 2015-08-02 18:16 +1000 |
| Message-ID | <mpkjji$u8n$1@speranza.aioe.org> |
| In reply to | #41036 |
mhx@iae.nl wrote: > ... > I think you meant to write: > > needs -anons > ANEW -dumps > > : <dump> ( addr #items xt -- ) > ROT LOCALS| addr xt | > 0 ?DO I #16 MOD 0= IF CR addr H. 2 SPACES ENDIF > addr ( addr -- bytesize ) xt EXECUTE +TO addr > LOOP ; > > : DUMP ( addr #items -- ) [: ( a -- bsz ) @ U. SPACE 1 CELLS ;] <dump> ; > : CDUMP ( addr #items -- ) [: ( a -- bsz ) C@ U. SPACE 1 ;] <dump> ; > : FDUMP ( addr #items -- ) [: ( a -- bsz ) F@ F. SPACE 1 FLOATS ;] <dump> ; > : $DUMP ( addr #items -- ) [: ( a -- bsz ) COUNT TUCK TYPE SPACE CHAR+ ;] <dump> ; It's Brodie's use of a DEFERed word to hold the xt that makes his examples so simple, readable and testable.
[toc] | [prev] | [next] | [standalone]
| From | mhx@iae.nl |
|---|---|
| Date | 2015-08-02 02:18 -0700 |
| Message-ID | <296d31ce-ea58-4416-9535-74c51dc3de8d@googlegroups.com> |
| In reply to | #41061 |
On Sunday, August 2, 2015 at 10:15:51 AM UTC+2, HAA wrote:
> mhx@iae.nl wrote:
> > ...
> > I think you meant to write:
> >
> > needs -anons
> > ANEW -dumps
> >
> > : <dump> ( addr #items xt -- )
> > ROT LOCALS| addr xt |
> > 0 ?DO I #16 MOD 0= IF CR addr H. 2 SPACES ENDIF
> > addr ( addr -- bytesize ) xt EXECUTE +TO addr
> > LOOP ;
> >
> > : DUMP ( addr #items -- ) [: ( a -- bsz ) @ U. SPACE 1 CELLS ;] <dump> ;
> > : CDUMP ( addr #items -- ) [: ( a -- bsz ) C@ U. SPACE 1 ;] <dump> ;
> > : FDUMP ( addr #items -- ) [: ( a -- bsz ) F@ F. SPACE 1 FLOATS ;] <dump> ;
> > : $DUMP ( addr #items -- ) [: ( a -- bsz ) COUNT TUCK TYPE SPACE CHAR+ ;] <dump> ;
>
> It's Brodie's use of a DEFERed word to hold the xt that makes his
> examples so simple, readable and testable.
I think this specific example does not show the full power
of DOER/MAKE, and also fails to illuminate the strength of
quotations (if any), because we can write it in the
old-fashioned way shown below. All definitions are useful
on their own, can be tested on the command line, will
probably not take more space than the two alternative
implementations, and are fully up- and down compatible.
needs -anons
ANEW -dumps
\ *** main ***
: DUMP ( addr #items xt -- )
ROT LOCALS| addr xt |
0 ?DO I #16 MOD 0= IF CR addr H. 2 SPACES ENDIF
addr ( addr -- bytesize ) xt EXECUTE +TO addr
LOOP ;
\ *** some handlers ***
:NONAME ( a -- sz ) 32B@ U. SPACE 1 CELLS ; constant 32BIT
:NONAME ( a -- sz ) C@ U. SPACE 1 CHARS ; constant CHARACTER
:NONAME ( a -- sz ) F@ F. SPACE 1 FLOATS ; constant F80
:NONAME ( a -- sz ) COUNT TUCK TYPE SPACE CHAR+ ; constant STRING
\ *** Tests ***
CREATE fbuffer 3e f, pi f, ln2 f, 2e fsqrt f, 77.1133e f, 123e f, -2e f,
CREATE $buffer ," aap" ," noot" ," mies" ," maniac"
fbuffer 7 F80 DUMP
fbuffer 8 CHARACTER DUMP
$buffer 4 STRING DUMP
$buffer 8 32BIT HEX DUMP
DOC
(*
FORTH> fbuffer 7 F80 DUMP
$01229D40 3.000000 3.141593 0.693147 1.414214 77.113300 123.000000 -2.000000 ok
FORTH> fbuffer 8 CHARACTER DUMP
$01229D40 0 0 0 0 0 0 0 192 ok
FORTH> $buffer 4 STRING DUMP
$01229DC0 aap noot mies maniac ok
FORTH> $buffer 8 32BIT HEX DUMP
$01229DC0 70616103 696D0474 61696E61 2020504D 0 0 0 0 ok
*)
ENDDOC
-marcel
[toc] | [prev] | [next] | [standalone]
| From | "HAA" <someone@microsoft.com> |
|---|---|
| Date | 2015-08-05 13:35 +1000 |
| Message-ID | <mps087$4ou$1@speranza.aioe.org> |
| In reply to | #41063 |
mhx@iae.nl wrote: > ... > I think this specific example does not show the full power > of DOER/MAKE, and also fails to illuminate the strength of > quotations (if any), because we can write it in the > old-fashioned way shown below. All definitions are useful > on their own, can be tested on the command line, will > probably not take more space than the two alternative > implementations, and are fully up- and down compatible. > > needs -anons > ANEW -dumps > > \ *** main *** > : DUMP ( addr #items xt -- ) > ROT LOCALS| addr xt | > 0 ?DO I #16 MOD 0= IF CR addr H. 2 SPACES ENDIF > addr ( addr -- bytesize ) xt EXECUTE +TO addr > LOOP ; > > \ *** some handlers *** > :NONAME ( a -- sz ) 32B@ U. SPACE 1 CELLS ; constant 32BIT > :NONAME ( a -- sz ) C@ U. SPACE 1 CHARS ; constant CHARACTER > :NONAME ( a -- sz ) F@ F. SPACE 1 FLOATS ; constant F80 > :NONAME ( a -- sz ) COUNT TUCK TYPE SPACE CHAR+ ; constant STRING > > \ *** Tests *** > CREATE fbuffer 3e f, pi f, ln2 f, 2e fsqrt f, 77.1133e f, 123e f, -2e f, > CREATE $buffer ," aap" ," noot" ," mies" ," maniac" > > fbuffer 7 F80 DUMP > fbuffer 8 CHARACTER DUMP > $buffer 4 STRING DUMP > $buffer 8 32BIT HEX DUMP You've made it harder to use. There are now several things to type and remember - the prefix words, what they mean, and DUMP. BTW Brodie's example might be further simplified defer .unit ( a -- increment) \ display byte or cell : <dump> ( a # -- ) 0 ?do i #16 mod 0= if cr dup h. space then dup .unit + loop drop ; : DUMP ( a #) [: @ h. 1 cells ;] is .unit <dump> ; : CDUMP ( a #) [: c@ hb. 1 chars ;] is .unit <dump> ;
[toc] | [prev] | [next] | [standalone]
| From | Bernd Paysan <bernd.paysan@gmx.de> |
|---|---|
| Date | 2015-08-01 21:37 +0200 |
| Message-ID | <mpj722$udp$1@dont-email.me> |
| In reply to | #41032 |
HAA wrote: > \ Same as above but using quotations > defer .unit ( a -- increment) \ display byte or cell > > : <dump> ( a # ) > 0 do i 16 mod 0= if cr dup i + 5 u.r 2 spaces then > dup i + .unit +loop drop ; > > : DUMP ( a #) [: @ 6 u.r 2 ;] is .unit <dump> ; > > : CDUMP ( a #) [: c@ 4 u.r 1 ;] is .unit <dump> ; Great. I always was wondering how to transform the DOER MAKE examples into code using DEFER and IS, and the ;AND and such things made that really hard. But with quotations, it just works. -- Bernd Paysan "If you want it done right, you have to do it yourself" net2o ID: kQusJzA;7*?t=uy@X}1GWr!+0qqp_Cn176t4(dQ* http://bernd-paysan.de/
[toc] | [prev] | [next] | [standalone]
| From | JennyB <jennybrien@googlemail.com> |
|---|---|
| Date | 2015-08-05 06:00 -0700 |
| Message-ID | <7b2d80c8-53d5-441d-a952-a3bb1e219108@googlegroups.com> |
| In reply to | #41045 |
On Saturday, 1 August 2015 20:37:06 UTC+1, Bernd Paysan wrote:
> Great. I always was wondering how to transform the DOER MAKE examples into
> code using DEFER and IS, and the ;AND and such things made that really hard.
> But with quotations, it just works.
>
Where it gets complicated is when DOER words start calling MAKE possibly on themselves -
Take the next example:
DOER ANNOUNCE
: LONG MAKE ANNOUNCE
CR ." You're in a large hall with a huge throne"
CR ." covered with a red velvet canopy."
MAKE ANNOUNCE
CR ." You're in the throne room." ;
DEFER ANNOUNCE
: LONG [: CR ." You're in a large hall with a huge throne"
CR ." covered with a red velvet canopy."
[: CR ." You're in the throne room." ;] IS ANNOUNCE ;]
IS ANNOUNCE ;
not too hard, but:
DOER SPEECH
: ALTERNATE
BEGIN
MAKE SPEECH ." HELLO "
MAKE SPEECH ." GOODBYE "
O UNTIL ;
... that's tricky. ALTERNATE has to toggle the action of SPEECH each time it is called.
That looks like a job for a CREATE ... DOES>:
: CUES \ n*xt n /name/ -- store n xts
CREATE 0 , (index) DUP , (limit) 0 DO , LOOP
DOES> \ execute indexed xt, bump index
DUP @ >R \ save index
DUP 2@ SWAP MOD OVER ! \ increment index
>R 2+ CELLS + @ EXECUTE ;
DEFER SPEECH
:NONAME [: ." GOODBYE" ;] IS SPEECH ;
:NONAME [: ." HELLO" ;] IS SPEECH ;
2 CUES ALTERNATE
[toc] | [prev] | [next] | [standalone]
Page 1 of 7 [1] 2 3 4 5 6 7 Next page →
Back to top | Article view | comp.lang.forth
csiph-web