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 3 of 7 — ← Prev page 1 2 [3] 4 5 6 7 Next page →
| From | hughaguilar96@gmail.com |
|---|---|
| Date | 2015-07-13 13:10 -0700 |
| Message-ID | <25ffc235-47bc-49db-b919-b701f55ad372@googlegroups.com> |
| In reply to | #40566 |
On Monday, July 13, 2015 at 6:13:43 AM UTC-7, Mark Wills wrote: > I personally have no experience with them, and I'm still struggling > to see a use for them. However, regarding executing and compiling the > XT of the quotation outside the scope of the parent definition: you > just make that behaviour undefined. Mark, it is not difficult to understand --- the iteration code (typically a BEGIN WHILE REPEAT loop) is hidden inside of the higher-order function --- this is as compared to cut-and-pasting the iteration code into the application program every time that it is needed to iterate through a data-structure. Information hiding! Always a good thing! > "Compiling or executing the quotation after the definition in which > the quotation has been defined has gone out of scope may leave the > system in an undefined state" or other such verbiage. I don't like the word "undefined" --- just call it a "fatal error" --- "undefined" leaves open a lot of possibilities for what may happen. Also, I prefer "exited" to "gone out of scope" --- you shouldn't use the word "scope" without specifying if you mean compile-time scope or run-time scope (you mean run-time here). > I'm still somewhat agog though there's serious interest in adding this > behaviour to the language, but the language doesn't include support > for... oooooh, I dunno, say, single dimension arrays out of the box. The purpose of quotations is to make general-purpose data-structures possible --- the code for iterating through them is hidden inside of higher-order functions provided in the code-library --- the user of the code library can use the container without knowing how it is implemented internally (can be complicated, such as for self-balancing trees, so you don't want this complication exposed to the user).
[toc] | [prev] | [next] | [standalone]
| From | Mark Wills <markwills1970@gmail.com> |
|---|---|
| Date | 2015-07-13 14:24 -0700 |
| Message-ID | <76ea7487-96c0-422b-aa28-09893f766f3c@googlegroups.com> |
| In reply to | #40582 |
I'm struggling to see the advantage of: : foo some code [: bar ;] more code execute ; against : foo some code more code bar ; It's just a different way of factoring. Can someone give me an example of something that can only be done using quotations?
[toc] | [prev] | [next] | [standalone]
| From | hughaguilar96@gmail.com |
|---|---|
| Date | 2015-07-13 18:51 -0700 |
| Message-ID | <388025ef-faf7-4e0d-93c1-1ae677c5092a@googlegroups.com> |
| In reply to | #40584 |
On Monday, July 13, 2015 at 2:24:20 PM UTC-7, Mark Wills wrote:
> I'm struggling to see the advantage of:
>
> : foo some code [: bar ;] more code execute ;
>
> against
>
> : foo some code more code bar ;
>
> It's just a different way of factoring.
You can struggle mightily and never see the advantage in the former --- because it is nonsense.
I think that the Forth-200x committee gave us fake quotations (and your "bonkers simple" implementation was fake too) for the purpose of confusing people who don't know what quotations are. Their plan was that they would tell everybody: "These are quotations!" Then everybody would would say: "Quotations are useless!" Then they would say: "Well yes, quotations are useless, but we gave them to you because Hugh was asking for them --- so blame him!"
> Can someone give me an example of something that can only be done using quotations?
Every example in my document: http://www.forth.org/FMITE.txt
Stop listening to the Forth-200x promoters --- they are talking nonsense, about how quotations are just :NONAME with syntactic sugar, and are useless.
I already told you that the idea is to hide the iteration code inside of the higher-order functions rather than paste it into the application program code. This is not complicated. Clear your mind of all that obfuscation coming from the Forth-200x committee --- think about the concept for two minutes --- it is easy and obvious.
Here is an example from my document:
list
d field .name$ \ employee name
d field .salary \ salary per year in dollars
c field .female? \ flag indicating gender
constant employee
: count-females local{ employee-head | cnt -- females }
\ EMPLOYEE-HEAD is the head of a LIST linked list
employee-head @ { .female? c@ cnt +! } each
cnt @ ;
Notice that we are iterating through a linked list. But where is the BEGIN WHILE REPEAT loop??? It is hidden inside of the EACH higher-order function!
It is better to hide this iteration code inside of the higher-order function rather than paste it into the application code:
: count-females local{ employee-head | cnt -- females }
\ EMPLOYEE-HEAD is the head of a LIST linked list
employee-head @ begin dup while
dup .female? c@ cnt +! \ flags in LOTD are 1 for TRUE or 0 for FALSE
.fore @ repeat drop \ the .FORE field is hidden in the LIST struct
cnt @ ;
Pasting all this iteration code into the application code tends to bloat out the COUNT-FEMALES function. Also, it is error-prone because you may do this dozens of times in a program and could screw it up here or there. This iteration code is just traversing a linked list so it is pretty simple --- code that is traversing a self-balancing binary tree (especially if the code inserts or deletes nodes) is much more complicated --- you really don't want to expose such complicated code to the user where it is likely to get screwed up.
If you still don't get it, then you must have been out in the noonday sun too long and your brains are addled --- happens to Englishmen all the time --- this is the most likely explanation for why Stephen Pelc doesn't just put my disambiguifiers in VFX so all of his non-executable execution tokens are hidden and are not exposed to the user.
Information hiding! Always a good thing!
[toc] | [prev] | [next] | [standalone]
| From | Julian Fondren <julian.fondren@gmail.com> |
|---|---|
| Date | 2015-07-13 20:19 -0700 |
| Message-ID | <29b6eb31-b795-41df-b4d9-5d51dbd71634@googlegroups.com> |
| In reply to | #40591 |
On Monday, July 13, 2015 at 8:51:44 PM UTC-5, hughag...@gmail.com wrote:
> I think that the Forth-200x committee
Anyone, not just the committee, can start with an RfD.
Of this matter, nobody has gone that far.
> Here is an example from my document:
>
> list
> d field .name$ \ employee name
> d field .salary \ salary per year in dollars
> c field .female? \ flag indicating gender
> constant employee
>
> : count-females local{ employee-head | cnt -- females }
> \ EMPLOYEE-HEAD is the head of a LIST linked list
> employee-head @ { .female? c@ cnt +! } each
> cnt @ ;
With 'fake' quotations:
: count-females ( -- u )
0 [: female? c@ + ;] each-employee ;
This could also be written:
: (count-females) ( u -- u' ) female? c@ + ;
: count-females ( -- ) 0 ['] (count-females) each-employee ;
> Notice that we are iterating through a linked list. But where is the BEGIN WHILE REPEAT loop??? It is hidden inside of the EACH higher-order function!
Higher-order programming is great and all, but it doesn't require
quotations, so selling it won't necessarily sell someone on
quotations.
[toc] | [prev] | [next] | [standalone]
| From | hughaguilar96@gmail.com |
|---|---|
| Date | 2015-07-13 20:49 -0700 |
| Message-ID | <43fc5f95-cb66-4374-aeb1-a785ea86efce@googlegroups.com> |
| In reply to | #40592 |
On Monday, July 13, 2015 at 8:19:51 PM UTC-7, Julian Fondren wrote:
> On Monday, July 13, 2015 at 8:51:44 PM UTC-5, hughag...@gmail.com wrote:
> > I think that the Forth-200x committee
>
> Anyone, not just the committee, can start with an RfD.
I can't.
Nobody can write an RfD unless they are a brown-noser --- ultimately, Leon Wagner decides what is in Forth-200x --- the whole business with the RfDs is just astro-turfing (an effort to make Forth-200x appear to be a grassroots movement when it is actually owned entirely by Forth Inc.).
> Of this matter, nobody has gone that far.
See above --- they are just brown-nosers --- they aren't going to do anything unless they can be sure ahead of time that Leon Wagner will approve.
> > Here is an example from my document:
> >
> > list
> > d field .name$ \ employee name
> > d field .salary \ salary per year in dollars
> > c field .female? \ flag indicating gender
> > constant employee
> >
> > : count-females local{ employee-head | cnt -- females }
> > \ EMPLOYEE-HEAD is the head of a LIST linked list
> > employee-head @ { .female? c@ cnt +! } each
> > cnt @ ;
>
> With 'fake' quotations:
>
> : count-females ( -- u )
> 0 [: female? c@ + ;] each-employee ;
>
> This could also be written:
>
> : (count-females) ( u -- u' ) female? c@ + ;
> : count-females ( -- ) 0 ['] (count-females) each-employee ;
What you have here (the second version) is essentially the same thing that I've been doing in the novice-package for years with EACH etc..
This works in simple cases, but it has problems:
1.) It is inefficient to push all the internal data to the return-stack before the EXECUTE and then pull it off again after the EXECUTE. Because this is done inside of a loop, the inefficiency hits hard.
2.) You get a lot of stack-juggling in your quotation when there is more than one datum in the parent function that needs to be accessed --- this is both inefficient and error-prone --- once again, inside of a loop so it hits hard.
Note that pushing all of the internal data to the return-stack before the EXECUTE is problematic because the xt is either on the return-stack in which case it gets buried, or it is on the data-stack in which case it is in the way of the data that you want to push (so you end up with a lot of stack-juggling). I solved this problem (in the bar-feature higher-order functions such as |EACH but not EACH) in the FMITE by holding the xt in a register while I did my pushing of data to the return-stack, and then executing that register --- this is much more efficient and clean.
What you showed me above as Forth-200x code is almost exactly the same as what I've been doing for years in the novice-package. That is actually quite funny, as everybody has been denouncing the novice-package as "crap" since in came out, and now you are using the same technique that my novice-package is based on. Anyway, I'm leaving fake-quotations behind me now --- I have real quotations in the FMITE.
[toc] | [prev] | [next] | [standalone]
| From | Julian Fondren <julian.fondren@gmail.com> |
|---|---|
| Date | 2015-07-13 21:48 -0700 |
| Message-ID | <1784f297-d99f-43cd-8b3b-d5b92dca6412@googlegroups.com> |
| In reply to | #40594 |
On Monday, July 13, 2015 at 10:49:19 PM UTC-5, hughag...@gmail.com wrote: > On Monday, July 13, 2015 at 8:19:51 PM UTC-7, Julian Fondren wrote: > > This could also be written: > > > > : (count-females) ( u -- u' ) female? c@ + ; > > : count-females ( -- ) 0 ['] (count-females) each-employee ; > > This works in simple cases, but it has problems: > 1.) It is inefficient to push all the internal data to the return-stack before the EXECUTE and then pull it off again after the EXECUTE. Because this is done inside of a loop, the inefficiency hits hard. > 2.) You get a lot of stack-juggling in your quotation when there is more than one datum in the parent function that needs to be accessed --- this is both inefficient and error-prone --- once again, inside of a loop so it hits hard. This sounds like: Forth is inefficient! You're always having to provide, on a stack, what other words expect, and they just pop them right back off the stack and do something with them. Forth has a lot of stack juggling! Especially when there's more than one thing to access. Lots of stack juggling is inefficient and error-prone. Even inner loops have stack operations! I'm already using Forth, though. So I already know about stack juggling. I just imagine that I might in the future want to expose some registers for higher-order state (ARM and x86_64 both have 16 general purpose registers; it's worth thinking about some uses for them), or that I might want a SUB-EXECUTE that more efficiently stashes state around an EXECUTE. There's also the option of expanding the higher-order code into its callers, and optimizing stack usage in the combined code. It'd be a different story if the minor discipline of maintaining a clean data stack were *less* efficient than some clear or existing alternative for existing Forths that run on existing hardware. You keep linking to a document titled "the [NAME] micro-processor", which doesn't *look* much like a report on your cool new way of doing higher order programming.
[toc] | [prev] | [next] | [standalone]
| From | "Alex McDonald" <blog@rivadpm.com> |
|---|---|
| Date | 2015-07-14 09:38 +0100 |
| Message-ID | <mo2ho0$st8$1@dont-email.me> |
| In reply to | #40594 |
on 14/07/2015 04:49:17, wrote: > On Monday, July 13, 2015 at 8:19:51 PM UTC-7, Julian Fondren wrote: >> On Monday, July 13, 2015 at 8:51:44 PM UTC-5, hughag...@gmail.com wrote: >> > I think that the Forth-200x committee >> >> Anyone, not just the committee, can start with an RfD. > > I can't. You can.
[toc] | [prev] | [next] | [standalone]
| From | Raimond Dragomir <raimond.dragomir@gmail.com> |
|---|---|
| Date | 2015-07-13 21:44 -0700 |
| Message-ID | <358c85f4-7336-4988-96ab-673f492d71ca@googlegroups.com> |
| In reply to | #40592 |
> > With 'fake' quotations: > > : count-females ( -- u ) > 0 [: female? c@ + ;] each-employee ; You are missing the point here. I don't want to write each-employee, each-tomato, each-potato every time. All I want is a EACH. Probably you can re-write your example. > > This could also be written: > > : (count-females) ( u -- u' ) female? c@ + ; > : count-females ( -- ) 0 ['] (count-females) each-employee ; > This is a classical example already of how a quotation can be substituted by a named definition. Almost always with a forced name, hard to document (it is decoupled from the main logic which is in the parent) and in the main logic you need the tick. Not to say that all you have is the data stack for comunicating with the parent logic and this is ok only for trivial examples.
[toc] | [prev] | [next] | [standalone]
| From | hughaguilar96@gmail.com |
|---|---|
| Date | 2015-07-13 21:53 -0700 |
| Message-ID | <e80f44fb-fea1-47cd-8d52-742e81df5a94@googlegroups.com> |
| In reply to | #40595 |
On Monday, July 13, 2015 at 9:44:14 PM UTC-7, Raimond Dragomir wrote: > > > > With 'fake' quotations: > > > > : count-females ( -- u ) > > 0 [: female? c@ + ;] each-employee ; > > You are missing the point here. I don't want to write each-employee, each-tomato, > each-potato every time. All I want is a EACH. > Probably you can re-write your example. I noticed that too, but didn't mention it. Most likely Julien doesn't get the concept of inheritance --- every class (such as EMPLOYEE in my example) that is defined with LIST as its parent class inherits all of the functionality provided for LIST --- this includes EACH FIND-NODE FIND-PRIOR etc.. This is somewhat beside the point that we are discussing however (quotations), which is why I didn't bother mentioning it. > > This could also be written: > > > > : (count-females) ( u -- u' ) female? c@ + ; > > : count-females ( -- ) 0 ['] (count-females) each-employee ; > > > > This is a classical example already of how a quotation can be substituted > by a named definition. Almost always with a forced name, hard to document > (it is decoupled from the main logic which is in the parent) and in the > main logic you need the tick. Not to say that all you have is the data > stack for comunicating with the parent logic and this is ok only for > trivial examples. You have understood the concept! Good job! The fact that one person has understood my document, makes me feel confident that my document is understandable. :-)
[toc] | [prev] | [next] | [standalone]
| From | Julian Fondren <julian.fondren@gmail.com> |
|---|---|
| Date | 2015-07-13 22:04 -0700 |
| Message-ID | <b59c987c-e29d-4ae5-864e-0212e720d5e8@googlegroups.com> |
| In reply to | #40595 |
On Monday, July 13, 2015 at 11:44:14 PM UTC-5, Raimond Dragomir wrote:
> >
> > With 'fake' quotations:
> >
> > : count-females ( -- u )
> > 0 [: female? c@ + ;] each-employee ;
>
> You are missing the point here. I don't want to write each-employee, each-tomato,
> each-potato every time. All I want is a EACH.
The point here is the quotation and how it communicates with the
higher order word. The higher-order word is EACH-EMPLOYEE because
this code is excerpted from a larger body where I just whipped up a
linked list from a VARIABLE and the specific list operations that I
needed.
More of it, for fun:
: female ( -- ) employees @ cell+ >o 1 female? c! o> ;
"Bob" 64 hire
"Bobby" 70 hire
"McBob" 50 hire
"Bobette" 45 hire female
"Bobberson" 40 hire
"Bobina" 45 hire female
> Probably you can re-write your example.
Probably?
: count-females ( -- u )
0 [: female? c@ + ;] employees each ;
> Not to say that all you have is the data
> stack for comunicating with the parent logic and this is ok only for
> trivial examples.
Two words, in Forth, only have the data stack with which to
communicate. And this is OK only for trivial examples.
Sorry, I don't quite follow. Can you provide a non-trivial example?
[toc] | [prev] | [next] | [standalone]
| From | humptydumpty <ouatubi@gmail.com> |
|---|---|
| Date | 2015-07-14 01:22 -0700 |
| Message-ID | <31f14ce3-2751-40b7-b751-0592605f6333@googlegroups.com> |
| In reply to | #40591 |
marți, 14 iulie 2015, 04:51:44 UTC+3, hughag...@gmail.com a scris:
> On Monday, July 13, 2015 at 2:24:20 PM UTC-7, Mark Wills wrote:
> > I'm struggling to see the advantage of:
> >
> > : foo some code [: bar ;] more code execute ;
> >
> > against
> >
> > : foo some code more code bar ;
> >
> > It's just a different way of factoring.
>
> You can struggle mightily and never see the advantage in the former --- because it is nonsense.
>
> I think that the Forth-200x committee gave us fake quotations (and your "bonkers simple" implementation was fake too) for the purpose of confusing people who don't know what quotations are. Their plan was that they would tell everybody: "These are quotations!" Then everybody would would say: "Quotations are useless!" Then they would say: "Well yes, quotations are useless, but we gave them to you because Hugh was asking for them --- so blame him!"
>
> > Can someone give me an example of something that can only be done using quotations?
>
> Every example in my document: http://www.forth.org/FMITE.txt
>
> Stop listening to the Forth-200x promoters --- they are talking nonsense, about how quotations are just :NONAME with syntactic sugar, and are useless.
>
> I already told you that the idea is to hide the iteration code inside of the higher-order functions rather than paste it into the application program code. This is not complicated. Clear your mind of all that obfuscation coming from the Forth-200x committee --- think about the concept for two minutes --- it is easy and obvious.
>
> Here is an example from my document:
>
> list
> d field .name$ \ employee name
> d field .salary \ salary per year in dollars
> c field .female? \ flag indicating gender
> constant employee
>
> : count-females local{ employee-head | cnt -- females }
> \ EMPLOYEE-HEAD is the head of a LIST linked list
> employee-head @ { .female? c@ cnt +! } each
> cnt @ ;
>
> Notice that we are iterating through a linked list. But where is the BEGIN WHILE REPEAT loop??? It is hidden inside of the EACH higher-order function!
>
> It is better to hide this iteration code inside of the higher-order function rather than paste it into the application code:
>
> : count-females local{ employee-head | cnt -- females }
> \ EMPLOYEE-HEAD is the head of a LIST linked list
> employee-head @ begin dup while
> dup .female? c@ cnt +! \ flags in LOTD are 1 for TRUE or 0 for FALSE
> .fore @ repeat drop \ the .FORE field is hidden in the LIST struct
> cnt @ ;
>
> Pasting all this iteration code into the application code tends to bloat out the COUNT-FEMALES function. Also, it is error-prone because you may do this dozens of times in a program and could screw it up here or there. This iteration code is just traversing a linked list so it is pretty simple --- code that is traversing a self-balancing binary tree (especially if the code inserts or deletes nodes) is much more complicated --- you really don't want to expose such complicated code to the user where it is likely to get screwed up.
>
> If you still don't get it, then you must have been out in the noonday sun too long and your brains are addled --- happens to Englishmen all the time --- this is the most likely explanation for why Stephen Pelc doesn't just put my disambiguifiers in VFX so all of his non-executable execution tokens are hidden and are not exposed to the user.
>
> Information hiding! Always a good thing!
Hi!
Macros way:
: ]each
] 2>R
]] begin dup while dup [[
2R> evaluate
]] .fore @ repeat drop [[
; immediate
: count-females local{ employee-head | cnt -- females }
\ EMPLOYEE-HEAD is the head of a LIST linked list
employee-head @ [ S" .female? c@ cnt +!" ]each
cnt @ ;
Have a nice day,
humptydumpty
[toc] | [prev] | [next] | [standalone]
| From | humptydumpty <ouatubi@gmail.com> |
|---|---|
| Date | 2015-07-14 01:47 -0700 |
| Message-ID | <24240c50-5be6-4e00-a00d-6c3eb3c767d7@googlegroups.com> |
| In reply to | #40603 |
On Tuesday, July 14, 2015 at 11:22:40 AM UTC+3, humptydumpty wrote:
> marți, 14 iulie 2015, 04:51:44 UTC+3, hughag...@gmail.com a scris:
> > On Monday, July 13, 2015 at 2:24:20 PM UTC-7, Mark Wills wrote:
> > > I'm struggling to see the advantage of:
> > >
> > > : foo some code [: bar ;] more code execute ;
> > >
> > > against
> > >
> > > : foo some code more code bar ;
> > >
> > > It's just a different way of factoring.
> >
> > You can struggle mightily and never see the advantage in the former --- because it is nonsense.
> >
> > I think that the Forth-200x committee gave us fake quotations (and your "bonkers simple" implementation was fake too) for the purpose of confusing people who don't know what quotations are. Their plan was that they would tell everybody: "These are quotations!" Then everybody would would say: "Quotations are useless!" Then they would say: "Well yes, quotations are useless, but we gave them to you because Hugh was asking for them --- so blame him!"
> >
> > > Can someone give me an example of something that can only be done using quotations?
> >
> > Every example in my document: http://www.forth.org/FMITE.txt
> >
> > Stop listening to the Forth-200x promoters --- they are talking nonsense, about how quotations are just :NONAME with syntactic sugar, and are useless.
> >
> > I already told you that the idea is to hide the iteration code inside of the higher-order functions rather than paste it into the application program code. This is not complicated. Clear your mind of all that obfuscation coming from the Forth-200x committee --- think about the concept for two minutes --- it is easy and obvious.
> >
> > Here is an example from my document:
> >
> > list
> > d field .name$ \ employee name
> > d field .salary \ salary per year in dollars
> > c field .female? \ flag indicating gender
> > constant employee
> >
> > : count-females local{ employee-head | cnt -- females }
> > \ EMPLOYEE-HEAD is the head of a LIST linked list
> > employee-head @ { .female? c@ cnt +! } each
> > cnt @ ;
> >
> > Notice that we are iterating through a linked list. But where is the BEGIN WHILE REPEAT loop??? It is hidden inside of the EACH higher-order function!
> >
> > It is better to hide this iteration code inside of the higher-order function rather than paste it into the application code:
> >
> > : count-females local{ employee-head | cnt -- females }
> > \ EMPLOYEE-HEAD is the head of a LIST linked list
> > employee-head @ begin dup while
> > dup .female? c@ cnt +! \ flags in LOTD are 1 for TRUE or 0 for FALSE
> > .fore @ repeat drop \ the .FORE field is hidden in the LIST struct
> > cnt @ ;
> >
> > Pasting all this iteration code into the application code tends to bloat out the COUNT-FEMALES function. Also, it is error-prone because you may do this dozens of times in a program and could screw it up here or there. This iteration code is just traversing a linked list so it is pretty simple --- code that is traversing a self-balancing binary tree (especially if the code inserts or deletes nodes) is much more complicated --- you really don't want to expose such complicated code to the user where it is likely to get screwed up.
> >
> > If you still don't get it, then you must have been out in the noonday sun too long and your brains are addled --- happens to Englishmen all the time --- this is the most likely explanation for why Stephen Pelc doesn't just put my disambiguifiers in VFX so all of his non-executable execution tokens are hidden and are not exposed to the user.
> >
> > Information hiding! Always a good thing!
>
> Hi!
> Macros way:
>
> : ]each
> ] 2>R
> ]] begin dup while dup [[
> 2R> evaluate
> ]] .fore @ repeat drop [[
> ; immediate
>
> : count-females local{ employee-head | cnt -- females }
> \ EMPLOYEE-HEAD is the head of a LIST linked list
> employee-head @ [ S" .female? c@ cnt +!" ]each
> cnt @ ;
>
>
> Have a nice day,
> humptydumpty
Maybe a better version, which shows a balanced stack before-after loop :
: ]each
] 2>R
]] begin dup while dup [[
2R> evaluate
]] .fore @ repeat [[
; immediate
: count-females local{ employee-head | cnt -- females }
\ EMPLOYEE-HEAD is the head of a LIST linked list
employee-head @ [ S" .female? c@ cnt +!" ]each drop
cnt @ ;
Have a nice day,
humptydumpty
[toc] | [prev] | [next] | [standalone]
| From | hughaguilar96@gmail.com |
|---|---|
| Date | 2015-07-14 09:56 -0700 |
| Message-ID | <b4bf3fce-d8cc-4cf0-9b5c-08e5b49ce0b7@googlegroups.com> |
| In reply to | #40603 |
On Tuesday, July 14, 2015 at 1:22:40 AM UTC-7, humptydumpty wrote:
> marți, 14 iulie 2015, 04:51:44 UTC+3, hughag...@gmail.com a scris:
> > list
> > d field .name$ \ employee name
> > d field .salary \ salary per year in dollars
> > c field .female? \ flag indicating gender
> > constant employee
> >
> > : count-females local{ employee-head | cnt -- females }
> > \ EMPLOYEE-HEAD is the head of a LIST linked list
> > employee-head @ { .female? c@ cnt +! } each
> > cnt @ ;
> >
> > Notice that we are iterating through a linked list. But where is the BEGIN WHILE REPEAT loop??? It is hidden inside of the EACH higher-order function!
> >
> > It is better to hide this iteration code inside of the higher-order function rather than paste it into the application code:
> >
> > : count-females local{ employee-head | cnt -- females }
> > \ EMPLOYEE-HEAD is the head of a LIST linked list
> > employee-head @ begin dup while
> > dup .female? c@ cnt +! \ flags in LOTD are 1 for TRUE or 0 for FALSE
> > .fore @ repeat drop \ the .FORE field is hidden in the LIST struct
> > cnt @ ;
> Hi!
> Macros way:
>
> : ]each
> ] 2>R
> ]] begin dup while dup [[
> 2R> evaluate
> ]] .fore @ repeat drop [[
> ; immediate
>
> : count-females local{ employee-head | cnt -- females }
> \ EMPLOYEE-HEAD is the head of a LIST linked list
> employee-head @ [ S" .female? c@ cnt +!" ]each
> cnt @ ;
>
>
> Have a nice day,
> humptydumpty
That ]] [[ is ugly. Use MACRO: instead.
I have this in the novice package:
macro: next>r ( node -- node ) \ r: -- next-node
dup .fore @ >r ;
macro: each[ \ toucher: i*x node -- j*x
begin dup while
next>r ;
macro: ]each
r> repeat drop ;
I also have these comments:
\ EACH[...]EACH uses the return stack. This can create havoc in functions that use locals or use >R and R>.
The reason why I push the internal data onto the return-stack is because I want the code inside to have access to the data-stack. In my FMITE document I call this a bar-feature higher-order function. You aren't doing that, so your code must use local variables.
\ FIND-NODE and FIND-PRIOR can't be written like this because they both involve an early-out.
This really kills the macro technique. The macro technique only works when you traverse all the way through the entire data-structure, rather than stop when you have found a node that meets some criteria.
Another problem with the macro technique is that the code you are generating can be quite bulky. A self-balancing tree, for example, is much more complicated than a linked list. You don't really want to generate all of this code in the middle of your application program functions, as this may be done dozens of times. There is very little speed advantage.
I had EACH[ ... ]EACH in the novice package years ago (all of this stuff was written in 2009 and 2010). I thought that it was funny earlier to see Julien presenting my old techniques as Forth-200x code, with the assumption that I was being educated on ideas that I hadn't thought of --- now you're doing it, and it is starting to become less funny and rather annoying...
[toc] | [prev] | [next] | [standalone]
| From | Julian Fondren <julian.fondren@gmail.com> |
|---|---|
| Date | 2015-07-14 10:45 -0700 |
| Message-ID | <b0e5174a-6b43-4b9a-a55f-a642d49a1afa@googlegroups.com> |
| In reply to | #40622 |
On Tuesday, July 14, 2015 at 11:56:08 AM UTC-5, hughag...@gmail.com wrote: > That ]] [[ is ugly. Use MACRO: instead. The advantages of ]] [[ over MACRO: are: 1. you can use them multiple times in a word. 2. they do not POSTPONE an EVALUATE , as MACRO: does. So to understand a word using ]] [[ you need only know the state of the dictionary (and the current order and BASE et al.) at the time that word is defined. With MACRO: you must also think of the state of the dictionary whenever that word is used. > \ FIND-NODE and FIND-PRIOR can't be written like this because they both involve an early-out. So use a word particular to leaving that construct , rather than EXIT (c.f. DO ... LOOP and LEAVE ) > This really kills the macro technique. The macro technique only works when you traverse all the way through the entire data-structure, rather than stop when you have found a node that meets some criteria. Or have the inner code accept a flag letting it know if it should continue (c.f. BEGIN ... UNTIL ) > Another problem with the macro technique is that the code you are generating can be quite bulky. A self-balancing tree, for example, is much more complicated than a linked list. You don't really want to generate all of this code in the middle of your application program functions, as this may be done dozens of times. There is very little speed advantage. And all of that code needs to be inline? Macros can't also use words that do a lot of the work? > I had EACH[ ... ]EACH in the novice package years ago (all of this stuff was written in 2009 and 2010). Put something about murder being bad in there. Then, in a few years, when someone is offhandedly speaking against murder, you can get huffy and say, "who do you think you're talking to? I *invented* murder being bad! All this stuff you're saying now was written in my novice package back in 2015!"
[toc] | [prev] | [next] | [standalone]
| From | humptydumpty <ouatubi@gmail.com> |
|---|---|
| Date | 2015-07-14 11:10 -0700 |
| Message-ID | <1ed3d490-5396-41c8-aaca-e5e129866b6d@googlegroups.com> |
| In reply to | #40622 |
On Tuesday, July 14, 2015 at 7:56:08 PM UTC+3, hughag...@gmail.com wrote:
> On Tuesday, July 14, 2015 at 1:22:40 AM UTC-7, humptydumpty wrote:
> > marți, 14 iulie 2015, 04:51:44 UTC+3, hughag...@gmail.com a scris:
> > > list
> > > d field .name$ \ employee name
> > > d field .salary \ salary per year in dollars
> > > c field .female? \ flag indicating gender
> > > constant employee
> > >
> > > : count-females local{ employee-head | cnt -- females }
> > > \ EMPLOYEE-HEAD is the head of a LIST linked list
> > > employee-head @ { .female? c@ cnt +! } each
> > > cnt @ ;
> > >
> > > Notice that we are iterating through a linked list. But where is the BEGIN WHILE REPEAT loop??? It is hidden inside of the EACH higher-order function!
> > >
> > > It is better to hide this iteration code inside of the higher-order function rather than paste it into the application code:
> > >
> > > : count-females local{ employee-head | cnt -- females }
> > > \ EMPLOYEE-HEAD is the head of a LIST linked list
> > > employee-head @ begin dup while
> > > dup .female? c@ cnt +! \ flags in LOTD are 1 for TRUE or 0 for FALSE
> > > .fore @ repeat drop \ the .FORE field is hidden in the LIST struct
> > > cnt @ ;
>
> > Hi!
> > Macros way:
> >
> > : ]each
> > ] 2>R
> > ]] begin dup while dup [[
> > 2R> evaluate
> > ]] .fore @ repeat drop [[
> > ; immediate
> >
> > : count-females local{ employee-head | cnt -- females }
> > \ EMPLOYEE-HEAD is the head of a LIST linked list
> > employee-head @ [ S" .female? c@ cnt +!" ]each
> > cnt @ ;
> >
> >
> > Have a nice day,
> > humptydumpty
>
> That ]] [[ is ugly. Use MACRO: instead.
>
> I have this in the novice package:
>
> macro: next>r ( node -- node ) \ r: -- next-node
> dup .fore @ >r ;
>
> macro: each[ \ toucher: i*x node -- j*x
> begin dup while
> next>r ;
>
> macro: ]each
> r> repeat drop ;
>
> I also have these comments:
>
> \ EACH[...]EACH uses the return stack. This can create havoc in functions that use locals or use >R and R>.
>
> The reason why I push the internal data onto the return-stack is because I want the code inside to have access to the data-stack. In my FMITE document I call this a bar-feature higher-order function. You aren't doing that, so your code must use local variables.
>
> \ FIND-NODE and FIND-PRIOR can't be written like this because they both involve an early-out.
>
> This really kills the macro technique. The macro technique only works when you traverse all the way through the entire data-structure, rather than stop when you have found a node that meets some criteria.
>
> Another problem with the macro technique is that the code you are generating can be quite bulky. A self-balancing tree, for example, is much more complicated than a linked list. You don't really want to generate all of this code in the middle of your application program functions, as this may be done dozens of times. There is very little speed advantage.
>
> I had EACH[ ... ]EACH in the novice package years ago (all of this stuff was written in 2009 and 2010). I thought that it was funny earlier to see Julien presenting my old techniques as Forth-200x code, with the assumption that I was being educated on ideas that I hadn't thought of --- now you're doing it, and it is starting to become less funny and rather annoying...
Hi!
>
> \ FIND-NODE and FIND-PRIOR can't be written like this because they both involve an early-out.
>
> This really kills the macro technique. The macro technique only works when you traverse all the way through the entire data-structure, rather than stop when you have found a node that meets some criteria.
>
It's not problem, add a WHILE .. THEN:
: ]each
] 2>R
]] begin dup while [[
2R> evaluate
]] .fore @ repeat [[
; immediate
: count-females local{ employee-head | cnt -- females }
\ EMPLOYEE-HEAD is the head of a LIST linked list
employee-head @ [ S" dup test-node? WHILE dup .female? c@ cnt +!" ]each THEN drop
cnt @ ;
Of course a node should be on top-of stack. What else is 'employee-head @'
if not first node. And as in a loop, stack should be preserved&balanced,
common sense tells that current-node is on top. After loop undesirable
node is dropped.
> Another problem with the macro technique is that the code you are generating can be quite bulky. A self-balancing tree, for example, is much more complicated than a linked list. You don't really want to generate all of this code in the middle of your application program functions, as this may be done dozens of times. There is very little speed advantage.
>
Yes, could be bulky. But what i presented is an alternative, not a general
cure.
Have a nice day,
humptydumpty
[toc] | [prev] | [next] | [standalone]
| From | "Alex McDonald" <blog@rivadpm.com> |
|---|---|
| Date | 2015-07-14 09:35 +0100 |
| Message-ID | <mo2hia$s90$1@dont-email.me> |
| In reply to | #40591 |
on 14/07/2015 02:51:38, wrote: > On Monday, July 13, 2015 at 2:24:20 PM UTC-7, Mark Wills wrote: >> I'm struggling to see the advantage of: >> >> : foo some code [: bar ;] more code execute ; >> >> against >> >> : foo some code more code bar ; >> >> It's just a different way of factoring. > > You can struggle mightily and never see the advantage in the former > --- bec ause it is nonsense. > > I think that the Forth-200x committee gave us fake quotations (and > your "bo nkers simple" implementation was fake too) for the purpose of > confusing peo ple who don't know what quotations are. Their plan was > that they would tell everybody: "These are quotations!" Then everybody > would would say: "Quotat ions are useless!" Then they would say: "Well > yes, quotations are useless, but we gave them to you because Hugh was > asking for them --- so blame him!" Please provide a definition of quotations (or an RfD; I don't mind either way) so the rest of us human mortals can work out why our implementations are fakes, and how we might rectify that.
[toc] | [prev] | [next] | [standalone]
| From | Mark Wills <markwills1970@gmail.com> |
|---|---|
| Date | 2015-07-14 02:17 -0700 |
| Message-ID | <0c6ca795-2ef4-4cec-a134-c5030167dca5@googlegroups.com> |
| In reply to | #40605 |
On Tuesday, 14 July 2015 09:35:47 UTC+1, Alex McDonald wrote: > on 14/07/2015 02:51:38, wrote: > > On Monday, July 13, 2015 at 2:24:20 PM UTC-7, Mark Wills wrote: > >> I'm struggling to see the advantage of: > >> > >> : foo some code [: bar ;] more code execute ; > >> > >> against > >> > >> : foo some code more code bar ; > >> > >> It's just a different way of factoring. > > > > You can struggle mightily and never see the advantage in the former > > --- bec ause it is nonsense. > > > > I think that the Forth-200x committee gave us fake quotations (and > > your "bo nkers simple" implementation was fake too) for the purpose of > > confusing peo ple who don't know what quotations are. Their plan was > > that they would tell everybody: "These are quotations!" Then everybody > > would would say: "Quotat ions are useless!" Then they would say: "Well > > yes, quotations are useless, but we gave them to you because Hugh was > > asking for them --- so blame him!" > > Please provide a definition of quotations (or an RfD; I don't mind either > way) so the rest of us human mortals can work out why our implementations > are fakes, and how we might rectify that. Yeah! In what way is my implementation fake? I don't get it. It seems to satisfy all the requirements, as far as I can tell.
[toc] | [prev] | [next] | [standalone]
| From | humptydumpty <ouatubi@gmail.com> |
|---|---|
| Date | 2015-07-14 02:24 -0700 |
| Message-ID | <8f0831bb-f51a-488a-a43b-078dfde5607c@googlegroups.com> |
| In reply to | #40609 |
On Tuesday, July 14, 2015 at 12:17:48 PM UTC+3, Mark Wills wrote: > On Tuesday, 14 July 2015 09:35:47 UTC+1, Alex McDonald wrote: > > on 14/07/2015 02:51:38, wrote: > > > On Monday, July 13, 2015 at 2:24:20 PM UTC-7, Mark Wills wrote: > > >> I'm struggling to see the advantage of: > > >> > > >> : foo some code [: bar ;] more code execute ; > > >> > > >> against > > >> > > >> : foo some code more code bar ; > > >> > > >> It's just a different way of factoring. > > > > > > You can struggle mightily and never see the advantage in the former > > > --- bec ause it is nonsense. > > > > > > I think that the Forth-200x committee gave us fake quotations (and > > > your "bo nkers simple" implementation was fake too) for the purpose of > > > confusing peo ple who don't know what quotations are. Their plan was > > > that they would tell everybody: "These are quotations!" Then everybody > > > would would say: "Quotat ions are useless!" Then they would say: "Well > > > yes, quotations are useless, but we gave them to you because Hugh was > > > asking for them --- so blame him!" > > > > Please provide a definition of quotations (or an RfD; I don't mind either > > way) so the rest of us human mortals can work out why our implementations > > are fakes, and how we might rectify that. > > Yeah! In what way is my implementation fake? I don't get it. It seems > to satisfy all the requirements, as far as I can tell. Hi! It looks like a reply to Hugh. Have a nice day, humptydumpty
[toc] | [prev] | [next] | [standalone]
| From | Mark Wills <markwills1970@gmail.com> |
|---|---|
| Date | 2015-07-14 02:25 -0700 |
| Message-ID | <73ff338e-6c75-48f9-9e5e-e6e185501374@googlegroups.com> |
| In reply to | #40591 |
On Tuesday, 14 July 2015 02:51:44 UTC+1, hughag...@gmail.com wrote: > On Monday, July 13, 2015 at 2:24:20 PM UTC-7, Mark Wills wrote: > > I'm struggling to see the advantage of: > > > > : foo some code [: bar ;] more code execute ; > > > > against > > > > : foo some code more code bar ; > > > > It's just a different way of factoring. > > You can struggle mightily and never see the advantage in the former --- because it is nonsense. > > I think that the Forth-200x committee gave us fake quotations (and your "bonkers simple" implementation was fake too) [snip] Ouch! How is it fake? It seems to work as far as I can tell. And the quotation has access to the enclosing definition's locals. I'm not seeing where it's wrong?
[toc] | [prev] | [next] | [standalone]
| From | hughaguilar96@gmail.com |
|---|---|
| Date | 2015-07-14 09:32 -0700 |
| Message-ID | <0cc6b93c-e8f7-42b7-92fc-1f5528746966@googlegroups.com> |
| In reply to | #40611 |
On Tuesday, July 14, 2015 at 2:25:14 AM UTC-7, Mark Wills wrote: > On Tuesday, 14 July 2015 02:51:44 UTC+1, hughag...@gmail.com wrote: > > On Monday, July 13, 2015 at 2:24:20 PM UTC-7, Mark Wills wrote: > > > I'm struggling to see the advantage of: > > > > > > : foo some code [: bar ;] more code execute ; > > > > > > against > > > > > > : foo some code more code bar ; > > > > > > It's just a different way of factoring. > > > > You can struggle mightily and never see the advantage in the former --- because it is nonsense. > > > > I think that the Forth-200x committee gave us fake quotations (and your "bonkers simple" implementation was fake too) [snip] > > Ouch! How is it fake? It seems to work as far as I can tell. And the > quotation has access to the enclosing definition's locals. > > I'm not seeing where it's wrong? Oh, come on Mark! This is not that difficult! You have to pass the xt of the quotation into another function (the "higher-order" function) and that function will EXECUTE the quotation --- when the quotation executes, it has access to the local variables of its parent function (the function that called the higher-order function and which is still in scope waiting for the the higher-order function to exit). Go back to that example I gave you. COUNT-FEMALES is the parent function (what you called "enclosing definition" above). The quotation is defined with curly brackets. EACH is the higher-order function. EACH has a BEGIN WHILE REPEAT loop that traverses the list, and it does an EXECUTE on the xt of the quotation for each node, giving the address of the node to the quotation as a parameter. Notice how the quotation accesses the CNT local variable of the COUNT-FEMALES function when it is executed inside of the EACH function? Explaining this basic stuff over and over is becoming tiresome --- just think about it a little bit! --- this is easy and obvious.
[toc] | [prev] | [next] | [standalone]
Page 3 of 7 — ← Prev page 1 2 [3] 4 5 6 7 Next page →
Back to top | Article view | comp.lang.forth
csiph-web