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


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

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

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

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


Contents

  How do quotation work, I can not foound them in 20xx Tessa Bonting <tessa.bonting@gmail.com> - 2015-07-12 06:48 -0700
    Re: How do quotation work, I can not foound them in 20xx anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-12 15:10 +0000
      Re: How do quotation work, I can not foound them in 20xx Tessa Bonting <tessa.bonting@gmail.com> - 2015-07-12 08:47 -0700
      Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-13 01:15 -0700
        Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-13 01:20 -0700
          Re: How do quotation work, I can not foound them in 20xx Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-13 01:30 -0700
            Re: How do quotation work, I can not foound them in 20xx Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-13 01:33 -0700
        Re: How do quotation work, I can not foound them in 20xx Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-13 01:28 -0700
    Re: How do quotation work, I can not foound them in 20xx Julian Fondren <julian.fondren@gmail.com> - 2015-07-12 08:23 -0700
      Re: How do quotation work, I can not foound them in 20xx Coos Haak <chforth@hccnet.nl> - 2015-07-12 18:56 +0200
        Re: How do quotation work, I can not foound them in 20xx Julian Fondren <julian.fondren@gmail.com> - 2015-07-13 20:24 -0700
          Re: How do quotation work, I can not foound them in 20xx Coos Haak <chforth@hccnet.nl> - 2015-07-14 09:43 +0200
      Re: How do quotation work, I can not foound them in 20xx "HAA" <someone@microsoft.com> - 2015-07-18 14:18 +1000
        Re: How do quotation work, I can not foound them in 20xx "HAA" <someone@microsoft.com> - 2015-08-01 12:46 +1000
          Re: How do quotation work, I can not foound them in 20xx mhx@iae.nl - 2015-08-01 00:52 -0700
            Re: How do quotation work, I can not foound them in 20xx "HAA" <someone@microsoft.com> - 2015-08-02 18:16 +1000
              Re: How do quotation work, I can not foound them in 20xx mhx@iae.nl - 2015-08-02 02:18 -0700
                Re: How do quotation work, I can not foound them in 20xx "HAA" <someone@microsoft.com> - 2015-08-05 13:35 +1000
          Re: How do quotation work, I can not foound them in 20xx Bernd Paysan <bernd.paysan@gmx.de> - 2015-08-01 21:37 +0200
            Re: How do quotation work, I can not foound them in 20xx JennyB <jennybrien@googlemail.com> - 2015-08-05 06:00 -0700
              Re: How do quotation work, I can not foound them in 20xx anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-08-05 13:16 +0000
                Re: How do quotation work, I can not foound them in 20xx JennyB <jennybrien@googlemail.com> - 2015-08-05 09:40 -0700
                  Re: How do quotation work, I can not foound them in 20xx anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-08-06 14:34 +0000
                    Re: How do quotation work, I can not foound them in 20xx JennyB <jennybrien@googlemail.com> - 2015-08-07 00:33 -0700
                    Re: How do quotation work, I can not foound them in 20xx "HAA" <someone@microsoft.com> - 2015-08-15 12:37 +1000
                      Re: How do quotation work, I can not foound them in 20xx Bernd Paysan <bernd.paysan@gmx.de> - 2015-08-15 13:53 +0200
                        Re: How do quotation work, I can not foound them in 20xx "HAA" <someone@microsoft.com> - 2015-08-16 12:53 +1000
                  Re: How do quotation work, I can not foound them in 20xx "HAA" <someone@microsoft.com> - 2015-08-08 13:06 +1000
                  Re: How do quotation work, I can not foound them in 20xx "WJ" <w_a_x_man@yahoo.com> - 2015-09-15 03:23 +0000
    Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-12 14:55 -0700
      Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-13 12:53 +0100
        Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-13 06:13 -0700
          Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-13 16:00 +0100
            Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-13 09:12 -0700
            Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-13 09:26 -0700
          Re: How do quotation work, I can not foound them in 20xx Coos Haak <chforth@hccnet.nl> - 2015-07-13 17:00 +0200
            Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-13 16:58 +0100
              Re: How do quotation work, I can not foound them in 20xx Coos Haak <chforth@hccnet.nl> - 2015-07-13 20:53 +0200
          Re: How do quotation work, I can not foound them in 20xx bettilyona@gmail.com - 2015-07-13 09:13 -0700
            Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-13 09:15 -0700
          Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-13 13:10 -0700
            Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-13 14:24 -0700
              Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-13 18:51 -0700
                Re: How do quotation work, I can not foound them in 20xx Julian Fondren <julian.fondren@gmail.com> - 2015-07-13 20:19 -0700
                  Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-13 20:49 -0700
                    Re: How do quotation work, I can not foound them in 20xx Julian Fondren <julian.fondren@gmail.com> - 2015-07-13 21:48 -0700
                    Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-14 09:38 +0100
                  Re: How do quotation work, I can not foound them in 20xx Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-13 21:44 -0700
                    Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-13 21:53 -0700
                    Re: How do quotation work, I can not foound them in 20xx Julian Fondren <julian.fondren@gmail.com> - 2015-07-13 22:04 -0700
                Re: How do quotation work, I can not foound them in 20xx humptydumpty <ouatubi@gmail.com> - 2015-07-14 01:22 -0700
                  Re: How do quotation work, I can not foound them in 20xx humptydumpty <ouatubi@gmail.com> - 2015-07-14 01:47 -0700
                  Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-14 09:56 -0700
                    Re: How do quotation work, I can not foound them in 20xx Julian Fondren <julian.fondren@gmail.com> - 2015-07-14 10:45 -0700
                    Re: How do quotation work, I can not foound them in 20xx humptydumpty <ouatubi@gmail.com> - 2015-07-14 11:10 -0700
                Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-14 09:35 +0100
                  Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-14 02:17 -0700
                    Re: How do quotation work, I can not foound them in 20xx humptydumpty <ouatubi@gmail.com> - 2015-07-14 02:24 -0700
                Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-14 02:25 -0700
                  Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-14 09:32 -0700
                    Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-14 17:50 +0100
                      Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-14 10:48 -0700
                        Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-14 18:59 +0100
                          Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-14 20:49 +0100
                            Re: How do quotation work, I can not foound them in 20xx "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-15 00:52 -0400
                              Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-15 12:09 +0100
                                Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-15 04:19 -0700
                                  Re: How do quotation work, I can not foound them in 20xx "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-15 22:10 -0400
                                    Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-16 00:42 -0700
                                      Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-16 14:29 +0100
                                        Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-16 12:52 -0700
                                    Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-16 09:59 +0100
                                Re: How do quotation work, I can not foound them in 20xx Mike Mellen <mmellen@intellikey.com> - 2015-07-15 07:56 -0400
                                  Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-15 16:27 +0100
                              Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-15 10:47 -0700
                                Re: How do quotation work, I can not foound them in 20xx "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-15 21:50 -0400
                              Re: How do quotation work, I can not foound them in 20xx stephen@mpeforth.com (Stephen Pelc) - 2015-07-15 19:38 +0000
                                Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-15 12:58 -0700
                                Re: How do quotation work, I can not foound them in 20xx "Rod Pemberton" <boo@fasdfrewar.cdm> - 2015-07-15 22:20 -0400
                    Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-14 09:53 -0700
                      Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-14 10:12 -0700
                        Re: How do quotation work, I can not foound them in 20xx Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-14 10:53 -0700
                          Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-14 20:06 +0100
                            Re: How do quotation work, I can not foound them in 20xx Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-14 12:18 -0700
                              Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-14 20:52 +0100
                                Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-14 13:39 -0700
                                  Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-14 22:20 +0100
                                Re: How do quotation work, I can not foound them in 20xx Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-14 21:10 -0700
                                  Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-15 12:03 +0100
                                    Re: How do quotation work, I can not foound them in 20xx Coos Haak <chforth@hccnet.nl> - 2015-07-15 14:16 +0200
                                    Re: How do quotation work, I can not foound them in 20xx Coos Haak <chforth@hccnet.nl> - 2015-07-15 14:04 +0200
                                      Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-15 15:44 +0100
                                        Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-15 15:47 +0100
                                        Re: How do quotation work, I can not foound them in 20xx anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-15 15:26 +0000
                                          Re: How do quotation work, I can not foound them in 20xx JennyB <jennybrien@googlemail.com> - 2015-07-16 05:41 -0700
                                            Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-16 14:13 +0100
                          Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-14 14:18 -0700
                          Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-15 02:42 -0700
                        Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-15 01:26 -0700
                          Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-15 10:44 -0700
                            Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-15 19:31 +0100
                              Re: How do quotation work, I can not foound them in 20xx Paul Rubin <no.email@nospam.invalid> - 2015-07-15 11:48 -0700
                                Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-15 12:13 -0700
                                Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-15 20:18 +0100
                        Re: How do quotation work, I can not foound them in 20xx "WJ" <w_a_x_man@yahoo.com> - 2015-07-22 11:11 +0000
                      Re: How do quotation work, I can not foound them in 20xx Håkan Thörngren <hth313@gmail.com> - 2015-07-14 11:38 -0700
                        Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-14 19:58 +0100
                        Re: How do quotation work, I can not foound them in 20xx anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-15 05:55 +0000
                          Re: How do quotation work, I can not foound them in 20xx Håkan Thörngren <hth313@gmail.com> - 2015-07-15 00:03 -0700
                        Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-15 01:41 -0700
              Re: How do quotation work, I can not foound them in 20xx Paul Rubin <no.email@nospam.invalid> - 2015-07-13 22:05 -0700
            Re: How do quotation work, I can not foound them in 20xx Mark Wills <markwills1970@gmail.com> - 2015-07-13 14:24 -0700
              Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-13 23:13 +0100
                Re: How do quotation work, I can not foound them in 20xx "Elizabeth D. Rather" <erather@forth.com> - 2015-07-13 13:03 -1000
                  Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-14 09:31 +0100
                  Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-15 13:24 -0700
                    Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-15 22:04 +0100
            Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-13 22:52 +0100
          Re: How do quotation work, I can not foound them in 20xx hughaguilar96@gmail.com - 2015-07-13 13:12 -0700
          Re: How do lambdas work, I cannot find them in 20xx "WJ" <w_a_x_man@yahoo.com> - 2016-07-11 23:02 +0000
            Re: How do lambdas work, I cannot find them in 20xx "WJ" <w_a_x_man@yahoo.com> - 2016-07-12 02:56 +0000
        Re: How do quotation work, I can not foound them in 20xx stephen@mpeforth.com (Stephen Pelc) - 2015-07-13 13:16 +0000
        Re: How do quotation work, I can not foound them in 20xx anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-13 16:00 +0000
          Re: How do quotation work, I can not foound them in 20xx "Alex McDonald" <blog@rivadpm.com> - 2015-07-13 17:58 +0100
    Re: How do quotation work, I can not foound them in 20xx Steve Graham <solitary.wanderer52@gmail.com> - 2015-08-06 09:54 -0700
      Re: How do quotation work, I can not foound them in 20xx Coos Haak <chforth@hccnet.nl> - 2015-08-06 21:19 +0200

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


#41129

Fromanton@mips.complang.tuwien.ac.at (Anton Ertl)
Date2015-08-05 13:16 +0000
Message-ID<2015Aug5.151642@mips.complang.tuwien.ac.at>
In reply to#41128
JennyB <jennybrien@googlemail.com> writes:
>  DOER SPEECH
>  : ALTERNATE
>      BEGIN 
>       MAKE SPEECH ." HELLO "
>       MAKE SPEECH ." GOODBYE "
>      O UNTIL ;
>
>... that's tricky. ALTERNATE has to toggle the action of SPEECH each time it is called. 
>        
>That looks like a job for a CREATE ... DOES>:
>
> : CUES \ n*xt n /name/ -- store n xts
>   CREATE 0 , (index) DUP , (limit) 0 DO , LOOP
>   DOES>  \ execute indexed xt, bump index
>          DUP @ >R  \ save index
>          DUP 2@ SWAP MOD OVER ! \ increment index
>          >R 2+ CELLS + @ EXECUTE ;
>
>DEFER SPEECH
>  :NONAME [: ." GOODBYE" ;] IS SPEECH ;
>  :NONAME [: ." HELLO" ;] IS SPEECH  ;
>  2 CUES ALTERNATE

Appears overly complicated to me.  Maybe something like that:

defer speech
defer hello
defer goodbye
:noname ." hello" ['] goodbye is speech ; is hello
:noname ." goodbye" ['] hello is speech ; is goodbye
' hello is speech

Hmm, this misses ALTERNATE.  Is that doing anything useful?

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: http://www.forth200x.org/forth200x.html
   EuroForth 2015: http://www.mpeforth.com/euroforth2015/euroforth2015.htm

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


#41132

FromJennyB <jennybrien@googlemail.com>
Date2015-08-05 09:40 -0700
Message-ID<e5bd1ce6-3cfc-4bff-82e7-9e23f4e71dec@googlegroups.com>
In reply to#41129
On Wednesday, 5 August 2015 14:22:58 UTC+1, Anton Ertl  wrote:

> Appears overly complicated to me.  Maybe something like that:
> 
> defer speech
> defer hello
> defer goodbye
> :noname ." hello" ['] goodbye is speech ; is hello
> :noname ." goodbye" ['] hello is speech ; is goodbye
> ' hello is speech
> 
> Hmm, this misses ALTERNATE.  Is that doing anything useful?
> 
I should have been a bit clearer; ALTERNATE toggles the action of SPEECH each time ALTERNATE is called
Thus:

alternate 
speech HELLO
...
speech HELLO
alternate 
speech GOODBYE
...
speech GOODBYE
alternate 
speech HELLO

So

Defer Speech
Defer Alternate
Defer Goodbye

: Hello [: ." Hello" ;] IS Speech   ['] Goodbye IS Alternate ; 
' Hello IS Alternate
:NONAME [: ."Goodbye" ;] IS Speech  ['] Hello IS Alternate ; IS Goodbye

Clearer?

Let's try Brodie's Toddler example:

( TODDLER: Example of DOER/MAKE 12/01/83 )
 DOER ANSWER
 : RECITAL
 CR ." Your daddy is standing on the table. Ask him 'WHY?' "
 MAKE ANSWER ." To change the light bulb."
 BEGIN
 MAKE ANSWER ." Because it's burned out."
 MAKE ANSWER ." Because it was old."
 MAKE ANSWER ." Because we put it in there a long time ago."
 MAKE ANSWER ." Because it was dark!"
 MAKE ANSWER ." Because it was night time!!"
 MAKE ANSWER ." Stop saying WHY?"
 MAKE ANSWER ." Because it's driving me crazy."
 MAKE ANSWER ." Just let me change this light bulb!"
 FALSE UNTIL ;
 : WHY? CR ANSWER QUIT ;

DEFER ANSWER
DEFER NOTAGAIN!

: THAT \ /name/ -- set deferred word to the action it had at compile time
  ' DUP DEFER@ POSTPONE LITERAL POSTPONE LITERAL POSTPONE DEFER! ; IMMEDIATE

 :NONAME ." Just let me change this light bulb!" NOTAGAIN! ; IS ANSWER
 :NONAME ." Because it's driving me crazy." THAT ANSWER ; IS ANSWER
 :NONAME ." Stop saying WHY?" THAT ANSWER ; IS ANSWER
 :NONAME ." Because it was night time!!" THAT ANSWER ; IS ANSWER
 :NONAME ." Because it was dark!" THAT ANSWER ; IS ANSWER
 :NONAME ." Because we put it in there a long time ago." THAT ANSWER ; 
  IS ANSWER
 :NONAME ." Because it was old." THAT ANSWER ; IS ANSWER
 :NONAME ." Because it's burned out." THAT ANSWER ; IS ANSWER
 ' ANSWER IS NOTAGAIN! 

: RECITAL
 CR ." Your daddy is standing on the table. Ask him 'WHY?' "  
 [: ."To change the light bulb" THAT ANSWER ;] IS ANSWER ;

: WHY?  CR ANSWER ;

Or using Cues (now indexing the other away, executing the first command in the list first.)

DEFER WHY?

  :NONAME ." Because it's burned out." ;
  :NONAME ." Because it was old." ;
  :NONAME ." Because we put it in there a long time ago." ;
  :NONAME ." Because it was dark!" ;
  :NONAME ." Because it was night time!!" ;
  :NONAME ." Stop saying WHY?" ;
  :NONAME ." Because it's driving me crazy." ;
  :NONAME ." Just let me change this light bulb!" ;
  8 Cues ANSWER

: RECITAL
 CR ." Your daddy is standing on the table. Ask him 'WHY?' "  
 [: CR ."To change the light bulb" 
    [: CR ANSWER ;] IS WHY? ;] IS WHY? ;

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


#41146

Fromanton@mips.complang.tuwien.ac.at (Anton Ertl)
Date2015-08-06 14:34 +0000
Message-ID<2015Aug6.163444@mips.complang.tuwien.ac.at>
In reply to#41132
JennyB <jennybrien@googlemail.com> writes:
>On Wednesday, 5 August 2015 14:22:58 UTC+1, Anton Ertl  wrote:
>
>> Appears overly complicated to me.  Maybe something like that:
>> 
>> defer speech
>> defer hello
>> defer goodbye
>> :noname ." hello" ['] goodbye is speech ; is hello
>> :noname ." goodbye" ['] hello is speech ; is goodbye
>> ' hello is speech
>> 
>> Hmm, this misses ALTERNATE.  Is that doing anything useful?
>> 
>I should have been a bit clearer; ALTERNATE toggles the action of SPEECH each time ALTERNATE is called
>Thus:
>
>alternate 
>speech HELLO
>...
>speech HELLO
>alternate 
>speech GOODBYE
>...
>speech GOODBYE
>alternate 
>speech HELLO
>
>So
>
>Defer Speech
>Defer Alternate
>Defer Goodbye
>
>: Hello [: ." Hello" ;] IS Speech   ['] Goodbye IS Alternate ; 
>' Hello IS Alternate
>:NONAME [: ."Goodbye" ;] IS Speech  ['] Hello IS Alternate ; IS Goodbye
>
>Clearer?

I find the different time levels hard to follow.  I'll try something
else:

defer speech
: hello ." hello" ;
' hello is speech
: alternate [: ." goodbye" ;] ['] hello + action-of speech - is speech ;

The first ALTERNATE in the input above is unnecessary with this
version, but if you insist on that, you can define it as:

defer speech
: goodbye ." goodbye" ;
' goodbye is speech
: alternate [: ." hello" ;] ['] goodbye + action-of speech - is speech ;

The trick of using + and - (or alternatively, XOR and XOR) to
alternate between two cells may be hard to follow, but the timing
levels are simpler in this version.

>Let's try Brodie's Toddler example:
>
>( TODDLER: Example of DOER/MAKE 12/01/83 )
> DOER ANSWER
> : RECITAL
> CR ." Your daddy is standing on the table. Ask him 'WHY?' "
> MAKE ANSWER ." To change the light bulb."
> BEGIN
> MAKE ANSWER ." Because it's burned out."
> MAKE ANSWER ." Because it was old."
> MAKE ANSWER ." Because we put it in there a long time ago."
> MAKE ANSWER ." Because it was dark!"
> MAKE ANSWER ." Because it was night time!!"
> MAKE ANSWER ." Stop saying WHY?"
> MAKE ANSWER ." Because it's driving me crazy."
> MAKE ANSWER ." Just let me change this light bulb!"
> FALSE UNTIL ;
> : WHY? CR ANSWER QUIT ;
...
>: RECITAL
> CR ." Your daddy is standing on the table. Ask him 'WHY?' "  
> [: CR ."To change the light bulb" 
>    [: CR ANSWER ;] IS WHY? ;] IS WHY? ;

That sounds right:

defer why?
: recital
  CR ." Your daddy is standing on the table. Ask him 'WHY?' "
  [: ." To change the light bulb." 
   [: ." Because it's burned out."
    [: ." Because it was old."
     [: ." Because we put it in there a long time ago."
      [: ." Because it was dark!"
       [: ." Because it was night time!!"
        [: ." Stop saying WHY?"
         [: ." Because it's driving me crazy."
          [: ." Just let me change this light bulb!"
          ;] is why?
         ;] is why?
        ;] is why?
       ;] is why?
      ;] is why?
     ;] is why?
    ;] is why?
   ;] is why?
  ;] is why? ;

I guess we can wrap it in a BEGIN AGAIN loop if you want it to start
again instead of giving the last answer again and again.

Are there any useful application for this stuff?

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: http://www.forth200x.org/forth200x.html
   EuroForth 2015: http://www.mpeforth.com/euroforth2015/euroforth2015.htm

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


#41151

FromJennyB <jennybrien@googlemail.com>
Date2015-08-07 00:33 -0700
Message-ID<6b33a8a2-4cd8-49c8-b3f8-4242607b8bd7@googlegroups.com>
In reply to#41146
On Thursday, 6 August 2015 15:58:05 UTC+1, Anton Ertl  wrote:

> I find the different time levels hard to follow.  I'll try something
> else:
> 
> defer speech
> : hello ." hello" ;
> ' hello is speech
> : alternate [: ." goodbye" ;] ['] hello + action-of speech - is speech ;
> 
> The first ALTERNATE in the input above is unnecessary with this
> version, but if you insist on that, you can define it as:
> 
> defer speech
> : goodbye ." goodbye" ;
> ' goodbye is speech
> : alternate [: ." hello" ;] ['] goodbye + action-of speech - is speech ;
> 
> The trick of using + and - (or alternatively, XOR and XOR) to
> alternate between two cells may be hard to follow, but the timing
> levels are simpler in this version.

That's very neat. A good example of exploiting Forth lack of type enforcement.
> 

> Are there any useful application for this stuff?
> 

Probably purely recreational. :)

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


#41318

From"HAA" <someone@microsoft.com>
Date2015-08-15 12:37 +1000
Message-ID<mqm8i5$s9d$1@speranza.aioe.org>
In reply to#41146
Anton Ertl wrote:
> ...
> defer why?
> : recital
>   CR ." Your daddy is standing on the table. Ask him 'WHY?' "
>   [: ." To change the light bulb."
>    [: ." Because it's burned out."
>     [: ." Because it was old."
>      [: ." Because we put it in there a long time ago."
>       [: ." Because it was dark!"
>        [: ." Because it was night time!!"
>         [: ." Stop saying WHY?"
>          [: ." Because it's driving me crazy."
>           [: ." Just let me change this light bulb!"
>           ;] is why?
>          ;] is why?
>         ;] is why?
>        ;] is why?
>       ;] is why?
>      ;] is why?
>     ;] is why?
>    ;] is why?
>   ;] is why? ;
>
> I guess we can wrap it in a BEGIN AGAIN loop if you want it to start
> again instead of giving the last answer again and again.

The loop has to span quotations which rules out using BEGIN AGAIN
for most systems.  An alternative strategy is given below.

variable restart

defer answer

: recital
  cr ." Your daddy is standing on the table. Ask him 'WHY?' "
  [: ." To change the light bulb."
   [: ." Because it's burned out."
    [: ." Because it was old."
     [: ." Because we put it in there a long time ago."
      [: ." Because it was dark!"
       [: ." Because it was night time!!"
        [: ." Stop saying WHY?"
         [: ." Because it's driving me crazy."
          [: ." Just let me change this light bulb!"
          ;] is answer  restart @ is answer
         ;] is answer
        ;] is answer
       ;] is answer
      ;] is answer
     ;] is answer
    ;] is answer
   ;] dup restart !  is answer
  ;] is answer ;

: why? cr answer quit ;



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


#41319

FromBernd Paysan <bernd.paysan@gmx.de>
Date2015-08-15 13:53 +0200
Message-ID<mqn951$oo9$1@dont-email.me>
In reply to#41318
HAA wrote:
> The loop has to span quotations which rules out using BEGIN AGAIN
> for most systems.  An alternative strategy is given below.
> 
> variable restart
> 
> defer answer
> 
> : recital
>   cr ." Your daddy is standing on the table. Ask him 'WHY?' "
>   [: ." To change the light bulb."
>    [: ." Because it's burned out."
>     [: ." Because it was old."
>      [: ." Because we put it in there a long time ago."
>       [: ." Because it was dark!"
>        [: ." Because it was night time!!"
>         [: ." Stop saying WHY?"
>          [: ." Because it's driving me crazy."
>           [: ." Just let me change this light bulb!"
>           ;] is answer  restart @ is answer

Almost.  Should be
             restart @ is answer ;] is answer

in this line.  You restart after saying "just let me change this light 
bulb".

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

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


#41325

From"HAA" <someone@microsoft.com>
Date2015-08-16 12:53 +1000
Message-ID<mqotuo$apt$1@speranza.aioe.org>
In reply to#41319
Bernd Paysan wrote:
> HAA wrote:
> > The loop has to span quotations which rules out using BEGIN AGAIN
> > for most systems.  An alternative strategy is given below.
> >
> > variable restart
> >
> > defer answer
> >
> > : recital
> >   cr ." Your daddy is standing on the table. Ask him 'WHY?' "
> >   [: ." To change the light bulb."
> >    [: ." Because it's burned out."
> >     [: ." Because it was old."
> >      [: ." Because we put it in there a long time ago."
> >       [: ." Because it was dark!"
> >        [: ." Because it was night time!!"
> >         [: ." Stop saying WHY?"
> >          [: ." Because it's driving me crazy."
> >           [: ." Just let me change this light bulb!"
> >           ;] is answer  restart @ is answer
>
> Almost.  Should be
>              restart @ is answer ;] is answer
>
> in this line.  You restart after saying "just let me change this light
> bulb".

Yes.  Thanks for spotting it.

> >          ;] is answer
> >         ;] is answer
> >        ;] is answer
> >       ;] is answer
> >      ;] is answer
> >     ;] is answer
> >    ;] dup restart !  is answer
> >   ;] is answer ;
> >
> > : why? cr answer quit ;


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


#41186

From"HAA" <someone@microsoft.com>
Date2015-08-08 13:06 +1000
Message-ID<mq3rl2$1k3$1@speranza.aioe.org>
In reply to#41132
JennyB wrote:
>
> Let's try Brodie's Toddler example:
>
> ( TODDLER: Example of DOER/MAKE 12/01/83 )
>  DOER ANSWER
>  : RECITAL
>  CR ." Your daddy is standing on the table. Ask him 'WHY?' "
>  MAKE ANSWER ." To change the light bulb."
>  BEGIN
>  MAKE ANSWER ." Because it's burned out."
>  MAKE ANSWER ." Because it was old."
>  MAKE ANSWER ." Because we put it in there a long time ago."
>  MAKE ANSWER ." Because it was dark!"
>  MAKE ANSWER ." Because it was night time!!"
>  MAKE ANSWER ." Stop saying WHY?"
>  MAKE ANSWER ." Because it's driving me crazy."
>  MAKE ANSWER ." Just let me change this light bulb!"
>  FALSE UNTIL ;
>  : WHY? CR ANSWER QUIT ;

Cheap and simple.  Fussy systems may require some ALIGNs.

    : s,"  postpone s"  here over 1+ allot place ;

    variable ptr  here ptr !

    here cell+ ,  s," To change the light bulb."
    here cell+ ,  here ( *)  s," Because it's burned out."
    here cell+ ,  s," Because it was old."
    here cell+ ,  s," Because we put it in there a long time ago."
    here cell+ ,  s," Because it was dark!"
    here cell+ ,  s," Because it was night time!!"
    here cell+ ,  s," Stop saying WHY?"
    here cell+ ,  s," Because it's driving me crazy."
    here cell+ ,  s," Just let me change this light bulb!"
          ( *) ,

    : WHY?  ptr @ @ count 2dup + ptr ! cr type ;

    : RECITAL
      CR ." Your daddy is standing on the table. Ask him 'WHY?' " ;



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


#42009

From"WJ" <w_a_x_man@yahoo.com>
Date2015-09-15 03:23 +0000
Message-ID<mt82ut$1jo$1@dont-email.me>
In reply to#41132
JennyB wrote:

> On Wednesday, 5 August 2015 14:22:58 UTC+1, Anton Ertl  wrote:
> 
> > Appears overly complicated to me.  Maybe something like that:
> > 
> > defer speech
> > defer hello
> > defer goodbye
> > :noname ." hello" ['] goodbye is speech ; is hello
> > :noname ." goodbye" ['] hello is speech ; is goodbye
> > ' hello is speech
> > 
> > Hmm, this misses ALTERNATE.  Is that doing anything useful?
> > 
> I should have been a bit clearer; ALTERNATE toggles the action of SPEECH each time ALTERNATE is called
> Thus:
> 
> alternate 
> speech HELLO
> ...
> speech HELLO
> alternate 
> speech GOODBYE
> ...
> speech GOODBYE
> alternate 
> speech HELLO
> 
> So
> 
> Defer Speech
> Defer Alternate
> Defer Goodbye
> 
> : Hello [: ." Hello" ;] IS Speech   ['] Goodbye IS Alternate ; 
> ' Hello IS Alternate
> :NONAME [: ."Goodbye" ;] IS Speech  ['] Hello IS Alternate ; IS Goodbye
> 
> Clearer?
> 
> Let's try Brodie's Toddler example:
> 
> ( TODDLER: Example of DOER/MAKE 12/01/83 )
>  DOER ANSWER
>  : RECITAL
>  CR ." Your daddy is standing on the table. Ask him 'WHY?' "
>  MAKE ANSWER ." To change the light bulb."
>  BEGIN
>  MAKE ANSWER ." Because it's burned out."
>  MAKE ANSWER ." Because it was old."
>  MAKE ANSWER ." Because we put it in there a long time ago."
>  MAKE ANSWER ." Because it was dark!"
>  MAKE ANSWER ." Because it was night time!!"
>  MAKE ANSWER ." Stop saying WHY?"
>  MAKE ANSWER ." Because it's driving me crazy."
>  MAKE ANSWER ." Just let me change this light bulb!"
>  FALSE UNTIL ;
>  : WHY? CR ANSWER QUIT ;
> 
> DEFER ANSWER
> DEFER NOTAGAIN!
> 
> : THAT \ name -- set deferred word to the action it had at compile time
>   ' DUP DEFER@ POSTPONE LITERAL POSTPONE LITERAL POSTPONE DEFER! ; IMMEDIATE
> 
>  :NONAME ." Just let me change this light bulb!" NOTAGAIN! ; IS ANSWER
>  :NONAME ." Because it's driving me crazy." THAT ANSWER ; IS ANSWER
>  :NONAME ." Stop saying WHY?" THAT ANSWER ; IS ANSWER
>  :NONAME ." Because it was night time!!" THAT ANSWER ; IS ANSWER
>  :NONAME ." Because it was dark!" THAT ANSWER ; IS ANSWER
>  :NONAME ." Because we put it in there a long time ago." THAT ANSWER ; 
>   IS ANSWER
>  :NONAME ." Because it was old." THAT ANSWER ; IS ANSWER
>  :NONAME ." Because it's burned out." THAT ANSWER ; IS ANSWER
>  ' ANSWER IS NOTAGAIN! 
> 
> : RECITAL
>  CR ." Your daddy is standing on the table. Ask him 'WHY?' "  
>  [: ."To change the light bulb" THAT ANSWER ;] IS ANSWER ;
> 
> : WHY?  CR ANSWER ;
> 
> Or using Cues (now indexing the other away, executing the first command in the list first.)
> 
> DEFER WHY?
> 
>   :NONAME ." Because it's burned out." ;
>   :NONAME ." Because it was old." ;
>   :NONAME ." Because we put it in there a long time ago." ;
>   :NONAME ." Because it was dark!" ;
>   :NONAME ." Because it was night time!!" ;
>   :NONAME ." Stop saying WHY?" ;
>   :NONAME ." Because it's driving me crazy." ;
>   :NONAME ." Just let me change this light bulb!" ;
>   8 Cues ANSWER
> 
> : RECITAL
>  CR ." Your daddy is standing on the table. Ask him 'WHY?' "  
>  [: CR ."To change the light bulb" 
>     [: CR ANSWER ;] IS WHY? ;] IS WHY? ;

Oforth:

Put the following into a file named "t.of":

  : rotate( lbuf ) { lbuf removeFirst lbuf add }

  : foo {|actions|
    [ #[ "Action 1." . ],
      #[ "Action" .  4 sqrt . ],
      #[ "Action 3." . ] ]
    asListBuffer -> actions
    #[ actions first perform  actions rotate ] }

  foo times( 6 )


Then, in the interpreter do:

  "t.of" load

The output:

Action 1. Action 2 Action 3. Action 1. Action 2 Action 3. ok

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


#40554

Fromhughaguilar96@gmail.com
Date2015-07-12 14:55 -0700
Message-ID<4b4b9f86-766c-430b-84e2-a76beaba8701@googlegroups.com>
In reply to#40544
On Sunday, July 12, 2015 at 6:48:30 AM UTC-7, Tessa Bonting wrote:
> Hey to all,
> 
> Can anyone tell me how qoutation work.

Quotations don't work in Forth-200x --- all you have is :NONAME faked up as a quotation.

Quotations do work in the FMITE processor --- the quotation has access to the parent function's local variables.

http://www.forth.org/FMITE.txt

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


#40565

From"Alex McDonald" <blog@rivadpm.com>
Date2015-07-13 12:53 +0100
Message-ID<mo08oa$9sb$1@dont-email.me>
In reply to#40554
on 12/07/2015 22:55:03,  wrote:
> On Sunday, July 12, 2015 at 6:48:30 AM UTC-7, Tessa Bonting wrote:
>> Hey to all,
>>
>> Can anyone tell me how qoutation work.
> 
> Quotations don't work in Forth-200x --- all you have is :NONAME faked
> up as a quotation.
> 
> Quotations do work in the FMITE processor --- the quotation has access
> to the parent function's local variables.
> 
> http://www.forth.org/FMITE.txt
> 

There's no accepted definition of quotation, or how it should work, nor a
standardization in the latest draft Forth 200x Draft 14.5. There does
appear to be a consensus; the ability to define a nameless word inside a
definition, and retrieve an execution token for EXECUTE. It's seen as a
useful adjunct to :NONAME and ticking named code.

The ability to address locals has not been properly discussed, since it
opens up the issue of the lifetime of the XT vs the lifetime of the
local. The XT can be EXECUTEd or COMPILE,d inside or outside of the
enclosing definition, since Forth doesn't have the concept of scope for
code, only data on the stacks and LOCALs. Therefore any local defined in
the outer definition and used in the quotation can only be addressed
inside the execution scope of the quotation. That limits the quotation
that uses outer local's use; but since there isn't much extant experience
with them, this may or many not be an issue.

Personal experience so far; (1) I don't tend to use locals inside the
quotation and (b) I don't have any use yet for quotations outside the
parent's execution scope.

What is your experience with this?

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


#40566

FromMark Wills <markwills1970@gmail.com>
Date2015-07-13 06:13 -0700
Message-ID<d376d0f8-95cd-49fc-a94d-16f00bc781af@googlegroups.com>
In reply to#40565
On Monday, 13 July 2015 12:53:07 UTC+1, Alex McDonald  wrote:
> on 12/07/2015 22:55:03,  wrote:
> > On Sunday, July 12, 2015 at 6:48:30 AM UTC-7, Tessa Bonting wrote:
> >> Hey to all,
> >>
> >> Can anyone tell me how qoutation work.
> > 
> > Quotations don't work in Forth-200x --- all you have is :NONAME faked
> > up as a quotation.
> > 
> > Quotations do work in the FMITE processor --- the quotation has access
> > to the parent function's local variables.
> > 
> > http://www.forth.org/FMITE.txt
> > 
> 
> There's no accepted definition of quotation, or how it should work, nor a
> standardization in the latest draft Forth 200x Draft 14.5. There does
> appear to be a consensus; the ability to define a nameless word inside a
> definition, and retrieve an execution token for EXECUTE. It's seen as a
> useful adjunct to :NONAME and ticking named code.
> 
> The ability to address locals has not been properly discussed, since it
> opens up the issue of the lifetime of the XT vs the lifetime of the
> local. The XT can be EXECUTEd or COMPILE,d inside or outside of the
> enclosing definition, since Forth doesn't have the concept of scope for
> code, only data on the stacks and LOCALs. Therefore any local defined in
> the outer definition and used in the quotation can only be addressed
> inside the execution scope of the quotation. That limits the quotation
> that uses outer local's use; but since there isn't much extant experience
> with them, this may or many not be an issue.
> 
> Personal experience so far; (1) I don't tend to use locals inside the
> quotation and (b) I don't have any use yet for quotations outside the
> parent's execution scope.
> 
> What is your experience with this?

I personally have no experience with them, and I'm still struggling
to see a use for them. However, regarding executing and compiling the
XT of the quotation outside the scope of the parent definition: you
just make that behaviour undefined.

"Compiling or executing the quotation after the definition in which
the quotation has been defined has gone out of scope may leave the
system in an undefined state" or other such verbiage.

I'm still somewhat agog though there's serious interest in adding this
behaviour to the language, but the language doesn't include support
for... oooooh, I dunno, say, single dimension arrays out of the box.

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


#40568

From"Alex McDonald" <blog@rivadpm.com>
Date2015-07-13 16:00 +0100
Message-ID<mo0jn6$jnu$1@dont-email.me>
In reply to#40566
on 13/07/2015 14:13:37, Mark Wills wrote:
> On Monday, 13 July 2015 12:53:07 UTC+1, Alex McDonald  wrote:
>> on 12/07/2015 22:55:03,  wrote:
>> > On Sunday, July 12, 2015 at 6:48:30 AM UTC-7, Tessa Bonting wrote:
>> >> Hey to all,
>> >>
>> >> Can anyone tell me how qoutation work.
>> >
>> > Quotations don't work in Forth-200x --- all you have is :NONAME faked
>> > up as a quotation.
>> >
>> > Quotations do work in the FMITE processor --- the quotation has access
>> > to the parent function's local variables.
>> >
>> > http://www.forth.org/FMITE.txt
>> >
>>
>> There's no accepted definition of quotation, or how it should work, nor a
>> standardization in the latest draft Forth 200x Draft 14.5. There does
>> appear to be a consensus; the ability to define a nameless word inside a
>> definition, and retrieve an execution token for EXECUTE. It's seen as a
>> useful adjunct to :NONAME and ticking named code.
>>
>> The ability to address locals has not been properly discussed, since it
>> opens up the issue of the lifetime of the XT vs the lifetime of the
>> local. The XT can be EXECUTEd or COMPILE,d inside or outside of the
>> enclosing definition, since Forth doesn't have the concept of scope for
>> code, only data on the stacks and LOCALs. Therefore any local defined in
>> the outer definition and used in the quotation can only be addressed
>> inside the execution scope of the quotation. That limits the quotation
>> that uses outer local's use; but since there isn't much extant experience
>> with them, this may or many not be an issue.
>>
>> Personal experience so far; (1) I don't tend to use locals inside the
>> quotation and (b) I don't have any use yet for quotations outside the
>> parent's execution scope.
>>
>> What is your experience with this?
> 
> I personally have no experience with them, and I'm still struggling
> to see a use for them. 

Anywhere you might want to pass an xt to another xt. Sorting for example;

: cstr-ascend count swap count compare 0> ; \ sort compare for ascending
foo-sort ( array elems -- ) ['] cstr-ascend sort ;

Or we could have

bar-sort ( array elems -- ) [: count swap count compare 0> ;] sort ;

What CTSR-ASCEND is doing isn't in the word FOO-SORT sorting, and it
needs a name. Of course, for simple stuff that has a single word, then

: int-ascend-sort [: > ;] sort ;

is just

: int-ascend-sort ['] > sort ;

> However, regarding executing and compiling the
> XT of the quotation outside the scope of the parent definition: you
> just make that behaviour undefined.

If the quotation doesn't use locals, then I'd disagree; it would be
difficult to imagine an implementation where it wouldn't work in that
case.

> 
> "Compiling or executing the quotation after the definition in which
> the quotation has been defined has gone out of scope may leave the
> system in an undefined state" or other such verbiage.
> 
> I'm still somewhat agog though there's serious interest in adding this
> behaviour to the language, but the language doesn't include support
> for... oooooh, I dunno, say, single dimension arrays out of the box.
> 

: 1dim create cells allot does> swap cells + ; 
10 1dim myarray
10 0 myarray !
20 1 myarray !
0 myarray @ 1 myarray @ + 2 myarray !

and so on. 

The language allows this out of the box. Qoutations on the other hand may
require non-standard words to implement -- or at least, non-standard
words to implement efficently.

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


#40572

FromMark Wills <markwills1970@gmail.com>
Date2015-07-13 09:12 -0700
Message-ID<12427150-5fab-4abd-aae9-1b7a4811027f@googlegroups.com>
In reply to#40568
On Monday, 13 July 2015 16:00:15 UTC+1, Alex McDonald  wrote:
> 
> The language allows this out of the box. Qoutations on the other hand may
> require non-standard words to implement -- or at least, non-standard
> words to implement efficently.

Yes, that's a good point.

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


#40575

FromMark Wills <markwills1970@gmail.com>
Date2015-07-13 09:26 -0700
Message-ID<0ab82af6-e64b-4d1e-b4a6-9afdfe65672e@googlegroups.com>
In reply to#40568
On Monday, 13 July 2015 16:00:15 UTC+1, Alex McDonald  wrote:
> on 13/07/2015 14:13:37, Mark Wills wrote:
> > On Monday, 13 July 2015 12:53:07 UTC+1, Alex McDonald  wrote:
> >> on 12/07/2015 22:55:03,  wrote:
> >> > On Sunday, July 12, 2015 at 6:48:30 AM UTC-7, Tessa Bonting wrote:
> >> >> Hey to all,
> >> >>
> >> >> Can anyone tell me how qoutation work.
> >> >
> >> > Quotations don't work in Forth-200x --- all you have is :NONAME faked
> >> > up as a quotation.
> >> >
> >> > Quotations do work in the FMITE processor --- the quotation has access
> >> > to the parent function's local variables.
> >> >
> >> > http://www.forth.org/FMITE.txt
> >> >
> >>
> >> There's no accepted definition of quotation, or how it should work, nor a
> >> standardization in the latest draft Forth 200x Draft 14.5. There does
> >> appear to be a consensus; the ability to define a nameless word inside a
> >> definition, and retrieve an execution token for EXECUTE. It's seen as a
> >> useful adjunct to :NONAME and ticking named code.
> >>
> >> The ability to address locals has not been properly discussed, since it
> >> opens up the issue of the lifetime of the XT vs the lifetime of the
> >> local. The XT can be EXECUTEd or COMPILE,d inside or outside of the
> >> enclosing definition, since Forth doesn't have the concept of scope for
> >> code, only data on the stacks and LOCALs. Therefore any local defined in
> >> the outer definition and used in the quotation can only be addressed
> >> inside the execution scope of the quotation. That limits the quotation
> >> that uses outer local's use; but since there isn't much extant experience
> >> with them, this may or many not be an issue.
> >>
> >> Personal experience so far; (1) I don't tend to use locals inside the
> >> quotation and (b) I don't have any use yet for quotations outside the
> >> parent's execution scope.
> >>
> >> What is your experience with this?
> > 
> > I personally have no experience with them, and I'm still struggling
> > to see a use for them. 
> 
> Anywhere you might want to pass an xt to another xt. Sorting for example;
> 
> : cstr-ascend count swap count compare 0> ; \ sort compare for ascending
> foo-sort ( array elems -- ) ['] cstr-ascend sort ;
> 
> Or we could have
> 
> bar-sort ( array elems -- ) [: count swap count compare 0> ;] sort ;
> 
> What CTSR-ASCEND is doing isn't in the word FOO-SORT sorting, and it
> needs a name. Of course, for simple stuff that has a single word, then
> 
> : int-ascend-sort [: > ;] sort ;
> 
> is just
> 
> : int-ascend-sort ['] > sort ;
> 
> > However, regarding executing and compiling the
> > XT of the quotation outside the scope of the parent definition: you
> > just make that behaviour undefined.
> 
> If the quotation doesn't use locals, then I'd disagree; it would be
> difficult to imagine an implementation where it wouldn't work in that
> case.
> 
> > 
> > "Compiling or executing the quotation after the definition in which
> > the quotation has been defined has gone out of scope may leave the
> > system in an undefined state" or other such verbiage.
> > 
> > I'm still somewhat agog though there's serious interest in adding this
> > behaviour to the language, but the language doesn't include support
> > for... oooooh, I dunno, say, single dimension arrays out of the box.
> > 
> 
> : 1dim create cells allot does> swap cells + ; 
> 10 1dim myarray
> 10 0 myarray !
> 20 1 myarray !
> 0 myarray @ 1 myarray @ + 2 myarray !
> 
> and so on. 
> 
> The language allows this out of the box. Qoutations on the other hand may
> require non-standard words to implement -- or at least, non-standard
> words to implement efficently.

Turns out it's bonkers simple to implement. Well, it is on my system:

: [: ( int: -- addr )
  postpone 0
  postpone if
  here postpone docol
; immediate

: ;] ( int: addr --  run: -- xt )
  postpone exit
  >r postpone then
  r> postpone lit ,
; immediate

[ My system is Forth-83, with some ANS harnesses, such as POSTPONE ]

: test 1 2 [: 3 ;] 4 ;
swap execute .s
1 2 4 3 ok:4

They get access to locals 'for free' (as in, no code required):
: test
  locals{ fred }
  99 set fred \ load fred with 99
  [: fred 1+ ;] execute .
;
test 
100 ok:0

[ My locals aren't standard, they're home-brew ]

Oh well. :-)

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


#40569

FromCoos Haak <chforth@hccnet.nl>
Date2015-07-13 17:00 +0200
Message-ID<1k23qvww36xfi$.xs8iprf01wvo$.dlg@40tude.net>
In reply to#40566
Op Mon, 13 Jul 2015 06:13:41 -0700 (PDT) schreef Mark Wills:

> On Monday, 13 July 2015 12:53:07 UTC+1, Alex McDonald  wrote:
>> on 12/07/2015 22:55:03,  wrote:
>>> On Sunday, July 12, 2015 at 6:48:30 AM UTC-7, Tessa Bonting wrote:
>>>> Hey to all,
>>>>
>>>> Can anyone tell me how qoutation work.
>>> 
>>> Quotations don't work in Forth-200x --- all you have is :NONAME faked
>>> up as a quotation.
>>> 
>>> Quotations do work in the FMITE processor --- the quotation has access
>>> to the parent function's local variables.
>>> 
>>> http://www.forth.org/FMITE.txt
>>> 
>> 
>> There's no accepted definition of quotation, or how it should work, nor a
>> standardization in the latest draft Forth 200x Draft 14.5. There does
>> appear to be a consensus; the ability to define a nameless word inside a
>> definition, and retrieve an execution token for EXECUTE. It's seen as a
>> useful adjunct to :NONAME and ticking named code.
>> 
>> The ability to address locals has not been properly discussed, since it
>> opens up the issue of the lifetime of the XT vs the lifetime of the
>> local. The XT can be EXECUTEd or COMPILE,d inside or outside of the
>> enclosing definition, since Forth doesn't have the concept of scope for
>> code, only data on the stacks and LOCALs. Therefore any local defined in
>> the outer definition and used in the quotation can only be addressed
>> inside the execution scope of the quotation. That limits the quotation
>> that uses outer local's use; but since there isn't much extant experience
>> with them, this may or many not be an issue.
>> 
>> Personal experience so far; (1) I don't tend to use locals inside the
>> quotation and (b) I don't have any use yet for quotations outside the
>> parent's execution scope.
>> 
>> What is your experience with this?
> 
> I personally have no experience with them, and I'm still struggling
> to see a use for them. However, regarding executing and compiling the
> XT of the quotation outside the scope of the parent definition: you
> just make that behaviour undefined.
> 
> "Compiling or executing the quotation after the definition in which
> the quotation has been defined has gone out of scope may leave the
> system in an undefined state" or other such verbiage.
> 
There is :NONAME where execution behaviour is defined in the standard:
--
xt Execution: ( i×x -- j×x )
Execute the definition specified by xt. The stack effects
i×x and j×x represent arguments to and results from xt, respectively.
--
There is nothing about compilation behaviour though.

> I'm still somewhat agog though there's serious interest in adding this
> behaviour to the language, but the language doesn't include support
> for... oooooh, I dunno, say, single dimension arrays out of the box.

Variants of WORDS could use quotations, using traverse-wordlist.
  print every word
[: name>string type true ;]
  print only words beginning with A.
[: name>string over 'A' = if type else 2drop then true ;]
  print and stops after finding first word with lenght 7
[: name>string dup 7 = if type false else 2drop true ;]

groet Coos

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


#40570

From"Alex McDonald" <blog@rivadpm.com>
Date2015-07-13 16:58 +0100
Message-ID<mo0n46$1qq$1@dont-email.me>
In reply to#40569
on 13/07/2015 16:00:46, Coos Haak wrote:
> Op Mon, 13 Jul 2015 06:13:41 -0700 (PDT) schreef Mark Wills:
> 

>>
>> I personally have no experience with them, and I'm still struggling
>> to see a use for them. However, regarding executing and compiling the
>> XT of the quotation outside the scope of the parent definition: you
>> just make that behaviour undefined.
>>
>> "Compiling or executing the quotation after the definition in which
>> the quotation has been defined has gone out of scope may leave the
>> system in an undefined state" or other such verbiage.
>>
> There is :NONAME where execution behaviour is defined in the standard:
> -- xt Execution: ( i×x -- j×x )
> Execute the definition specified by xt. The stack effects
> i×x and j×x represent arguments to and results from xt, respectively.
> --
> There is nothing about compilation behaviour though.

3.4.3.3 Compilation semantics
Unless otherwise specified in a "Compilation:" section of the glossary
entry, the compilation semantics of a Forth definition shall be to append
its execution semantics to the execution semantics of the current
definition.

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


#40581

FromCoos Haak <chforth@hccnet.nl>
Date2015-07-13 20:53 +0200
Message-ID<1trmhio1w2irb.enz29sok22ct$.dlg@40tude.net>
In reply to#40570
Op Mon, 13 Jul 2015 16:58:21 +0100 schreef Alex McDonald:

> on 13/07/2015 16:00:46, Coos Haak wrote:
>> Op Mon, 13 Jul 2015 06:13:41 -0700 (PDT) schreef Mark Wills:
>> 
> 
>>>
>>> I personally have no experience with them, and I'm still struggling
>>> to see a use for them. However, regarding executing and compiling the
>>> XT of the quotation outside the scope of the parent definition: you
>>> just make that behaviour undefined.
>>>
>>> "Compiling or executing the quotation after the definition in which
>>> the quotation has been defined has gone out of scope may leave the
>>> system in an undefined state" or other such verbiage.
>>>
>> There is :NONAME where execution behaviour is defined in the standard:
>> -- xt Execution: ( i×x -- j×x )
>> Execute the definition specified by xt. The stack effects
>> i×x and j×x represent arguments to and results from xt, respectively.
>> --
>> There is nothing about compilation behaviour though.
> 
> 3.4.3.3 Compilation semantics
> Unless otherwise specified in a "Compilation:" section of the glossary
> entry, the compilation semantics of a Forth definition shall be to append
> its execution semantics to the execution semantics of the current
> definition.

Didn't think to look into the general pages. Thanks.

groet Coos

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


#40573

Frombettilyona@gmail.com
Date2015-07-13 09:13 -0700
Message-ID<3b48fca0-6748-4093-827f-9d68f2549d33@googlegroups.com>
In reply to#40566
On Monday, July 13, 2015 at 7:13:43 AM UTC-6, Mark Wills wrote:
> On Monday, 13 July 2015 12:53:07 UTC+1, Alex McDonald  wrote:
> > on 12/07/2015 22:55:03,  wrote:
> > > On Sunday, July 12, 2015 at 6:48:30 AM UTC-7, Tessa Bonting wrote:
> > >> Hey to all,
> > >>
> > >> Can anyone tell me how qoutation work.
> > > 
> > > Quotations don't work in Forth-200x --- all you have is :NONAME faked
> > > up as a quotation.
> > > 
> > > Quotations do work in the FMITE processor --- the quotation has access
> > > to the parent function's local variables.
> > > 
> > > http://www.forth.org/FMITE.txt
> > > 
> > 
> > There's no accepted definition of quotation, or how it should work, nor a
> > standardization in the latest draft Forth 200x Draft 14.5. There does
> > appear to be a consensus; the ability to define a nameless word inside a
> > definition, and retrieve an execution token for EXECUTE. It's seen as a
> > useful adjunct to :NONAME and ticking named code.
> > 
> > The ability to address locals has not been properly discussed, since it
> > opens up the issue of the lifetime of the XT vs the lifetime of the
> > local. The XT can be EXECUTEd or COMPILE,d inside or outside of the
> > enclosing definition, since Forth doesn't have the concept of scope for
> > code, only data on the stacks and LOCALs. Therefore any local defined in
> > the outer definition and used in the quotation can only be addressed
> > inside the execution scope of the quotation. That limits the quotation
> > that uses outer local's use; but since there isn't much extant experience
> > with them, this may or many not be an issue.
> > 
> > Personal experience so far; (1) I don't tend to use locals inside the
> > quotation and (b) I don't have any use yet for quotations outside the
> > parent's execution scope.
> > 
> > What is your experience with this?
> 
> I personally have no experience with them, and I'm still struggling
> to see a use for them. However, regarding executing and compiling the
> XT of the quotation outside the scope of the parent definition: you
> just make that behaviour undefined.
> 
> "Compiling or executing the quotation after the definition in which
> the quotation has been defined has gone out of scope may leave the
> system in an undefined state" or other such verbiage.
> 
> I'm still somewhat agog though there's serious interest in adding this
> behaviour to the language, but the language doesn't include support
> for... oooooh, I dunno, say, single dimension arrays out of the box.

The word 'agog' is a new to me.

agog -- Full of keen anticipation or excitement; eager.

Somehow, I think you meant the opposite.  Maybe you're aghast at everyone's agog?

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


#40574

FromMark Wills <markwills1970@gmail.com>
Date2015-07-13 09:15 -0700
Message-ID<5d49b321-0105-45fa-8b6a-529108e7aa07@googlegroups.com>
In reply to#40573
On Monday, 13 July 2015 17:13:56 UTC+1, betti...@gmail.com  wrote:
> On Monday, July 13, 2015 at 7:13:43 AM UTC-6, Mark Wills wrote:
> > On Monday, 13 July 2015 12:53:07 UTC+1, Alex McDonald  wrote:
> > > on 12/07/2015 22:55:03,  wrote:
> > > > On Sunday, July 12, 2015 at 6:48:30 AM UTC-7, Tessa Bonting wrote:
> > > >> Hey to all,
> > > >>
> > > >> Can anyone tell me how qoutation work.
> > > > 
> > > > Quotations don't work in Forth-200x --- all you have is :NONAME faked
> > > > up as a quotation.
> > > > 
> > > > Quotations do work in the FMITE processor --- the quotation has access
> > > > to the parent function's local variables.
> > > > 
> > > > http://www.forth.org/FMITE.txt
> > > > 
> > > 
> > > There's no accepted definition of quotation, or how it should work, nor a
> > > standardization in the latest draft Forth 200x Draft 14.5. There does
> > > appear to be a consensus; the ability to define a nameless word inside a
> > > definition, and retrieve an execution token for EXECUTE. It's seen as a
> > > useful adjunct to :NONAME and ticking named code.
> > > 
> > > The ability to address locals has not been properly discussed, since it
> > > opens up the issue of the lifetime of the XT vs the lifetime of the
> > > local. The XT can be EXECUTEd or COMPILE,d inside or outside of the
> > > enclosing definition, since Forth doesn't have the concept of scope for
> > > code, only data on the stacks and LOCALs. Therefore any local defined in
> > > the outer definition and used in the quotation can only be addressed
> > > inside the execution scope of the quotation. That limits the quotation
> > > that uses outer local's use; but since there isn't much extant experience
> > > with them, this may or many not be an issue.
> > > 
> > > Personal experience so far; (1) I don't tend to use locals inside the
> > > quotation and (b) I don't have any use yet for quotations outside the
> > > parent's execution scope.
> > > 
> > > What is your experience with this?
> > 
> > I personally have no experience with them, and I'm still struggling
> > to see a use for them. However, regarding executing and compiling the
> > XT of the quotation outside the scope of the parent definition: you
> > just make that behaviour undefined.
> > 
> > "Compiling or executing the quotation after the definition in which
> > the quotation has been defined has gone out of scope may leave the
> > system in an undefined state" or other such verbiage.
> > 
> > I'm still somewhat agog though there's serious interest in adding this
> > behaviour to the language, but the language doesn't include support
> > for... oooooh, I dunno, say, single dimension arrays out of the box.
> 
> The word 'agog' is a new to me.
> 
> agog -- Full of keen anticipation or excitement; eager.
> 
> Somehow, I think you meant the opposite.  Maybe you're aghast at everyone's agog?

I'm aghast that I used the word agog, where I meant aghast :-)

I must use it more often!

[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