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


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

Would ?EXIT work in all ANS-Forth systems?

Started bylehs <skydda.barnen@gmail.com>
First post2017-05-10 08:21 -0700
Last post2017-05-15 11:23 +0000
Articles 20 on this page of 135 — 21 participants

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


Contents

  Would ?EXIT work in all ANS-Forth systems? lehs <skydda.barnen@gmail.com> - 2017-05-10 08:21 -0700
    Re: Would ?EXIT work in all ANS-Forth systems? Alex <alex@rivadpm.com> - 2017-05-10 16:39 +0100
      Re: Would ?EXIT work in all ANS-Forth systems? lehs <skydda.barnen@gmail.com> - 2017-05-10 08:46 -0700
      Re: Would ?EXIT work in all ANS-Forth systems? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-10 16:04 +0000
      Re: Would ?EXIT work in all ANS-Forth systems? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-11 04:22 -0500
        Re: Would ?EXIT work in all ANS-Forth systems? Alex <alex@rivadpm.com> - 2017-05-11 10:35 +0100
          Re: Would ?EXIT work in all ANS-Forth systems? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-11 05:08 -0500
            Re: Would ?EXIT work in all ANS-Forth systems? Julian Fondren <julian.fondren@gmail.com> - 2017-05-11 03:51 -0700
              Re: Would ?EXIT work in all ANS-Forth systems? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-11 07:02 -0500
              Re: Would ?EXIT work in all ANS-Forth systems? rickman <gnuarm@gmail.com> - 2017-05-13 11:55 -0400
          Re: Would ?EXIT work in all ANS-Forth systems? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-15 09:32 -0500
            Re: Would ?EXIT work in all ANS-Forth systems? Cecil Bayona <cbayona@cbayona.com> - 2017-05-15 11:56 -0500
              Re: Would ?EXIT work in all ANS-Forth systems? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-15 12:20 -0500
                Re: Would ?EXIT work in all ANS-Forth systems? Cecil Bayona <cbayona@cbayona.com> - 2017-05-15 12:31 -0500
                  Re: Would ?EXIT work in all ANS-Forth systems? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-15 15:50 -0500
    Re: Would ?EXIT work in all ANS-Forth systems? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-10 16:49 +0000
      Re: Would ?EXIT work in all ANS-Forth systems? lehs <skydda.barnen@gmail.com> - 2017-05-10 12:04 -0700
    Re: Would ?EXIT work in all ANS-Forth systems? humptydumpty <ouatubi@gmail.com> - 2017-05-11 01:08 -0700
      Re: Would ?EXIT work in all ANS-Forth systems? Alex <alex@rivadpm.com> - 2017-05-11 09:13 +0100
        Re: Would ?EXIT work in all ANS-Forth systems? humptydumpty <ouatubi@gmail.com> - 2017-05-11 01:48 -0700
          Re: Would ?EXIT work in all ANS-Forth systems? Alex <alex@rivadpm.com> - 2017-05-11 09:59 +0100
    Re: Would ?EXIT work in all ANS-Forth systems? "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-05-12 14:20 +0000
      Re: Would ?EXIT work in all ANS-Forth systems? lehs <skydda.barnen@gmail.com> - 2017-05-12 17:01 -0700
        Re: Would ?EXIT work in all ANS-Forth systems? humptydumpty <ouatubi@gmail.com> - 2017-05-12 22:18 -0700
          Re: Would ?EXIT work in all ANS-Forth systems? lehs <skydda.barnen@gmail.com> - 2017-05-13 03:09 -0700
          Re: Would ?EXIT work in all ANS-Forth systems? "HAA" <someone@microsoft.com> - 2017-05-13 21:07 +1000
          Re: Would ?EXIT work in all ANS-Forth systems? "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-05-13 14:20 +0000
            Re: Would ?EXIT work in all ANS-Forth systems? "HAA" <someone@microsoft.com> - 2017-05-14 11:59 +1000
              Re: Would ?EXIT work in all ANS-Forth systems? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-14 09:21 -0500
                Re: Would ?EXIT work in all ANS-Forth systems? humptydumpty <ouatubi@gmail.com> - 2017-05-14 10:43 -0700
                  Re: Would ?EXIT work in all ANS-Forth systems? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-14 18:35 -0500
                    Re: Would ?EXIT work in all ANS-Forth systems? Lars Brinkhoff <lars.spam@nocrew.org> - 2017-05-15 07:11 +0200
                      Re: Would ?EXIT work in all ANS-Forth systems? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-15 04:35 -0500
                        Re: Would ?EXIT work in all ANS-Forth systems? Julian Fondren <julian.fondren@gmail.com> - 2017-05-15 03:54 -0700
                          Re: Would ?EXIT work in all ANS-Forth systems? mhx@iae.nl - 2017-05-15 04:07 -0700
                          Re: Would ?EXIT work in all ANS-Forth systems? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-15 06:23 -0500
                            Re: Would ?EXIT work in all ANS-Forth systems? Julian Fondren <julian.fondren@gmail.com> - 2017-05-15 06:53 -0700
                              Re: Would ?EXIT work in all ANS-Forth systems? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-15 09:18 -0500
                    Re: Would ?EXIT work in all ANS-Forth systems? humptydumpty <ouatubi@gmail.com> - 2017-05-14 22:44 -0700
                      Re: Would ?EXIT work in all ANS-Forth systems? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-15 04:16 -0500
                        Re: Would ?EXIT work in all ANS-Forth systems? humptydumpty <ouatubi@gmail.com> - 2017-05-16 02:00 -0700
                        Re: Would ?EXIT work in all ANS-Forth systems? humptydumpty <ouatubi@gmail.com> - 2017-05-16 02:43 -0700
                          Re: Would ?EXIT work in all ANS-Forth systems? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-16 05:08 -0500
                          Re: Would ?EXIT work in all ANS-Forth systems? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-16 12:11 +0000
                            Re: Would ?EXIT work in all ANS-Forth systems? NN <november.nihal@gmail.com> - 2017-05-17 05:24 -0700
                              Re: Would ?EXIT work in all ANS-Forth systems? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-17 07:35 -0500
                                Re: Would ?EXIT work in all ANS-Forth systems? Alex <alex@rivadpm.com> - 2017-05-17 14:59 +0100
                              Re: Would ?EXIT work in all ANS-Forth systems? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-17 13:30 +0000
                  Re: Would ?EXIT work in all ANS-Forth systems? "HAA" <someone@microsoft.com> - 2017-05-15 11:09 +1000
                    Re: Would ?EXIT work in all ANS-Forth systems? Raimond Dragomir <raimond.dragomir@gmail.com> - 2017-05-14 21:17 -0700
                    Re: Would ?EXIT work in all ANS-Forth systems? Lars Brinkhoff <lars.spam@nocrew.org> - 2017-05-15 07:13 +0200
                      Re: Would ?EXIT work in all ANS-Forth systems? "HAA" <someone@microsoft.com> - 2017-05-16 10:24 +1000
                        Re: Would ?EXIT work in all ANS-Forth systems? humptydumpty <ouatubi@gmail.com> - 2017-05-16 01:13 -0700
                          Re: Would ?EXIT work in all ANS-Forth systems? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-16 12:26 +0000
                            Re: Would ?EXIT work in all ANS-Forth systems? humptydumpty <ouatubi@gmail.com> - 2017-05-17 01:58 -0700
                              Re: Would ?EXIT work in all ANS-Forth systems? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-17 16:45 +0000
                                Re: Would ?EXIT work in all ANS-Forth systems? obi65537@gmail.com - 2017-05-25 12:04 -0700
                                  Re: Would ?EXIT work in all ANS-Forth systems? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-26 10:02 +0000
                                    Re: Would ?EXIT work in all ANS-Forth systems? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-26 07:46 -0500
                                      Re: Would ?EXIT work in all ANS-Forth systems? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-26 13:53 +0000
                                        Re: Would ?EXIT work in all ANS-Forth systems? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-26 10:14 -0500
                                      Re: Would ?EXIT work in all ANS-Forth systems? Cecil Bayona <cbayona@cbayona.com> - 2017-05-26 10:16 -0500
                                        Re: Would ?EXIT work in all ANS-Forth systems? Raimond Dragomir <raimond.dragomir@gmail.com> - 2017-05-26 08:59 -0700
                                          Re: Would ?EXIT work in all ANS-Forth systems? Cecil Bayona <cbayona@cbayona.com> - 2017-05-26 11:27 -0500
                                            Re: Would ?EXIT work in all ANS-Forth systems? Raimond Dragomir <raimond.dragomir@gmail.com> - 2017-05-26 10:19 -0700
                                              Re: Would ?EXIT work in all ANS-Forth systems? Lars Brinkhoff <lars.spam@nocrew.org> - 2017-05-26 20:20 +0200
                                                Re: Would ?EXIT work in all ANS-Forth systems? Raimond Dragomir <raimond.dragomir@gmail.com> - 2017-05-26 21:38 -0700
                                              Re: Would ?EXIT work in all ANS-Forth systems? Cecil Bayona <cbayona@cbayona.com> - 2017-05-26 14:06 -0500
                                                Re: Would ?EXIT work in all ANS-Forth systems? Raimond Dragomir <raimond.dragomir@gmail.com> - 2017-05-26 22:00 -0700
                            Re: Would ?EXIT work in all ANS-Forth systems? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-26 17:06 +0000
                              Re: Would ?EXIT work in all ANS-Forth systems? hum9 <obi65537@gmail.com> - 2017-05-27 01:15 -0700
                                Re: Would ?EXIT work in all ANS-Forth systems? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-28 14:17 +0000
                              Re: Would ?EXIT work in all ANS-Forth systems? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-27 17:40 +0000
                          Re: Would ?EXIT work in all ANS-Forth systems? "HAA" <someone@microsoft.com> - 2017-05-24 15:46 +1000
                            Re: Would ?EXIT work in all ANS-Forth systems? humptydumpty <obi65537@gmail.com> - 2017-05-25 11:51 -0700
                            Re: Would ?EXIT work in all ANS-Forth systems? humptydumpty <obi65537@gmail.com> - 2017-05-25 20:38 -0700
                            Re: Would ?EXIT work in all ANS-Forth systems? obi65537@gmail.com - 2017-05-25 22:03 -0700
                              Re: Would ?EXIT work in all ANS-Forth systems? obi65537@gmail.com - 2017-05-25 22:09 -0700
                                Re: Would ?EXIT work in all ANS-Forth systems? "HAA" <someone@microsoft.com> - 2017-05-26 21:56 +1000
                                  Re: Would ?EXIT work in all ANS-Forth systems? Alex <alex@rivadpm.com> - 2017-05-26 13:30 +0100
                                    Re: Would ?EXIT work in all ANS-Forth systems? "HAA" <someone@microsoft.com> - 2017-05-27 15:04 +1000
                                      Re: Would ?EXIT work in all ANS-Forth systems? Alex <alex@rivadpm.com> - 2017-05-27 17:33 +0100
                                        Re: Would ?EXIT work in all ANS-Forth systems? "HAA" <someone@microsoft.com> - 2017-05-29 12:17 +1000
                                  Re: Would ?EXIT work in all ANS-Forth systems? hum9 <obi65537@gmail.com> - 2017-05-27 00:33 -0700
                                Re: Would ?EXIT work in all ANS-Forth systems? "HAA" <someone@microsoft.com> - 2017-05-27 14:53 +1000
                                  READ-FILE over-specified? "HAA" <someone@microsoft.com> - 2017-05-27 21:28 +1000
                                    Re: READ-FILE over-specified? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-27 13:11 +0000
                                      Re: READ-FILE over-specified? "HAA" <someone@microsoft.com> - 2017-05-29 13:47 +1000
                                    Re: READ-FILE over-specified? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-05-28 09:44 +0200
                                      Re: READ-FILE over-specified? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-28 13:41 +0000
                                        Re: READ-FILE over-specified? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-05-28 19:59 +0200
                        Re: Would ?EXIT work in all ANS-Forth systems? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2017-05-16 09:42 +0100
                          Re: Would ?EXIT work in all ANS-Forth systems? Alex <alex@rivadpm.com> - 2017-05-16 09:53 +0100
                            Re: Would ?EXIT work in all ANS-Forth systems? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-16 04:53 -0500
                              Re: Would ?EXIT work in all ANS-Forth systems? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-05-16 12:32 +0200
                              Re: Would ?EXIT work in all ANS-Forth systems? Alex <alex@rivadpm.com> - 2017-05-16 12:35 +0100
                                Re: Would ?EXIT work in all ANS-Forth systems? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-16 10:48 -0500
                                  Re: Would ?EXIT work in all ANS-Forth systems? Alex <alex@rivadpm.com> - 2017-05-16 18:23 +0100
                                    Re: Would ?EXIT work in all ANS-Forth systems? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-17 04:33 -0500
                                      Re: Would ?EXIT work in all ANS-Forth systems? Alex <alex@rivadpm.com> - 2017-05-17 12:29 +0100
                              Re: Would ?EXIT work in all ANS-Forth systems? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-16 10:28 +0000
                                Re: Would ?EXIT work in all ANS-Forth systems? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-16 10:43 -0500
                                  Re: Would ?EXIT work in all ANS-Forth systems? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-16 16:34 +0000
                                    Re: Would ?EXIT work in all ANS-Forth systems? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-16 12:41 -0500
                                      Re: Would ?EXIT work in all ANS-Forth systems? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-17 16:14 +0000
                                        Re: Would ?EXIT work in all ANS-Forth systems? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-18 03:05 -0500
                                          Re: Would ?EXIT work in all ANS-Forth systems? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-18 16:33 +0000
                                            Re: Would ?EXIT work in all ANS-Forth systems? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-18 12:43 -0500
                                        Re: Would ?EXIT work in all ANS-Forth systems? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-18 04:01 -0500
                                          Re: Would ?EXIT work in all ANS-Forth systems? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-18 15:41 +0000
                                            Re: Would ?EXIT work in all ANS-Forth systems? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-05-18 11:58 -0500
                                            Re: Would ?EXIT work in all ANS-Forth systems? Alex <alex@rivadpm.com> - 2017-05-18 22:57 +0100
                            Re: Would ?EXIT work in all ANS-Forth systems? "HAA" <someone@microsoft.com> - 2017-05-17 00:32 +1000
                              Re: Would ?EXIT work in all ANS-Forth systems? Alex <alex@rivadpm.com> - 2017-05-16 15:53 +0100
                  Re: Would ?EXIT work in all ANS-Forth systems? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-15 05:29 +0000
                    Re: Would ?EXIT work in all ANS-Forth systems? humptydumpty <ouatubi@gmail.com> - 2017-05-14 23:00 -0700
                  Re: Would ?EXIT work in all ANS-Forth systems? rickman <gnuarm@gmail.com> - 2017-05-17 12:27 -0400
              Re: Would ?EXIT work in all ANS-Forth systems? "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-05-15 09:16 +0000
              Re: Would ?EXIT work in all ANS-Forth systems? "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-05-15 09:55 +0000
          Re: Would ?EXIT work in all ANS-Forth systems? "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-05-13 14:25 +0000
            Re: Would ?EXIT work in all ANS-Forth systems? Julian Fondren <julian.fondren@gmail.com> - 2017-05-13 07:49 -0700
              Re: Would ?EXIT work in all ANS-Forth systems? "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-05-15 09:59 +0000
              Re: Would ?EXIT work in all ANS-Forth systems? "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-05-15 12:22 +0000
        Re: Would ?EXIT work in all ANS-Forth systems? "Rudy Velthuis" <newsgroups@rvelthuis.de> - 2017-05-13 14:19 +0000
    Re: Would ?EXIT work in all ANS-Forth systems? lehs <skydda.barnen@gmail.com> - 2017-05-14 23:23 -0700
      Re: Would ?EXIT work in all ANS-Forth systems? Raimond Dragomir <raimond.dragomir@gmail.com> - 2017-05-15 00:10 -0700
        Re: Would ?EXIT work in all ANS-Forth systems? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-15 09:35 +0000
      Re: Would ?EXIT work in all ANS-Forth systems? lehs <skydda.barnen@gmail.com> - 2017-05-15 00:54 -0700
        Return-address manipulation (was: Would ?EXIT ...) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-15 08:47 +0000
          Re: Return-address manipulation (was: Would ?EXIT ...) stephen@mpeforth.com (Stephen Pelc) - 2017-05-15 11:53 +0000
            Re: Return-address manipulation (was: Would ?EXIT ...) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-05-16 13:03 +0000
              Re: Return-address manipulation (was: Would ?EXIT ...) Raimond Dragomir <raimond.dragomir@gmail.com> - 2017-05-16 07:06 -0700
                Re: Return-address manipulation (was: Would ?EXIT ...) Raimond Dragomir <raimond.dragomir@gmail.com> - 2017-05-16 07:14 -0700
      Re: Would ?EXIT work in all ANS-Forth systems? "Elizabeth D. Rather" <erather@forth.com> - 2017-05-14 21:58 -1000
        Re: Would ?EXIT work in all ANS-Forth systems? stephen@mpeforth.com (Stephen Pelc) - 2017-05-15 11:23 +0000

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


#59064

FromAlex <alex@rivadpm.com>
Date2017-05-11 09:59 +0100
Message-ID<of18ut$3b9$1@dont-email.me>
In reply to#59063
On 5/11/2017 09:48, humptydumpty wrote:
>> Or use CATCH/THROW.
>>
>> -- 
>> Alex
> CATCH/THROW will not preserve data-stack.  That could be
> solved by saving data-stack into variables or return stack.

Good point.

-- 
Alex

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


#59120

From"Rudy Velthuis" <newsgroups@rvelthuis.de>
Date2017-05-12 14:20 +0000
Message-ID<xn0kpw9sb3vk37k004@nntp.aioe.org>
In reply to#58987
lehs wrote:

> : ?exit ( flag -- )  if 2r> 2drop then ;
> 
> I'm doing a kind of filtering word and want to replace  IF EXIT THEN
> with  ?EXIT if this works.

Probably only on indirectly threaded systems, and even there, there may
be more or fewer items on the return stack.

-- 
Rudy Velthuis        http://www.rvelthuis.de

"In the 1980s capitalism triumphed over communism. In the 1990s
 it triumphed over democracy."
 -- David Korten

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


#59134

Fromlehs <skydda.barnen@gmail.com>
Date2017-05-12 17:01 -0700
Message-ID<d74f6f30-3f7f-47d2-a3ea-9535ddb4d59d@googlegroups.com>
In reply to#59120
Den fredag 12 maj 2017 kl. 16:20:24 UTC+2 skrev Rudy Velthuis:
> lehs wrote:
> 
> > : ?exit ( flag -- )  if 2r> 2drop then ;
> > 
> > I'm doing a kind of filtering word and want to replace  IF EXIT THEN
> > with  ?EXIT if this works.
> 
> Probably only on indirectly threaded systems, and even there, there may
> be more or fewer items on the return stack.
> 
> -- 
> Rudy Velthuis        http://www.rvelthuis.de
> 
> "In the 1980s capitalism triumphed over communism. In the 1990s
>  it triumphed over democracy."
>  -- David Korten

Yes you are right. Anton Ertls suggestion is perfect:

: ?exit postpone if postpone exit postpone then ; immediate 

Nowadays I focus on calculations and I've stopped thinking outside the box... :)

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


#59148

Fromhumptydumpty <ouatubi@gmail.com>
Date2017-05-12 22:18 -0700
Message-ID<1cca60ee-6f98-443d-8466-d7efbea8724f@googlegroups.com>
In reply to#59134
On Saturday, May 13, 2017 at 3:01:03 AM UTC+3, lehs wrote:
> Den fredag 12 maj 2017 kl. 16:20:24 UTC+2 skrev Rudy Velthuis:
> > lehs wrote:
> > 
> > > : ?exit ( flag -- )  if 2r> 2drop then ;
> > > 
> > > I'm doing a kind of filtering word and want to replace  IF EXIT THEN
> > > with  ?EXIT if this works.
> > 
> > Probably only on indirectly threaded systems, and even there, there may
> > be more or fewer items on the return stack.
> > 
> > -- 
> > Rudy Velthuis        http://www.rvelthuis.de
> > 
> > "In the 1980s capitalism triumphed over communism. In the 1990s
> >  it triumphed over democracy."
> >  -- David Korten
> 
> Yes you are right. Anton Ertls suggestion is perfect:
> 
> : ?exit postpone if postpone exit postpone then ; immediate 
> 
> Nowadays I focus on calculations and I've stopped thinking outside the box... :)

LOL!

Then what "return stack" means? :)

Please, review what "return stack" stands for every kind of
 threading. Also what "subroutine" means for in generic
 programming.

Return stack manipulations  does *not work* for inlined
 or tail-recursion optimized words.

Please, don't get bullshitted. Sometimes that is a preferred
 sport here in c.l.f.

Also, sometimes I wonder if c.l.f. does not mean 
control.language.forth,  not comp.lang.forth.

--
Have a nice day,
hum9

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


#59162

Fromlehs <skydda.barnen@gmail.com>
Date2017-05-13 03:09 -0700
Message-ID<c734b4db-e387-4cb8-9d15-679cdf448c36@googlegroups.com>
In reply to#59148
Den lördag 13 maj 2017 kl. 07:18:32 UTC+2 skrev humptydumpty:
> On Saturday, May 13, 2017 at 3:01:03 AM UTC+3, lehs wrote:
> > Den fredag 12 maj 2017 kl. 16:20:24 UTC+2 skrev Rudy Velthuis:
> > > lehs wrote:
> > > 
> > > > : ?exit ( flag -- )  if 2r> 2drop then ;
> > > > 
> > > > I'm doing a kind of filtering word and want to replace  IF EXIT THEN
> > > > with  ?EXIT if this works.
> > > 
> > > Probably only on indirectly threaded systems, and even there, there may
> > > be more or fewer items on the return stack.
> > > 
> > > -- 
> > > Rudy Velthuis        http://www.rvelthuis.de
> > > 
> > > "In the 1980s capitalism triumphed over communism. In the 1990s
> > >  it triumphed over democracy."
> > >  -- David Korten
> > 
> > Yes you are right. Anton Ertls suggestion is perfect:
> > 
> > : ?exit postpone if postpone exit postpone then ; immediate 
> > 
> > Nowadays I focus on calculations and I've stopped thinking outside the box... :)
> 
> LOL!
> 
> Then what "return stack" means? :)
> 
> Please, review what "return stack" stands for every kind of
>  threading. Also what "subroutine" means for in generic
>  programming.
> 
> Return stack manipulations  does *not work* for inlined
>  or tail-recursion optimized words.
> 
> Please, don't get bullshitted. Sometimes that is a preferred
>  sport here in c.l.f.
> 
> Also, sometimes I wonder if c.l.f. does not mean 
> control.language.forth,  not comp.lang.forth.
> 
> --
> Have a nice day,
> hum9

I don't know if your post is directed to me or Rudy Velthuis. But yes, some do use Internet for spreading shit and some to spread good ideas. And some, like me, use Internet to temporary circumvent laziness and ignorans.

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


#59163

From"HAA" <someone@microsoft.com>
Date2017-05-13 21:07 +1000
Message-ID<of6pcv$1ont$1@gioia.aioe.org>
In reply to#59148
humptydumpty wrote:
> On Saturday, May 13, 2017 at 3:01:03 AM UTC+3, lehs wrote:
> > Den fredag 12 maj 2017 kl. 16:20:24 UTC+2 skrev Rudy Velthuis:
> > > lehs wrote:
> > >
> > > > : ?exit ( flag -- )  if 2r> 2drop then ;
> > > >
> > > > I'm doing a kind of filtering word and want to replace  IF EXIT THEN
> > > > with  ?EXIT if this works.
> > >
> > > Probably only on indirectly threaded systems, and even there, there may
> > > be more or fewer items on the return stack.
> > >
> > > --
> > > Rudy Velthuis        http://www.rvelthuis.de
> >
> > Yes you are right. Anton Ertls suggestion is perfect:
> >
> > : ?exit postpone if postpone exit postpone then ; immediate
> >
> > Nowadays I focus on calculations and I've stopped thinking outside the box... :)
>
> LOL!
>
> Then what "return stack" means? :)

In ANS it does not mean - nor does it need to be - a 'return stack' at all :)




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


#59171

From"Rudy Velthuis" <newsgroups@rvelthuis.de>
Date2017-05-13 14:20 +0000
Message-ID<xn0kpxod34i5h3a00e@nntp.aioe.org>
In reply to#59148
humptydumpty wrote:

> > Yes you are right. Anton Ertls suggestion is perfect:
> > 
> > : ?exit postpone if postpone exit postpone then ; immediate 
> > 
> > Nowadays I focus on calculations and I've stopped thinking outside
> > the box... :)
> 
> LOL!
> 
> Then what "return stack" means? :)

Different things in different systems. And, as I said, there will be
many systems that only put *one* cell on the return stack if they enter
a definition, so 2R> and 2DROP would be wrong already.


-- 
Rudy Velthuis        http://www.rvelthuis.de

"Gravity cannot be held responsible for people falling in love." 
 -- Albert Einstein

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


#59199

From"HAA" <someone@microsoft.com>
Date2017-05-14 11:59 +1000
Message-ID<of8dmm$3rk$1@gioia.aioe.org>
In reply to#59171
Rudy Velthuis wrote:
> humptydumpty wrote:
>
> > > Yes you are right. Anton Ertls suggestion is perfect:
> > >
> > > : ?exit postpone if postpone exit postpone then ; immediate
> > >
> > > Nowadays I focus on calculations and I've stopped thinking outside
> > > the box... :)
> >
> > LOL!
> >
> > Then what "return stack" means? :)
>
> Different things in different systems. And, as I said, there will be
> many systems that only put *one* cell on the return stack if they enter
> a definition, so 2R> and 2DROP would be wrong already.

But it does raise the issue of *wanting* to drop a level.  In the days
when "return stack" meant return stack and threaded code was the
norm  R> DROP  is what you would use.   ANS precludes this,
forcing programmers to adopt inefficient solutions.  Here's an
example of a routine that deserves to be as efficient as it looks.

: ?# ( ud -- ud )  #  2dup d0= if  r> drop  then ;

: #,S ( ud -- 0 0 )  begin ?#  ?#  ?#  [char] , hold  again ;


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


#59218

FromAndrew Haley <andrew29@littlepinkcloud.invalid>
Date2017-05-14 09:21 -0500
Message-ID<b_6dnSjckr5k-oXEnZ2dnUU7-enNnZ2d@supernews.com>
In reply to#59199
HAA <someone@microsoft.com> wrote:

> In the days when "return stack" meant return stack and threaded code
> was the norm R> DROP is what you would use.  ANS precludes this,
> forcing programmers to adopt inefficient solutions.

No.  That is not how it happened.  ANS did not preclude return stack
hackery because it wasn't portable anyway.  Before the ANS process
began, the number of return stack items pushed by a colon definition
wasn't always 1.  And maybe you'd even be using a different stack for
return addresses.  So maybe the R> DROP trick would work, maybe not.

In that sense, the situation is not any different post-ANS: if you
want to depend on a colon definition pushing one item onto the return
stack you can still assume that.  ANS did not cause this trick to stop
working: it was descriptive rather than prescriptive.

> Here's an example of a routine that deserves to be as efficient as
> it looks.
> 
> : ?# ( ud -- ud )  #  2dup d0= if  r> drop  then ;
> 
> : #,S ( ud -- 0 0 )  begin ?#  ?#  ?#  [char] , hold  again ;

I hope that wouldn't pass review.

Andrew.

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


#59223

Fromhumptydumpty <ouatubi@gmail.com>
Date2017-05-14 10:43 -0700
Message-ID<aa0cb564-cbe6-49b5-b7f4-059f5eebf2d7@googlegroups.com>
In reply to#59218
On Sunday, May 14, 2017 at 5:21:50 PM UTC+3, Andrew Haley wrote:
> HAA wrote:
> 
> > In the days when "return stack" meant return stack and threaded code
> > was the norm R> DROP is what you would use.  ANS precludes this,
> > forcing programmers to adopt inefficient solutions.
> 
> No.  That is not how it happened.  ANS did not preclude return stack
> hackery because it wasn't portable anyway.  Before the ANS process
> began, the number of return stack items pushed by a colon definition
> wasn't always 1.  And maybe you'd even be using a different stack for
> return addresses.

This is mind boggling! Was that Forth? What is the percentage
of such implementations from all Forth implementations?

>  So maybe the R> DROP trick would work, maybe not.

But this is not a trick. Is applying knowledge that on return-stack
is the address of continuation(partial) of current definition caller.

> 
> In that sense, the situation is not any different post-ANS: if you
> want to depend on a colon definition pushing one item onto the return
> stack you can still assume that.  ANS did not cause this trick to stop
> working: it was descriptive rather than prescriptive.
> 
> > Here's an example of a routine that deserves to be as efficient as
> > it looks.
> > 
> > : ?# ( ud -- ud )  #  2dup d0= if  r> drop  then ;
> > 
> > : #,S ( ud -- 0 0 )  begin ?#  ?#  ?#  [char] , hold  again ;
> 
> I hope that wouldn't pass review.

This is a very nice factored code!

What matter is idea behind code. User will modify  '?#'  definition
accordingly with used Forth implementation, if necessary, or choose
another Forth implementation.

> 
> Andrew.

--
Have a nice day,
hum9

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


#59233

FromAndrew Haley <andrew29@littlepinkcloud.invalid>
Date2017-05-14 18:35 -0500
Message-ID<_6OdnQW2rOImdIXEnZ2dnUU7-IvNnZ2d@supernews.com>
In reply to#59223
humptydumpty <ouatubi@gmail.com> wrote:
> On Sunday, May 14, 2017 at 5:21:50 PM UTC+3, Andrew Haley wrote:
>> HAA wrote:
>> 
>> > In the days when "return stack" meant return stack and threaded code
>> > was the norm R> DROP is what you would use.  ANS precludes this,
>> > forcing programmers to adopt inefficient solutions.
>> 
>> No.  That is not how it happened.  ANS did not preclude return stack
>> hackery because it wasn't portable anyway.  Before the ANS process
>> began, the number of return stack items pushed by a colon definition
>> wasn't always 1.  And maybe you'd even be using a different stack for
>> return addresses.
> 
> This is mind boggling! Was that Forth? What is the percentage
> of such implementations from all Forth implementations?

Not huge, and I couldn't put a number on it.  But I have seen them.
An 8086 far call pushed two cells onto the return stack, which was a
good match for a 16-bit system with multiple segements.  There were
also single-chip computers with very restricted stack space, but could
run an OK Forth.  The desire to run Forth on these machines was
justified, I think, and IMO more important than return stack tricks.

>>  So maybe the R> DROP trick would work, maybe not.
> 
> But this is not a trick. Is applying knowledge that on return-stack
> is the address of continuation(partial) of current definition caller.

One person's trick is another's technique, I suppose.

>> In that sense, the situation is not any different post-ANS: if you
>> want to depend on a colon definition pushing one item onto the return
>> stack you can still assume that.  ANS did not cause this trick to stop
>> working: it was descriptive rather than prescriptive.
>> 
>> > Here's an example of a routine that deserves to be as efficient as
>> > it looks.
>> > 
>> > : ?# ( ud -- ud )  #  2dup d0= if  r> drop  then ;
>> > 
>> > : #,S ( ud -- 0 0 )  begin ?#  ?#  ?#  [char] , hold  again ;
>> 
>> I hope that wouldn't pass review.
> 
> This is a very nice factored code!

It is, but it's so odd that I'd have to question whether the very
simple job it does justifies the oddness.

> What matter is idea behind code. User will modify  '?#'  definition
> accordingly with used Forth implementation, if necessary, or choose
> another Forth implementation.

: ?# ( ud -- ud' t )  #  2dup or ;
: #,S ( ud -- 0 0 )
   begin
      ?# while  ?# while  ?# while
      [char] , hold
   repeat  then then ;

So, not quite as cute, but it does the job.  And the reader can see
where the exits are.  What advantage did the return stack, er,
technique :-) bring you?

Andrew.

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


#59247

FromLars Brinkhoff <lars.spam@nocrew.org>
Date2017-05-15 07:11 +0200
Message-ID<86mvae66x4.fsf@molnjunk.nocrew.org>
In reply to#59233
Andrew Haley wrote:
>>>> : ?# ( ud -- ud )  #  2dup d0= if  r> drop  then ;
>>>> : #,S ( ud -- 0 0 )  begin ?#  ?#  ?#  [char] , hold  again ;
>>> 
>>> I hope that wouldn't pass review.
>
>> What matter is idea behind code. User will modify '?#' definition
>> accordingly with used Forth implementation, if necessary, or choose
>> another Forth implementation.
>
> : ?# ( ud -- ud' t )  #  2dup or ;
> : #,S ( ud -- 0 0 )
>    begin
>       ?# while  ?# while  ?# while
>       [char] , hold
>    repeat  then then ;
>
> So, not quite as cute, but it does the job.  And the reader can see
> where the exits are.  What advantage did the return stack, er,
> technique :-) bring you?

I'm reminded of Sam Falvo's 2010 article "The Declarative, Imperative,
then Inquisitive Pattern"

https://sam-falvo.github.io/2010/02/27/declarative-imperative-then-inquisitive

It does use return stack tricks quite heavily.

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


#59279

FromAndrew Haley <andrew29@littlepinkcloud.invalid>
Date2017-05-15 04:35 -0500
Message-ID<McudnW3gutfB64TEnZ2dnUU7-K_NnZ2d@supernews.com>
In reply to#59247
Lars Brinkhoff <lars.spam@nocrew.org> wrote:
> 
> I'm reminded of Sam Falvo's 2010 article "The Declarative, Imperative,
> then Inquisitive Pattern"
> 
> https://sam-falvo.github.io/2010/02/27/declarative-imperative-then-inquisitive
> 
> It does use return stack tricks quite heavily.

It does indeed.  I think it would be hard to follow and debug.  I'd
note that his examples can be written fairly easily without abnormal
exits by using quotations:

   : r-edge?   cx @ 79 = ;
   : -wrap     r-edge? if 0 cx !  -scroll 1 cy +!  r> drop then ;
   : bumped    -wrap   1 cx +! ;

(i.e. declare that we haven't wrapped then bump the cursor.)

could become
   
   : <r-edge ( - t)  cx @ 80 < ;
   : -wrapped ( xt)
      <r-edge if  execute  exit  then  drop
      0 cx !  -scroll 1 cy +! ;
   : bumped   [: 1 cx +! ;] -wrapped ;

(i.e. bump the cursor if we haven't wrapped.)

This is one of the reasons I like quotations: they provide a portable
way to do much of the stuff that otherwise would need return stack
manipulation.

Andrew.

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


#59289

FromJulian Fondren <julian.fondren@gmail.com>
Date2017-05-15 03:54 -0700
Message-ID<ffc0b8ac-d3c2-4884-9883-abcb325fd2ea@googlegroups.com>
In reply to#59279
On Monday, May 15, 2017 at 4:35:29 AM UTC-5, Andrew Haley wrote:
> It does indeed.  I think it would be hard to follow and debug.  I'd
> note that his examples can be written fairly easily without abnormal
> exits by using quotations:
> 
>    : r-edge?   cx @ 79 = ;
>    : -wrap     r-edge? if 0 cx !  -scroll 1 cy +!  r> drop then ;
>    : bumped    -wrap   1 cx +! ;
> 
> (i.e. declare that we haven't wrapped then bump the cursor.)
> 
> could become
>    
>    : <r-edge ( - t)  cx @ 80 < ;
>    : -wrapped ( xt)
>       <r-edge if  execute  exit  then  drop
>       0 cx !  -scroll 1 cy +! ;
>    : bumped   [: 1 cx +! ;] -wrapped ;
> 
> (i.e. bump the cursor if we haven't wrapped.)

Well -SCROLL is also a return-stack manipulating word, and one that
exits from BUMPED rather than its immediate caller of -WRAPPED

Putting that aside, with quotations you would need a level of nesting
for each -WRAP -tier word. Even with one level I already wonder if it
isn't too ugly. Would you actually write that code and use it?
Wouldn't you end up doing something like the following instead?

  : wrap? ( -- f )   cx @ 80 < ;
  : scroll? ( -- f ) cx @ 59 = ;
  : wrap  ( -- )     0 cx ! ;
  : bumped ( -- )
    wrap? if wrap scroll? if scrolledUp then exit then
    1 cx +! ;

> 
> This is one of the reasons I like quotations: they provide a portable
> way to do much of the stuff that otherwise would need return stack
> manipulation.
> 
> Andrew.

Anyway, and not just because I had an idea, let's benchmark it:

  variable cx
  variable cy
  
  : b-edge?   cy @ 59 = ;
  : -scroll   b-edge? if ( scrolled up ) r> r> 2drop then [ -opt ] ;
  : r-edge?   cx @ 79 = ;
  : -wrap     r-edge? if 0 cx !  -scroll 1 cy +!  r> drop then [ -opt ] ;
  : bumped1   -wrap   1 cx +! ;
  
  : wrap? ( -- f )   cx @ 80 < ;
  : scroll? ( -- f ) cx @ 59 = ;
  : wrap  ( -- )     0 cx ! ;
  : bumped2 ( -- )  
    wrap? if wrap scroll? if ( scrolled up ) then exit then
    1 cx +! ;
  
  needs -anons
  : <r-edge ( - t)  cx @ 80 < ;
  : -wrapped ( xt)
     <r-edge if execute  exit  then  drop
     0 cx !  -scroll 1 cy +! ;
  : bumped3  [: 1 cx +! ;] -wrapped [ -opt ] ;
  
  : exits: ( "word" -- )
    42 ' ]] literal catch dup literal = if drop exit else throw then [[ ;
  immediate
  : -scroll ( -- ) b-edge? if ( scrolled up ) 42 throw then ;
  : r-edge? ( -- f )  cx @ 79 = ;
  : -wrap ( -- ) r-edge? if 0 cx ! -scroll 1 cy +! 42 throw then ; 
  : bumped4 ( -- )  exits: -wrap
    1 cx +! ;
  
  : bench ( n -- )
    cr
    cr ." bumped1: " timer-reset dup 0 do bumped1 loop .elapsed
    cr ." bumped2: " timer-reset dup 0 do bumped2 loop .elapsed
    cr ." bumped3: " timer-reset dup 0 do bumped3 loop .elapsed
    cr ." bumped4: " timer-reset     0 do bumped4 loop .elapsed ;

With 5 million runs on my machine:

  bumped1: 0.011 seconds elapsed.
  bumped2: 0.009 seconds elapsed.
  bumped3: 0.027 seconds elapsed.
  bumped4: 0.070 seconds elapsed.
  
  bumped1: 0.011 seconds elapsed.
  bumped2: 0.009 seconds elapsed.
  bumped3: 0.027 seconds elapsed.
  bumped4: 0.070 seconds elapsed.
  
  bumped1: 0.011 seconds elapsed.
  bumped2: 0.009 seconds elapsed.
  bumped3: 0.026 seconds elapsed.
  bumped4: 0.069 seconds elapsed.

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


#59291

Frommhx@iae.nl
Date2017-05-15 04:07 -0700
Message-ID<ec2e475c-e5d9-4cbd-a82e-54c301810ffa@googlegroups.com>
In reply to#59289
On Monday, May 15, 2017 at 12:54:13 PM UTC+2, Julian Fondren wrote:
[..]
>   : wrap? ( -- f )   cx @ 80 < ;
>   : scroll? ( -- f ) cx @ 59 = ;
>   : wrap  ( -- )     0 cx ! ;
>   : bumped2 ( -- )
>     wrap? if wrap scroll? if ( scrolled up ) then exit then
>     1 cx +! ;
>   
[..] 
>   bumped1: 0.011 seconds elapsed.
>   bumped2: 0.009 seconds elapsed.
>   bumped3: 0.027 seconds elapsed.
>   bumped4: 0.070 seconds elapsed.

I'm glad to see the elegant one win the race!

-marcel

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


#59293

FromAndrew Haley <andrew29@littlepinkcloud.invalid>
Date2017-05-15 06:23 -0500
Message-ID<1fKdnQv9u-otEoTEnZ2dnUU7-dudnZ2d@supernews.com>
In reply to#59289
Julian Fondren <julian.fondren@gmail.com> wrote:
> On Monday, May 15, 2017 at 4:35:29 AM UTC-5, Andrew Haley wrote:
>> It does indeed.  I think it would be hard to follow and debug.  I'd
>> note that his examples can be written fairly easily without abnormal
>> exits by using quotations:
>> 
>>    : r-edge?   cx @ 79 = ;
>>    : -wrap     r-edge? if 0 cx !  -scroll 1 cy +!  r> drop then ;
>>    : bumped    -wrap   1 cx +! ;
>> 
>> (i.e. declare that we haven't wrapped then bump the cursor.)
>> 
>> could become
>>    
>>    : <r-edge ( - t)  cx @ 80 < ;
>>    : -wrapped ( xt)
>>       <r-edge if  execute  exit  then  drop
>>       0 cx !  -scroll 1 cy +! ;
>>    : bumped   [: 1 cx +! ;] -wrapped ;
>> 
>> (i.e. bump the cursor if we haven't wrapped.)
> 
> Well -SCROLL is also a return-stack manipulating word, and one that
> exits from BUMPED rather than its immediate caller of -WRAPPED
> 
> Putting that aside, with quotations you would need a level of nesting
> for each -WRAP -tier word. Even with one level I already wonder if it
> isn't too ugly. Would you actually write that code and use it?
> Wouldn't you end up doing something like the following instead?
> 
>  : wrap? ( -- f )   cx @ 80 < ;
>  : scroll? ( -- f ) cx @ 59 = ;
>  : wrap  ( -- )     0 cx ! ;
>  : bumped ( -- )
>    wrap? if wrap scroll? if scrolledUp then exit then
>    1 cx +! ;

Yeah, of course.  Simple and straighforward wins the day.  :-)

Andrew.

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


#59302

FromJulian Fondren <julian.fondren@gmail.com>
Date2017-05-15 06:53 -0700
Message-ID<e00d484f-2b7c-4693-b1fd-2d621c2aa652@googlegroups.com>
In reply to#59293
On Monday, May 15, 2017 at 6:07:09 AM UTC-5, m...@iae.nl wrote:
> [..] 
> >   bumped1: 0.011 seconds elapsed.
> >   bumped2: 0.009 seconds elapsed.
> >   bumped3: 0.027 seconds elapsed.
> >   bumped4: 0.070 seconds elapsed.
> 
> I'm glad to see the elegant one win the race!
> 
> -marcel

I made some mistakes in the winner's code, but fixing them doesn't
change the numbers any.

On Monday, May 15, 2017 at 6:23:34 AM UTC-5, Andrew Haley wrote:
> > Putting that aside, with quotations you would need a level of nesting
> > for each -WRAP -tier word. Even with one level I already wonder if it
> > isn't too ugly. Would you actually write that code and use it?
> > Wouldn't you end up doing something like the following instead?
> > 
> >  : wrap? ( -- f )   cx @ 80 < ;
> >  : scroll? ( -- f ) cx @ 59 = ;
> >  : wrap  ( -- )     0 cx ! ;
> >  : bumped ( -- )
> >    wrap? if wrap scroll? if scrolledUp then exit then
> >    1 cx +! ;
> 
> Yeah, of course.  Simple and straighforward wins the day.  :-)
> 
> Andrew.

The intended appeal of the return stack manipulation code is that
it's easier. "How do I bump? Putting exceptional cases aside, let's
just add 1 to CX". Probably you'd write BUMPED first and then fill in
the exceptions as they occur to you. There's one apparent path through
the definition, with an asterisk, whereas with the code above it's
clear that control flow depends on two tests giving you four potential
paths that you have to keep in mind. It would be even more
straightforward to number the paths:

  : bumped ( -- )
    wrap? 2 and scroll? 1 and or case
      3 of 0 cx !  scrolledUp endof
      2 of 0 cx !  1 cy +! endof
      1 of 1 cx +! endof
      0 of 1 cx +! endof
    endcase ;

The easiness claim is a difficult one to discuss, though.

With mostly pretend units:

  \ effort - style - performance - dissatisfaction (why sad?)
   50 - continuation - 16 - ???
  150 - quotation    - 27 - 30 (less ported; this use is harder to follow)
  100 - optimal      - 10 -  5 (can't have exceptions as a factor)
   50 - exhaustive   - 14 - 20 (CASE)

Where ??? depends on

- do you have to tell the optimizer about it?
- how concerned are you with porting such code?
- are you comfortable enough with it you've started giving
  presentations on return-stack manipulation design patterns? Or are
  you horrified by this unreadable hackish nonsense?
- has anyone told you this is good who doesn't clearly hate children
  and stack comments?

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


#59305

FromAndrew Haley <andrew29@littlepinkcloud.invalid>
Date2017-05-15 09:18 -0500
Message-ID<6NOdnestCoE6JYTEnZ2dnUU7-V_NnZ2d@supernews.com>
In reply to#59302
Julian Fondren <julian.fondren@gmail.com> wrote:
> On Monday, May 15, 2017 at 6:07:09 AM UTC-5, m...@iae.nl wrote:
>> [..] 
>> >   bumped1: 0.011 seconds elapsed.
>> >   bumped2: 0.009 seconds elapsed.
>> >   bumped3: 0.027 seconds elapsed.
>> >   bumped4: 0.070 seconds elapsed.
>> 
>> I'm glad to see the elegant one win the race!
> 
> I made some mistakes in the winner's code, but fixing them doesn't
> change the numbers any.
> 
> On Monday, May 15, 2017 at 6:23:34 AM UTC-5, Andrew Haley wrote:
>> > Putting that aside, with quotations you would need a level of nesting
>> > for each -WRAP -tier word. Even with one level I already wonder if it
>> > isn't too ugly. Would you actually write that code and use it?
>> > Wouldn't you end up doing something like the following instead?
>> > 
>> >  : wrap? ( -- f )   cx @ 80 < ;
>> >  : scroll? ( -- f ) cx @ 59 = ;
>> >  : wrap  ( -- )     0 cx ! ;
>> >  : bumped ( -- )
>> >    wrap? if wrap scroll? if scrolledUp then exit then
>> >    1 cx +! ;
>> 
>> Yeah, of course.  Simple and straighforward wins the day.  :-)
> 
> The intended appeal of the return stack manipulation code is that
> it's easier.

Perhaps, but even if so you're left with something that is harder to
debug than it was to write.

"Everyone knows that debugging is twice as hard as writing a program
in the first place. So if you're as clever as you can be when you
write it, how will you ever debug it?"

    Brian Kernighan, "The Elements of Programming Style"

And of course, in the cursor control example, it makes sense to handle
all of the edge cases together if possible.

The disagreement that I have is that the return stack manipulation
makes things easier.  One of the precious simplifying assumptions when
reading code is that (unless an exception is thrown) control comes
right back from a word you just called.  Without that, the maintenance
programmer (and most programmers do that most of the time) has much
less to get hold of.

> With mostly pretend units:
> 
>  \ effort - style - performance - dissatisfaction (why sad?)
>   50 - continuation - 16 - ???
>  150 - quotation    - 27 - 30 (less ported; this use is harder to follow)
>  100 - optimal      - 10 -  5 (can't have exceptions as a factor)
>   50 - exhaustive   - 14 - 20 (CASE)
> 
> Where ??? depends on
> 
> - do you have to tell the optimizer about it?
> - how concerned are you with porting such code?
> - are you comfortable enough with it you've started giving
>  presentations on return-stack manipulation design patterns? Or are
>  you horrified by this unreadable hackish nonsense?
> - has anyone told you this is good who doesn't clearly hate children
>  and stack comments?

I wouldn't have said that return stack manipulation was less effort
than the others.  Each to their own.

Andrew.

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


#59257

Fromhumptydumpty <ouatubi@gmail.com>
Date2017-05-14 22:44 -0700
Message-ID<09d30e76-18cc-4a30-bba2-1ffe6e586357@googlegroups.com>
In reply to#59233
On Monday, May 15, 2017 at 2:35:28 AM UTC+3, Andrew Haley wrote:
> humptydumpty wrote:
> > On Sunday, May 14, 2017 at 5:21:50 PM UTC+3, Andrew Haley wrote:
> >> HAA wrote:
> >> 
> >> > In the days when "return stack" meant return stack and threaded code
> >> > was the norm R> DROP is what you would use.  ANS precludes this,
> >> > forcing programmers to adopt inefficient solutions.
> >> 
> >> No.  That is not how it happened.  ANS did not preclude return stack
> >> hackery because it wasn't portable anyway.  Before the ANS process
> >> began, the number of return stack items pushed by a colon definition
> >> wasn't always 1.  And maybe you'd even be using a different stack for
> >> return addresses.
> > 
> > This is mind boggling! Was that Forth? What is the percentage
> > of such implementations from all Forth implementations?
> 
> Not huge, and I couldn't put a number on it.  But I have seen them.
> An 8086 far call pushed two cells onto the return stack, which was a
> good match for a 16-bit system with multiple segements.  There were
> also single-chip computers with very restricted stack space, but could
> run an OK Forth.  The desire to run Forth on these machines was
> justified, I think, and IMO more important than return stack tricks.

That I could understand: on 8086 push a pair segment:offset as a
return address, and have accordingly work on two items on return-stack.

What I do not understand is "And maybe you'd even be using a
different stack for return addresses." So there is a stack
(even not hardware) for returning addresses from a definition.
 What could prevent to discard a return address to skip return
to the caller?

> 
> >>  So maybe the R> DROP trick would work, maybe not.
> > 
> > But this is not a trick. Is applying knowledge that on return-stack
> > is the address of continuation(partial) of current definition caller.
> 
> One person's trick is another's technique, I suppose.

Having a quick look at how Scheme treats continuations,
I think there is more than a mere technique.

As Forth model has implicit parameters passing by data stack,
also has implicit continuations addresses passing on return stack.

Inlining or tail call optimzation are special cases and should
be treated accordingly.

> 
> >> In that sense, the situation is not any different post-ANS: if you
> >> want to depend on a colon definition pushing one item onto the return
> >> stack you can still assume that.  ANS did not cause this trick to stop
> >> working: it was descriptive rather than prescriptive.
> >> 
> >> > Here's an example of a routine that deserves to be as efficient as
> >> > it looks.
> >> > 
> >> > : ?# ( ud -- ud )  #  2dup d0= if  r> drop  then ;
> >> > 
> >> > : #,S ( ud -- 0 0 )  begin ?#  ?#  ?#  [char] , hold  again ;
> >> 
> >> I hope that wouldn't pass review.
> > 
> > This is a very nice factored code!
> 
> It is, but it's so odd that I'd have to question whether the very
> simple job it does justifies the oddness.
> 
> > What matter is idea behind code. User will modify  '?#'  definition
> > accordingly with used Forth implementation, if necessary, or choose
> > another Forth implementation.
> 
> : ?# ( ud -- ud' t )  #  2dup or ;
> : #,S ( ud -- 0 0 )
>    begin
>       ?# while  ?# while  ?# while
>       [char] , hold
>    repeat  then then ;
> 
> So, not quite as cute, but it does the job.  And the reader can see
> where the exits are.  What advantage did the return stack, er,
> technique :-) bring you?

Maybe compiled code size ?

> 
> Andrew.

--
Have a nice day,
hum9

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


#59276

FromAndrew Haley <andrew29@littlepinkcloud.invalid>
Date2017-05-15 04:16 -0500
Message-ID<QNadnSTCY7587ITEnZ2dnUU7-IWdnZ2d@supernews.com>
In reply to#59257
humptydumpty <ouatubi@gmail.com> wrote:
> 
> That I could understand: on 8086 push a pair segment:offset as a
> return address, and have accordingly work on two items on return-stack.
> 
> What I do not understand is "And maybe you'd even be using a
> different stack for return addresses." So there is a stack
> (even not hardware) for returning addresses from a definition.
> What could prevent to discard a return address to skip return
> to the caller?

The return stack is internal to the processor, in internal RAM.  The
stack used by >R and R is in external memory.  So you have three
stacks, the hardware return stack being the third one.

> Having a quick look at how Scheme treats continuations,
> I think there is more than a mere technique.

I don't think that you can glorify return stack hackery in this way.
It's far less useful than continuations.  Real continuations would be
quite interesting.

>> > What matter is idea behind code. User will modify  '?#'  definition
>> > accordingly with used Forth implementation, if necessary, or choose
>> > another Forth implementation.
>> 
>> : ?# ( ud -- ud' t )  #  2dup or ;
>> : #,S ( ud -- 0 0 )
>>    begin
>>       ?# while  ?# while  ?# while
>>       [char] , hold
>>    repeat  then then ;
>> 
>> So, not quite as cute, but it does the job.  And the reader can see
>> where the exits are.  What advantage did the return stack, er,
>> technique :-) bring you?
> 
> Maybe compiled code size ?

Maybe, but it depends on the exact Forth.  I'd guess it's insignificant.

Andrew.

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


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

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


csiph-web