home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!ub4b!alcbel!se.alcbel!btma74.nohost.nodomain!cgra
- From: cgra@btma74.nohost.nodomain
- Newsgroups: comp.lang.forth
- Subject: Re: Documenting
- Message-ID: <1421@se.alcbel.be>
- Date: 12 Jan 93 08:25:47 GMT
- References: <4235.UUL1.3#5129@willett.pgh.pa.us>
- Sender: guest@se.alcbel.be
- Reply-To: cgra@se.alcbel.be
- Lines: 44
- Nntp-Posting-Host: btmwc2
-
-
- I was a novice Forth user once (weren't we all?) - now I guess you could
- call me an ex-user. Neither transition was voluntary - I was given the
- job of programming a piece of test equipment which happened to think Forth,
- so I did; for my current task the choice is between C and 386 assembler, so
- I use them. Curiously enough, the test equipment had a screen, keyboard,
- and a floppy drive, just like a PC (or even more like my ST, since it had
- a 68000 inside); whereas my current task is for an imbedded system. Funny old
- world.
-
- To get to the point: I came from a background of Algol/Pascal/CHILL (not C),
- sat down in front of a Forth machine with "stream" files, opened a textbook,
- and got hacking. I ended up with a sizeable application which validated
- levels 2 and 3 of our X.25 implementation more thoroughly than any PTT had
- done (i.e., found bugs they never did :-)). In the course of doing so I
- kind of "evolved" a style out of my block-structured background and the
- screen-oriented style of the literature:
-
- : FOO ( -- )
- BAR BAZ JEREMY BEADLE DWEEZY DUP ROT ZOOI ( dig potatoes ) @
- ;
-
- A lot of the embedded comments were running commentaries on the state of the
- stack - if _I_ needed to write it down, then I left it in for any poor sucker
- who might have to maintain the code. (Write-only code is way out of fashion).
-
- Nested control structures? Didn't seem to need 'em. For the basic state
- machine, I used defining words supplied with the equipment - and added some
- of my own. For the only really logic-intensive part (checking X.25 facilities)
- I ended up defining more words than expected - if some great monolithic word
- didn't work then I'd split it up for debugging purposes, and once it was
- working there was no compelling reason to put it back together again. And it's
- surprising how often these 'sub-words' come in useful again...
-
- I found the "Forth experience" instructive, and I'd happily repeat it.
- It will probably affect my coding style in block-structured languages, in the
- sense of making my procedures shorter and my nesting shallower.
-
- So if one day you come across an X.25 implementation written in strangely
- "horizontal" C, check the author's name...
-
- __________________________________________________________________________
- Chris Gray | Any views expressed are those of the author and not of
- cgra@se.alcbel.be | any organisation with the author may be associated.
-