wejgaard / tclforth Goto Github PK
View Code? Open in Web Editor NEWMulti-platform desktop Forth based on Tcl/Tk
License: Other
Multi-platform desktop Forth based on Tcl/Tk
License: Other
The OSX archive expander sometimes claims that the downloaded TclForth.app is damaged, when you start it. Other Zip expanders, e.g. Stuffit Expander or BetterZip, deliver a working app.
Change font (type and size) directly in the Console:
Create new font (Tcl):
tcl font create Large -family Courier -size 20
Change font, make it active (Forth):
"-font Large" Console config
--- Together, copy to console ---
tcl font create Large -family Courier -size 20
"-font Large" Console config
--- Changing size ---
tcl font configure Large -size 15
TclForth is a Forth system that uses Tcl as its native language. It is a symbiosis of both worlds: The Forth code and colon words are compiled to Tcl procedures that handle arguments and results on a stack. The Forth and Tcl procedures coexist in the Tcl namespace and are all taken care of by the Tcl runtime system. Thus, the Tcl bytecode interpreter is also the inner interpreter of TclForth. For more see http://wiki.tcl.tk/37199.
I have built applications with TclForth for a while and now release it as an open source project. The system is prepared as self-contained double-click executables for Windows and OS-X (starpacks) and as a set of source files for Tcl in Linux and elsewhere. Installation = unzip.
I have not attempted to pack the complete universe of Tcl into Forth words. There are the usual standard words and a set of Tk words that I have needed so far. You are welcome to add whatever you miss.
The user guide in the wiki illustrates the features.
In the 0.71 release there is no .exe file while the 0.70 release of the day before has one.
Could the .exe be added, please?
(Discussed in comp.lang.forth)
Classic (standard) Forth systems are remarkably consistent in using techniques invented 40 years ago. For instance, the classic interpreter still executes command lines word by word. I wonder why. Of course, it works and everyone is used to it. But it does not have to be that way.
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.
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.
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.
TclForth has no CREATE DOES>. How, then, would you implement this Forth example, from (http://rosettacode.org/wiki/One-dimensional_cellular_automata#Forth).
: init ( bits count -- )
0 do dup 1 and c, 2/ loop drop ;
20 constant size
create state $2556e size init 0 c,
: .state
cr size 0 do
state i + c@ if ." #" else space then
loop ;
: ctable create does> + c@ ;
ctable rules $68 8 init
: gen
state c@ ( window )
size 0 do
2* state i + 1+ c@ or 7 and
dup rules state i + c!
loop drop ;
: life1d ( n -- )
.state 1 do gen .state loop ;
10 life1d
_###_##_#_#_#_#__#__
_#_#####_#_#_#______
__##___##_#_#_______
__##___###_#________
__##___#_##_________
__##____###_________
__##____#_#_________
__##_____#__________
__##________________
__##________________
__##________________
(The 'space' in .state changed to ." _")
I am totally lost in how to get this going in my Linux (mint). The directions are a little scant for me. I downloaded the Tclforth.zip and Source code (zip) for Tclforth v0.7.0.
I open a terminal and changed director to the source directory. But, the Linux directions "source tfmain.tcl" has me stymied.
Can someone please hold my hand in getting something up and running? I have been using tkinter in python and want to try it in forth.
Once upon a time, back in the 1980's I created a forth compiler for a DataGeneral s/200 and also for a z80 computer. I just installed swiftforth and have been re-learning forth.
Any help to just get this up and running would be appreciated. thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.