home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / forth / 3828 < prev    next >
Encoding:
Text File  |  1993-01-12  |  2.7 KB  |  57 lines

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