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


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

local variable

Started bygrobibi <tristanhennequin@free.fr>
First post2015-03-15 00:43 +0100
Last post2015-07-05 08:44 -0700
Articles 20 on this page of 127 — 24 participants

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


Contents

  local variable grobibi <tristanhennequin@free.fr> - 2015-03-15 00:43 +0100
    Re: local variable "Elizabeth D. Rather" <erather@forth.com> - 2015-03-14 15:01 -1000
      Re: local variable grobibi <tristanhennequin@free.fr> - 2015-03-15 02:50 +0100
        Re: local variable Gerard Sontag <gerardsontag@gmail.com> - 2015-07-11 09:49 -0700
          Re: local variable Coos Haak <chforth@hccnet.nl> - 2015-07-11 22:50 +0200
            Re: local variable Gerard Sontag <gerardsontag@gmail.com> - 2015-07-12 01:03 -0700
              Re: local variable Coos Haak <chforth@hccnet.nl> - 2015-07-12 17:18 +0200
      Re: local variable albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-03-15 03:02 +0000
    Re: local variable Bernd Paysan <bernd.paysan@gmx.de> - 2015-03-15 02:53 +0100
      Re: local variable "WJ" <w_a_x_man@yahoo.com> - 2015-03-17 22:29 +0000
        Re: local variable "WJ" <w_a_x_man@yahoo.com> - 2016-02-08 14:45 +0000
    Re: local variable hughaguilar96@gmail.com - 2015-03-14 20:45 -0700
      Re: local variable stephen@mpeforth.com (Stephen Pelc) - 2015-03-15 10:53 +0000
        Re: local variable Bernd Paysan <bernd.paysan@gmx.de> - 2015-03-15 22:54 +0100
        Re: local variable hughaguilar96@gmail.com - 2015-03-15 19:45 -0700
          Re: local variable hughaguilar96@gmail.com - 2015-03-15 20:15 -0700
            Re: local variable grobibi <tristanhennequin@free.fr> - 2015-03-16 08:42 +0100
          Re: local variable stephen@mpeforth.com (Stephen Pelc) - 2015-03-16 07:51 +0000
            Re: local variable hughaguilar96@gmail.com - 2015-03-16 09:59 -0700
              Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-03-16 20:31 +0000
              Re: local variable "WJ" <w_a_x_man@yahoo.com> - 2015-03-18 08:59 +0000
        Re: local variable "HAA" <someone@microsoft.com> - 2015-03-17 13:47 +1100
          Re: local variable stephen@mpeforth.com (Stephen Pelc) - 2015-03-17 10:59 +0000
            Re: local variable Bernd Paysan <bernd.paysan@gmx.de> - 2015-03-17 18:55 +0100
              Re: local variable stephen@mpeforth.com (Stephen Pelc) - 2015-03-17 18:43 +0000
            Re: local variable "HAA" <someone@microsoft.com> - 2015-03-18 13:25 +1100
              Re: local variable "Elizabeth D. Rather" <erather@forth.com> - 2015-03-17 16:43 -1000
                Re: local variable Bernd Paysan <bernd.paysan@gmx.de> - 2015-03-18 04:09 +0100
                  Re: local variable "Elizabeth D. Rather" <erather@forth.com> - 2015-03-17 17:55 -1000
                  Re: local variable "HAA" <someone@microsoft.com> - 2015-03-20 22:28 +1100
                    Re: local variable Bernd Paysan <bernd.paysan@gmx.de> - 2015-03-20 15:43 +0100
                    Identifying self interest (was Re: local variable) "Alex McDonald" <blog@rivadpm.com> - 2015-03-20 15:20 +0000
              Re: local variable "WJ" <w_a_x_man@yahoo.com> - 2015-03-18 08:48 +0000
                Re: local variable "WJ" <w_a_x_man@yahoo.com> - 2015-09-16 18:55 +0000
                  Re: local variable hughaguilar96@gmail.com - 2015-09-16 22:03 -0700
          Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-03-17 14:18 +0000
            Re: local variable albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-03-17 16:24 +0000
              Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-03-17 16:34 +0000
              Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-03-18 14:32 +0000
            Re: local variable Bernd Paysan <bernd.paysan@gmx.de> - 2015-03-17 20:08 +0100
              Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-03-18 15:21 +0000
    Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-03-16 15:36 +0000
      Re: local variable hughaguilar96@gmail.com - 2015-03-16 10:09 -0700
        Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-03-16 20:24 +0000
          Re: local variable "Rod Pemberton" <buzz@notnotnontnooatno.cmm> - 2015-03-16 19:00 -0400
            Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-03-17 12:06 +0000
              Re: local variable stephen@mpeforth.com (Stephen Pelc) - 2015-03-17 14:37 +0000
              Re: local variable Bernd Paysan <bernd.paysan@gmx.de> - 2015-03-17 18:58 +0100
            Re: local variable Doug Hoffman <glidedog@gmail.com> - 2015-03-17 08:55 -0400
            Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-03-17 14:15 +0000
        Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-03-17 16:54 +0000
          Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-03-17 17:45 +0000
            Re: local variable Bernd Paysan <bernd.paysan@gmx.de> - 2015-03-17 20:14 +0100
            Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-03-20 15:06 +0000
              Re: local variable hughaguilar96@gmail.com - 2015-03-20 16:14 -0700
                Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-03-21 09:47 +0000
              Re: local variable hughaguilar96@gmail.com - 2015-07-04 19:52 -0700
                Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-05 07:24 +0100
                  Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 02:04 -0700
                    Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-05 10:36 +0100
                      Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 03:25 -0700
                        Re: local variable Bernd Paysan <bernd.paysan@gmx.de> - 2015-07-05 15:28 +0200
                          Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 08:11 -0700
                            Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 08:21 -0700
                              Re: local variable Bernd Paysan <bernd.paysan@gmx.de> - 2015-07-05 23:53 +0200
                                Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 20:31 -0700
                          Re: local variable hughaguilar96@gmail.com - 2015-07-05 19:56 -0700
                      Re: local variable hughaguilar96@gmail.com - 2015-07-05 19:57 -0700
                        Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-06 08:09 +0100
                          Re: local variable hughaguilar96@gmail.com - 2015-07-06 19:59 -0700
                            Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-07 08:30 +0100
                              Re: local variable Michael Barry <barrym95838@yahoo.com> - 2015-07-10 00:35 -0700
                                Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-10 01:41 -0700
                                  Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-10 13:55 +0100
                                    Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-10 07:13 -0700
                                      Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-10 16:29 +0100
                                        Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-10 08:57 -0700
                                          Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-10 17:48 +0100
                                            Re: local variable Paul Rubin <no.email@nospam.invalid> - 2015-07-10 10:02 -0700
                                              Re: local variable "WJ" <w_a_x_man@yahoo.com> - 2015-09-16 17:30 +0000
                                            Re: local variable Mark Wills <markwills1970@gmail.com> - 2015-07-10 10:28 -0700
                                              Re: local variable "Elizabeth D. Rather" <erather@forth.com> - 2015-07-10 08:00 -1000
                                                Re: local variable hughaguilar96@gmail.com - 2015-07-10 21:31 -0700
                                              Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-10 19:13 +0100
                                                Re: local variable "Elizabeth D. Rather" <erather@forth.com> - 2015-07-10 09:06 -1000
                                                  Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-11 14:10 +0000
                                                    Re: local variable humptydumpty <ouatubi@gmail.com> - 2015-07-11 10:14 -0700
                                                      Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-12 15:56 +0000
                                                        Re: local variable humptydumpty <ouatubi@gmail.com> - 2015-07-12 11:48 -0700
                                            Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-10 21:21 -0700
                                              Re: local variable hughaguilar96@gmail.com - 2015-07-10 21:56 -0700
                                              Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-11 23:51 +0100
                                            Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-11 13:42 +0000
                                              Re: local variable franck.bensusan@gmail.com - 2015-07-12 02:17 -0700
                                                Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-12 15:12 +0000
                                                  Re: local variable franck.bensusan@gmail.com - 2015-07-13 02:37 -0700
                                                    Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-13 16:13 +0000
                                                      Re: local variable franck.bensusan@gmail.com - 2015-07-13 14:48 -0700
                                                        Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-14 06:41 +0000
                                                          Re: local variable franck.bensusan@gmail.com - 2015-07-14 01:44 -0700
                                        Re: local variable Bernd Linsel <bl1@gmx.com> - 2015-07-11 11:03 +0200
                                          Re: local variable Bernd Linsel <bl1@gmx.com> - 2015-07-11 11:11 +0200
                                            Re: local variable hughaguilar96@gmail.com - 2015-07-12 16:43 -0700
                                          Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-11 15:14 +0000
                                            Re: local variable Julian Fondren <julian.fondren@gmail.com> - 2015-07-11 17:57 -0700
                                              Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-12 15:32 +0000
                                Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-10 13:13 +0100
                              Re: local variable hughaguilar96@gmail.com - 2015-07-10 21:48 -0700
                    Re: local variable franck.bensusan@gmail.com - 2015-07-05 03:47 -0700
                      Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 04:15 -0700
                        Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 04:27 -0700
                          Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 04:39 -0700
                        Re: local variable franck.bensusan@gmail.com - 2015-07-05 07:08 -0700
    Re: local variable "WJ" <w_a_x_man@yahoo.com> - 2015-03-18 05:04 +0000
      Re: local variable "WJ" <w_a_x_man@yahoo.com> - 2016-02-08 16:09 +0000
    Ignore the standard Stefan Mauerhofer <smauerhofer@androsoft.ch> - 2015-03-18 04:09 -0700
      Re: Ignore the standard Doug Hoffman <glidedog@gmail.com> - 2015-03-18 07:26 -0400
        Re: Ignore the standard "WJ" <w_a_x_man@yahoo.com> - 2015-03-20 17:31 +0000
          Re: Ignore the standard Doug Hoffman <glidedog@gmail.com> - 2015-03-20 17:41 -0400
            Re: Ignore the standard "Elizabeth D. Rather" <erather@forth.com> - 2015-03-20 14:26 -1000
              Re: Ignore the standard Doug Hoffman <glidedog@gmail.com> - 2015-03-21 06:00 -0400
                Re: Ignore the standard hughaguilar96@gmail.com - 2015-03-21 15:11 -0700
            Re: Ignore the standard Bernd Paysan <bernd.paysan@gmx.de> - 2015-03-21 02:49 +0100
              Re: Ignore the standard Doug Hoffman <glidedog@gmail.com> - 2015-03-21 06:04 -0400
      Re: Ignore the standard "Alex McDonald" <blog@rivadpm.com> - 2015-03-18 16:05 +0000
      Re: Ignore the standard "WJ" <w_a_x_man@yahoo.com> - 2015-03-20 17:13 +0000
    Re: local variable foxaudioresearch@gmail.com - 2015-07-05 08:44 -0700

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


#40304

FromRaimond Dragomir <raimond.dragomir@gmail.com>
Date2015-07-05 03:25 -0700
Message-ID<99b6063d-11ba-465b-b6b7-b142032aefe5@googlegroups.com>
In reply to#40302
duminică, 5 iulie 2015, 12:36:05 UTC+3, Alex McDonald a scris:
> on 05/07/2015 10:04:13, Raimond Dragomir wrote:
> > duminica, 5 iulie 2015, 09:24:27 UTC+3, Alex McDonald a scris:
> >> on 05/07/2015 03:52:50,  wrote:
> >> > On Friday, March 20, 2015 at 8:27:20 AM UTC-7, Anton Ertl wrote:
> >> >> Concerning quotations, the problem is not whether you can define them
> >> >> inside (ok, there is a bit of implementation effort required to
> >> >> support that), but whether locals defined outside are visible inside,
> >> >> and you already have that with a single local definition at the
> >> >> outermost level in combination with quotations.  For now the locals
> >> >> from outside are not visible inside in Gforth; making them visible
> >> >> there in general requires garbage collection of the activation
> >> >> records.  There have been discussions on ways to support something
> >> >> like this in a more limited way, but these ideas are still at the
> >> >> conceptual stage.
> >> >
> >> > I have real quotations here:
> >> > http://www.forth.org/FMITE.txt> >
> >> > I mean, not the Payson-faked quotations that are just :NONAME with
> >> > syntactic sugar --- real quotations that have access to the parent
> >> > function's local variables.
> >> >
> >>
> >> Does this work in FMITE?
> >>
> >> : foo {: myloc :} [: myloc 1+ ;] ;
> >> 10 foo execute
> > 
> > if myloc is a "normal" local variable (on a stack, NOT on a heap) this
> > won't work in any forth. At the time of the execute, the myloc
> > variable is
> > 
> > out of scope.
> > 
> > In what forth is it working?
> 
> None, since garbage collection is not a feature (although gforth has an
> experimental collector).
> 
> > 
> > In my system this doesn't work:
> > def foo { myloc } [ myloc @ 1+ ] ;
> > 
> > But this is working:
> > def foo { myloc } [ myloc @ 1+ ] execute ;
> > 10 foo .
> > 11  ok
> > 
> > 
> 
> Then, as Hugh complains about Bernd's "faked quotations", his FMITE is no
> more than :NONAME syntactic sugar. Perhaps worse, as from what I read
> there the language does not permit use of the quotation outside of its
> enclosing word.

I don't know the Bernd's quotations or Hugh's. Maybe it's time to do
some comparison between them? Some test cases like the above (but working).
I would implement the cases in my system if possible also.
It could be real instructive. 

Which one is willing to start the competition? :D

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


#40312

FromBernd Paysan <bernd.paysan@gmx.de>
Date2015-07-05 15:28 +0200
Message-ID<mnbbaf$i4j$1@dont-email.me>
In reply to#40304
Raimond Dragomir wrote:
> I don't know the Bernd's quotations or Hugh's. Maybe it's time to do
> some comparison between them? Some test cases like the above (but
> working). I would implement the cases in my system if possible also.
> It could be real instructive.

My quotations don't have access to the locals of the surrounding definition.  
They have access to the stack.  In fact, the quotations are just an unnamed 
definition in the middle of another definition.  The convention for higher 
order functions is that they call the quotation with full access to the 
stack underneath, so you can do things with that.

E.g. count the number of words in a wordlist with TRAVERSE-WORDLIST:

: count-words ( wid -- n )  0 [: drop 1+ true ;] rot traverse-wordlist ;

forth-wordlist count-words . 1933  ok

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
net2o ID: kQusJzA;7*?t=uy@X}1GWr!+0qqp_Cn176t4(dQ*
http://bernd-paysan.de/

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


#40316

FromRaimond Dragomir <raimond.dragomir@gmail.com>
Date2015-07-05 08:11 -0700
Message-ID<fa059ad2-f840-44a5-8b40-c75c733c9bc3@googlegroups.com>
In reply to#40312
duminică, 5 iulie 2015, 16:28:04 UTC+3, Bernd Paysan a scris:
> Raimond Dragomir wrote:
> > I don't know the Bernd's quotations or Hugh's. Maybe it's time to do
> > some comparison between them? Some test cases like the above (but
> > working). I would implement the cases in my system if possible also.
> > It could be real instructive.
> 
> My quotations don't have access to the locals of the surrounding definition.  
> They have access to the stack.  In fact, the quotations are just an unnamed 
> definition in the middle of another definition.  The convention for higher 
> order functions is that they call the quotation with full access to the 
> stack underneath, so you can do things with that.
> 
> E.g. count the number of words in a wordlist with TRAVERSE-WORDLIST:
> 
> : count-words ( wid -- n )  0 [: drop 1+ true ;] rot traverse-wordlist ;
> 
> forth-wordlist count-words . 1933  ok
> 
> -- 
> Bernd Paysan
> "If you want it done right, you have to do it yourself"
> net2o ID: kQusJzA;7*?t=uy@X}1GWr!+0qqp_Cn176t4(dQ*
> http://bernd-paysan.de/

Here it is in my system:

def countwords ( wid -- n ) 0 [ ( nt ) drop 1+ true ] rot traversewordlist ;
 ok
~quo countwords .
193  ok
~qlib countwords .
116  ok

I don't like the naming with '-' sign. I prefer the C's '_' but wherever
possible, nothing :-D

I sometimes use camelcase naming (only in applications). My system is case 
sensitive, with all kernel words lower case.

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


#40317

FromRaimond Dragomir <raimond.dragomir@gmail.com>
Date2015-07-05 08:21 -0700
Message-ID<bfebf816-dd18-4be2-8a6d-58c7ad243b83@googlegroups.com>
In reply to#40316
duminică, 5 iulie 2015, 18:11:46 UTC+3, Raimond Dragomir a scris:
> duminică, 5 iulie 2015, 16:28:04 UTC+3, Bernd Paysan a scris:
> > Raimond Dragomir wrote:
> > > I don't know the Bernd's quotations or Hugh's. Maybe it's time to do
> > > some comparison between them? Some test cases like the above (but
> > > working). I would implement the cases in my system if possible also.
> > > It could be real instructive.
> > 
> > My quotations don't have access to the locals of the surrounding definition.  
> > They have access to the stack.  In fact, the quotations are just an unnamed 
> > definition in the middle of another definition.  The convention for higher 
> > order functions is that they call the quotation with full access to the 
> > stack underneath, so you can do things with that.
> > 
> > E.g. count the number of words in a wordlist with TRAVERSE-WORDLIST:
> > 
> > : count-words ( wid -- n )  0 [: drop 1+ true ;] rot traverse-wordlist ;
> > 
> > forth-wordlist count-words . 1933  ok
> > 
> > -- 
> > Bernd Paysan
> > "If you want it done right, you have to do it yourself"
> > net2o ID: kQusJzA;7*?t=uy@X}1GWr!+0qqp_Cn176t4(dQ*
> > http://bernd-paysan.de/
> 
> Here it is in my system:
> 
> def countwords ( wid -- n ) 0 [ ( nt ) drop 1+ true ] rot traversewordlist ;
>  ok
> ~quo countwords .
> 193  ok
> ~qlib countwords .
> 116  ok
> 
> I don't like the naming with '-' sign. I prefer the C's '_' but wherever
> possible, nothing :-D
> 
> I sometimes use camelcase naming (only in applications). My system is case 
> sensitive, with all kernel words lower case.

Some versions of the same thing with locals:

def cw  0 [{ nt } 1+ true ] rot traversewordlist ;
 ok
~quo cw .
193  ok
def cw { wid -- n }  0 [{ nt } 1+ true ] wid @ traversewordlist ;
cw reDef
 ok
~quo cw .
193  ok
def cw { wid | nt -- n }  0 [ nt ! 1+ true ] wid @ traversewordlist ;
cw reDef
 ok
~quo cw .
193  ok

nt local is not used, but very nice as a self documentation :)

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


#40327

FromBernd Paysan <bernd.paysan@gmx.de>
Date2015-07-05 23:53 +0200
Message-ID<mnc8ub$130$1@dont-email.me>
In reply to#40317
Raimond Dragomir wrote:
> Some versions of the same thing with locals:
> 
> def cw  0 [{ nt } 1+ true ] rot traversewordlist ;

This sort of locals is doable with my quotations:

: cw ( wid -- n )  0 [: { nt } 1+ true ;] rot traverse-wordlist ;
forth-wordlist cw . 1934  ok

(still running the same session)

The thing people like Hugh want is something like

: cw ( wid -- n ) 0 { n } [: drop n 1+ to n true ;] swap traverse-wordlist
  n ;

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
net2o ID: kQusJzA;7*?t=uy@X}1GWr!+0qqp_Cn176t4(dQ*
http://bernd-paysan.de/

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


#40341

FromRaimond Dragomir <raimond.dragomir@gmail.com>
Date2015-07-05 20:31 -0700
Message-ID<a11e52ca-19da-447d-81f3-5a2aa426d59b@googlegroups.com>
In reply to#40327
luni, 6 iulie 2015, 00:53:36 UTC+3, Bernd Paysan a scris:
> Raimond Dragomir wrote:
> > Some versions of the same thing with locals:
> > 
> > def cw  0 [{ nt } 1+ true ] rot traversewordlist ;
> 
> This sort of locals is doable with my quotations:
> 
> : cw ( wid -- n )  0 [: { nt } 1+ true ;] rot traverse-wordlist ;
> forth-wordlist cw . 1934  ok
> 
> (still running the same session)
> 
> The thing people like Hugh want is something like
> 
> : cw ( wid -- n ) 0 { n } [: drop n 1+ to n true ;] swap traverse-wordlist
>   n ;
> 
> -- 
> Bernd Paysan
> "If you want it done right, you have to do it yourself"
> net2o ID: kQusJzA;7*?t=uy@X}1GWr!+0qqp_Cn176t4(dQ*
> http://bernd-paysan.de/

def cw { wid | n -- n } [ drop 1 n +! true ] wid @ traversewordlist n @ ;
 ok
~quo cw .
193  ok

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


#40339

Fromhughaguilar96@gmail.com
Date2015-07-05 19:56 -0700
Message-ID<415a11c0-1a33-4a35-9780-da0af4021d19@googlegroups.com>
In reply to#40312
On Sunday, July 5, 2015 at 6:28:04 AM UTC-7, Bernd Paysan wrote:
> Raimond Dragomir wrote:
> > I don't know the Bernd's quotations or Hugh's. Maybe it's time to do
> > some comparison between them? Some test cases like the above (but
> > working). I would implement the cases in my system if possible also.
> > It could be real instructive.

I have abundant example code in my document --- rewrite any of that using the Payson-faked quotations --- this will only be possible with the bar-feature quotations, and in Forth-200x it will be a big inefficient mess.
 
> My quotations don't have access to the locals of the surrounding definition.  
> They have access to the stack.  In fact, the quotations are just an unnamed 
> definition in the middle of another definition.  The convention for higher 
> order functions is that they call the quotation with full access to the 
> stack underneath, so you can do things with that.

My quotations in FMITE have access to the locals of the parent function (what you call "surrounding definition" above).

If a bar-feature higher-order function is used, then the quotations have access to the data-stack of the parent function.

> E.g. count the number of words in a wordlist with TRAVERSE-WORDLIST:
> 
> : count-words ( wid -- n )  0 [: drop 1+ true ;] rot traverse-wordlist ;
> 
> forth-wordlist count-words . 1933  ok

TRAVERSE-WORDLIST is the only higher-order function that you have in Forth-200x --- you trot this out as your example every time that the subject of quotations comes up --- you aren't showing the source-code for TRAVERSE-WORDLIST because it is a mess, and this messiness is also why you have never written any other higher-order function.

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


#40340

Fromhughaguilar96@gmail.com
Date2015-07-05 19:57 -0700
Message-ID<9f757589-60ce-47d5-aa34-a508f79a5f5f@googlegroups.com>
In reply to#40302
On Sunday, July 5, 2015 at 2:36:05 AM UTC-7, Alex McDonald wrote:
> Then, as Hugh complains about Bernd's "faked quotations", his FMITE is no
> more than :NONAME syntactic sugar. Perhaps worse, as from what I read
> there the language does not permit use of the quotation outside of its
> enclosing word.

Alex McDonald is lying --- as usual.

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


#40346

From"Alex McDonald" <blog@rivadpm.com>
Date2015-07-06 08:09 +0100
Message-ID<mnd9hc$ojn$1@dont-email.me>
In reply to#40340
on 06/07/2015 03:57:53,  wrote:
> On Sunday, July 5, 2015 at 2:36:05 AM UTC-7, Alex McDonald wrote:
>> Then, as Hugh complains about Bernd's "faked quotations", his FMITE is no
>> more than :NONAME syntactic sugar. Perhaps worse, as from what I read
>> there the language does not permit use of the quotation outside of its
>> enclosing word.
> 
> Alex McDonald is lying --- as usual.
> 

Have you read your own stuff?

"It is illegal to execute the xt of a quotation after the parent function
has gone out of scope (done its EXIT)."

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


#40378

Fromhughaguilar96@gmail.com
Date2015-07-06 19:59 -0700
Message-ID<b0eb4f4b-7cbc-4e10-815c-de4ac366452f@googlegroups.com>
In reply to#40346
On Monday, July 6, 2015 at 12:09:53 AM UTC-7, Alex McDonald wrote:
> on 06/07/2015 03:57:53,  wrote:
> > On Sunday, July 5, 2015 at 2:36:05 AM UTC-7, Alex McDonald wrote:
> >> Then, as Hugh complains about Bernd's "faked quotations", his FMITE is no
> >> more than :NONAME syntactic sugar. Perhaps worse, as from what I read
> >> there the language does not permit use of the quotation outside of its
> >> enclosing word.
> > 
> > Alex McDonald is lying --- as usual.
> > 
> 
> Have you read your own stuff?
> 
> "It is illegal to execute the xt of a quotation after the parent function
> has gone out of scope (done its EXIT)."

Alex McDonald purposely misrepresents everything --- twists people words around to mean the exact opposite of what they said, then plays dumb as if he didn't understand the original words.

Also, Alex McDonald will repeat the same lie over and over again, such as saying that my disambiguifiers don't work or that they require the word being disambiguified to be immediate --- he is just hoping that I won't respond every time and that a few of his lies will get through without being refuted --- once again, he plays dumb as if he doesn't know that what he is saying is untrue.

Alex McDonald is a liar --- he twists everything around and nothing he says is true --- I recommend that people ignore him.

If people want to know how the FMITE works, I recommend that they read my document: http://www.forth.org/FMITE.txt

I don't really want to discuss the FMITE with ANS-Forth promoters because ANS-Forth is a cult and the members routinely lie about everything (covering up ANS-Forth's failures, and projecting failure on competing ideas) --- discussing anything with ANS-Forth promoters is a waste of time, comparable to wrestling a pig (you end up covered in mud, and the pig enjoys it).

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


#40389

From"Alex McDonald" <blog@rivadpm.com>
Date2015-07-07 08:30 +0100
Message-ID<mnfv4a$tkp$1@dont-email.me>
In reply to#40378
on 07/07/2015 03:59:28,  wrote:
> On Monday, July 6, 2015 at 12:09:53 AM UTC-7, Alex McDonald wrote:
>> on 06/07/2015 03:57:53,  wrote:
>> > On Sunday, July 5, 2015 at 2:36:05 AM UTC-7, Alex McDonald wrote:
>> >> Then, as Hugh complains about Bernd's "faked quotations", his FMITE is
> no
>> >> more than :NONAME syntactic sugar. Perhaps worse, as from what I read
>> >> there the language does not permit use of the quotation outside of its
>> >> enclosing word.
>> >
>> > Alex McDonald is lying --- as usual.
>> >
>>
>> Have you read your own stuff?
>>
>> "It is illegal to execute the xt of a quotation after the parent function
>> has gone out of scope (done its EXIT)."
> 
> Alex McDonald purposely misrepresents everything --- twists people
> words ar ound to mean the exact opposite of what they said, then plays
> dumb as if he didn't understand the original words.

Ummm... what didn't I understand about the original words "It is illegal
to execute the xt of a quotation after the parent function has gone out
of scope?" This looks like a slam dunk to me.

> 
> Also, Alex McDonald will repeat the same lie over and over again, such
> as s aying that my disambiguifiers don't work or that they require the
> word bein g disambiguified to be immediate --- he is just hoping that
> I won't respond every time and that a few of his lies will get through
> without being refut ed --- once again, he plays dumb as if he doesn't
> know that what he is sayi ng is untrue.

I couldn't get your code to work. I imagine most other people didn't try.
 
> 
> Alex McDonald is a liar --- he twists everything around and nothing he
> says is true --- I recommend that people ignore him.
> 

Point out my lies, or expect my lawyers (Butt, Hurt & Cox LLP) to be in
contact by the end of the week.

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


#40480

FromMichael Barry <barrym95838@yahoo.com>
Date2015-07-10 00:35 -0700
Message-ID<830fadec-a923-4d6e-8125-4a4a274258ac@googlegroups.com>
In reply to#40389
On Tuesday, July 7, 2015 at 12:30:40 AM UTC-7, Alex McDonald wrote:
> ...
> Ummm... what didn't I understand about the original words "It is
> illegal to execute the xt of a quotation after the parent function
> has gone out of scope?" This looks like a slam dunk to me.
> 

I read Hugh's document carefully at least once, and it's a bit too
  advanced for me to understand it completely, but my impression is
  that you are correct.  If an orphaned quotation is called, it
  would happily execute, but would likely corrupt the stack.  Is
  this some kind of catastrophic failure in the design, or just an
  implementation decision that needs to be carefully followed?

> ...
> I couldn't get your code to work. I imagine most other people didn't
> try.
>

I was waiting for him to share his simulator with me before I tried
  his code.  Did you use his document to whip up your own simulator,
  or are you executing it by hand (or in your head)?  I know that
  you're a pretty sharp cookie, but it puzzles me that you would
  bother to expend the effort.  I know that Hugh isn't interested in
  your opinion, but I am.  Could you share a few thoughts about what
  you feel may be the merits and/or faults of his design?  I, for
  one, thought that it was kind of neat, and I don't feel eccentric
  or ignorant enough to be the only one here who thought so.

Mike B.
 

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


#40484

FromRaimond Dragomir <raimond.dragomir@gmail.com>
Date2015-07-10 01:41 -0700
Message-ID<b46d0efe-b8ac-4bfa-8246-a6459e5ebb76@googlegroups.com>
In reply to#40480
vineri, 10 iulie 2015, 10:35:43 UTC+3, Michael Barry a scris:
> On Tuesday, July 7, 2015 at 12:30:40 AM UTC-7, Alex McDonald wrote:
> > ...
> > Ummm... what didn't I understand about the original words "It is
> > illegal to execute the xt of a quotation after the parent function
> > has gone out of scope?" This looks like a slam dunk to me.
> > 
> 
> I read Hugh's document carefully at least once, and it's a bit too
>   advanced for me to understand it completely, but my impression is
>   that you are correct.  If an orphaned quotation is called, it
>   would happily execute, but would likely corrupt the stack.  Is
>   this some kind of catastrophic failure in the design, or just an
>   implementation decision that needs to be carefully followed?
> 
> > ...
> > I couldn't get your code to work. I imagine most other people didn't
> > try.
> >
> 
> I was waiting for him to share his simulator with me before I tried
>   his code.  Did you use his document to whip up your own simulator,
>   or are you executing it by hand (or in your head)?  I know that
>   you're a pretty sharp cookie, but it puzzles me that you would
>   bother to expend the effort.  I know that Hugh isn't interested in
>   your opinion, but I am.  Could you share a few thoughts about what
>   you feel may be the merits and/or faults of his design?  I, for
>   one, thought that it was kind of neat, and I don't feel eccentric
>   or ignorant enough to be the only one here who thought so.
> 
> Mike B.

Hi Mike,

Hugh's design is not faulty. The problem is that his saying is taken out of 
context by Alex. 
Indeed is not possible to run a quotation when its parent is not 
running, because the paren't locals are out of scope. 
But This is only the case when the quotation is using a parent local. 
In all other cases it's definitely possible to run the quotation. 
So a parent can 'return' a quotation xt on the stack 
and this xt can be executed everywhere and anytime, as long as the quotation
is not using parent locals. If it uses parent locals it can be executed
only inside the parent.
That's what is Hugh saying. Alex took an afirmation out of context and wants
to proove something. It is totally unfair, not to say that he gave a non-
working example (in any system). 
I made the point at that time, giving the correct example (that works in my 
system (and Hugh's also, I'm sure).
Hugh's may have a simulator (a cross-compiler for the FMITE but FMITE is
not a real processor yet) but I have a working system on which I can test
for real. So I'm not talking here "in theory".

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


#40492

From"Alex McDonald" <blog@rivadpm.com>
Date2015-07-10 13:55 +0100
Message-ID<mnof8f$tst$1@dont-email.me>
In reply to#40484
on 10/07/2015 09:41:36, Raimond Dragomir wrote:
> vineri, 10 iulie 2015, 10:35:43 UTC+3, Michael Barry a scris:
>> On Tuesday, July 7, 2015 at 12:30:40 AM UTC-7, Alex McDonald wrote:
>> > ...
>> > Ummm... what didn't I understand about the original words "It is
>> > illegal to execute the xt of a quotation after the parent function
>> > has gone out of scope?" This looks like a slam dunk to me.
>> >
>>
>> I read Hugh's document carefully at least once, and it's a bit too
>>   advanced for me to understand it completely, but my impression is
>>   that you are correct.  If an orphaned quotation is called, it
>>   would happily execute, but would likely corrupt the stack.  Is
>>   this some kind of catastrophic failure in the design, or just an
>>   implementation decision that needs to be carefully followed?
>>
>> > ...
>> > I couldn't get your code to work. I imagine most other people didn't
>> > try.
>> >
>>
>> I was waiting for him to share his simulator with me before I tried
>>   his code.  Did you use his document to whip up your own simulator,
>>   or are you executing it by hand (or in your head)?  I know that
>>   you're a pretty sharp cookie, but it puzzles me that you would
>>   bother to expend the effort.  I know that Hugh isn't interested in
>>   your opinion, but I am.  Could you share a few thoughts about what
>>   you feel may be the merits and/or faults of his design?  I, for
>>   one, thought that it was kind of neat, and I don't feel eccentric
>>   or ignorant enough to be the only one here who thought so.
>>
>> Mike B.
> 
> Hi Mike,
> 
> Hugh's design is not faulty. The problem is that his saying is taken
> out of context by Alex.

Here's what Anton Ertl said re quotations.

|> Concerning quotations, the problem is not whether you can define them
|> inside (ok, there is a bit of implementation effort required to
|> support that), but whether locals defined outside are visible inside,
|> and you already have that with a single local definition at the
|> outermost level in combination with quotations.  For now the locals
|> from outside are not visible inside in Gforth; making them visible
|> there in general requires garbage collection of the activation
|> records.  There have been discussions on ways to support something
|> like this in a more limited way, but these ideas are still at the
|> conceptual stage.

Here's what Hugh claimed in response.

|I have real quotations here:
|http://www.forth.org/FMITE.txt

|I mean, not the Payson-faked quotations that are just 
|:NONAME with syntactic sugar --- real quotations that 
|have access to the parent function's local variables.


> Indeed is not possible to run a quotation when its parent is not
> running, because the paren't locals are out of scope.

But that was Anton's point to which Hugh was responding.  

> But This is only the case when the quotation is using a parent local.
> In all other cases it's definitely possible to run the quotation.
> So a parent can 'return' a quotation xt on the stack
> and this xt can be executed everywhere and anytime, as long as the
> quotation is not using parent locals. If it uses parent locals it can
> be executed only inside the parent.
> That's what is Hugh saying. 

Hugh was claiming much more and delivering a lot less. In fact, the
gyrations he proposes in section 16 of http://www.forth.org/FMITE.txt are
to avoid the dreaded "maybe/maybe not" ambguities that Hugh finds hard to
handle in the ANS Forth spec. Hugh isn't proposing to prevent quotations
that refer to out of scope locals at compile time, btw, but at run time
in what looks like a compute heavy process. Having read through it
briefly, I'm not even sure it's feasible, since it depends on a hidden
local on the return stack with the address of the parent, and it would
probably invalidate quotations inside quotations.

> Alex took an afirmation out of context and
> wants to proove something. It is totally unfair, not to say that he
> gave a non- working example (in any system).

Of course it's non-working, since it requires garbage collection as Anton
notes.

: foo {: myloc :} [: myloc 1+ ;] ;
10 foo execute 

Because that was Anton's point, which Hugh missed.

> I made the point at that time, giving the correct example (that works
> in my system (and Hugh's also, I'm sure).
> Hugh's may have a simulator (a cross-compiler for the FMITE but FMITE
> is not a real processor yet) but I have a working system on which I
> can test for real. So I'm not talking here "in theory".
> 

"It is illegal to execute the xt of a quotation after the parent function
has gone out of scope (done its EXIT)." Please show me where I've taken
Hugh out of context.

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


#40493

FromRaimond Dragomir <raimond.dragomir@gmail.com>
Date2015-07-10 07:13 -0700
Message-ID<ebe5f448-5311-4949-83c8-e420c71e7080@googlegroups.com>
In reply to#40492
> |> Concerning quotations, the problem is not whether you can define them
> |> inside (ok, there is a bit of implementation effort required to
> |> support that), but whether locals defined outside are visible inside,
> |> and you already have that with a single local definition at the
> |> outermost level in combination with quotations.  For now the locals
> |> from outside are not visible inside in Gforth; making them visible
> |> there in general requires garbage collection of the activation
> |> records.  There have been discussions on ways to support something
> |> like this in a more limited way, but these ideas are still at the
> |> conceptual stage.
> 
Anton Ertl is speaking "in general". 
No, garbage collection and "activation records" are not required for a
static language (like forth). My implementation proves that. My forth is
as static as any other classical forth out there (not Oforth or Factor).
Are we talking of dynamic languages now? Since when?

Maybe that "limited way" would be the way that I and Hugh implemented?
(with the only "limitation" of the parent's locals going out of scope
when parent exits) Well, good news, it's not at a conceptual stage
anymore, it's implemented and working.

> Here's what Hugh claimed in response.
> 
> |I have real quotations here:
> |http://www.forth.org/FMITE.txt
> 
> |I mean, not the Payson-faked quotations that are just 
> |:NONAME with syntactic sugar --- real quotations that 
> |have access to the parent function's local variables.
> 
> 
That's completely true. Are you bothered by the "real" term? In a static
language locals are on a stack not on a heap. It's an inherent limitation
for them to go out of scope when their parent exits. 

> > Indeed is not possible to run a quotation when its parent is not
> > running, because the paren't locals are out of scope.
> 
> But that was Anton's point to which Hugh was responding.  
> 

If Anton is talking of dynamic languages (I didn't see the fact he is)
it's his problem if he cannot understand the quotations of a static
language. However he made some note about a "limited way" in a conceptual
stage.

The fact is that Gforth doesn't have what I and Hugh have, quotations which
can "see" locals of an outer level. Probably Hugh is proud of that and
calls his quotations "real". "Real" or "not real" but definetely better.

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


#40494

From"Alex McDonald" <blog@rivadpm.com>
Date2015-07-10 16:29 +0100
Message-ID<mnoo9j$1ck$1@dont-email.me>
In reply to#40493
on 10/07/2015 15:13:06, Raimond Dragomir wrote:

>>
> 
> If Anton is talking of dynamic languages (I didn't see the fact he is)
> it's his problem if he cannot understand the quotations of a static
> language. However he made some note about a "limited way" in a
> conceptual stage.

What is a static language or a dynamic language? They are terms I'm
unfamiliar with, unless you mean static vs dynamic typing, which is not
what we're taking about here. The discussion is about quotations in
relation to name scope and closure-like behaviour.

> 
> The fact is that Gforth doesn't have what I and Hugh have, quotations
> which can "see" locals of an outer level. Probably Hugh is proud of
> that and calls his quotations "real". "Real" or "not real" but
> definetely better.

Why better? Do you have a use case you can show? I also support this
feature, but I haven't found a use for it.

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


#40495

FromRaimond Dragomir <raimond.dragomir@gmail.com>
Date2015-07-10 08:57 -0700
Message-ID<40c66af5-0dab-46b6-aafe-60aad5b38337@googlegroups.com>
In reply to#40494
> What is a static language or a dynamic language? They are terms I'm
> unfamiliar with, unless you mean static vs dynamic typing, which is not
> what we're taking about here. The discussion is about quotations in
> relation to name scope and closure-like behaviour.
> 
A dynamic language is a language that needs a garbage collector.

> > 
> > The fact is that Gforth doesn't have what I and Hugh have, quotations
> > which can "see" locals of an outer level. Probably Hugh is proud of
> > that and calls his quotations "real". "Real" or "not real" but
> > definetely better.
> 
> Why better? Do you have a use case you can show? I also support this
> feature, but I haven't found a use for it.

It's about high order words (like "map", "filter", "apply", etc. see Oforth, see Factor) in strong relation with data structures. 

What I'm trying to achieve is to have a as much as possible a classical forth 
system but with support for general purpose data structures and high 
order words + quotations at a level that will not require a garbage
collector.

Something like a "static" Oforth or a "static" Factor. :-D

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


#40496

From"Alex McDonald" <blog@rivadpm.com>
Date2015-07-10 17:48 +0100
Message-ID<mnosts$jps$1@dont-email.me>
In reply to#40495
on 10/07/2015 16:57:56, Raimond Dragomir wrote:
> 
>> What is a static language or a dynamic language? They are terms I'm
>> unfamiliar with, unless you mean static vs dynamic typing, which is not
>> what we're taking about here. The discussion is about quotations in
>> relation to name scope and closure-like behaviour.
>>
> A dynamic language is a language that needs a garbage collector.

C++ has closures but no GC
http://www.cprogramming.com/c++11/c++11-lambda-closures.html, and the
same is true of Rust http://doc.rust-lang.org/book/README.html.

> 
>> >
>> > The fact is that Gforth doesn't have what I and Hugh have, quotations
>> > which can "see" locals of an outer level. Probably Hugh is proud of
>> > that and calls his quotations "real". "Real" or "not real" but
>> > definetely better.
>>
>> Why better? Do you have a use case you can show? I also support this
>> feature, but I haven't found a use for it.
> 
> It's about high order words (like "map", "filter", "apply", etc. see
> Oforth, see Factor) in strong relation with data structures.

I get that, but I was wondering what the benefit of using outer locals in
quotations might be.

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


#40497

FromPaul Rubin <no.email@nospam.invalid>
Date2015-07-10 10:02 -0700
Message-ID<87r3og54jj.fsf@jester.gateway.sonic.net>
In reply to#40496
"Alex McDonald" <blog@rivadpm.com> writes:
> C++ has closures but no GC
> http://www.cprogramming.com/c++11/c++11-lambda-closures.html, and the
> same is true of Rust http://doc.rust-lang.org/book/README.html.

Yes but I think Lisp programmers would look at that and groan.
Traditionally such closures are allocated on the heap and garbage
collected, because of the upward funarg problem:
   https://en.wikipedia.org/wiki/Funarg_problem

> I get that, but I was wondering what the benefit of using outer locals
> in quotations might be.

Here's a Python example:

    def square(x): return x*x
    def double(x): return x*2

    def compose(f,g):
        def c(x): return f(g(x))  # <--- uses outer locals
        return c  # <---- c uses upward funargs

    double_square = compose(double, square)

    print(double_square(3))    # prints 18 which is 2*(3*3)

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


#42035

From"WJ" <w_a_x_man@yahoo.com>
Date2015-09-16 17:30 +0000
Message-ID<mtc8up$llq$1@dont-email.me>
In reply to#40497
Paul Rubin wrote:

> > I was wondering what the benefit of using outer locals
> > in quotations might be.
> 
> Here's a Python example:
> 
>     def square(x): return x*x
>     def double(x): return x*2
> 
>     def compose(f,g):
>         def c(x): return f(g(x))  # <--- uses outer locals
>         return c  # <---- c uses upward funargs
> 
>     double_square = compose(double, square)
> 
>     print(double_square(3))    # prints 18 which is 2*(3*3)


Oforth:

: square { dup * }
: double { 2 * }

: compose(f, g) { #[ g perform f perform ] }

compose( #double, #square ) Constant new: double-square

3 double-square perform .

18 ok

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


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

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


csiph-web