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


Groups > comp.lang.forth > #53167

Re: f.) for Gorth

From anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups comp.lang.forth
Subject Re: f.) for Gorth
Date 2016-12-07 17:50 +0000
Organization Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID <2016Dec7.185020@mips.complang.tuwien.ac.at> (permalink)
References <33ce84eb-b042-440d-8e0c-8134b7db18df@googlegroups.com> <2016Dec6.185910@mips.complang.tuwien.ac.at> <a093eec3-ce28-4534-bfd8-abe58dfde6c6@googlegroups.com> <2016Dec7.121119@mips.complang.tuwien.ac.at> <23ba8f31-3755-4c67-8cae-0903d10370e7@googlegroups.com>

Show all headers | View raw


Julian Fondren <julian.fondren@gmail.com> writes:
>On Wednesday, December 7, 2016 at 6:51:46 AM UTC-6, Anton Ertl wrote:
>> While we are at the topic of >STRING-EXECUTE: Another thing it is good
>> for is for constructing strings programmatically.  E.g., do something
>> like (untested)
>> 
>> : call-emacs ( c-addr u line column -- )
>>   [: ." emacs +" swap 0 .r ." :" 0 .r space type ;] >string-execute 
>>   2dup system free throw ;
>> 
>> Try to write that without >STRING-EXECUTE, and see how much code would
>> be needed.
>
>Recently I partially reimplemented SwiftForth's [BUF BUF] words for
>VFX and for iForth. With these words, in iForth:
>
>  : call-emacs ( c-addr u line column -- )
>    [BUF ." echo emacs +" swap 0 .r ." :" . type BUF]
>    @BUF system ;

That's a (probably much older) variation of the same idea.

>This only required vectorable EMIT and TYPE from the system:
>
>  'emit @ constant 'orig-emit
>  'type @ constant 'orig-type
>  
>  $8000 buffer: buf
>  variable BP
>  
>  : buf-emit ( c -- )
>    BP @ c! BP ++ ;
>  
>  : buf-type ( c-addr u -- )
>    BP @ swap dup BP +! move ;
>  
>  : [buf ( -- )
>    buf BP !
>    ['] buf-emit 'emit !
>    ['] buf-type 'type ! ;
>  
>  : buf] ( -- )
>    'orig-emit 'emit !
>    'orig-type 'type ! ;
>  
>  : @buf ( -- c-addr u )
>    buf BP @ over - ;
>
>Disadvantages:
>
>1. 'buffered' code can't call a word that uses these words
>as well to buffer some output, with more hassle. This works
>automatically with >STRING-EXECUTE

I guess you can do the same for the [BUF...BUF] syntax, but the
implementation becomes more complicated, approaching that of
>STRING-EXECUTE.

>3. it's not as visually neat as a quotation and >STRING-EXECUTE

I guess there are people who will disagree:-).

5. An exception between [BUF and BUF] leaves EMIT and TYPE redirected.

>Advantages:
>
>1. all of these implementations use a fixed buffer. How can I limit
>>STRING-EXECUTE's memory use?

A fixed buffer is a disadvantage in my book.  There is no provision
for limiting memory use by >STRING-EXECUTE.  I considered an
alternative interface

>buffer-execute ( ... c-addr u1 xt -- ... u2 )

where you pass the buffer, and then the string would be naturally
limited to u1.  But it's quite cumbersome to write programs that work
for all cases with such an interface (SUBSTITUTE is even worse), so I
did not implement it.

I just tried the buffer size limitation of SwiftForth:

: x [buf do space loop buf] ; 1000000000 0 x  ok                               
@buf .s 
184104108 1000000000 <-Top  ok

works even with 2*10^9, but produces

Signal #11 at 08071D35 in (B-EMIT)

when I tried it with "3000000000 0 x"

@buf then outputs

169014444 -2147483647 <-Top

But that's a pretty natural limit for a 32-bit Forth system.

>2. with all of them it's easy to open the code up and extend it to
>f.e. auto-flush the buffer to stdout after a point, or to push the
>buffer to a stack, or to truncate buffered I/O after a point, or even
>to 'scroll' the buffer and keep only what's most recently emitted.
>>STRING-EXECUTE is a black box.

You can also look in the implementation of >STRING-EXECUTE, and derive
such variations from it if you want.

>3. You can interrupt and resume the buffering from within a buffered
>expression.
>
>  : .headers ]BUF @BUF TYPE [BUF ;
>  ...
>  : go [BUF generate-lots-of-output BUF] ;

You lost me here.

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: http://www.forth200x.org/forth200x.html
   EuroForth 2016: http://www.euroforth.org/ef16/

Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

f.) for Gorth josv@planet.nl - 2016-12-06 03:40 -0800
  Re: f.) for Gorth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-12-06 15:48 +0100
  Re: f.) for Gorth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-12-06 17:59 +0000
    Re: f.) for Gorth josv@planet.nl - 2016-12-06 13:17 -0800
      Re: f.) for Gorth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-12-07 11:11 +0000
        Re: f.) for Gorth Julian Fondren <julian.fondren@gmail.com> - 2016-12-07 06:11 -0800
          Re: f.) for Gorth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-12-07 17:50 +0000
        Re: f.) for Gorth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-12-07 15:23 +0100
          Re: f.) for Gorth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-12-08 16:18 +0000
        Re: f.) for Gorth josv@planet.nl - 2016-12-07 06:46 -0800
          Re: f.) for Gorth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-12-07 17:41 +0000
  Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-06 10:34 -0800
    Re: f.) for Gorth josv@planet.nl - 2016-12-09 12:11 -0800
      Re: f.) for Gorth "HAA" <someone@microsoft.com> - 2016-12-23 13:23 +1100
    Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-15 15:42 -0800
  Re: f.) for Gorth "HAA" <someone@microsoft.com> - 2016-12-07 13:06 +1100
    Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-06 18:32 -0800
      Re: f.) for Gorth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-12-07 12:41 +0100
        Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-07 19:49 -0800
          Re: f.) for Gorth Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2016-12-08 08:12 +0000
            Re: f.) for Gorth Rod Pemberton <NeedNotReplyHere@xrsevnneqk.cem> - 2016-12-08 18:53 -0500
              Re: f.) for Gorth Alex <alex@rivadpm.com> - 2016-12-09 00:01 +0000
                Re: f.) for Gorth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-12-09 12:17 +0100
                Re: f.) for Gorth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-12-09 13:01 +0000
              Re: f.) for Gorth "HAA" <someone@microsoft.com> - 2016-12-09 11:19 +1100
                Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-08 22:23 -0800
                Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-09 07:11 -0800
                Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-20 22:40 -0800
                Re: f.) for Gorth Julian Fondren <julian.fondren@gmail.com> - 2016-12-20 23:59 -0800
                Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-21 21:17 -0800
                Re: f.) for Gorth The Beez <the.beez.speaks@gmail.com> - 2016-12-13 08:51 -0800
                Re: f.) for Gorth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-12-09 12:47 +0000
                Re: f.) for Gorth "HAA" <someone@microsoft.com> - 2016-12-10 11:54 +1100
                Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-09 17:28 -0800
                Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-09 18:20 -0800
                Re: f.) for Gorth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-12-10 14:26 +0000
                Re: f.) for Gorth The Beez <the.beez.speaks@gmail.com> - 2016-12-13 09:14 -0800
                Re: f.) for Gorth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-12-13 19:24 +0100
                Re: f.) for Gorth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-12-14 07:29 -0600
                Re: f.) for Gorth Hans Bezemer <the.beez.speaks@gmail.com> - 2016-12-14 18:29 +0100
                Re: f.) for Gorth Julian Fondren <julian.fondren@gmail.com> - 2016-12-14 10:13 -0800
                Re: f.) for Gorth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-12-15 03:45 -0600
                Re: f.) for Gorth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-12-15 10:42 +0000
                Re: f.) for Gorth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-12-15 05:11 -0600
                Re: f.) for Gorth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-12-15 12:36 +0000
                Re: f.) for Gorth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-12-15 07:33 -0600
                Re: f.) for Gorth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-12-15 14:31 +0000
                Re: f.) for Gorth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-12-15 14:34 -0600
                Re: f.) for Gorth Paul Rubin <no.email@nospam.invalid> - 2016-12-15 16:20 -0800
                Re: f.) for Gorth Julian Fondren <julian.fondren@gmail.com> - 2016-12-15 16:46 -0800
                Re: f.) for Gorth Julian Fondren <julian.fondren@gmail.com> - 2016-12-17 09:23 -0800
                Re: f.) for Gorth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-12-19 02:56 -0600
                Re: f.) for Gorth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-12-16 08:10 +0000
                Re: f.) for Gorth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-12-16 10:00 -0600
                Re: f.) for Gorth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-12-18 10:32 +0000
                Re: f.) for Gorth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-12-19 03:22 -0600
                Re: f.) for Gorth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-12-16 14:14 +0100
                Re: f.) for Gorth Bernd Paysan <bernd@net2o.de> - 2016-12-19 19:41 +0000
                Re: f.) for Gorth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-12-20 03:02 -0600
                Re: f.) for Gorth mhx@iae.nl - 2016-12-20 01:27 -0800
                Re: f.) for Gorth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-12-20 12:35 +0000
                Re: f.) for Gorth Charles Montgomery <cgm@physics.utoledo.edu> - 2016-12-20 21:23 -0500
                Re: f.) for Gorth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-12-21 07:29 +0000
                Re: f.) for Gorth Charles Montgomery <cgm@physics.utoledo.edu> - 2016-12-21 22:24 -0500
                Re: f.) for Gorth "David N. Williams" <williams@umich.edu> - 2016-12-22 08:10 -0500
                Re: f.) for Gorth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-12-22 17:39 +0000
                Re: f.) for Gorth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-12-15 12:53 +0100
                Re: f.) for Gorth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-12-15 05:59 -0600
                Re: f.) for Gorth "Robert L." <No_spamming@noWhere_7073.org> - 2017-01-03 16:15 +0000
                Re: f.) for Gorth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-12-14 17:06 +0000
                Re: f.) for Gorth "HAA" <someone@microsoft.com> - 2016-12-18 10:58 +1100
                Re: f.) for Gorth Paul Rubin <no.email@nospam.invalid> - 2016-12-17 17:26 -0800
                Re: f.) for Gorth "HAA" <someone@microsoft.com> - 2016-12-19 13:16 +1100
                Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-18 19:19 -0800
                Re: f.) for Gorth john <anon@example.com> - 2016-12-19 11:03 +0000
                Re: f.) for Gorth Mark Wills <markwills1970@gmail.com> - 2016-12-20 01:46 -0800
                Re: f.) for Gorth john <anon@example.com> - 2016-12-20 12:14 +0000
                Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-20 17:34 -0800
                Re: f.) for Gorth Paul Rubin <no.email@nospam.invalid> - 2016-12-18 19:25 -0800
                Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-18 19:45 -0800
                Re: f.) for Gorth "HAA" <someone@microsoft.com> - 2016-12-22 11:32 +1100
                Re: f.) for Gorth Bernd Paysan <bernd@net2o.de> - 2017-01-03 19:33 +0000
                Re: f.) for Gorth hughaguilar96@gmail.com - 2017-01-03 22:13 -0800
                Re: f.) for Gorth Alex <alex@rivadpm.com> - 2017-01-04 23:03 +0000
                Re: f.) for Gorth hughaguilar96@gmail.com - 2017-01-06 22:52 -0800
                Re: f.) for Gorth Alex <alex@rivadpm.com> - 2017-01-07 22:45 +0000
                Re: f.) for Gorth hughaguilar96@gmail.com - 2017-01-07 17:23 -0800
                Re: f.) for Gorth Alex <alex@rivadpm.com> - 2017-01-08 09:13 +0000
                Re: f.) for Gorth hughaguilar96@gmail.com - 2017-01-08 17:10 -0800
                Re: f.) for Gorth Alex <alex@rivadpm.com> - 2017-01-09 10:22 +0000
                Re: f.) for Gorth stephen@mpeforth.com - 2017-01-08 07:00 -0800
                Re: f.) for Gorth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-05-20 14:09 +0200
                Re: f.) for Gorth Matthias Trute <matthias.trute@gmail.com> - 2017-01-11 01:14 -0800
    Re: f.) for Gorth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-12-07 12:26 +0100
      Re: f.) for Gorth "HAA" <someone@microsoft.com> - 2016-12-08 10:21 +1100
        Re: f.) for Gorth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-12-20 15:45 +0100
          Re: f.) for Gorth Alex <alex@rivadpm.com> - 2016-12-20 15:33 +0000
          Re: f.) for Gorth "HAA" <someone@microsoft.com> - 2016-12-22 11:37 +1100
            Re: f.) for Gorth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-12-22 14:19 +0100
              Re: f.) for Gorth "HAA" <someone@microsoft.com> - 2016-12-23 12:11 +1100
                Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-22 17:49 -0800
                Re: f.) for Gorth "HAA" <someone@microsoft.com> - 2016-12-23 20:41 +1100
            Re: f.) for Gorth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-05-20 14:21 +0200
  Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-15 22:31 -0800
    Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-16 18:26 -0800
      Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-18 16:41 -0800
        Re: f.) for Gorth stephen@mpeforth.com - 2016-12-20 02:20 -0800
          Re: f.) for Gorth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-12-20 13:04 +0000
            Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-20 17:27 -0800
  Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-17 10:36 -0800
    Re: f.) for Gorth Julian Fondren <julian.fondren@gmail.com> - 2016-12-17 11:51 -0800
      Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-18 19:35 -0800
        Re: f.) for Gorth albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2016-12-19 14:17 +0100
          Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-19 10:10 -0800
            Re: f.) for Gorth Alex <alex@rivadpm.com> - 2016-12-19 20:33 +0000
              Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-19 18:11 -0800
                Re: f.) for Gorth Julian Fondren <julian.fondren@gmail.com> - 2016-12-19 19:03 -0800
                Re: f.) for Gorth Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2016-12-20 08:10 +0000
                Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-20 18:05 -0800
                Re: f.) for Gorth  -  what is a number? Jan Coombs <jenfhaomndgfwutc@murmic.plus.com> - 2016-12-21 09:04 +0000
                Re: f.) for Gorth Alex <alex@rivadpm.com> - 2016-12-20 15:26 +0000
                Re: f.) for Gorth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-12-20 11:30 -0600
                Language stds (was Re: f.) for Gorth) Alex <alex@rivadpm.com> - 2016-12-20 19:49 +0000
                Re: Language stds (was Re: f.) for Gorth) john <anon@example.com> - 2016-12-20 20:06 +0000
                Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-20 17:52 -0800
                Re: f.) for Gorth Alex <alex@rivadpm.com> - 2016-12-21 13:47 +0000
                Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-21 20:46 -0800
                Re: f.) for Gorth Alex <alex@rivadpm.com> - 2016-12-22 14:33 +0000
                Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-22 07:06 -0800
                Re: f.) for Gorth Julian Fondren <julian.fondren@gmail.com> - 2016-12-22 07:21 -0800
                Re: f.) for Gorth Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2016-12-23 07:41 +0000
                Re: f.) for Gorth Alex <alex@rivadpm.com> - 2016-12-23 08:33 +0000
                Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-23 18:22 -0800
                Re: f.) for Gorth Julian Fondren <julian.fondren@gmail.com> - 2016-12-23 20:28 -0800
                Re: f.) for Gorth hughaguilar96@gmail.com - 2016-12-26 18:30 -0800
                Language stds (Re: f.) for Gorth) "HAA" <someone@microsoft.com> - 2016-12-24 12:12 +1100
                Re: Language stds (Re: f.) for Gorth) Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-12-24 03:28 -0600
                Re: Language stds (Re: f.) for Gorth) "Elizabeth D. Rather" <erather@forth.com> - 2016-12-24 10:02 -0600
                Re: Language stds (Re: f.) for Gorth) hughaguilar96@gmail.com - 2016-12-24 16:13 -0800
                Re: Language stds (Re: f.) for Gorth) Alex <alex@rivadpm.com> - 2016-12-24 18:13 +0000
                Re: Language stds (Re: f.) for Gorth) "HAA" <someone@microsoft.com> - 2016-12-28 09:24 +1100
                Re: Language stds (Re: f.) for Gorth) "Elizabeth D. Rather" <erather@forth.com> - 2016-12-27 17:10 -0600
                Re: Language stds (Re: f.) for Gorth) hughaguilar96@gmail.com - 2016-12-27 22:58 -0800
                Re: Language stds (Re: f.) for Gorth) "HAA" <someone@microsoft.com> - 2016-12-29 10:12 +1100
                Re: Language stds (Re: f.) for Gorth) "Elizabeth D. Rather" <erather@forth.com> - 2016-12-29 17:03 -0800
                Re: Language stds (Re: f.) for Gorth) hughaguilar96@gmail.com - 2016-12-29 19:35 -0800
                Re: Language stds (Re: f.) for Gorth) Howerd <howerdo@yahoo.co.uk> - 2016-12-30 05:27 -0800
                Re: Language stds (Re: f.) for Gorth) hughaguilar96@gmail.com - 2016-12-30 19:11 -0800
                Re: Language stds (Re: f.) for Gorth) hughaguilar96@gmail.com - 2016-12-31 06:42 -0800

csiph-web