On Sun, 26 Oct 2014 18:06:42 +0000, mm0fmf wrote:
> On 26/10/2014 16:44, rickman wrote:
>> Now I need to learn how to use gforth to open a serial port and open a
>> window from and send text to it to be displayed.
>
> Is this a new version of Trivial Pursuit? :-)
>
> Forth... sweet baby Jesus what an abomination of a language. 'Coz people
> don't write unreadable code as it is without using a
> "write-once-read-never" language like Forth.
>
There's one that's considerably worse - Ken Iverson's APL.
For starters, it evaluates an expression strictly right to left and does
not use either operator precedence or grouping, i.e. brackets, to let the
programmer deviate from this evaluation order.
Although there are, apparently ASCII implementations, the preferred ones
use a special charset and keyboard which have no other known use:
Advantage: You can write compact code: Ken Iverson once wrote a text
editor in 25 lines
Disadantage: the ultimate write-only programming language: when Ken
Iverson needed to modify that text editor six months later, even he
couldn't understand it.
> It's 2014 and soon will 2015. Must be time to let Forth rest in peace
> now and move to a modern language.
>
Maybe so, but I wouldn't be surprised to find there's still a lot of it
still running in radio-astronomy labs.
To the OP: Pardon my digression.
What, exactly do you want to do with Forth now you have it installed?
IOW, are you expecting to run somebody else's Forth code, or are you
intending to teach yourself Forth and write a program yourself that uses
a serial port to read and write data?
Forth is an interactive system that contains its own command line
interpreter and runtime environment, so running gforth from the RPi
command line should cause it to prompt for input exactly as if you'd
started a BASIC interpreter or another bash shell.
gforth may or may not use the Linux filing system to store programs -
that depends on the way it has implemented Forth. Years ago I dabbled
with a traditional Forth implementation on a 6809 microcomputer that ran
Flex 09 (a CP/M contemporary). Traditional Forth systems stored programs
as a set of one or more numbered screens, each of 1KB (i.e. 16 lines of
64 characters). The version I used kept these in a large, randomly
accesses file along with the set of words[1] that defined the Forth
runtime/command interpreter/compiler/standard library.
To drive something external, such as a serial line, you need to write or
download a set of words that can read from and write to a serial port.
Again, the details at the lowest level of words used for this will depend
on the Forth implementation you're using. Unfortunately, because these
will need to use the Linux i/o system you may find that they have system
dependencies.
[1] 'word' is a Forth term that roughly corresponds to a C function
function.
My Forth books date from 1983 and 1985, which shows how long it is since
I last looked at it. As a result I have no suggestions about more recent
reference material though
http://www.forth.org may be worth a look.
HTH
--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |