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


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

Quotations

Started byRaimond Dragomir <raimond.dragomir@gmail.com>
First post2015-07-05 22:35 -0700
Last post2016-06-09 17:18 +0000
Articles 20 on this page of 107 — 15 participants

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


Contents

  Quotations Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 22:35 -0700
    Re: Quotations humptydumpty <ouatubi@gmail.com> - 2015-07-05 23:03 -0700
      Re: Quotations Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 23:21 -0700
      Re: Quotations humptydumpty <ouatubi@gmail.com> - 2015-07-06 00:00 -0700
    Re: Quotations Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-06 00:10 -0700
    Re: Quotations Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2015-07-06 09:39 +0100
      Re: Quotations Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-06 05:28 -0700
        Re: Quotations franck.bensusan@gmail.com - 2015-07-06 15:02 -0700
          Re: Quotations Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-06 22:43 -0700
            Re: Quotations Stefan Mauerhofer <smauerhofer@androsoft.ch> - 2015-07-06 23:06 -0700
              Re: Quotations Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-07 01:27 -0700
                Re: Quotations Stefan Mauerhofer <smauerhofer@androsoft.ch> - 2015-07-07 03:40 -0700
            Re: Quotations franck.bensusan@gmail.com - 2015-07-07 04:08 -0700
        Re: Quotations humptydumpty <ouatubi@gmail.com> - 2015-07-10 02:34 -0700
          Re: Quotations Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-14 11:30 -0700
            Re: Quotations franck.bensusan@gmail.com - 2015-07-16 03:28 -0700
              Re: Quotations Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-16 09:11 -0700
      Re: Quotations Paul Rubin <no.email@nospam.invalid> - 2015-07-08 12:04 -0700
    Re: Quotations humptydumpty <ouatubi@gmail.com> - 2016-05-28 13:06 -0700
    Re: Quotations humptydumpty <ouatubi@gmail.com> - 2016-05-29 02:22 -0700
      Re: Quotations humptydumpty <ouatubi@gmail.com> - 2016-05-29 10:41 -0700
        Re: Quotations franck.bensusan@gmail.com - 2016-05-29 12:38 -0700
          Re: Quotations humptydumpty <ouatubi@gmail.com> - 2016-05-29 23:03 -0700
            Re: Quotations humptydumpty <ouatubi@gmail.com> - 2016-05-30 00:34 -0700
              Re: Quotations franck.bensusan@gmail.com - 2016-05-30 03:04 -0700
                Re: Quotations humptydumpty <ouatubi@gmail.com> - 2016-05-30 03:41 -0700
                  Re: Quotations franck.bensusan@gmail.com - 2016-05-30 08:26 -0700
                    Re: Quotations humptydumpty <ouatubi@gmail.com> - 2016-05-30 08:46 -0700
              Re: Quotations Cecil Bayona <cbayona@cbayona.com> - 2016-05-30 10:01 -0500
                Re: Quotations humptydumpty <ouatubi@gmail.com> - 2016-05-30 08:33 -0700
            Re: Quotations franck.bensusan@gmail.com - 2016-05-30 00:44 -0700
              Re: Quotations humptydumpty <ouatubi@gmail.com> - 2016-05-30 01:03 -0700
              Re: Quotations hughaguilar96@gmail.com - 2016-06-02 22:07 -0700
                Re: Quotations humptydumpty <ouatubi@gmail.com> - 2016-06-02 23:11 -0700
                  Re: Quotations hughaguilar96@gmail.com - 2016-06-03 05:18 -0700
                    Re: Quotations hughaguilar96@gmail.com - 2016-06-03 05:28 -0700
                    Re: Quotations hughaguilar96@gmail.com - 2016-06-03 05:56 -0700
            Re: Quotations anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-05-30 15:24 +0000
              Re: Quotations humptydumpty <ouatubi@gmail.com> - 2016-05-30 11:33 -0700
                Re: Quotations anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-06-01 14:23 +0000
              Re: Quotations humptydumpty <ouatubi@gmail.com> - 2016-05-30 11:46 -0700
                Re: Quotations anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-06-01 14:27 +0000
                  Re: Quotations hughaguilar96@gmail.com - 2016-06-01 07:53 -0700
              Re: Quotations humptydumpty <ouatubi@gmail.com> - 2016-05-30 12:43 -0700
                Re: Quotations humptydumpty <ouatubi@gmail.com> - 2016-05-31 13:25 -0700
                  Re: Quotations hughaguilar96@gmail.com - 2016-05-31 16:57 -0700
                    Re: Quotations hughaguilar96@gmail.com - 2016-05-31 19:33 -0700
                    Re: Quotations humptydumpty <ouatubi@gmail.com> - 2016-06-01 03:20 -0700
                  Re: Quotations humptydumpty <ouatubi@gmail.com> - 2016-06-01 03:15 -0700
                Re: Quotations anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-06-01 14:29 +0000
                  Re: Quotations hughaguilar96@gmail.com - 2016-06-01 08:20 -0700
                    Re: Quotations hughaguilar96@gmail.com - 2016-06-01 18:59 -0700
                      Re: Quotations "WJ" <w_a_x_man@yahoo.com> - 2016-06-02 06:05 +0000
                    Re: Quotations alex@rivadpm.com - 2016-06-09 09:59 -0700
                      Re: Quotations "WJ" <w_a_x_man@yahoo.com> - 2016-06-09 17:47 +0000
                  Re: Quotations humptydumpty <ouatubi@gmail.com> - 2016-06-01 09:12 -0700
                  Re: Quotations "HAA" <someone@microsoft.com> - 2016-06-02 12:45 +1000
                    Re: Quotations Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-06-02 04:42 -0500
                      Re: Quotations Raimond Dragomir <raimond.dragomir@gmail.com> - 2016-06-02 05:08 -0700
                        Re: Quotations Paul Rubin <no.email@nospam.invalid> - 2016-06-02 06:53 -0700
                        Re: Quotations anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-06-02 13:54 +0000
                          Re: Quotations hughaguilar96@gmail.com - 2016-06-02 13:09 -0700
                          Re: Quotations "HAA" <someone@microsoft.com> - 2016-06-04 12:45 +1000
                            Re: Quotations hughaguilar96@gmail.com - 2016-06-03 20:52 -0700
                            Re: Quotations anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-06-04 15:05 +0000
                              Re: Quotations hughaguilar96@gmail.com - 2016-06-06 01:41 -0700
                                Re: Quotations anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-06-06 13:12 +0000
                                  Re: Quotations hughaguilar96@gmail.com - 2016-06-06 08:29 -0700
                                    Re: Quotations anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-06-07 06:06 +0000
                                  Re: Quotations mhx@iae.nl - 2016-06-06 10:51 -0700
                                    Re: Quotations anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-06-07 06:36 +0000
                                      Re: Quotations hughaguilar96@gmail.com - 2016-06-07 00:44 -0700
                                      Re: Quotations mhx@iae.nl - 2016-06-07 11:35 -0700
                                        Re: Quotations anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-06-08 07:14 +0000
                                          Re: Quotations hughaguilar96@gmail.com - 2016-06-09 00:58 -0700
                                          Re: Quotations "WJ" <w_a_x_man@yahoo.com> - 2016-06-09 11:37 +0000
                                      Re: Quotations Paul Rubin <no.email@nospam.invalid> - 2016-06-07 12:37 -0700
                                        Re: Quotations hughaguilar96@gmail.com - 2016-06-07 19:03 -0700
                        Re: Quotations Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-06-02 11:12 -0500
                          Re: Quotations Paul Rubin <no.email@nospam.invalid> - 2016-06-02 09:42 -0700
                            Re: Quotations Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-06-03 02:53 -0500
                              Re: Quotations Paul Rubin <no.email@nospam.invalid> - 2016-06-03 23:00 -0700
                                Re: Quotations Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-06-04 04:37 -0500
                                  Re: Quotations Paul Rubin <no.email@nospam.invalid> - 2016-06-05 19:12 -0700
                                    Re: Quotations Paul Rubin <no.email@nospam.invalid> - 2016-06-05 21:20 -0700
                                      Re: Quotations franck.bensusan@gmail.com - 2016-06-09 02:55 -0700
                                        Re: Quotations hughaguilar96@gmail.com - 2016-06-09 19:20 -0700
                                          Re: Quotations franck.bensusan@gmail.com - 2016-06-10 07:00 -0700
                                            Re: Quotations hughaguilar96@gmail.com - 2016-06-10 10:00 -0700
                                              Re: Quotations franck.bensusan@gmail.com - 2016-06-10 10:56 -0700
                                                Re: Quotations hughaguilar96@gmail.com - 2016-06-10 17:56 -0700
                                                  Re: Quotations Mark Wills <markwills1970@gmail.com> - 2016-06-14 05:18 -0700
                                                    Re: Quotations hughaguilar96@gmail.com - 2016-06-26 16:12 -0700
                        Re: Quotations hughaguilar96@gmail.com - 2016-06-02 12:41 -0700
                          Re: Quotations humptydumpty <ouatubi@gmail.com> - 2016-06-02 13:03 -0700
                      Re: Quotations anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-06-02 13:37 +0000
                        Re: Quotations Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-06-08 04:33 -0500
                          Re: Quotations anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-06-08 09:39 +0000
                            Re: Quotations Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-06-08 05:53 -0500
                              Re: Quotations anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-06-08 11:30 +0000
                                Re: Quotations Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-06-08 08:11 -0500
                                Re: Quotations hughaguilar96@gmail.com - 2016-06-09 01:09 -0700
        Re: Quotations humptydumpty <ouatubi@gmail.com> - 2016-05-30 08:54 -0700
      Re: Quotations hughaguilar96@gmail.com - 2016-05-31 12:06 -0700
        Re: Quotations humptydumpty <ouatubi@gmail.com> - 2016-05-31 13:41 -0700
        Re: Quotations "WJ" <w_a_x_man@yahoo.com> - 2016-05-31 21:09 +0000
    Lambdas (closures) "WJ" <w_a_x_man@yahoo.com> - 2016-06-09 17:18 +0000

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


#47638

Fromhumptydumpty <ouatubi@gmail.com>
Date2016-05-30 11:46 -0700
Message-ID<9e445e5b-4ae5-4405-bdf5-dcb0cd24017f@googlegroups.com>
In reply to#47634
On Monday, May 30, 2016 at 7:10:26 PM UTC+3, Anton Ertl wrote:
> humptydumpty <> writes:
> >My point is that 'quotations by continuation' variant is simple=20
> >to implement and understand
> 
> Your 0/-1 IF trick is nice, but does not look simpler than the equally
> capable AHEAD-using variant, e.g., (tested):
> 
> : rexit   ( --   )    RDROP ;
> : (r:)    ( -- r )    r@ cell+ cell+ ; \ <--  VVVVV

Why? Forth-implementation specific?

> : r[      ( -- r )    postpone (r:)  postpone AHEAD   ; immediate
> : ]r      ( --   )    postpone REXIT postpone THEN ; immediate
> : rcall   ( r -- )    >R ; \ <--
> : mcall[] ( uidx -- ) ( rn..r1 cont )
>         cells RP@ + @ >R ; \ <--
> 
> >and permits use  inside quotations=20
> >of locals defined in parent body (if needed).
> 
> Getting locals to work in some cases is easy.  The problem is getting
> them to work in all cases, or letting the user know when they don't
> work.
> 
> Maybe letting them work in some cases and silently break in other
> cases is the Forth way (many Forth features work that way), or maybe
> not: In most cases in Forth it is pretty easy to understand why the
> breakage occurs; there are cases where it's a little more complicated
> to follow see why the breakage occurs, and such cases have led to long
> and heated debates: The primary example is STATE-smartness.
> 
> Given that the locals implementation is not normally user-visible, I
> think that silent breakage is even worse here than for STATE; OTOH, if
> people don't know how it works, they at least may have less trouble to
> think about how it should work.
> 
> Anyway, here's an example where the locals don't work as one would
> like:
> 
> : x/times   { r u -- }
>         u 0 DO I r rcall LOOP ;
> 
> Works with TTIMES2, but breaks with TTIMES3.
> 
> BTW, note that the "SWAP TIMES" here and similar code in your examples
> show that it's a good idea to pass normally-constant arguments like
> the quotation on the top-of-stack.
> 
> - 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 2016: http://www.euroforth.org/ef16/

Have a nice day,
humptydumpty

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


#47690

Fromanton@mips.complang.tuwien.ac.at (Anton Ertl)
Date2016-06-01 14:27 +0000
Message-ID<2016Jun1.162708@mips.complang.tuwien.ac.at>
In reply to#47638
humptydumpty <ouatubi@gmail.com> writes:
>On Monday, May 30, 2016 at 7:10:26 PM UTC+3, Anton Ertl wrote:
>> humptydumpty <> writes:
>> >My point is that 'quotations by continuation' variant is simple=20
>> >to implement and understand
>> 
>> Your 0/-1 IF trick is nice, but does not look simpler than the equally
>> capable AHEAD-using variant, e.g., (tested):
>> 
>> : rexit   ( --   )    RDROP ;
>> : (r:)    ( -- r )    r@ cell+ cell+ ; \ <--  VVVVV
>
>Why? Forth-implementation specific?

Yes.  Yes, looking at your version again, it assumes a certain way of
dealing with return addresses that many Forth systems satisfy (at
least in the absense of locals), but no more.  Cute.

- 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 2016: http://www.euroforth.org/ef16/

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


#47693

Fromhughaguilar96@gmail.com
Date2016-06-01 07:53 -0700
Message-ID<cef617db-fe73-4002-972b-e1d6b8930b3b@googlegroups.com>
In reply to#47690
On Wednesday, June 1, 2016 at 7:29:01 AM UTC-7, Anton Ertl wrote:
> humptydumpty <ouatubi@gmail.com> writes:
> >On Monday, May 30, 2016 at 7:10:26 PM UTC+3, Anton Ertl wrote:
> >> humptydumpty <> writes:
> >> >My point is that 'quotations by continuation' variant is simple=20
> >> >to implement and understand
> >> 
> >> Your 0/-1 IF trick is nice, but does not look simpler than the equally
> >> capable AHEAD-using variant, e.g., (tested):
> >> 
> >> : rexit   ( --   )    RDROP ;
> >> : (r:)    ( -- r )    r@ cell+ cell+ ; \ <--  VVVVV
> >
> >Why? Forth-implementation specific?
> 
> Yes.  Yes, looking at your version again, it assumes a certain way of
> dealing with return addresses that many Forth systems satisfy (at
> least in the absense of locals), but no more.  Cute.

HumptyDumpty's original version with IF was loosely-standard, meaning that it was likely to work on multiple ANS-Forth compilers. It was not standard though, so it was not guaranteed to work on all ANS-Forth compilers. 

Anton is pushing for a gForth-specific solution because he wants people to use gForth.

I wrote a VFX-specific solution because VFX provides reasonable speed, whereas gForth is slower than molasses in January (gForth is about half the speed of SwiftForth, and SwiftForth is slower than molasses in March).

Obviously, quotations aren't going to be in Forth-200x --- so just pick a Forth compiler that you like and write a compiler-specific version for it --- I already did this with VFX.

This thread has been pretty fun --- so far, the only thing lacking is for Stephen Pelc to tell me to RTFM and complain that I "can't read" --- that is what he usually says when I write some Forth code.

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


#47639

Fromhumptydumpty <ouatubi@gmail.com>
Date2016-05-30 12:43 -0700
Message-ID<58c4638d-3015-4b2a-bfc1-b7abb368dbd3@googlegroups.com>
In reply to#47634
On Monday, May 30, 2016 at 7:10:26 PM UTC+3, Anton Ertl wrote:
> humptydumpty writes:
> >My point is that 'quotations by continuation' variant is simple=20
> >to implement and understand
> 
> Your 0/-1 IF trick is nice, but does not look simpler than the equally
> capable AHEAD-using variant, e.g., (tested):
> 
> : rexit   ( --   )    RDROP ;
> : (r:)    ( -- r )    r@ cell+ cell+ ; \ <--  VVVVV


I think that this offset is GForth specific...
I think that 'AHEAD' version is faster than '-1/0 IF',
but requires some knowledge of the forth implementation that run the code.


> : r[      ( -- r )    postpone (r:)  postpone AHEAD   ; immediate
> : ]r      ( --   )    postpone REXIT postpone THEN ; immediate
> : rcall   ( r -- )    >R ; \ <--
> : mcall[] ( uidx -- ) ( rn..r1 cont )
>         cells RP@ + @ >R ; \ <--
> 
> >and permits use  inside quotations=20
> >of locals defined in parent body (if needed).
> 
> Getting locals to work in some cases is easy.  The problem is getting
> them to work in all cases, or letting the user know when they don't
> work.
> 
> Maybe letting them work in some cases and silently break in other
> cases is the Forth way (many Forth features work that way), or maybe
> not: In most cases in Forth it is pretty easy to understand why the
> breakage occurs; there are cases where it's a little more complicated
> to follow see why the breakage occurs, and such cases have led to long
> and heated debates: The primary example is STATE-smartness.
> 
> Given that the locals implementation is not normally user-visible, I
> think that silent breakage is even worse here than for STATE; OTOH, if
> people don't know how it works, they at least may have less trouble to
> think about how it should work.
> 
> Anyway, here's an example where the locals don't work as one would
> like:
> 
> : x/times   { r u -- }
>         u 0 DO I r rcall LOOP ;
> 
> Works with TTIMES2, but breaks with TTIMES3.
> 
> BTW, note that the "SWAP TIMES" here and similar code in your examples
> show that it's a good idea to pass normally-constant arguments like
> the quotation on the top-of-stack.
> 
> - 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 2016: http://www.euroforth.org/ef16/


Looks like we have to not use locals in 'high-order words', 
to give enough room for user-programmers  :)

But I know that in GForth J is third item in rstack, 
so modifying accordingly:

: times     ( u r -- ;)
        >R 0 DO J rcall LOOP RDROP
;
: x\times   ( u r -- ;)
        >R 1- 0 swap DO I J rcall -1 +LOOP RDROP
;
: x/times   ( u r -- ;)
        >R 0 DO I J rcall LOOP RDROP
;

.. and have a nicer definitions for 'higher-order words' :)

Have a nice day,
humptydumpty

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


#47663

Fromhumptydumpty <ouatubi@gmail.com>
Date2016-05-31 13:25 -0700
Message-ID<fa5975f4-7bac-46b3-89f0-e1f4d116b848@googlegroups.com>
In reply to#47639
On Monday, May 30, 2016 at 10:43:37 PM UTC+3, humptydumpty wrote:
> On Monday, May 30, 2016 at 7:10:26 PM UTC+3, Anton Ertl wrote:
> > humptydumpty writes:
> > >My point is that 'quotations by continuation' variant is simple=20
> > >to implement and understand
> > 
> > Your 0/-1 IF trick is nice, but does not look simpler than the equally
> > capable AHEAD-using variant, e.g., (tested):
> > 
> > : rexit   ( --   )    RDROP ;
> > : (r:)    ( -- r )    r@ cell+ cell+ ; \ <--  VVVVV
> 
> 
> I think that this offset is GForth specific...
> I think that 'AHEAD' version is faster than '-1/0 IF',
> but requires some knowledge of the forth implementation that run the code.
> 
> 
> > : r[      ( -- r )    postpone (r:)  postpone AHEAD   ; immediate
> > : ]r      ( --   )    postpone REXIT postpone THEN ; immediate
> > : rcall   ( r -- )    >R ; \ <--
> > : mcall[] ( uidx -- ) ( rn..r1 cont )
> >         cells RP@ + @ >R ; \ <--
> > 
> > >and permits use  inside quotations=20
> > >of locals defined in parent body (if needed).
> > 
> > Getting locals to work in some cases is easy.  The problem is getting
> > them to work in all cases, or letting the user know when they don't
> > work.
> > 
> > Maybe letting them work in some cases and silently break in other
> > cases is the Forth way (many Forth features work that way), or maybe
> > not: In most cases in Forth it is pretty easy to understand why the
> > breakage occurs; there are cases where it's a little more complicated
> > to follow see why the breakage occurs, and such cases have led to long
> > and heated debates: The primary example is STATE-smartness.
> > 
> > Given that the locals implementation is not normally user-visible, I
> > think that silent breakage is even worse here than for STATE; OTOH, if
> > people don't know how it works, they at least may have less trouble to
> > think about how it should work.
> > 
> > Anyway, here's an example where the locals don't work as one would
> > like:
> > 
> > : x/times   { r u -- }
> >         u 0 DO I r rcall LOOP ;
> > 
> > Works with TTIMES2, but breaks with TTIMES3.
> > 
> > BTW, note that the "SWAP TIMES" here and similar code in your examples
> > show that it's a good idea to pass normally-constant arguments like
> > the quotation on the top-of-stack.
> > 
> > - 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 2016: http://www.euroforth.org/ef16/
> 
> 
> Looks like we have to not use locals in 'high-order words', 
> to give enough room for user-programmers  :)
> 
> But I know that in GForth J is third item in rstack, 
> so modifying accordingly:
> 
> : times     ( u r -- ;)
>         >R 0 DO J rcall LOOP RDROP
> ;
> : x\times   ( u r -- ;)
>         >R 1- 0 swap DO I J rcall -1 +LOOP RDROP
> ;
> : x/times   ( u r -- ;)
>         >R 0 DO I J rcall LOOP RDROP
> ;
> 
> .. and have a nicer definitions for 'higher-order words' :)
> 
> Have a nice day,
> humptydumpty

Just definitions, without tests:

8<---
\ rquotation.fs - quotations by continuations.
\ Should work on all forths where return-stack is a stack of continuations.
\ On most forths this code should work.
\ OBS.: this kind of manipulations of return-stack do not belongs
\ to those approved by 'ANS-Forth Standard'.

: REXIT   ( --   )    R> DROP ;
: (R:)    ( -- R )    R@ 0 ;
: R[      ( -- R )    POSTPONE (R:)  POSTPONE IF   ; IMMEDIATE
: ]R      ( --   )    POSTPONE REXIT POSTPONE THEN ; IMMEDIATE
: RCALL   ( R -- )    >R -1 ;

\ A faster variant writen by Anton Ertl on c.l.f.
\ OBS.: Offset from 'AHEAD' used on '(r:) definition
\ is Forth implementation dependent.
\ : rexit   ( --   )    RDROP ;
\ : (r:)    ( -- r )    r@ cell+ cell+ ; \ <--  VVVVV
\ : r[      ( -- r )    postpone (r:)  postpone AHEAD ; immediate
\ : ]r      ( --   )    postpone REXIT postpone THEN  ; immediate
\ : rcall   ( r -- )    >R ; \ <-- 

\ --- Some high-worder words:
\ On some Forth implementations, rquotations can use parents locals,
\ on others only if 'High-Order Words' do not use locals,
\ others do not.  You must check.  Here examples of HOW's that
\ do not use locals.

: R??     ( RFALSE RTRUE F -- )
        IF SWAP THEN DROP >R -1
;

\ A safe-recursion local use of a global variable:
\ ---
\    Compile code that store pair (address,its value) on return stack
\    and store at that address a new value
: LET{      ( n1 a -- , R: -- n0 a ) 
	POSTPONE DUP POSTPONE DUP
	POSTPONE @ POSTPONE >R POSTPONE >R
	POSTPONE !
; IMMEDIATE
\    Compile code that from pair (address,old value) from return stack,
\    restore to address his old value
: }TEL      ( R: n0 a -- )
	POSTPONE R> POSTPONE R> POSTPONE SWAP POSTPONE !
; IMMEDIATE
\ ---

	VARIABLE X
\ Word names are inspired from Raimond Dragomir c.l.f. post.
: RTIMES     ( U R -- )
        X LET{ 0 DO X @ RCALL LOOP }TEL
;
: R\TIMES   ( U R -- )
        X LET{ 1- 0 SWAP DO I X @ RCALL -1 +LOOP }TEL
;
: R/TIMES   ( U R -- )
        X LET{ 0 DO I X @ RCALL LOOP }TEL
;
8<---

Have a nice day,
humptydumpty

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


#47671

Fromhughaguilar96@gmail.com
Date2016-05-31 16:57 -0700
Message-ID<3161b6eb-ba99-44fd-9837-a9cf07642706@googlegroups.com>
In reply to#47663
On Tuesday, May 31, 2016 at 1:25:15 PM UTC-7, humptydumpty wrote:
> Just definitions, without tests:
> 
> 8<---
> \ rquotation.fs - quotations by continuations.
> \ Should work on all forths where return-stack is a stack of continuations.
> \ On most forths this code should work.
> \ OBS.: this kind of manipulations of return-stack do not belongs
> \ to those approved by 'ANS-Forth Standard'.
> 
> : REXIT   ( --   )    R> DROP ;
> : (R:)    ( -- R )    R@ 0 ;
> : R[      ( -- R )    POSTPONE (R:)  POSTPONE IF   ; IMMEDIATE
> : ]R      ( --   )    POSTPONE REXIT POSTPONE THEN ; IMMEDIATE
> : RCALL   ( R -- )    >R -1 ;
> 
> \ A faster variant writen by Anton Ertl on c.l.f.
> \ OBS.: Offset from 'AHEAD' used on '(r:) definition
> \ is Forth implementation dependent.
> \ : rexit   ( --   )    RDROP ;
> \ : (r:)    ( -- r )    r@ cell+ cell+ ; \ <--  VVVVV
> \ : r[      ( -- r )    postpone (r:)  postpone AHEAD ; immediate
> \ : ]r      ( --   )    postpone REXIT postpone THEN  ; immediate
> \ : rcall   ( r -- )    >R ; \ <-- 
> 
> \ --- Some high-worder words:
> \ On some Forth implementations, rquotations can use parents locals,
> \ on others only if 'High-Order Words' do not use locals,
> \ others do not.  You must check.  Here examples of HOW's that
> \ do not use locals.

Here is a new VFX-specific version that uses AHEAD. This is not only faster but it is also easier to read (the 0 and -1 flags in the original version were somewhat confusing):

: rexit     ( --   )    rdrop ;
: (r:)      ( -- r )    r@ 5 + ;    \ 5 is the size of a JMP instruction in 32-bit x86
: r[        ( -- r )    postpone (r:)  postpone ahead ;  immediate
: ]r        ( --   )    postpone rexit  postpone then ;  immediate

code rcall  ( r -- )    \ in VFX the LF is in EDI
    push edi            \ this is the HOF's LF which won't be used by the quotation
    mov edi, 0 [edi]    \ this is the parent's LF which will be used in the quotation
    call ' execute
    pop edi             \ restore HOF's LF
    next, end-code

> : R??     ( RFALSE RTRUE F -- )
>         IF SWAP THEN DROP >R -1
> ;
> 
> \ A safe-recursion local use of a global variable:
> \ ---
> \    Compile code that store pair (address,its value) on return stack
> \    and store at that address a new value
> : LET{      ( n1 a -- , R: -- n0 a ) 
> 	POSTPONE DUP POSTPONE DUP
> 	POSTPONE @ POSTPONE >R POSTPONE >R
> 	POSTPONE !
> ; IMMEDIATE
> \    Compile code that from pair (address,old value) from return stack,
> \    restore to address his old value
> : }TEL      ( R: n0 a -- )
> 	POSTPONE R> POSTPONE R> POSTPONE SWAP POSTPONE !
> ; IMMEDIATE
> \ ---
> 
> 	VARIABLE X
> \ Word names are inspired from Raimond Dragomir c.l.f. post.
> : RTIMES     ( U R -- )
>         X LET{ 0 DO X @ RCALL LOOP }TEL
> ;
> : R\TIMES   ( U R -- )
>         X LET{ 1- 0 SWAP DO I X @ RCALL -1 +LOOP }TEL
> ;
> : R/TIMES   ( U R -- )
>         X LET{ 0 DO I X @ RCALL LOOP }TEL
> ;
> 8<---
> 
> Have a nice day,
> humptydumpty

You used the names LET{ and }TEL --- this is not very readable.

IIRC, writing word backwards was done in BASH. Also, during the 19th century the English would spell words backwards to mean the opposite of the word --- an example would be "yob" for a backwards-acting boy --- anyway, it is overly cute and diminishes readability.

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


#47676

Fromhughaguilar96@gmail.com
Date2016-05-31 19:33 -0700
Message-ID<697d1db9-baea-4235-9505-63256857a090@googlegroups.com>
In reply to#47671
On Tuesday, May 31, 2016 at 4:57:19 PM UTC-7, hughag...@gmail.com wrote:
> Here is a new VFX-specific version that uses AHEAD. This is not only faster but it is also easier to read (the 0 and -1 flags in the original version were somewhat confusing):
> 
> : rexit     ( --   )    rdrop ;
> : (r:)      ( -- r )    r@ 5 + ;    \ 5 is the size of a JMP instruction in 32-bit x86
> : r[        ( -- r )    postpone (r:)  postpone ahead ;  immediate
> : ]r        ( --   )    postpone rexit  postpone then ;  immediate
> 
> code rcall  ( r -- )    \ in VFX the LF is in EDI
>     push edi            \ this is the HOF's LF which won't be used by the quotation
>     mov edi, 0 [edi]    \ this is the parent's LF which will be used in the quotation
>     call ' execute
>     pop edi             \ restore HOF's LF
>     next, end-code

I tested this under VFX and it works. I surprised that it does work though. I expected the VFX optimizer to discard all the code between AHEAD and THEN as being dead code that can't be reached. I also expected the VFX optimizer to inline (R:) and REXIT because they are short, which would also screw everything up.

Pelc could easily upgrade VFX with these optimizations which would prevent this non-standard code from working. Pelc does what Leon Wagner tells him to do, and Leon Wagner is motivated to prevent quotations from working because he is opposed to general-purpose data-structures (he does what Elizabeth Rather tells him to do, and she has made a career out of preventing general-purpose data-structures). 

Leon Wagner has already approved the Paysan-faked quotations for Forth-200x --- the purpose of this was so the committee could say: "Well, we have quotations, but they are totally useless for general-purpose data-structures, so it just goes to show that we should have not implemented quotations and that general-purpose data-structures are impossible."

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


#47684

Fromhumptydumpty <ouatubi@gmail.com>
Date2016-06-01 03:20 -0700
Message-ID<4d471c23-bd8c-4bbb-8881-20899e8f5f4c@googlegroups.com>
In reply to#47671
On Wednesday, June 1, 2016 at 2:57:19 AM UTC+3, hughag...@gmail.com wrote:
> On Tuesday, May 31, 2016 at 1:25:15 PM UTC-7, humptydumpty wrote:
> > Just definitions, without tests:
> > 
> > 8<---
> > \ rquotation.fs - quotations by continuations.
> > \ Should work on all forths where return-stack is a stack of continuations.
> > \ On most forths this code should work.
> > \ OBS.: this kind of manipulations of return-stack do not belongs
> > \ to those approved by 'ANS-Forth Standard'.
> > 
> > : REXIT   ( --   )    R> DROP ;
> > : (R:)    ( -- R )    R@ 0 ;
> > : R[      ( -- R )    POSTPONE (R:)  POSTPONE IF   ; IMMEDIATE
> > : ]R      ( --   )    POSTPONE REXIT POSTPONE THEN ; IMMEDIATE
> > : RCALL   ( R -- )    >R -1 ;
> > 
> > \ A faster variant writen by Anton Ertl on c.l.f.
> > \ OBS.: Offset from 'AHEAD' used on '(r:) definition
> > \ is Forth implementation dependent.
> > \ : rexit   ( --   )    RDROP ;
> > \ : (r:)    ( -- r )    r@ cell+ cell+ ; \ <--  VVVVV
> > \ : r[      ( -- r )    postpone (r:)  postpone AHEAD ; immediate
> > \ : ]r      ( --   )    postpone REXIT postpone THEN  ; immediate
> > \ : rcall   ( r -- )    >R ; \ <-- 
> > 
> > \ --- Some high-worder words:
> > \ On some Forth implementations, rquotations can use parents locals,
> > \ on others only if 'High-Order Words' do not use locals,
> > \ others do not.  You must check.  Here examples of HOW's that
> > \ do not use locals.
> 
> Here is a new VFX-specific version that uses AHEAD. This is not only faster but it is also easier to read (the 0 and -1 flags in the original version were somewhat confusing):
> 
> : rexit     ( --   )    rdrop ;
> : (r:)      ( -- r )    r@ 5 + ;    \ 5 is the size of a JMP instruction in 32-bit x86
> : r[        ( -- r )    postpone (r:)  postpone ahead ;  immediate
> : ]r        ( --   )    postpone rexit  postpone then ;  immediate
> 
> code rcall  ( r -- )    \ in VFX the LF is in EDI
>     push edi            \ this is the HOF's LF which won't be used by the quotation
>     mov edi, 0 [edi]    \ this is the parent's LF which will be used in the quotation
>     call ' execute
>     pop edi             \ restore HOF's LF
>     next, end-code
> 
> > : R??     ( RFALSE RTRUE F -- )
> >         IF SWAP THEN DROP >R -1
> > ;
> > 
> > \ A safe-recursion local use of a global variable:
> > \ ---
> > \    Compile code that store pair (address,its value) on return stack
> > \    and store at that address a new value
> > : LET{      ( n1 a -- , R: -- n0 a ) 
> > 	POSTPONE DUP POSTPONE DUP
> > 	POSTPONE @ POSTPONE >R POSTPONE >R
> > 	POSTPONE !
> > ; IMMEDIATE
> > \    Compile code that from pair (address,old value) from return stack,
> > \    restore to address his old value
> > : }TEL      ( R: n0 a -- )
> > 	POSTPONE R> POSTPONE R> POSTPONE SWAP POSTPONE !
> > ; IMMEDIATE
> > \ ---
> > 
> > 	VARIABLE X
> > \ Word names are inspired from Raimond Dragomir c.l.f. post.
> > : RTIMES     ( U R -- )
> >         X LET{ 0 DO X @ RCALL LOOP }TEL
> > ;
> > : R\TIMES   ( U R -- )
> >         X LET{ 1- 0 SWAP DO I X @ RCALL -1 +LOOP }TEL
> > ;
> > : R/TIMES   ( U R -- )
> >         X LET{ 0 DO I X @ RCALL LOOP }TEL
> > ;
> > 8<---
> > 
> > Have a nice day,
> > humptydumpty
> 
> You used the names LET{ and }TEL --- this is not very readable.
> 
> IIRC, writing word backwards was done in BASH. Also, during the 19th century the English would spell words backwards to mean the opposite of the word --- an example would be "yob" for a backwards-acting boy --- anyway, it is overly cute and diminishes readability.

Hi!

Initially I used the triplet '>{','let{','}' (posted here in c.l.f somewhere).
Want to make it less ambiguous than using '}' for restoring old value for address.
Inspired from Bourne-shell (sh): like 'if..fi', 'case..esac', etc. :)

Have a nice day,
humptydumpty

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


#47683

Fromhumptydumpty <ouatubi@gmail.com>
Date2016-06-01 03:15 -0700
Message-ID<e91fe5fd-9ac9-4b7a-8bac-96f297d3a0b5@googlegroups.com>
In reply to#47663
On Tuesday, May 31, 2016 at 11:25:15 PM UTC+3, humptydumpty wrote:
> On Monday, May 30, 2016 at 10:43:37 PM UTC+3, humptydumpty wrote:
> > On Monday, May 30, 2016 at 7:10:26 PM UTC+3, Anton Ertl wrote:
> > > humptydumpty writes:
> > > >My point is that 'quotations by continuation' variant is simple=20
> > > >to implement and understand
> > > 
> > > Your 0/-1 IF trick is nice, but does not look simpler than the equally
> > > capable AHEAD-using variant, e.g., (tested):
> > > 
> > > : rexit   ( --   )    RDROP ;
> > > : (r:)    ( -- r )    r@ cell+ cell+ ; \ <--  VVVVV
> > 
> > 
> > I think that this offset is GForth specific...
> > I think that 'AHEAD' version is faster than '-1/0 IF',
> > but requires some knowledge of the forth implementation that run the code.
> > 
> > 
> > > : r[      ( -- r )    postpone (r:)  postpone AHEAD   ; immediate
> > > : ]r      ( --   )    postpone REXIT postpone THEN ; immediate
> > > : rcall   ( r -- )    >R ; \ <--
> > > : mcall[] ( uidx -- ) ( rn..r1 cont )
> > >         cells RP@ + @ >R ; \ <--
> > > 
> > > >and permits use  inside quotations=20
> > > >of locals defined in parent body (if needed).
> > > 
> > > Getting locals to work in some cases is easy.  The problem is getting
> > > them to work in all cases, or letting the user know when they don't
> > > work.
> > > 
> > > Maybe letting them work in some cases and silently break in other
> > > cases is the Forth way (many Forth features work that way), or maybe
> > > not: In most cases in Forth it is pretty easy to understand why the
> > > breakage occurs; there are cases where it's a little more complicated
> > > to follow see why the breakage occurs, and such cases have led to long
> > > and heated debates: The primary example is STATE-smartness.
> > > 
> > > Given that the locals implementation is not normally user-visible, I
> > > think that silent breakage is even worse here than for STATE; OTOH, if
> > > people don't know how it works, they at least may have less trouble to
> > > think about how it should work.
> > > 
> > > Anyway, here's an example where the locals don't work as one would
> > > like:
> > > 
> > > : x/times   { r u -- }
> > >         u 0 DO I r rcall LOOP ;
> > > 
> > > Works with TTIMES2, but breaks with TTIMES3.
> > > 
> > > BTW, note that the "SWAP TIMES" here and similar code in your examples
> > > show that it's a good idea to pass normally-constant arguments like
> > > the quotation on the top-of-stack.
> > > 
> > > - 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 2016: http://www.euroforth.org/ef16/
> > 
> > 
> > Looks like we have to not use locals in 'high-order words', 
> > to give enough room for user-programmers  :)
> > 
> > But I know that in GForth J is third item in rstack, 
> > so modifying accordingly:
> > 
> > : times     ( u r -- ;)
> >         >R 0 DO J rcall LOOP RDROP
> > ;
> > : x\times   ( u r -- ;)
> >         >R 1- 0 swap DO I J rcall -1 +LOOP RDROP
> > ;
> > : x/times   ( u r -- ;)
> >         >R 0 DO I J rcall LOOP RDROP
> > ;
> > 
> > .. and have a nicer definitions for 'higher-order words' :)
> > 
> > Have a nice day,
> > humptydumpty
> 
> Just definitions, without tests:
> 
> 8<---
> \ rquotation.fs - quotations by continuations.
> \ Should work on all forths where return-stack is a stack of continuations.
> \ On most forths this code should work.
> \ OBS.: this kind of manipulations of return-stack do not belongs
> \ to those approved by 'ANS-Forth Standard'.
> 
> : REXIT   ( --   )    R> DROP ;
> : (R:)    ( -- R )    R@ 0 ;
> : R[      ( -- R )    POSTPONE (R:)  POSTPONE IF   ; IMMEDIATE
> : ]R      ( --   )    POSTPONE REXIT POSTPONE THEN ; IMMEDIATE
> : RCALL   ( R -- )    >R -1 ;
> 
> \ A faster variant writen by Anton Ertl on c.l.f.
> \ OBS.: Offset from 'AHEAD' used on '(r:) definition
> \ is Forth implementation dependent.
> \ : rexit   ( --   )    RDROP ;
> \ : (r:)    ( -- r )    r@ cell+ cell+ ; \ <--  VVVVV
> \ : r[      ( -- r )    postpone (r:)  postpone AHEAD ; immediate
> \ : ]r      ( --   )    postpone REXIT postpone THEN  ; immediate
> \ : rcall   ( r -- )    >R ; \ <-- 
> 
> \ --- Some high-worder words:
> \ On some Forth implementations, rquotations can use parents locals,
> \ on others only if 'High-Order Words' do not use locals,
> \ others do not.  You must check.  Here examples of HOW's that
> \ do not use locals.
> 
> : R??     ( RFALSE RTRUE F -- )
>         IF SWAP THEN DROP >R -1
> ;
> 
> \ A safe-recursion local use of a global variable:
> \ ---
> \    Compile code that store pair (address,its value) on return stack
> \    and store at that address a new value
> : LET{      ( n1 a -- , R: -- n0 a ) 
> 	POSTPONE DUP POSTPONE DUP
> 	POSTPONE @ POSTPONE >R POSTPONE >R
> 	POSTPONE !
> ; IMMEDIATE
> \    Compile code that from pair (address,old value) from return stack,
> \    restore to address his old value
> : }TEL      ( R: n0 a -- )
> 	POSTPONE R> POSTPONE R> POSTPONE SWAP POSTPONE !
> ; IMMEDIATE
> \ ---
> 
> 	VARIABLE X
> \ Word names are inspired from Raimond Dragomir c.l.f. post.
> : RTIMES     ( U R -- )
>         X LET{ 0 DO X @ RCALL LOOP }TEL
> ;
> : R\TIMES   ( U R -- )
>         X LET{ 1- 0 SWAP DO I X @ RCALL -1 +LOOP }TEL
> ;
> : R/TIMES   ( U R -- )
>         X LET{ 0 DO I X @ RCALL LOOP }TEL
> ;
> 8<---
> 
> Have a nice day,
> humptydumpty


First revision. A reordering in 'LET{' provides a simplification in his
twin word '}TEL'.

8<---
\ rquotation.fs - quotations by continuations.
\ Should work on all forths where return-stack is a stack of continuations.
\ On most forths this code should work.
\ OBS.: this kind of manipulations of return-stack do not belongs
\ to those approved by 'ANS-Forth Standard'.

: REXIT   ( --   )    R> DROP ;
: (R:)    ( -- R )    R@ 0 ;
: R[      ( -- R )    POSTPONE (R:)  POSTPONE IF   ; IMMEDIATE
: ]R      ( --   )    POSTPONE REXIT POSTPONE THEN ; IMMEDIATE
: RCALL   ( R -- )    >R -1 ;

\ A faster variant writen by Anton Ertl on c.l.f.
\ OBS.: Offset from 'AHEAD' used on '(r:) definition
\ is Forth implementation dependent.
\ : rexit   ( --   )    RDROP ;
\ : (r:)    ( -- r )    r@ cell+ cell+ ; \ <--  VVVVV
\ : r[      ( -- r )    postpone (r:)  postpone AHEAD ; immediate
\ : ]r      ( --   )    postpone REXIT postpone THEN  ; immediate
\ : rcall   ( r -- )    >R ; \ <--

\ --- Some high-worder words:
\ On some Forth implementations, rquotations can use parents locals,
\ on others only if 'High-Order Words' do not use locals,
\ others do not.  You must check.  Here examples of HOW's that
\ do not use locals.

: R??     ( RFALSE RTRUE F -- )
        IF SWAP THEN DROP >R -1
;

\ A safe-recursion local use of a global variable:
\ ---
\    Compile code that store pair (address,its value) on return stack
\    and store at that address a new value
: LET{      ( n1 a -- , R: -- n0 a )
        POSTPONE DUP POSTPONE DUP
        POSTPONE >R POSTPONE @ POSTPONE >R
        POSTPONE !
; IMMEDIATE
\    Compile code that from pair (address,old value) from return stack,
\    restore to address his old value
: }TEL      ( R: n0 a -- )
        POSTPONE R> POSTPONE R> POSTPONE !
; IMMEDIATE
\ ---

        VARIABLE X
\ Word names are inspired from Raimond Dragomir c.l.f. post.
: RTIMES     ( U R -- )
        X LET{ 0 DO X @ RCALL LOOP }TEL
;
: R\TIMES   ( U R -- )
        X LET{ 1- 0 SWAP DO I X @ RCALL -1 +LOOP }TEL
;
: R/TIMES   ( U R -- )
        X LET{ 0 DO I X @ RCALL LOOP }TEL
;
8<---

Have a nice day,
humptydumpty

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


#47692

Fromanton@mips.complang.tuwien.ac.at (Anton Ertl)
Date2016-06-01 14:29 +0000
Message-ID<2016Jun1.162929@mips.complang.tuwien.ac.at>
In reply to#47639
humptydumpty <ouatubi@gmail.com> writes:
>On Monday, May 30, 2016 at 7:10:26 PM UTC+3, Anton Ertl wrote:
>> Getting locals to work in some cases is easy.  The problem is getting
>> them to work in all cases, or letting the user know when they don't
>> work.
...
>Looks like we have to not use locals in 'high-order words', 
>to give enough room for user-programmers  :)

That's just one of the cases where it does not work in Gforth.
Here's another one:

: foo ( n f -- )
  if 
    { n } r[ n . ]r 
  else
    drop r[ ." false ]r
  then
  rcall ;

And some of the uses that work on Gforth will fail on the next system.
That's why the discussion about locals in quotations has settled on
standardizing only accessing locals from a quotation that were defined
in that quotation; that should be relatively easy to implement on
every system.  There have been some discussions on how to extend that,
but I have my doubts that any of these ideas will be accepted by the
larger community or the committee.  Even quotations without such
complications still have their detractors.

- 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 2016: http://www.euroforth.org/ef16/

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


#47695

Fromhughaguilar96@gmail.com
Date2016-06-01 08:20 -0700
Message-ID<7e03bb21-b7e0-4dc6-9662-7689a1a6ebfa@googlegroups.com>
In reply to#47692
On Wednesday, June 1, 2016 at 7:49:46 AM UTC-7, Anton Ertl wrote:
> humptydumpty <ouatubi@gmail.com> writes:
> >On Monday, May 30, 2016 at 7:10:26 PM UTC+3, Anton Ertl wrote:
> >> Getting locals to work in some cases is easy.  The problem is getting
> >> them to work in all cases, or letting the user know when they don't
> >> work.
> ...
> >Looks like we have to not use locals in 'high-order words', 
> >to give enough room for user-programmers  :)
> 
> That's just one of the cases where it does not work in Gforth.
> Here's another one:
> 
> : foo ( n f -- )
>   if 
>     { n } r[ n . ]r 
>   else
>     drop r[ ." false ]r
>   then
>   rcall ;

The ANS-Forth document (section 13.3.3) says:
"The position in program source at which the sequence of (LOCAL) messages is sent, referred to here as the point at which locals are declared, shall not lie within the scope of any control structure;"

So, Anton Ertl is complaining that HumptyDumpty's non-standard code won't work on the non-standard gForth compiler --- and this is HumptyDumpty's fault --- Anton Ertl is the chair-person of the Forth-200x Standard committee, so he is an expert on what is standard!

> And some of the uses that work on Gforth will fail on the next system.
> That's why the discussion about locals in quotations has settled on
> standardizing only accessing locals from a quotation that were defined
> in that quotation; that should be relatively easy to implement on
> every system.  There have been some discussions on how to extend that,
> but I have my doubts that any of these ideas will be accepted by the
> larger community or the committee.  Even quotations without such
> complications still have their detractors.

The reason why the Forth-200x discussion about locals in quotations has "settled" on Paysan-faked quotations (quotations that fail to provide access to the parent function's locals) is because Elizabeth Rather is opposed to general-purpose data-structures --- she will never allow quotations in Forth-200x --- she will only allow Paysan-faked quotations which are useless, so she can say: "See! Quotations are useless! You should have listened to me and not implemented quotations at all!"

Bernd Paysan wrote his fake quotations according to a spec provided to him by Leon Wagner. He didn't write the RfD however because Forth-200x is astro-turf, meaning that it is a corporate project that is faked up to look like a grass-roots project. Because of this, it is politically awkward for the RfDs to be written by the committee members. So, Bernd Paysan had his pocket-boy Alex McDonald write the RfD to make it look like the idea of fake quotations arose in the "Forth community" (imagine hundreds of Forthers all over the world chanting: "Give us fake quotations that are useless! We demand that the committee obey our will!"). The RfD was going to be a slam-dunk from a ladder for Alex McDonald --- but then Alex McDonald disappeared --- now the RfD is left in limbo while Anton and Bernd search for a new pocket-boy who will put his name on the RfD. 

First the Forth-200x committee had John Passaniti pretending to represent the "Forth community," but flaming-gay John disappeared. Then the Forth-200x committee had Alex McDonald pretending to represent the "Forth community," but Alex "I do standards for a living" McDonald disappeared. This is a chronic problem for the Forth-200x committee --- their pocket boys disappear --- then they have to find new pocket boys to put their names on the RfDs.

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


#47707

Fromhughaguilar96@gmail.com
Date2016-06-01 18:59 -0700
Message-ID<76b07551-44f3-48f2-848e-9750a1d98f88@googlegroups.com>
In reply to#47695
On Wednesday, June 1, 2016 at 8:20:39 AM UTC-7, hughag...@gmail.com wrote:
> On Wednesday, June 1, 2016 at 7:49:46 AM UTC-7, Anton Ertl wrote:
> > humptydumpty <ouatubi@gmail.com> writes:
> > >On Monday, May 30, 2016 at 7:10:26 PM UTC+3, Anton Ertl wrote:
> > >> Getting locals to work in some cases is easy.  The problem is getting
> > >> them to work in all cases, or letting the user know when they don't
> > >> work.
> > ...
> > >Looks like we have to not use locals in 'high-order words', 
> > >to give enough room for user-programmers  :)
> > 
> > That's just one of the cases where it does not work in Gforth.
> > Here's another one:
> > 
> > : foo ( n f -- )
> >   if 
> >     { n } r[ n . ]r 
> >   else
> >     drop r[ ." false ]r
> >   then
> >   rcall ;
> 
> The ANS-Forth document (section 13.3.3) says:
> "The position in program source at which the sequence of (LOCAL) messages is sent, referred to here as the point at which locals are declared, shall not lie within the scope of any control structure;"
> 
> So, Anton Ertl is complaining that HumptyDumpty's non-standard code won't work on the non-standard gForth compiler --- and this is HumptyDumpty's fault --- Anton Ertl is the chair-person of the Forth-200x Standard committee, so he is an expert on what is standard!

ANS-Forth is a set of rules. Some of the rules are good, others reflect the ignorance of the ANS-Forth committee, and others seem to be sabotage in the sense that they were put there to prevent ANS-Forth programmers from writing cross-compilers in competition with Forth Inc. and MPE.

The rule mentioned above is a good rule. If locals can only be declared at the beginning of a function, then quotations are easy to implement. This is why I have the same rule in Straight Forth.

Anton Ertl breaks the rules willy-nilly without regard for whether they are good rules or bad rules. I think that Anton Ertl's major problem is that he is really a C programmer at heart and doesn't really know anything beyond C. His gForth is basically an RPN version of C.

C allows functions to declare local variables inside of { } code blocks, which typically means inside of control structures (a WHILE structure, for example, has an { } block that it executes repeatedly). The reason why C does this, is that C functions are typically huge (I've seen them 100 lines long). The C function is like a mini-program! The C programmer doesn't want to be required to declare all of the function's locals at the top of the function because there might be a dozen or more locals, and some of them are only used inside of a particular control-structure so it makes more sense to define them there where they are used rather than at the top mixed together with all the other locals. This is not the way of Forth though. The rule-of-thumb in Forth is to average about 3 lines per function, and to not exceed 7 lines (there are exceptions of course, but this is pretty typical of well-written code). We can have all of our locals declared at the top. We don't need locals declared within control-structures.

A major failing of C is that C doesn't support quotations. Most C programmers don't know what quotations are (they wouldn't from C experience; they can only learn about quotations from other more advanced languages). Most likely, Anton Ertl doesn't know what quotations are used for. This is why he believes: "the discussion about locals in quotations has settled on standardizing only accessing locals from a quotation that were defined in that quotation." This statement reveals an almost complete ignorance of what quotations are used for! Quotations don't need to have their own locals --- the function is less than 7 lines long and the quotations are typically less than one line long (there can often be two quotations on a single line). The quotations do need to have access to the parent function's locals because this is how they communicate information back to the parent function when they are executing inside of the HOF.

Consider my LIST.4TH package. I have EACH which is like a HOF in that it traverses the list and executes the pseudo-quotation (called a "toucher" in my documentation) for every node in the list. Lets say that the quotation has to count how many nodes meet some criteria. The advantage of a quotation is that it has access to the parent function's locals, so we can have a local (lets call it CNT) and the quotation can increment this local every time that it finds a node that meets the criteria. Before executing EACH the parent function sets CNT to 0 and after EACH has executed the parent function now has CNT set to the count of how many nodes matched the criteria. The quotation would be pretty short (a one-liner) --- all it does is test the node for the criteria and increment CNT if the node meets the criteria.

Also, Anton rejected my RfD for ALLOCATION because GCC doesn't provide that feature in its heap and his gForth (written in GCC) uses the heap in GLIBC (MALLOC and FREE and all that). This once again reveals that Anton is a C programmer at heart and really doesn't know about any programming concepts that aren't already in C. 

Anton is striving to hold Forth down to the level of C --- he doesn't remember that there was a time prior to ANS-Forth when Forth and C were both taken seriously and were in competition --- he thinks C is the "god language" and Forth is a toy language written in C. This is why Forth-200x, with Anton as the chair-person, is destined to failure --- you can't put a C programmer in charge of Forth standardization and expect Forth to be anything more than a toy language written in C --- you definitely aren't going to get any features or concepts in Forth-200x that aren't already in C.

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


#47717

From"WJ" <w_a_x_man@yahoo.com>
Date2016-06-02 06:05 +0000
Message-ID<nioiao$3d2$1@dont-email.me>
In reply to#47707
hughaguilar96@gmail.com wrote:

> Most C programmers don't know what quotations are
> (they wouldn't from C experience; they can only
> learn about quotations from other more advanced languages).

They can't learn about "quotations" from more advanced languages.
More advanced languages call them lambdas or anonymous functions.

The term "quotation" is nonsensical.

-- 
Amazon bans book.  After nearly a month on the site, all traces of the book and
its 80 reviews have been removed.
http://jamesfetzer.blogspot.com/2015/11/debunking-sandy-hook-debunkers-5.html
https://www.youtube.com/watch?v=EEl_1HWFRfo

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


#47986

Fromalex@rivadpm.com
Date2016-06-09 09:59 -0700
Message-ID<4913a2af-29f6-4b50-98ac-7a5120a048d4@googlegroups.com>
In reply to#47695
On Wednesday, June 1, 2016 at 4:20:39 PM UTC+1, hughag...@gmail.com wrote:

> Bernd Paysan wrote his fake quotations according to a spec provided to him by Leon Wagner. He didn't write the RfD however because Forth-200x is astro-turf, meaning that it is a corporate project that is faked up to look like a grass-roots project. Because of this, it is politically awkward for the RfDs to be written by the committee members. So, Bernd Paysan had his pocket-boy Alex McDonald write the RfD to make it look like the idea of fake quotations arose in the "Forth community" (imagine hundreds of Forthers all over the world chanting: "Give us fake quotations that are useless! We demand that the committee obey our will!"). The RfD was going to be a slam-dunk from a ladder for Alex McDonald --- but then Alex McDonald disappeared --- now the RfD is left in limbo while Anton and Bernd search for a new pocket-boy who will put his name on the RfD. 
> 
> First the Forth-200x committee had John Passaniti pretending to represent the "Forth community," but flaming-gay John disappeared. Then the Forth-200x committee had Alex McDonald pretending to represent the "Forth community," but Alex "I do standards for a living" McDonald disappeared. This is a chronic problem for the Forth-200x committee --- their pocket boys disappear --- then they have to find new pocket boys to put their names on the RfDs.

I still lurk here. Work and other issues have kept me too busy, and frankly, not having to deal with you in my limited free time has been a relief. I do hope that your might fuck off before I start to rekindle my interest in Forth again, but like taxes and the pox I suspect you will be with us for some time.

Don't take care. 

-- 
Alex

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


#47988

From"WJ" <w_a_x_man@yahoo.com>
Date2016-06-09 17:47 +0000
Message-ID<njca35$u7q$1@dont-email.me>
In reply to#47986
alex@rivadpm.com wrote:

> I still lurk here. Work
> and other issues have
> kept me too busy, and
> frankly, not having to
> deal with you in my
> limited free time has
> been a relief. I do hope
> that your might fuck off
> before I start to
> rekindle my interest in
> Forth again,

I agree!  It's not fair that Hugh is allowed to defy
The Masters, while we are humbly abasing ourselves
before Them!  He has got to be taught that he is not
allowed to think for himself!  And if he can't
control his thoughts, then at least he must be kept
from saying what he is thinking!  There has got
to be a law against anti-Masterism!

>               but like
> taxes and the pox I

Take care!  By complaining about taxes, you are
offending The Masters!

> suspect you will be with
> us for some time.
> 
> Don't take care. 

I agree!  I hate him as much as you do!
Hugh the hater must be eliminated!
All haters must be done away with!

-- 
For two years ... he was held in solitary confinement in the Toronto West
Detention Centre, on the pretext that he is a threat to national security....
[A] court in Mannheim sentenced him to five years imprisonment for the crime of
"popular incitement" under Germany's notorious "Holocaust denial" statute.
http://www.revisionists.com/revisionists/zundel.html

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


#47696

Fromhumptydumpty <ouatubi@gmail.com>
Date2016-06-01 09:12 -0700
Message-ID<7321fd60-830d-4750-8150-f56c79824078@googlegroups.com>
In reply to#47692
On Wednesday, June 1, 2016 at 5:49:46 PM UTC+3, Anton Ertl wrote:
> humptydumpty writes:
> >On Monday, May 30, 2016 at 7:10:26 PM UTC+3, Anton Ertl wrote:
> >> Getting locals to work in some cases is easy.  The problem is getting
> >> them to work in all cases, or letting the user know when they don't
> >> work.
> ...
> >Looks like we have to not use locals in 'high-order words', 
> >to give enough room for user-programmers  :)
> 
> That's just one of the cases where it does not work in Gforth.
> Here's another one:
> 
> : foo ( n f -- )
>   if 
>     { n } r[ n . ]r 
>   else
>     drop r[ ." false ]r
>   then
>   rcall ;
> 
> And some of the uses that work on Gforth will fail on the next system.
> That's why the discussion about locals in quotations has settled on
> standardizing only accessing locals from a quotation that were defined
> in that quotation; that should be relatively easy to implement on
> every system.  There have been some discussions on how to extend that,
> but I have my doubts that any of these ideas will be accepted by the
> larger community or the committee.  Even quotations without such
> complications still have their detractors.
> 
> - 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 2016: http://www.euroforth.org/ef16/

Hi!

> Here's another one:
> 
> : foo ( n f -- )
>   if 
>     { n } r[ n . ]r 
>   else
>     drop r[ ." false ]r
>   then
>   rcall ;
> 

Then you want from 'rcall' location rquotation placed inside 'if..else' branch.
Let's execute body of rquotation from 'rcall' place:

: bar IF { n } ELSE drop ." FALSE" THEN n . ;                                   :3: Undefined word
: bar IF { n } ELSE drop ." FALSE" THEN >>>n<<< . ;
Backtrace:
$7FEF3F580A08 throw 
$7FEF3F596C18 no.extensions 
$7FEF3F584340 compiler-notfound1 
  ok

Proper way (preserving stack-effect):

: baz  ( n f -- )  swap { n } IF r[ n . ]r ELSE r[ ." FALSE" ]r THEN rcall ;  ok10 -1 baz .s 10 <0>  ok                                                     
10  0 baz .s FALSE<0>  ok                                                   

Have a nice day,
humptydumpty

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


#47708

From"HAA" <someone@microsoft.com>
Date2016-06-02 12:45 +1000
Message-ID<nio6hb$fd6$1@gioia.aioe.org>
In reply to#47692
Anton Ertl wrote:
> ...
> That's why the discussion about locals in quotations has settled on
> standardizing only accessing locals from a quotation that were defined
> in that quotation;

Usefulness and efficiency - not ease of implementation - should be the goal.
Quotations are intended to be short fragments of code dependent on the
parent.  To maintain efficiency quotations *must* have access to the parent's
locals if locals are the mechanism by which the parent operates.  IIRC Hugh
said something to this effect a while back and I agree with him.


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


#47725

FromAndrew Haley <andrew29@littlepinkcloud.invalid>
Date2016-06-02 04:42 -0500
Message-ID<X4Odnd2-vbnwYtLKnZ2dnUU7-bPNnZ2d@supernews.com>
In reply to#47708
HAA <someone@microsoft.com> wrote:
> Anton Ertl wrote:
>> ...
>> That's why the discussion about locals in quotations has settled on
>> standardizing only accessing locals from a quotation that were defined
>> in that quotation;
> 
> Usefulness and efficiency - not ease of implementation - should be
> the goal.

The core design principle of Forth has always been that the entire
system is simple and small.  That there is no magic "under the hood";
that the implementation of the system is just as simple as it appears
to be.

> Quotations are intended to be short fragments of code dependent on
> the parent.  To maintain efficiency quotations *must* have access to
> the parent's locals if locals are the mechanism by which the parent
> operates.

One problem with this approach is the lifetime of the quotations.
There's no garbage collection, so we have to put the captured locals
(or references to them) somewhere.  We could keep them on one of the
stacks, but we'd have a dangling reference problem.  We could keep
them in dynamic storage, but the user would have to know when to free
them.  Neither of these strikes me as a good idea.  Also, we'd need a
mechanism which allows access to captured locals as well as locals
declared in a quotation.  All of this turns a simple and useful
proposal into a sprawling mess, IMO.

And there is no point when we already have a perfectly good mechanism
for capturing data already: the stack.  Locals seemed to be a good
idea at the time, but like many language features a multiplying effect
causes burgeoning complexity when combined with other language
features such as quotations.

Andrew.

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


#47729

FromRaimond Dragomir <raimond.dragomir@gmail.com>
Date2016-06-02 05:08 -0700
Message-ID<c75df337-769e-4e18-aa91-28d2bf7b6d8f@googlegroups.com>
In reply to#47725
> One problem with this approach is the lifetime of the quotations.
> There's no garbage collection, so we have to put the captured locals

Who said the parent's locals should be captured? Local variables are 
"local" variables. When parent exits, its locals are gone. Simple as that.
If you access local variables of an out of scope definition, well, think
twice, maybe it's your fault, maybe you should do your things differently.

The trend is to name these "local variables" differently. Lua name them
somehow but I don't remember how. The idea is "local variables" are 
exactly that, and "local" variables that may be captured by a quotation
are a completely different thing.

> them.  Neither of these strikes me as a good idea.  Also, we'd need a
> mechanism which allows access to captured locals as well as locals
> declared in a quotation.  All of this turns a simple and useful
> proposal into a sprawling mess, IMO.

The mechanism is so simple and easy to implement... Did you hear about frame pointers?

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


#47733

FromPaul Rubin <no.email@nospam.invalid>
Date2016-06-02 06:53 -0700
Message-ID<87d1nzelyd.fsf@jester.gateway.pace.com>
In reply to#47729
Raimond Dragomir <raimond.dragomir@gmail.com> writes:
> Who said the parent's locals should be captured? Local variables are 
> "local" variables. When parent exits, its locals are gone. Simple as that.

The problem is that the quotation is potentially still around, holding
references to those locals.  In Lisp this is called the upward funarg
problem and it's handled by putting the parent locals in the heap, so
they get gc'd after the quotation (called a closure in Lisp terminology)
becomes unreachable.  In C++11, calling the closure after the parent
returns is UB.  Maybe that's reasonable for Forth as well.

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


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

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


csiph-web