Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #40544 > unrolled thread

How do quotation work, I can not foound them in 20xx

Started byTessa Bonting <tessa.bonting@gmail.com>
First post2015-07-12 06:48 -0700
Last post2015-08-06 21:19 +0200
Articles 20 on this page of 126 — 22 participants

Back to article view | Back to comp.lang.forth


Contents

  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 6 of 7 — ← Prev page 1 2 3 4 5 [6] 7  Next page →


#40661

From"Alex McDonald" <blog@rivadpm.com>
Date2015-07-15 19:31 +0100
Message-ID<mo68s1$k4c$1@dont-email.me>
In reply to#40659
on 15/07/2015 18:44:38, ha wrote:

> 
> Note that ANS-Forth (13.3.3) says this:
> - Locals shall not be declared until values previously placed on the
> return stack within the definition have been removed;
> - After a definition's locals have been declared, a program may place
> data on the return stack. However, if this is done, locals shall not
> be accessed until those values have been removed from the return
> stack;
> 
> So, the ANS-Forth document actually requires that all ANS-Forth
> systems use frameless-locals, meaning that >R etc. can't be used in
> conjunction with l ocals. As a practical matter, every ANS-Forth
> system ignores this limitatio n and uses a frame-pointer.

All that's required is counting and the return stack pointer; an extra
frame pointer isn't needed. Let's put the locals on the rstack. Assume
that it counts from 0 downwards, in that 0 is the index of the return
address on entry.

: foo {: a :} a 1 0 do a >r a r> loop ;
        ^1   ^2       ^3   ^4   

At ^1 A is initialized from the data stack, and is PUSHed on the rstack.
^2 is at rstack[0]. DO loop parameters PUSHed; let's say they are 2
cells, hence ^3 is now at rstack[-2]. >R does another PUSH, and now A is
rstack[-3] and so on.

[toc] | [prev] | [next] | [standalone]


#40662

FromPaul Rubin <no.email@nospam.invalid>
Date2015-07-15 11:48 -0700
Message-ID<87y4ihz27q.fsf@jester.gateway.sonic.net>
In reply to#40661
"Alex McDonald" <blog@rivadpm.com> writes:
> All that's required is counting and the return stack pointer; an extra
> frame pointer isn't needed....
> : foo {: a :} a 1 0 do a >r a r> loop ;
>         ^1   ^2       ^3   ^4   

That seems to assume you can statically track the r-stack depth, which
might not be possible:

  : foo {: a :} mystery if >r then a ...

you don't know at compile time whether mystery has returned true or
false.  So you don't know the depth of a.  Obviously stuff later in the
word has to clean up but you can't necessarily tell what's happening
there either.

[toc] | [prev] | [next] | [standalone]


#40663

Fromhughaguilar96@gmail.com
Date2015-07-15 12:13 -0700
Message-ID<c958bf09-9615-42ea-9fa8-f87072158403@googlegroups.com>
In reply to#40662
On Wednesday, July 15, 2015 at 11:48:43 AM UTC-7, Paul Rubin wrote:
> "Alex McDonald" <blog@rivadpm.com> writes:
> > All that's required is counting and the return stack pointer; an extra
> > frame pointer isn't needed....
> > : foo {: a :} a 1 0 do a >r a r> loop ;
> >         ^1   ^2       ^3   ^4   
> 
> That seems to assume you can statically track the r-stack depth, which
> might not be possible:
> 
>   : foo {: a :} mystery if >r then a ...
> 
> you don't know at compile time whether mystery has returned true or
> false.  So you don't know the depth of a.  Obviously stuff later in the
> word has to clean up but you can't necessarily tell what's happening
> there either.

Paul Rubin is right. 

This has been covered many times in the past:
https://groups.google.com/forum/#!topic/comp.lang.forth/vGu_EdaLDR4

On Sep 21, 7:37 pm, Hugh Aguilar <hughaguila...@yahoo.com> wrote: 
> On Sep 21, 1:47 pm, Brad Eckert <hwfw...@gmail.com> wrote: 
> 
> > On Wednesday, July 18, 2012 4:25:11 PM UTC-7, (unknown) wrote: 
> > >... locals on the return stack, which is not possible if it is 
> > >also going to support >R R@ R> etc., which it does. 
> 
> > If it's not possible, why do so many Forths do it? 
> 
> Forths that have locals and have >R R@ R> etc. typically give the 
> locals their own stack. If the locals are on the return-stack, then 
> you have to know at compile-time how many >R will be done at run-time 
> so that you know how to adjust the offsets of the locals from the 
> return-stack pointer. This isn't possible because the >R may be inside 
> of a loop and the number of iterations that the loop executes (and 
> hence the number of >R that get executed) depends upon parameters 
> given to the function at run-time. 
> 
> It is common to have >R inside of a loop when you have variable 
> numbers of parameters (usually a lot of non-zero data with a zero 
> sentinal underneath). This is sometimes also done with strings where 
> all of the chars in the string get pushed onto the return-stack. If 
> you don't understand how >R can be inside of a loop, I have examples 
> in my novice package: http://www.forth.org/novice.html 

[toc] | [prev] | [next] | [standalone]


#40664

From"Alex McDonald" <blog@rivadpm.com>
Date2015-07-15 20:18 +0100
Message-ID<mo6bjc$v0j$1@dont-email.me>
In reply to#40662
on 15/07/2015 19:48:43, Paul Rubin wrote:
> "Alex McDonald" <blog@rivadpm.com> writes:
>> All that's required is counting and the return stack pointer; an extra
>> frame pointer isn't needed....
>> : foo {: a :} a 1 0 do a >r a r> loop ;
>>         ^1   ^2       ^3   ^4
> 
> That seems to assume you can statically track the r-stack depth, which
> might not be possible:
> 
> : foo {: a :} mystery if >r then a ...
> 
> you don't know at compile time whether mystery has returned true or
> false. So you don't know the depth of a. Obviously stuff later in the
> word has to clean up but you can't necessarily tell what's happening
> there either.
> 

You're right. I didn't read my notes closely enough. A locals frame
pointer or the equivalent separate locals stack (as in Gforth) would be
required for that. My Forth does have support for static tracking; if you
avoid the mystery case, then using locals inside >R R> and DO LOOP can be
done.

 

[toc] | [prev] | [next] | [standalone]


#40741

From"WJ" <w_a_x_man@yahoo.com>
Date2015-07-22 11:11 +0000
Message-ID<montp0$hbc$1@dont-email.me>
In reply to#40623
hughaguilar96@gmail.com wrote:

> > They get access to locals 'for free' (as in, no code required):
> > : test
> >   locals{ fred }
> >   99 set fred \ load fred with 99
> >   [: fred 1+ ;] execute .
> > ;
> > test 
> > 100 ok:0
> 
> You did your EXECUTE inside of the parent
> function --- the idea is to pass the  quotation's
> xt into another function (the higher-order
> function) and do the EXECUTE there

An example from Scheme (it would be similar in other Lispy languages).
The lambda is a "quotation" that is passed to the higher-order function
"map".

(define (mul-by-n n numbers)
  (map
    (lambda (x) (* n x))
    numbers))

(mul-by-n 500 '(2 3 4 5))
 ===>
(1000 1500 2000 2500)

Using partial application or currying makes it shorter:

(define (mul-by-n n numbers)
  (map
    (pa$ * n)
    numbers))

-- 
The report card by the American Society of Civil Engineers showed the national
infrastructure a single grade above failure, a step from declining to the point
where everyday things simply stop working the way people expect them to. ---
washingtonpost.com/local/trafficandcommuting/us-infrastructure-gets-d-in-annual-report/2013/03/19/c48cb010-900b-11e2-9cfd-36d6c9b5d7ad_story.html

[toc] | [prev] | [next] | [standalone]


#40630

FromHåkan Thörngren <hth313@gmail.com>
Date2015-07-14 11:38 -0700
Message-ID<a27f8f88-f100-45df-88da-0299cad758be@googlegroups.com>
In reply to#40621
On Tuesday, July 14, 2015 at 6:53:59 PM UTC+2, Mark Wills wrote:
> Yes. I understand that. What I don't understand is what is fake about my implementation. Perhaps you were being tongue-in-cheek. It seems a valid implementation to me.

Nothing seems wrong with your implementation, but it depends on how you want it to behave.

What happens if you add a new binding with the same name?

: BAR
   locals{ fred }
   EXECUTE
;

: test
   locals{ fred } 
   99 set fred \ load fred with 99 
   [: fred 1+ ;] BAR .
;

Which fred will the quotation access?

Looking at the Forth-200x standard, it seems you should dynamically create locals to be visible in a dictionary search.

This is what the Lisp people call dynamic binding. The variable gets bound from the context where it is called. The alternative approach is lexical binding where the variable will get bound where it is defined.

With lexical binding you will always access the local 'fred' in test when running the quotation.

I prefer lexical binding as it feels more natural to me. I believe Hugh is doing lexical binding in his system, that by changing xt to be a pair of CFA and pointer to a locals record.

If I were to implement it, I would try to stay with a single xt token that can be EXECUTEd immediately. Then let a quotation which access locals of its containing word pay the
price. The containing word would in addition to setting up the locals record need to create a stub word to set up the locals base pointer before invoking the actual quotation.

Compiling a reference to a local would be a word that embeds an offset (like a lit), and it would just pick ut up and add it to the base pointer of the current locals record.

Using the xt of a quotation where the parent has gone out of scope would of course crash. That I think is an acceptable tradeoff in a stack language without any built in dynamic memory handling.

[toc] | [prev] | [next] | [standalone]


#40631

From"Alex McDonald" <blog@rivadpm.com>
Date2015-07-14 19:58 +0100
Message-ID<mo3m2h$5ch$1@dont-email.me>
In reply to#40630
on 14/07/2015 19:38:12, Håkan Thörngren wrote:
> On Tuesday, July 14, 2015 at 6:53:59 PM UTC+2, Mark Wills wrote:
>> Yes. I understand that. What I don't understand is what is fake about my implementation. Perhaps you were being tongue-in-cheek. It seems a valid implementation to me.
> 
> Nothing seems wrong with your implementation, but it depends on how
> you want it to behave.
> 
> What happens if you add a new binding with the same name?
> 
>: BAR
> locals{ fred }
> EXECUTE
> ;
> 
>: test
> locals{ fred }
> 99 set fred \ load fred with 99
> [: fred 1+ ;] BAR .
> ;
> 
> Which fred will the quotation access?
> 
> Looking at the Forth-200x standard, it seems you should dynamically
> create locals to be visible in a dictionary search.

The examples you give aren't ANS Forth, so it's impossible to tell.

[toc] | [prev] | [next] | [standalone]


#40641

Fromanton@mips.complang.tuwien.ac.at (Anton Ertl)
Date2015-07-15 05:55 +0000
Message-ID<2015Jul15.075550@mips.complang.tuwien.ac.at>
In reply to#40630
=?ISO-8859-1?Q?H=E5kan_Th=F6rngren?= <hth313@gmail.com> writes:
>: BAR
>   locals{ fred }
>   EXECUTE
>;
>
>: test
>   locals{ fred } 
>   99 set fred \ load fred with 99 
>   [: fred 1+ ;] BAR .
>;
>
>Which fred will the quotation access?
>
>Looking at the Forth-200x standard, it seems you should dynamically create locals to be visible in a dictionary search.

What makes you think so?

There are no quotations in Forth-2012, so this code is not Forth-2012
anyway.  But, e.g.:

: bar a ;
: foo { a } bar ;

is non-standard, and no Forth system I know will dynamically bind the
A in BAR to the A in FOO.

BTW, please limit the length of your lines to about 72 characters.

- 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]


#40642

FromHåkan Thörngren <hth313@gmail.com>
Date2015-07-15 00:03 -0700
Message-ID<ee6b6ddc-3f32-4d79-9327-930eee1ae989@googlegroups.com>
In reply to#40641
On Wednesday, July 15, 2015 at 8:03:43 AM UTC+2, Anton Ertl wrote:
> =?ISO-8859-1?Q?H=E5kan_Th=F6rngren?= writes:
> >: BAR
> >   locals{ fred }
> >   EXECUTE
> >;
> >
> >: test
> >   locals{ fred } 
> >   99 set fred \ load fred with 99 
> >   [: fred 1+ ;] BAR .
> >;
> >
> >Which fred will the quotation access?
> >
> >Looking at the Forth-200x standard, it seems you should dynamically create locals to be visible in a dictionary search.
> 
> What makes you think so?
> 
> There are no quotations in Forth-2012, so this code is not Forth-2012
> anyway.  But, e.g.:
> 
> : bar a ;
> : foo { a } bar ;
> 
> is non-standard, and no Forth system I know will dynamically bind the
> A in BAR to the A in FOO.
> 
> BTW, please limit the length of your lines to about 72 characters.
> 

You are right, it is just me getting compile time and run-time mixed
up.

It will work just fine, you extend the dictionary (13.3.3.1 a) at
compile time, and remove it when the word has been created.
And yes, it says so, compilation semantics.
That fixes the visibility issue that clouded my thinking.

And as quotations are not in Forth-2012, the problem of accessing
locals from them obviously will not exist.

Håkan

[toc] | [prev] | [next] | [standalone]


#40644

FromMark Wills <markwills1970@gmail.com>
Date2015-07-15 01:41 -0700
Message-ID<8cf7a41a-0f66-4bb6-abbe-ab1fed2b9320@googlegroups.com>
In reply to#40630
On Tuesday, 14 July 2015 19:38:15 UTC+1, Håkan Thörngren  wrote:
> On Tuesday, July 14, 2015 at 6:53:59 PM UTC+2, Mark Wills wrote:
> > Yes. I understand that. What I don't understand is what is fake about my implementation. Perhaps you were being tongue-in-cheek. It seems a valid implementation to me.
> 
> Nothing seems wrong with your implementation, but it depends on how you want it to behave.
> 
> What happens if you add a new binding with the same name?
> 
> : BAR
>    locals{ fred }
>    EXECUTE
> ;
> 
> : test
>    locals{ fred } 
>    99 set fred \ load fred with 99 
>    [: fred 1+ ;] BAR .
> ;
> 
> Which fred will the quotation access?
> 
> Looking at the Forth-200x standard, it seems you should dynamically create locals to be visible in a dictionary search.
> 
> This is what the Lisp people call dynamic binding. The variable gets bound from the context where it is called. The alternative approach is lexical binding where the variable will get bound where it is defined.
> 
> With lexical binding you will always access the local 'fred' in test when running the quotation.
> 
> I prefer lexical binding as it feels more natural to me. I believe Hugh is doing lexical binding in his system, that by changing xt to be a pair of CFA and pointer to a locals record.
> 
> If I were to implement it, I would try to stay with a single xt token that can be EXECUTEd immediately. Then let a quotation which access locals of its containing word pay the
> price. The containing word would in addition to setting up the locals record need to create a stub word to set up the locals base pointer before invoking the actual quotation.
> 
> Compiling a reference to a local would be a word that embeds an offset (like a lit), and it would just pick ut up and add it to the base pointer of the current locals record.
> 
> Using the xt of a quotation where the parent has gone out of scope would of course crash. That I think is an acceptable tradeoff in a stack language without any built in dynamic memory handling.

Indeed. See my post earlier about locals in my implementation.

Thanks, Håkan

Mark

[toc] | [prev] | [next] | [standalone]


#40599

FromPaul Rubin <no.email@nospam.invalid>
Date2015-07-13 22:05 -0700
Message-ID<87k2u31g85.fsf@jester.gateway.sonic.net>
In reply to#40584
Mark Wills <markwills1970@gmail.com> writes:
> I'm struggling to see the advantage of:
> : foo some code [: bar ;] more code execute ;   ...
> It's just a different way of factoring. Can someone give me an example
> of something that can only be done using quotations?

The usefulness is when you pass the quotation to something that takes an
xt as an arg.  Of course without quotations you could make another named
word and quote it to make the xt.  It's just convenience.

  0.001e fconstant h
  \ (D f)(x) = (f(x+h) - f(x)) / h
  : derivative {: func F:x :}
       x h f+ func execute    x func execute  f-  h f/ ;

  : square ( f -- f ) fdup f* ;

  ' square 3e derivative     \ prints approx derivative of x^2 at x=3

  [: fdup f* ;] 3e derivative  \ same thing without making an extra word

It doesn't seem that important for Forth but it is a main idiom of
functional programming.  If you're interested in that topic, this is
a good paper:

  http://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf

[toc] | [prev] | [next] | [standalone]


#40585

FromMark Wills <markwills1970@gmail.com>
Date2015-07-13 14:24 -0700
Message-ID<7277edbf-e96e-4957-b822-13bb32312614@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]


#40589

From"Alex McDonald" <blog@rivadpm.com>
Date2015-07-13 23:13 +0100
Message-ID<mo1d2m$tjf$1@dont-email.me>
In reply to#40585
on 13/07/2015 22:24:48, 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. Can someone give me an example
> of something that can only be done using quotations?
> 

No, since they are just nameless words. 

wordlist constant wid

: count-words 0 [: drop 1+ true ;] wid traverse-wordlist ;

: (count-words) drop 1+ true ;
: count-words 0 (count-words) wid traverse-wordlist ; 

I think the former is clearest.

[toc] | [prev] | [next] | [standalone]


#40590

From"Elizabeth D. Rather" <erather@forth.com>
Date2015-07-13 13:03 -1000
Message-ID<Df6dnYYzGoYt3jnInZ2dnUU7-IudnZ2d@supernews.com>
In reply to#40589
On 7/13/15 12:13 PM, Alex McDonald wrote:
> on 13/07/2015 22:24:48, 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. Can someone give me an example
>> of something that can only be done using quotations?
>>
>
> No, since they are just nameless words.
>
> wordlist constant wid
>
> : count-words 0 [: drop 1+ true ;] wid traverse-wordlist ;
>
> : (count-words) drop 1+ true ;
> : count-words 0 (count-words) wid traverse-wordlist ;
>
> I think the former is clearest.

Do you mean ... ['] (count-words) wid traverse-wordlist ?

In any case, I find the conventional one clearest. Particularly since I 
could reference (count-words) in testing (e.g., see (countwords) or 
locate (countwords) etc.).

Cheers,
Elizabeth

-- 
==================================================
Elizabeth D. Rather   (US & Canada)   800-55-FORTH
FORTH Inc.                         +1 310.999.6784
5959 West Century Blvd. Suite 700
Los Angeles, CA 90045
http://www.forth.com

"Forth-based products and Services for real-time
applications since 1973."
==================================================

[toc] | [prev] | [next] | [standalone]


#40604

From"Alex McDonald" <blog@rivadpm.com>
Date2015-07-14 09:31 +0100
Message-ID<mo2hb4$rj7$1@dont-email.me>
In reply to#40590
on 14/07/2015 00:03:10, "Elizabeth D. Rather" wrote:
> On 7/13/15 12:13 PM, Alex McDonald wrote:
>> on 13/07/2015 22:24:48, 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. Can someone give me an example
>>> of something that can only be done using quotations?
>>>
>>
>> No, since they are just nameless words.
>>
>> wordlist constant wid
>>
>> : count-words 0 [: drop 1+ true ;] wid traverse-wordlist ;
>>
>> : (count-words) drop 1+ true ;
>> : count-words 0 (count-words) wid traverse-wordlist ;
>>
>> I think the former is clearest.
> 
> Do you mean ... ['] (count-words) wid traverse-wordlist ?

Yes; typo. Tahnks.

> 
> In any case, I find the conventional one clearest. Particularly since
> I could reference (count-words) in testing (e.g., see (countwords) or
> locate (countwords) etc.).

YMMV, as in this case it does. 

> 
> Cheers,
> Elizabeth
> 

[toc] | [prev] | [next] | [standalone]


#40667

Fromhughaguilar96@gmail.com
Date2015-07-15 13:24 -0700
Message-ID<f9acfaec-9dad-44f4-a299-5b940eb0a5d8@googlegroups.com>
In reply to#40590
On Monday, July 13, 2015 at 4:03:13 PM UTC-7, Elizabeth D. Rather wrote:
> On 7/13/15 12:13 PM, Alex McDonald wrote:
> > wordlist constant wid
> >
> > : count-words 0 [: drop 1+ true ;] wid traverse-wordlist ;
> >
> > : (count-words) drop 1+ true ;
> > : count-words 0 (count-words) wid traverse-wordlist ;
> >
> > I think the former is clearest.
> 
> Do you mean ... ['] (count-words) wid traverse-wordlist ?
> 
> In any case, I find the conventional one clearest. Particularly since I 
> could reference (count-words) in testing (e.g., see (countwords) or 
> locate (countwords) etc.).

I use this second technique in my novice package routinely for general-purpose data-structures. This is what you said on that subject:
"Does '*every* application' you write use exactly the same kind of data arranged in the same way? If so, having written it once you can reuse it often. If not, you either have to rearrange your data to make it work or modify your 'general-purpose' structure."

Now however, you want to offer your support for this technique. Did you learn how the technique works between the time when you denounced it and when you promoted it? More likely, you don't understand any of this stuff --- you are just supporting Alex McDonald because he is attacking my FMITE design --- you don't really know what any of this is about, but you just support anybody who supports Forth-200x.

You have never posted any code on comp.lang.forth, except for example code taken directly out of the "Starting Forth" book. When you discuss technical issues, you typically demonstrate a complete failure to understand the subject (your comment above regarding general-purpose data-structures is a good example). You have never written a Forth program in your life --- you're a phony.

You are the reason why comp.lang.forth has become such a poisonous environment. Your encouraged John Passaniti to attack your perceived enemies and now you encourage Alex McDonald to attack your perceived enemies. Your entire life is founded upon demanding that Forth programmers support ANS-Forth as the standard, and encouraging antagonizers such as John Passaniti and Alex McDonald to attack anybody who refuses to accept ANS-Forth.

> Cheers,
> Elizabeth

I notice that you have stopped signing off with "Aloha." You had to leave Hawaii after the assassination attempt, didn't you? I notice that you have also stopped bragging about your big lawsuit against Apple Computer because they use the word "swift." You had to drop the lawsuit because of the assassination attempt, didn't you?

You are a disgrace to the Forth community.

[toc] | [prev] | [next] | [standalone]


#40668

From"Alex McDonald" <blog@rivadpm.com>
Date2015-07-15 22:04 +0100
Message-ID<mo6hq2$n2l$1@dont-email.me>
In reply to#40667
on 15/07/2015 21:24:20,  wrote:
> On Monday, July 13, 2015 at 4:03:13 PM UTC-7, Elizabeth D. Rather
> > wrote:
>> On 7/13/15 12:13 PM, Alex McDonald wrote:
> > wrote:
>> > wordlist constant wid
> > wrote:
>> >
> > wrote:
>> > : count-words 0 [: drop 1+ true ;] wid traverse-wordlist ;
> > wrote:
>> >
> > wrote:
>> > : (count-words) drop 1+ true ;
> > wrote:
>> > : count-words 0 (count-words) wid traverse-wordlist ;
> > wrote:
>> >
> > wrote:
>> > I think the former is clearest.
> > wrote:
>>
> > wrote:
>> Do you mean ... ['] (count-words) wid traverse-wordlist ?
> > wrote:
>>
> > wrote:
>> In any case, I find the conventional one clearest. Particularly since I
> wrote:
> 
>> could reference (count-words) in testing (e.g., see (countwords) or
>> locate (countwords) etc.).
> 
> I use this second technique in my novice package routinely for
> general-purp ose data-structures. This is what you said on that
> subject: "Does '*every* application' you write use exactly the same
> kind of data arr anged in the same way? If so, having written it once
> you can reuse it often . If not, you either have to rearrange your
> data to make it work or modify your 'general-purpose' structure."
> 
> Now however, you want to offer your support for this technique. Did
> you lea rn how the technique works between the time when you denounced
> it and when you promoted it? More likely, you don't understand any of
> this stuff --- yo u are just supporting Alex McDonald because he is
> attacking my FMITE design --- you don't really know what any of this
> is about, but you just support anybody who supports Forth-200x.
> 
> You have never posted any code on comp.lang.forth, except for example
> code taken directly out of the "Starting Forth" book. When you discuss
> technical issues, you typically demonstrate a complete failure to
> understand the sub ject (your comment above regarding general-purpose
> data-structures is a goo d example). You have never written a Forth
> program in your life --- you're a phony.
> 
> You are the reason why comp.lang.forth has become such a poisonous
> environm ent. Your encouraged John Passaniti to attack your perceived
> enemies and no w you encourage Alex McDonald to attack your perceived
> enemies. Your entire life is founded upon demanding that Forth
> programmers support ANS-Forth as the standard, and encouraging
> antagonizers such as John Passaniti and Alex McDonald to attack
> anybody who refuses to accept ANS-Forth.
> 
>> Cheers,
>> Elizabeth
> 
> I notice that you have stopped signing off with "Aloha." You had to
> leave H awaii after the assassination attempt, didn't you? I notice
> that you have a lso stopped bragging about your big lawsuit against
> Apple Computer because they use the word "swift." You had to drop the
> lawsuit because of the assas sination attempt, didn't you?
> 
> You are a disgrace to the Forth community.
> 

I hate repeating myself, but you really are one sad sack of shit.

[toc] | [prev] | [next] | [standalone]


#40588

From"Alex McDonald" <blog@rivadpm.com>
Date2015-07-13 22:52 +0100
Message-ID<mo1bt2$lqb$1@dont-email.me>
In reply to#40582
on 13/07/2015 21:10:30, hugh wrote:

> 
> The purpose of quotations is to make general-purpose data-structures
> possib le --- the code for iterating through them is hidden inside of
> higher-order functions provided in the code-library --- the user of
> the code library ca n use the container without knowing how it is
> implemented internally (can b e complicated, such as for
> self-balancing trees, so you don't want this com plication exposed to
> the user).
> 

If that was the point of quotations, we wouldn't need them, since :NONAME
and ticked named words are sufficent.

[toc] | [prev] | [next] | [standalone]


#40583

Fromhughaguilar96@gmail.com
Date2015-07-13 13:12 -0700
Message-ID<9e536d04-6734-4c73-a666-904105c22949@googlegroups.com>
In reply to#40566
On Monday, July 13, 2015 at 6:13:43 AM UTC-7, Mark Wills wrote:
> I'm still somewhat agog...

If you're Gog, does that mean that I'm Magog?

[toc] | [prev] | [next] | [standalone]


#49066 — Re: How do lambdas work, I cannot find them in 20xx

From"WJ" <w_a_x_man@yahoo.com>
Date2016-07-11 23:02 +0000
SubjectRe: How do lambdas work, I cannot find them in 20xx
Message-ID<nm18hj$o1a$1@dont-email.me>
In reply to#40566
Mark Wills wrote:

> 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.

Here's an example of using both one-dimensional arrays and
anonymous functions (don't call them "quotations"; that's idiotic).

OCaml:

Array.map
  (fun x -> x ** x)
  [| 2.2; 3.3; 4.4; 5.5; 6.6 |] ;;

[|5.6666957787500811; 51.415729444066585; 677.94080784554023;
  11803.064820864423; 256442.48376485694|]

-- 
If confirmed, Garland would be the fourth Jewish justice on the nation's
highest court, which is comprised entirely of Jews and Catholics. The three
current Jewish members of the Supreme Court are Ruth Bader Ginsburg, Elana
Kagan, and Stephen Breyer.
www.jta.org/2016/03/16/news-opinion/united-states/obama-to-name-jewish-federal-judge-to-supreme-court

[toc] | [prev] | [next] | [standalone]


Page 6 of 7 — ← Prev page 1 2 3 4 5 [6] 7  Next page →

Back to top | Article view | comp.lang.forth


csiph-web