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


Groups > comp.lang.forth > #33762

Re: TclForth Notes: Always Compiling, Forth without STATE

From Wolf Wejgaard <wolf@holonforth.com>
Newsgroups comp.lang.forth
Subject Re: TclForth Notes: Always Compiling, Forth without STATE
Date 2014-10-08 17:41 +0200
Organization Aioe.org NNTP Server
Message-ID <m13lv0$dod$1@speranza.aioe.org> (permalink)
References <m130qf$lb2$1@speranza.aioe.org>

Show all headers | View raw


Am 08.10.14 13:53, schrieb Albert van der Horst:
 > In article <m130qf$lb2$1@speranza.aioe.org>,
 > Wolf Wejgaard  <wolf@holonforth.com> wrote:
...

 >> TclForth compiles the command line and then executes the compiled line.
 >> If the command line is compiled it can handle immediate words. You can
 >> enter lines like this
 >>
 >>     1 begin dup 10 < if "*" else "&" then . 1+ dup 20 > until drop
 >>
 >>
 >> TclForth always compiles. Interpret is Compile and Execute.
 >
 > The above phrase works in ciforth after replacing . by $. and
 >     WANT -scripting-  WANT CASE-INSENSITIVE   WANT $.
 >     CASE-INSENSITIVE
 > Allowing this is a sensible extension (or I wouldn't have implemented 
it).
 > It can be implemented in a few lines.
 >

Nice

 >>
 >> If you need to calculate a value while compiling a definition, enclose
 >> the calculation in square brackets as usual. The code inside the
 >> brackets is compiled, then executed by ']' .
 >>
 >> There are just two moments in the interpreter when code is executed:
 >> end-of-command-line and ']'. Thus, STATE is obsolete, it is not tested.
 >>
 >> And if there is no STATE to test, the immediate bit also makes little
 >> sense. TclForth replaces immediate by Compiler.
 >
 > This can be an improvement in design, but its result is not ISO, e.g.
 >      : test [ 1 2 + . ] ] ." We gaan naar Rome" ;
 > This is allowed in ISO, the superfluous extra ] is a problem in your 
system.
 >

There is no extra ] needed, the final ] of the expression executes the 
script in the brackets. Actually the Forth script is compiled to a Tcl 
script and evaluated by Tcl. I just tested it -- and learned that '[' 
and ']' are still missing in TclForth source V052 -- so I added them 
with these two lines.

Compiler [  appendcode \[

Compiler ]  appendcode "\] "

The Forth script
     : test { -- } [ 1 2 + . ] ." We gaan naar Rome" ;

is compiled to the Tcl script
     proc test {} {
        [push 1 ; push 2 ;  + ;  .. ; ] push "We gaan naar Rome" ;
        print [pop] ;
     }
and later passed to Tcl for execution.

ok> test
3 We gaan naar Romeok>

 >>
 >> Immediate words are now Compiler words that execute native Tcl code. -
 >> Example:
 >>
 >>     Compiler if
 >>         appendcode "if \[pop\]  \{\n"
 >>
 >> Code and Colon words compile a call to their execution semantics.
 >> Compiler words perform their compilation semantics.
 >
 > The attractive thing about Forth is the extensible compiler.
 > Will I have to learn tcl to extend your compiler?
 >

Yes, the compiler words are defined in Tcl script.

Regards, Wolf

 >>
 >> --
 >>
 >> I am still struggling with the text and welcome comments to clarify it.
 >>
 >> Anyway: TclForth works and is available for inspection.
 >>
 >> --
 >> Wolf Wejgaard
 >
 > Groetjes Albert
 >

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


Thread

TclForth Notes: Always Compiling, Forth without STATE Wolf Wejgaard <wolf@holonforth.com> - 2014-10-08 11:40 +0200
  Re: TclForth Notes: Always Compiling, Forth without STATE albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-10-08 11:53 +0000
  Re: TclForth Notes: Always Compiling, Forth without STATE Wolf Wejgaard <wolf@holonforth.com> - 2014-10-08 17:41 +0200
    Re: TclForth Notes: Always Compiling, Forth without STATE Joachim Merkel <jm@7fun.de> - 2014-11-30 22:20 +0100
      Re: TclForth Notes: Always Compiling, Forth without STATE Wolf Wejgaard <wolf@holonforth.com> - 2014-12-04 16:54 +0100
        Re: TclForth Notes: Always Compiling, Forth without STATE m.a.m.hendrix@tue.nl - 2014-12-05 00:05 -0800
          Re: TclForth Notes: Always Compiling, Forth without STATE "Elizabeth D. Rather" <erather@forth.com> - 2014-12-04 22:47 -1000
            Re: TclForth Notes: Always Compiling, Forth without STATE Bernd Paysan <bernd.paysan@gmx.de> - 2014-12-05 19:04 +0100
              Re: TclForth Notes: Always Compiling, Forth without STATE Wolf Wejgaard <wejgaard@gmail.com> - 2015-01-21 02:23 -0800
          Re: TclForth Notes: Always Compiling, Forth without STATE Wolf Wejgaard <wolf@holonforth.com> - 2014-12-06 08:53 +0100
            Re: TclForth Notes: Always Compiling, Forth without STATE mhx@iae.nl - 2014-12-06 00:21 -0800
        Re: TclForth Notes: Always Compiling, Forth without STATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2014-12-05 03:16 -0600
          Re: TclForth Notes: Always Compiling, Forth without STATE Wolf Wejgaard <wolf@holonforth.com> - 2014-12-06 09:31 +0100
            Re: TclForth Notes: Always Compiling, Forth without STATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2014-12-06 04:16 -0600
            Re: TclForth Notes: Always Compiling, Forth without STATE albert@spenarnc.xs4all.nl (Albert van der Horst) - 2014-12-06 10:40 +0000
            Re: TclForth Notes: Always Compiling, Forth without STATE anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-12-06 12:42 +0000
              Re: TclForth Notes: Always Compiling, Forth without STATE Wolf Wejgaard <wejgaard@gmail.com> - 2015-01-21 02:26 -0800
            Re: TclForth Notes: Always Compiling, Forth without STATE Joachim Merkel <jm412@gmx.de> - 2014-12-06 18:11 +0100
              Re: TclForth Notes: Always Compiling, Forth without STATE Joachim Merkel <jm@g7up.de> - 2014-12-06 18:25 +0100
              Re: TclForth Notes: Always Compiling, Forth without STATE Joachim Merkel <jm@7up.de> - 2014-12-06 18:42 +0100
            Re: TclForth Notes: Always Compiling, Forth without STATE mix <mix@test.net> - 2014-12-15 18:55 +0000
              Re: TclForth Notes: Always Compiling, Forth without STATE Coos Haak <chforth@hccnet.nl> - 2014-12-16 01:27 +0100
                Re: TclForth Notes: Always Compiling, Forth without STATE Coos Haak <chforth@hccnet.nl> - 2014-12-16 01:50 +0100
                Re: TclForth Notes: Always Compiling, Forth without STATE mix <mix@test.net> - 2014-12-16 05:04 +0000
                Re: TclForth Notes: Always Compiling, Forth without STATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2014-12-16 04:08 -0600
                Re: TclForth Notes: Always Compiling, Forth without STATE mix <mix@test.net> - 2014-12-16 23:32 +0000
                Re: TclForth Notes: Always Compiling, Forth without STATE "Elizabeth D. Rather" <erather@forth.com> - 2014-12-16 14:45 -1000
                Re: TclForth Notes: Always Compiling, Forth without STATE mix <mix@test.net> - 2014-12-17 06:01 +0000
                Re: TclForth Notes: Always Compiling, Forth without STATE "Elizabeth D. Rather" <erather@forth.com> - 2014-12-16 22:21 -1000
                Re: TclForth Notes: Always Compiling, Forth without STATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2014-12-17 02:24 -0600
                Re: TclForth Notes: Always Compiling, Forth without STATE "Elizabeth D. Rather" <erather@forth.com> - 2014-12-16 23:07 -1000
                Re: TclForth Notes: Always Compiling, Forth without STATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2014-12-17 08:21 -0600
                Re: TclForth Notes: Always Compiling, Forth without STATE "Elizabeth D. Rather" <erather@forth.com> - 2014-12-17 08:57 -1000
                Re: TclForth Notes: Always Compiling, Forth without STATE JennyB <jennybrien@googlemail.com> - 2014-12-17 04:52 -0800
                Re: TclForth Notes: Always Compiling, Forth without STATE anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-12-17 09:58 +0000
                Re: TclForth Notes: Always Compiling, Forth without STATE mix <mix@test.net> - 2014-12-18 04:11 +0000
                Re: TclForth Notes: Always Compiling, Forth without STATE mix <mix@test.net> - 2014-12-18 04:16 +0000
                Re: TclForth Notes: Always Compiling, Forth without STATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2014-12-17 02:11 -0600
                Re: TclForth Notes: Always Compiling, Forth without STATE stephen@mpeforth.com (Stephen Pelc) - 2014-12-17 13:17 +0000
                Re: TclForth Notes: Always Compiling, Forth without STATE Mark Wills <markwills1970@gmail.com> - 2014-12-17 06:24 -0800
        Re: TclForth Notes: Always Compiling, Forth without STATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2014-12-05 03:19 -0600
          Re: TclForth Notes: Always Compiling, Forth without STATE Wolf Wejgaard <wolf@holonforth.com> - 2014-12-06 09:31 +0100
            Re: TclForth Notes: Always Compiling, Forth without STATE Andrew Haley <andrew29@littlepinkcloud.invalid> - 2014-12-06 04:19 -0600
            Re: TclForth Notes: Always Compiling, Forth without STATE rickman <gnuarm@gmail.com> - 2014-12-08 01:14 -0500
  Re: TclForth Notes: Always Compiling, Forth without STATE the_gavino_himself <visphatesjava@gmail.com> - 2014-12-17 05:42 -0800

csiph-web