Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

WHEN ARE WE GOING TO SEE SOME SOURCE CODE

20 views
Skip to first unread message

Daniel John Lee Parnell

unread,
Mar 11, 1993, 5:38:05 PM3/11/93
to
Hi,
I am reasonably new to forth, and I was wondering, when is there going
to be some source code for interesting words that people have worked out.
If you look at the other news groups like comp.lang.pascal or even
rec.games.corewar, you see source code that new users like me can use to
learn from. I have done several major projects using forth, but I have not
been using it to it's fullest potential. For example, I have just finished
writing some software for my fathers company on an RTX-2000 based machine.
I have been using forth off and on for several years, but I have never had
much in the way of source to learn from.

Hope that all makes sense.

Daniel

--

------------------------------------------------------------------------------
My e-mail address is s92...@minyos.xx.rmit.oz.au 131.170.20.80 (it think)
Theres no point in being grown up if you cant act childish sometimes : Dr Who

cam...@aussie.enet.dec.com

unread,
Mar 14, 1993, 9:56:26 PM3/14/93
to

Australia wishes to apologise for the tone of the subject line introduced...
It probably does not correspond to yelling... ;-)

In article <1nof0d...@escargot.xx.rmit.OZ.AU>, s92...@minyos.xx.rmit.OZ.AU (Daniel John Lee Parnell) writes:
> I am reasonably new to forth, and I was wondering, when is there going
>to be some source code for interesting words that people have worked out.

Please post what you have done and we will comment on it.

>If you look at the other news groups like comp.lang.pascal or even
>rec.games.corewar, you see source code that new users like me can use to
>learn from.

Luckily (?) we are not comp.lang.pascal or rec.games.corewar. There is very
little demand for educational postings in this group. Yours is the first that
I have seen in four years reading.

> I have done several major projects using forth, but I have not
>been using it to it's fullest potential. For example, I have just finished
>writing some software for my fathers company on an RTX-2000 based machine.
>I have been using forth off and on for several years, but I have never had
>much in the way of source to learn from.

I didn't either. Nor did the creator of FORTH. When I really needed some I
just downloaded all the PD FORTHs that I could find and pulled them apart.
I even read some books and one or two standards. This may help you.

>Hope that all makes sense.

Not really. I find it difficult to believe that you think that this newsgroup
exists to educate you. It's your job, not ours. If you want to receive, you
must also give.

--
James Cameron
Digital Equipment Corporation (Australia) Pty. Limited A.C.N. 000 446 800
(cam...@aussie.enet.dec.com)

Julian V. Noble

unread,
Mar 15, 1993, 4:03:25 PM3/15/93
to
Let's try to keep the discussion civil and avoid churlishness.

One might equally well say that the first chap (or shiela--no sexism
here, mate!) to chip a stone axe had not been shown how to do it, but
had to learn on his own. True, but irrelevant. I suppose being an
educator swilling from the public till my sense of mission is not that
of everyone else.

Nonetheless, despite the unfortunate title of his posting, Daniel's
request that occasionally we gurus (a laugh in my case) post a neat
idea for sharing is not entirely out of place.

IMNSHO, of course. --jvn

Mike Haas

unread,
Mar 15, 1993, 6:57:46 PM3/15/93
to
In article <1nof0d...@escargot.xx.rmit.OZ.AU> s92...@minyos.xx.rmit.OZ.AU (Daniel John Lee Parnell) writes:
>Hi,
> I am reasonably new to forth, and I was wondering, when is there going
>to be some source code for interesting words that people have worked out.

Here's an interesting one to support conditional LOADing of screens...

Used like:

200 LOAD? SQRT \ if SQRT is not loaded already, LOAD it from SCR 200


: LOAD? ( scr# -- , <wordname> )
BL WORD FIND nip
IF
DROP
ELSE
LOAD
THEN
;


Daniel John Lee Parnell

unread,
Mar 17, 1993, 4:32:45 PM3/17/93
to
cam...@aussie.enet.dec.com () writes:

>Not really. I find it difficult to believe that you think that this newsgroup
>exists to educate you. It's your job, not ours. If you want to receive, you
>must also give.

I have already posted some words of mine that I developed to do 3D graphics.
Also, whenever I read this news group I invariably see someone writing that
forth is not doing very well gaining new users. I think that in order to
encourage new programmers the forth community in general should encourage the
newer forth programmers, and help them over many of the obsticals involved in
becoming proficent at forth. Saying that they have to educate them selves, in
my opinion is not the way to encourage them to continue using forth.

cam...@aussie.enet.dec.com

unread,
Mar 22, 1993, 12:53:23 AM3/22/93
to

In article <1993Mar15.2...@murdoch.acc.Virginia.EDU>, j...@fermi.clas.Virginia.EDU (Julian V. Noble) writes:
>Let's try to keep the discussion civil and avoid churlishness.

Right. Sorry. Must've been a bad day.

>Nonetheless, despite the unfortunate title of his posting, Daniel's
>request that occasionally we gurus (a laugh in my case) post a neat
>idea for sharing is not entirely out of place.

True.

It's very difficult though, to work out what would be useful. I lack knowledge
of how much my potential students know already.

I'd actually prefer to enter into dialog with someone who wants to learn
FORTH, rather than randomly posting. That way I'd be able to asses their
current standing and aim my work appropriately.

Leslie J. Somos

unread,
Mar 22, 1993, 4:49:24 PM3/22/93
to

In a previous article, cam...@aussie.enet.dec.com () says:
...

>Luckily (?) we are not comp.lang.pascal or rec.games.corewar. There is very
>little demand for educational postings in this group. Yours is the first that
>I have seen in four years reading.
...

Speaking for myself, there is some pent-up demand.
Here is number 2.

--

Carl Zmola

unread,
Mar 23, 1993, 3:02:17 PM3/23/93
to
cam...@aussie.enet.dec.com () writes:

>>Nonetheless, despite the unfortunate title of his posting, Daniel's
>>request that occasionally we gurus (a laugh in my case) post a neat
>>idea for sharing is not entirely out of place.
>True.
>It's very difficult though, to work out what would be useful. I lack knowledge
>of how much my potential students know already.

>I'd actually prefer to enter into dialog with someone who wants to learn
>FORTH, rather than randomly posting. That way I'd be able to asses their
>current standing and aim my work appropriately.

I'd like to see code that implements data structure or strings.
I've been frustrated by my lack of ablility to do it cleanly. I assume
you can just create large variables, but is there a standard way of
naming words to access the data elements. How about pushing and popping
the large elements to the stack (rot then becomes less usefull).

I am facinated by forth, and like the principles, but I can't
seem to work with it without implementing data structures for floating
point numbers and strings.

Carl
zm...@bert.eecs.uic.edu

Michael R Geddes

unread,
Mar 23, 1993, 11:09:56 PM3/23/93
to
zm...@bert.eecs.uic.edu (Carl Zmola) writes:

> I'd like to see code that implements data structure or strings.
>I've been frustrated by my lack of ablility to do it cleanly. I assume
>you can just create large variables, but is there a standard way of
>naming words to access the data elements. How about pushing and popping
>the large elements to the stack (rot then becomes less usefull).

Did I send anyone the code to the data-structs program which I posted to this
news group last year sometime.. it was called 'vars.seq' and had a very
recursive and extensive definition of structs/arrays/string types &c.
It was also able to create multiple instances of the variables. I could
probably dig up the code myself, but it's at home (400-500 km's away!!).
Another neat feature was its ability to copy arbitrary data structures
(trivial implementation too!).

Please send me/post the implementation if anyone has it!!

Michael Geddes.


Christopher Browne

unread,
Mar 24, 1993, 9:15:11 AM3/24/93
to
zm...@bert.eecs.uic.edu (Carl Zmola) writes:

> I'd like to see code that implements data structure or strings.
>I've been frustrated by my lack of ablility to do it cleanly. I assume
>you can just create large variables, but is there a standard way of
>naming words to access the data elements. How about pushing and popping
>the large elements to the stack (rot then becomes less usefull).

The original posting disappeared on me, and I think it included
something about floating point as well.

It would make sense to do up code for some individual data structures;
unfortunately, such things are often of rather limited and specific
use.

A "clean" system for strings or floating point is something that's a
MAJOR amount of work.

I've seen brief articles on such in FD; they tend to combine
significant design work with fairly intensive libraries of words.
It's not enough to have a good representation - you also need a
"clean" set of words.

I'd speculate that anyone that comes up with a sufficiently good
system probably would prefer to make it into a commercial product, and
if they're not good enough to make it viable, they're still probably
arrogant enough to try :-).

You'd probably be best off looking for a commercial quality product;
it may not be 100% "clean," but it'll probably have seen a lot more
work than what you or I have time to put into it.

--
Christopher Browne | PGP 2.0 key available
cbbr...@csi.uottawa.ca |======================================
University of Ottawa | Genius may have its limitations, but
Master of System Science Program | stupidity is not thus handicapped.

Jon Vander Hill

unread,
Mar 25, 1993, 2:34:55 PM3/25/93
to
>>>>> On Wed, 24 Mar 93 14:15:11 GMT, cbbr...@csi.uottawa.ca
>>>>> (Christopher Browne) said:

> A "clean" system for strings or floating point is something that's a
> MAJOR amount of work.

> It's not enough to have a good representation - you also need a
> "clean" set of words.

> You'd probably be best off looking for a commercial quality product;


> it may not be 100% "clean," but it'll probably have seen a lot more
> work than what you or I have time to put into it.

What attributes of a system or set of words make them "clean"?
This is not a flame. I'm really not sure what you mean.

Jon Vander Hill
j...@cas.org

Julian V. Noble

unread,
Mar 25, 1993, 2:40:18 PM3/25/93
to
>Tue, 23 Mar 1993 20:02:17 GMT comp.lang.forth Topic 15 of 57
>Article 11239 Re: WHEN ARE WE GOING TO SEE SOME SOURCE CODEResp 6 of 6
>Carl Zmola at University of Illinois at Chicago
>zm...@bert.eecs.uic.edu
>
> I'd like to see code that implements data structure or strings.
>I've been frustrated by my lack of ablility to do it cleanly. I assume
>you can just create large variables, but is there a standard way of
>naming words to access the data elements. How about pushing and popping
>the large elements to the stack (rot then becomes less usefull).
>
> I am facinated by forth, and like the principles, but I can't
>seem to work with it without implementing data structures for floating
>point numbers and strings.
>
> Carl
> zm...@bert.eecs.uic.edu

Here is a simple example of defining code to define and access a vector
of bytes, words (2 bytes), dwords (4 bytes) or qwords (8 bytes):

CREATE <types> 1 C, 2 C, 4 C, 8 C,
: #bytes ( n -- t) <types> + C@ ;
: long ; \ optional dummy word for style
0 CONSTANT byte 1 CONSTANT word 2 CONSTANT dword 3 CONSTANT qword
: 1ARRAY ( n t -- ) CREATE UNDER , SWAP #bytes * DUP , ALLOT
DOES> DUP 4 + SWAP @ ( -- adr t) ;
: } ( adr t n -- adr + n*#bytes[t] t ) OVER #bytes * ROT + SWAP ;

: GU: CREATE ] DOES> OVER + + @ EXECUTE ; \ execution arrays
GU: g@ C@ @ D@ Q@ ; \ generic @
GU: g! C! ! D! Q! ; \ generic !

\ Usage: 20 long byte 1ARRAY a{ \ creates a 20-byte long vector
\ a{ 3 } address and type of 3rd element.
\ To find contents of a{ 3 } say: a{ 3 } g@
\ To store to a{ 3 } (assuming correct stuff is on stack) say a{ 3 } g!

Hope you like it. It is based on a notation I have developed for scientific
computing, as described in my book "Scientific FORTH: a modern language for
scientific computing" (ISBN 0 9632775-0-2) as sold by the finest bookstores,
not to mention Forth Interest Group, Miller Microcomputer Services,
Forth Institute (Rochester, NY), MicroProcessor Engineering, Ltd., or
direct from the publisher,

Mechum Banks Publishing
P.O. Box 335
Ivy, Virginia 22945

Fax (804) 296 5488

Cheers! --jvn

Julian V. Noble

unread,
Mar 25, 1993, 3:43:19 PM3/25/93
to
I don't know about strings (I use them, but almost entirely 255-byte max
counted strings), but "clean" code for floating point (and much, much
more) is discussed in my book "Scientific FORTH: a modern language for
scientific computing" (ISBN 0-9632775-0-2, as sold in only the best of
stores, for the intelligentsia, natch). It also comes on the disk (update
files recently posted in encrypted form--sorry, you need the book to
decrypt-- on GEnie). Most of the code is high level, except for that which
uses directly the 80x87 chip. If you want fp for a non-Intel machine, if
it has a math co-processor translating will be fairly straightforward. If
you want software emulation (something I won't do--I agree with Chuck Moore
to this point: fp is no good unless you have a dedicated co-processor), you
can get Jack Brown's VP-Planner fp package and translate it to whatever
machine you like. It was, after all, a commercial-grade package (until
Lotus bombed them). I think it's on GEnie.

--jvn

Christopher Browne

unread,
Mar 25, 1993, 6:30:08 PM3/25/93
to

Consistent, orthogonal, complete. With a good interface to other
parts of the Forth system. That's hard.

I've seen various little libraries of string words here and there;
they often seem fairly good in and of themselves, but may not be
worthy of integration into the overall system.

A set of string words needs to be "powerful enough;" they should
include a fairly wide set of operations, including things like
catenation, extraction of substrings, searching, perhaps things like
changing case, and the like.

To this point, it's pretty easy. The operations involve some DO
LOOPS, some CMOVES, and other such stuff. Maybe some use of ASCII.

Unfortunately, you don't just do operations ON strings, you may want
to GET them, and PUT them somewhere. I/O rears its head. You don't
merely want to be able to process strings, you want to use your
Forth's facilities to read and write them too. The block/stream war
rears its ugly head. IO is relatively portable if you're using
blocks, but if you use stream files, the job gets tough.

Then comes the memory allocation problem. You have to make sure that
there's a good place (in memory) to put the results of a string
operation. The PAD might be a good spot, but some Forths don't have
one. And if you have a 400 byte string to work with, the PAD may not
hold it.

There was a fairly ancient FD that had a "stack string" library; you
would push the addresses of strings, and parameters for the operations
onto the stack, and it was quite faithful to the "stack" way of doing
things. (If I were doing it, I'd make up Yet Another Stack; I'm one
of those that think that Forth is the language that has "At Least Two
Stacks," and that more would probably be merrier.) Essentially, the
library seemed to have a region of memory that was a "stack" in which
strings would be stored, operated on, and returned to.

I don't know of any Forth string library that directly used dynamic
RAM allocation; that would be a fairly sensible alternative method
that allows the string system to be a little more general, because it
doesn't assume that strings have to be in a single canonical place.

In short, memory allocation is a problem.

A third "problem" is that it would be really nice to be able to run
strings through the interpreter. If you've got a really nice string
library, wouldn't it make sense to use it to make the interpreter
smarter? This is going to be terribly nonportable (even, I think, in
ANSI Forth), and without careful design will have lots of alligators
in it.

To sum up, it's hard to design a good string library, because there's
some "externals" like I/O, memory allocation and interpretation that
are going to be important despite the fact that they don't appear to
be string-related at first glance.

Any reasonably useful library won't be portable. I am unsure of
whether ANSI significantly influences this.

Does this explain what I meant?

Norman E. Smith, CDP

unread,
Mar 29, 1993, 7:57:30 AM3/29/93
to
Christropher Browne writes:

>Consistent, orthogonal, complete. With a good interface to other
>parts of the Forth system. That's hard.
>
>I've seen various little libraries of string words here and there;
>they often seem fairly good in and of themselves, but may not be
>worthy of integration into the overall system.
>

The best string package I have ever run across is in VAX Stoic. There
are only 7 or 8 words, but they are well factored and simply elegant.
They can easily be translated to Forth. I have used VAX Stoic in
a very large database publishing system for several years. Most of
the application ends up being string maninpulation.

Norm
____________________________________________________________________
Norman E. Smith, CDP Science Applications International
smi...@orvb.saic.com P.O. Box 2501
615-482-9031 301 Laboratory Road
Oak Ridge, Tenn. 37831-2501
SGML applications, TODAY!

Carl Zmola

unread,
Mar 29, 1993, 4:19:58 PM3/29/93
to
smi...@orvb.saic.com ("Norman E. Smith, CDP" ) writes:

>The best string package I have ever run across is in VAX Stoic. There
>are only 7 or 8 words, but they are well factored and simply elegant.
>They can easily be translated to Forth. I have used VAX Stoic in
>a very large database publishing system for several years. Most of
>the application ends up being string maninpulation.

What are these words, and what do they do?
It would be nice to see what these are. Is there a
reference available for Stoic?

Carl
zm...@cicero.spc.uchicago.edu

cam...@aussie.enet.dec.com

unread,
Mar 29, 1993, 7:19:48 PM3/29/93
to

In article <1o85du...@escargot.xx.rmit.OZ.AU>, s92...@minyos.xx.rmit.OZ.AU (Daniel John Lee Parnell) writes:
>cam...@aussie.enet.dec.com () writes:
>>Not really. I find it difficult to believe that you think that this newsgroup
>>exists to educate you. It's your job, not ours. If you want to receive, you
>>must also give.
>I have already posted some words of mine that I developed to do 3D graphics.

They were great. Keep it up. I learned from them.

>Also, whenever I read this news group I invariably see someone writing that
>forth is not doing very well gaining new users.

True. I think we should stop talking about it, and the problem will go away
over time. It's the discussion of the problem that helps to keep it uppermost
in people's minds.

>I think that in order to
>encourage new programmers the forth community in general should encourage the
>newer forth programmers, and help them over many of the obsticals involved in
>becoming proficent at forth.

Yes. I agree.

>Saying that they have to educate them selves, in
>my opinion is not the way to encourage them to continue using forth.

True. It would not encourage them to read such a statement.

But I won't lie to them. It is *their* responsibility to educate themselves;
nobody else can do it for them. We can all help, by providing input in
the form of discussion and source code, but in the end it's their problem.

Norman E. Smith, CDP

unread,
Mar 30, 1993, 8:42:51 AM3/30/93
to
Carl Zmola writes:

I got the VAX Stoic distribution from DECUS several years ago. I'll
dig out the tape order number if anyone is interested. Stoic is
an ancient Forth dialect (circa 1977-1980). It has quite a few
differences from Forth including a vocabulary stack (Which I like too..),
a separate loop stack, and the : comes after the word name
instead of before it. For example:

A Forth word-> : Forth swap drop rot etc ;
A Stoic word-> 'Stoic : swap drop rot etc ;

It took a little getting used to, but not that much different. The VAX
version was done by Roger Hauck. I forget who did the original version.

Stoic also has built in string variables that define the max length
the string can hold.

99 'a_string svariable

defines 'a_string' with a max length of 99 bytes. Stoic strings are
also counted, but with 2 bytes for the length. This allows
lllllooooonnnngggg strings. When a string operation is performed,
the result of the operation is truncated to fit within the max
length for that string variable.

Here is a summary of the Stoic string word set:

move_string ( 'from 'to --- )
.move_string ( 'from length 'to --- )
strap ( 'from 'to --- )
.strap ( 'from length 'to --- )
( strap is string append. The contents of the from
string are appended to the contents of the to
string)
stab ( char 'to --- )
( Store a byte - appends the char to the 'to' string)
msg ( 'string --- )
( Type the contents of string. i.e. count type )

These are the primary words I used. There are also a couple of string
compare words that I don't remember the stack comments for. One
compared whole strings and the other searched a string for a match
on a substring. Stoic also supports file I/O, so words to read
and write strings are there too.

Hope this sheds a little light and provides a little history worthy
of becoming trivia...

Mike Haas

unread,
Apr 7, 1993, 10:54:04 PM4/7/93
to

>>>Not really. I find it difficult to believe that you think that this newsgroup
>>>exists to educate you. It's your job, not ours. If you want to receive, you
>>>must also give.

Which is probably just what this new user would LOVE to do... to
participate. But short and short-sighted responses
like the above make it difficult.

SOMEBODY around here was complaining that vendors try to keep
secrets and won't share their proprietary technology... here's
a USER who won't share a little KNOWLEDGE!

>>I have already posted some words of mine that I developed to do 3D graphics.
>
>They were great. Keep it up. I learned from them.

Just think, if Forth were more portable, how we could move code
around, much of it INTER-PLATFORM!


>
>>Also, whenever I read this news group I invariably see someone writing that
>>forth is not doing very well gaining new users.
>
>True. I think we should stop talking about it, and the problem will go away
>over time. It's the discussion of the problem that helps to keep it uppermost
>in people's minds.

Now we are at one of the core problems, IMO. The belief that
everything is just fine the was it is, and nothing needs fixed,
nothing needs changed or standardized. We should all just
shut up and play with our little Forths.

Many newcomers would probably be surprised to know that Forth was
a favorite subject for major trade rags as little as 6 or 7 years
ago. Anyone who saw it will never forget the BYTE cover (yes,
BYTE magazine) with the word FORTH at the bottom of it,
with a beautiful illustration of concrete-looking "blocks"
(very solid in appearance), with a few small holes "drilled"
in them, through which passed interconnecting sets of
threads. Dr. Dobbs was almost dedicated to Forth. We've
all become painfully aware of the decline in published
Forth material in bookstores.

Yes, Forth was looked at quite heavily at one point.

If discussion of the problem helps keep it uppermost in peoples minds,
I say "It's about time".


0 new messages