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


Groups > comp.lang.forth > #1123

Re: redirecting TYPE to a string (was: Renaissance of Forth)

From Bernd Paysan <bernd.paysan@gmx.de>
Newsgroups comp.lang.forth
Subject Re: redirecting TYPE to a string (was: Renaissance of Forth)
Followup-To comp.lang.forth
Date 2011-04-10 18:07 +0200
Organization (posted via) M-net Telekommunikations GmbH
Message-ID <m71978-due.ln1@vimes.paysan.nom> (permalink)
References <6224e7e6-c367-4a01-baea-7532a2a164c1@e21g2000vbz.googlegroups.com> <2011Apr4.190953@mips.complang.tuwien.ac.at> <fjjr68-13g.ln1@vimes.paysan.nom> <2011Apr9.185419@mips.complang.tuwien.ac.at>

Followups directed to: comp.lang.forth

Show all headers | View raw


Anton Ertl wrote:

> What does %> do that we cannot do with ." and .\", which are much more
> familiar to Forth programmers.

Scans over multiple lines, and has a two-character termination sequence.  
It's related to PHP's <?php ?>, and originally designed for similar 
purposes (take a text template and fill in some fields from a program).

> Yes, redirecting TYPE to a string is a good way to construct strings
> in Forth, so I have implemented it
> <http://www.complang.tuwien.ac.at/viewcvs/cgi-
bin/viewcvs.cgi/gforth/str-exec.fs?view=markup>.

> A simple usage is:
> 
> 5 ' . >string-execute 2dup dump drop free throw
> 
> For your example above you would write:
> 
> : .mix2bytes_ind ( index n k i -- index n ) >r
>     >r over r@ 64 + swap
>     ." a" r@ 7 and 0 .r ." ^=ROL(rnds[states[" 0 .r ." ]^(0xff&(t>>"
>     $7 and 8 * 0 .r ." ))]," r> 7 r@ - 0 .r ." );" ;
> 
> : mix2bytes_ind, ( index n k i -- index n )
>     ['] .mix2bytes_ind >string-execute 2dup \c, ;

Nice.

> I wonder how many of the use cases for which people would like a more
> elaborate string library can be solved with this.

For producing strings, this is certainly quite useful, but for 
manipulating strings it's not.

> Finally, it uses locals pretty extensively.  The problem and its
> implementation should be small and easy enough to understand to lend
> itself to a challenge: I challenge the people who believe that code
> without locals is superior to show me such superior code.

Good challenge. Workshop for Forth-Tagung?

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://www.jwdt.com/~paysan/

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


Thread

Renaissance of Forth visualforth@rocketmail.com - 2011-03-31 16:06 -0700
  Re: Renaissance of Forth Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-04-01 02:29 -0500
  Re: Renaissance of Forth Albert van der Horst <albert@spenarnc.xs4all.nl> - 2011-04-01 12:46 +0000
    Re: Renaissance of Forth Dennis <daruffer@gmail.com> - 2011-04-01 07:36 -0700
      Re: Renaissance of Forth Brad <hwfwguy@gmail.com> - 2011-04-01 07:47 -0700
      Re: Renaissance of Forth John Passaniti <john.passaniti@gmail.com> - 2011-04-01 16:40 -0700
        Re: Renaissance of Forth BruceMcF <agila61@netscape.net> - 2011-04-01 18:20 -0700
    Re: Renaissance of Forth Paul Rubin <no.email@nospam.invalid> - 2011-04-01 12:34 -0700
      Re: Renaissance of Forth Albert van der Horst <albert@spenarnc.xs4all.nl> - 2011-04-02 00:23 +0000
        Re: Renaissance of Forth Paul Rubin <no.email@nospam.invalid> - 2011-04-01 16:24 -0700
  Re: Renaissance of Forth Gary Bergstrom <g.bergstrom@ieee.org> - 2011-04-01 08:36 -0700
  Re: Renaissance of Forth "The Beez'" <hansoft@bigfoot.com> - 2011-04-01 16:04 -0700
    Re: Renaissance of Forth mhx@iae.nl (Marcel Hendrix) - 2011-04-02 10:40 +0200
      Re: Renaissance of Forth John Passaniti <john.passaniti@gmail.com> - 2011-04-02 14:50 -0700
        Re: Renaissance of Forth "Massimo A. Dentico" <massimo_dentico@hotmail.com> - 2011-04-03 00:34 +0200
          Re: Renaissance of Forth John Passaniti <john.passaniti@gmail.com> - 2011-04-02 21:08 -0700
            Re: Renaissance of Forth mhx@iae.nl (Marcel Hendrix) - 2011-04-03 09:24 +0200
              Re: Renaissance of Forth John Passaniti <john.passaniti@gmail.com> - 2011-04-03 15:45 -0700
                Re: Renaissance of Forth Paul Rubin <no.email@nospam.invalid> - 2011-04-03 16:45 -0700
                Re: Renaissance of Forth Elizabeth D Rather <erather@forth.com> - 2011-04-03 14:01 -1000
                Re: Renaissance of Forth Albert van der Horst <albert@spenarnc.xs4all.nl> - 2011-04-06 22:43 +0000
                Re: Renaissance of Forth BruceMcF <agila61@netscape.net> - 2011-04-03 17:34 -0700
                Re: Renaissance of Forth John Passaniti <john.passaniti@gmail.com> - 2011-04-04 10:55 -0700
                Re: Renaissance of Forth pliz <s.m.plis@gmail.com> - 2011-04-04 13:11 -0700
                Re: Renaissance of Forth John Passaniti <john.passaniti@gmail.com> - 2011-04-05 09:10 -0700
                Re: Renaissance of Forth BruceMcF <agila61@netscape.net> - 2011-04-04 16:33 -0700
                Re: Renaissance of Forth Elizabeth D Rather <erather@forth.com> - 2011-04-04 16:31 -1000
                Re: Renaissance of Forth BruceMcF <agila61@netscape.net> - 2011-04-04 19:52 -0700
                Re: Renaissance of Forth John Passaniti <john.passaniti@gmail.com> - 2011-04-05 09:58 -0700
                Re: Renaissance of Forth BruceMcF <agila61@netscape.net> - 2011-04-05 18:36 -0700
                Re: Renaissance of Forth John Passaniti <john.passaniti@gmail.com> - 2011-04-06 13:53 -0700
                Re: Renaissance of Forth BruceMcF <agila61@netscape.net> - 2011-04-06 15:29 -0700
                Re: Renaissance of Forth John Passaniti <john.passaniti@gmail.com> - 2011-04-07 08:35 -0700
                Re: Renaissance of Forth BruceMcF <agila61@netscape.net> - 2011-04-07 16:20 -0700
                Re: Renaissance of Forth Alex McDonald <blog@rivadpm.com> - 2011-04-05 08:56 -0700
                Re: Renaissance of Forth John Passaniti <john.passaniti@gmail.com> - 2011-04-05 09:35 -0700
                Re: Renaissance of Forth Bluebee <visualforth@rocketmail.com> - 2011-04-06 17:48 -0700
                Re: Renaissance of Forth Bluebee <visualforth@rocketmail.com> - 2011-04-12 15:47 -0700
                Re: Renaissance of Forth John Passaniti <john.passaniti@gmail.com> - 2011-04-13 09:27 -0700
                Re: Renaissance of Forth Bluebee <visualforth@rocketmail.com> - 2011-04-13 09:55 -0700
                Re: Renaissance of Forth Richard Owlett <rowlett@pcnetinc.com> - 2011-04-13 13:02 -0500
                Re: Renaissance of Forth Elizabeth D Rather <erather@forth.com> - 2011-04-13 09:01 -1000
                Re: Renaissance of Forth Micke <oh2aun@gmail.com> - 2011-04-13 13:23 -0700
                Re: Renaissance of Forth Bluebee <visualforth@rocketmail.com> - 2011-04-13 20:32 -0700
                Re: Renaissance of Forth Micke <oh2aun@gmail.com> - 2011-04-13 20:52 -0700
                Re: Renaissance of Forth Bluebee <visualforth@rocketmail.com> - 2011-04-13 22:26 -0700
                Re: Renaissance of Forth Micke <oh2aun@gmail.com> - 2011-04-13 23:42 -0700
                Re: Renaissance of Forth Bluebee <visualforth@rocketmail.com> - 2011-04-14 10:42 -0700
                Re: Renaissance of Forth Micke <oh2aun@gmail.com> - 2011-04-14 13:06 -0700
                Re: Renaissance of Forth Bluebee <visualforth@rocketmail.com> - 2011-04-14 14:26 -0700
                Re: Renaissance of Forth Micke <oh2aun@gmail.com> - 2011-04-14 21:31 -0700
                Re: Renaissance of Forth Bluebee <visualforth@rocketmail.com> - 2011-04-14 23:42 -0700
                Re: Renaissance of Forth Micke <oh2aun@gmail.com> - 2011-04-15 00:56 -0700
                Re: Renaissance of Forth John Passaniti <john.passaniti@gmail.com> - 2011-04-15 08:03 -0700
                Re: Renaissance of Forth Micke <oh2aun@gmail.com> - 2011-04-15 09:28 -0700
                Re: Renaissance of Forth John Passaniti <john.passaniti@gmail.com> - 2011-04-15 10:28 -0700
                Re: Renaissance of Forth John Passaniti <john.passaniti@gmail.com> - 2011-04-13 20:40 -0700
                Re: Renaissance of Forth Bluebee <visualforth@rocketmail.com> - 2011-04-13 22:57 -0700
                Re: Renaissance of Forth John Passaniti <john.passaniti@gmail.com> - 2011-04-04 08:39 -0700
                Re: Renaissance of Forth Paul Rubin <no.email@nospam.invalid> - 2011-04-04 09:41 -0700
                Re: Renaissance of Forth Albert van der Horst <albert@spenarnc.xs4all.nl> - 2011-04-06 22:39 +0000
  Re: Renaissance of Forth Bluebee <visualforth@rocketmail.com> - 2011-04-02 20:32 -0700
    Re: Renaissance of Forth John Passaniti <john.passaniti@gmail.com> - 2011-04-02 22:06 -0700
      Re: Renaissance of Forth BruceMcF <agila61@netscape.net> - 2011-04-03 07:17 -0700
  Re: Renaissance of Forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-04-04 17:09 +0000
    Re: Renaissance of Forth Bernd Paysan <bernd.paysan@gmx.de> - 2011-04-05 15:55 +0200
      Re: Renaissance of Forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-04-07 16:25 +0000
        Re: Renaissance of Forth Bernd Paysan <bernd.paysan@gmx.de> - 2011-04-08 21:07 +0200
          Re: Renaissance of Forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-04-09 17:29 +0000
            Re: Renaissance of Forth Bernd Paysan <bernd.paysan@gmx.de> - 2011-04-10 18:39 +0200
      redirecting TYPE to a string (was: Renaissance of Forth) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-04-09 16:54 +0000
        Re: redirecting TYPE to a string (was: Renaissance of Forth) BruceMcF <agila61@netscape.net> - 2011-04-09 13:07 -0700
        Re: redirecting TYPE to a string (was: Renaissance of Forth) Bernd Paysan <bernd.paysan@gmx.de> - 2011-04-10 18:07 +0200

csiph-web