Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!husc6!mailrus!uwmcsd1!ig!agate!ucbvax!SCFVM.BITNET!ZMLEB
From: ZMLEB@SCFVM.BITNET (Lee Brotzman)
Newsgroups: comp.lang.forth
Subject: Infix operators
Message-ID: <8808121826.AA23206@jade.berkeley.edu>
Date: 12 Aug 88 17:53:00 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Organization: The Internet
Lines: 111


   Fraser Orr wondered why we Forth programmers don't use infix operators.
Well, we could if we wanted to.  I am following this message with another
that shows how to define infix operators in Forth.  It takes only three
very short Forth words, plus a series of redefinitions of the words you
would like to "infixize".

   Now, I guess the question is, "Why don't we want to use infix?"

   I can speak for no-one but myself when I say: I have had no trouble
learning to think in postfix.  Some people do, but that is their problem.
I have had no trouble learning to keep a three-deep stack in my head.
Some people do, but that is their problem.

   It is simply a matter of conventions and aptitudes, that's all.  Some
people get it and some people don't.  It's not really a big deal.  People
that like to program in Forth are not simply "unenlightened".  To the
contrary, many that I have met have been the most computer literate
people I've seen.  Using Forth is a matter of informed choice, not
ignorance.

   Fraser, I am sure that you have learned things that I would have a
terrible time at.  My wife is comptroller of a small company, and I
can't make hide nor hair of anything she does -- it's all "magic".
Likewise, the work I do -- archival and distribution of astronomical
data -- is "magic" to her.  I think it is time to accept the fact
that the problems you have with Forth are not universal.

   I grant you this:  Forth has a steep learning curve.  It also has
rewards for traveling up that curve that are difficult, if not
impossible, to find in other languages.

   For instance, take the message that I will send following this one.
I just saw it this morning on a local bulletin board dedicated to Forth
programming called the East Coast Forth Board (ECFB: 703-442-8695, 8-bits,
no parity, 1 Stop bit; 300, 1200, and 2400 baud; McLean, Virginia, USA).
My first thought was, "Fraser Orr should see this."  It was written by
Walt Pohl of Haverford College.  Using three simple Forth words, he can
redefine any Forth operator as infix rather than postfix.  It isn't fancy,
but it works.  Can you name another language where it is so easy to change
the compiler?  In C or Fortran or Pascal you are stuck with the language
constructs as they come, whether you like them or not (notwithstanding
the C macro facility).  In Forth, if you don't like it, CHANGE IT!

   It is this freedom that Forth programmers like.  It is individualism.
I can understand that you may not like it.  I only ask that you
understand that I (we) do.

   You also mentioned in your reply to me that you applaud the innovations
to the language I listed, but you added the caveat that if they weren't
part of a standard you wouldn't use them.  This I simply don't understand.
Do you mean to say that you have not built a library of functions in C for
your own use?  C without it's libraries -- much of which are not standard --
is practically useless.  Extensions to Forth are like C libraries.
They are useful items that have been developed to add functionality.
Many Forth programmers have their own versions of "mylib.c", except with a
different name of course, just like C programmers.  It is something we
share, not something that sets us apart.

   As for developing a typing system in Forth, I participated in a many-
months-long discussion about data typing on the ECFB with Mr. George
Hawkins.  To summarize it now would be impossible, suffice it to
say that data typing is possible at a great expense in compile time overhead.
If you are accustomed to traditional language compilers, waiting a minute
or two to compile a program probably doesn't bother you.  To a Forth
programmer, that is an interminable wait.  Anything that impacts compile
time, even if it may decrease some testing time will be resisted.

   Personally, the typing scheme used in Forth, where the data are not
typed but the operators on the data are (e.g. + to add two integers and
D+ to add two double precision integers) doesn't bother me in the least.
Another one of those attitude differences, I suppose.

   As for my statement of the rapid evolution of Forth.  On the scale of
the single programmer, the changes are not so great.  He has his system
and sticks with it.  That system evolves at its own rate and if
he has purchased a commercial system, his vendor should supply periodic
updates which outline any changes.  This evens out the learning curve
somewhat.

   By keeping "plugged in" to forums such as Usenet and BITNET, and the
bulletin boards like the ECFB and its "sister" boards the North Coast
Forth Board (NCFB) and the British Columbia Forth Board (BCFB), all
three of which I recommend very highly, one can see how things are
changing and adapt or not as one sees fit.  Electronic Forth conferences
also exist on other commercial systems like BIX and GEnie.  The Forth
Interest Group publishes a periodical with articles about new developments.
The Journal of Forth Applications and Research, published by the Institute
for Applied Forth Research in Rochester, New York, also carries articles
about advancements and applications in Forth.  Using these resources,
one can learn a lot.  I am sure that some of the international subscribers
to the BITNET FIGI-L mail conference can also tell of resources available
in their countries.

   Forth isn't just a "back woods" programming language anymore, even
though it isn't as popular as Fortran, C, Pascal, COBOL, and Ada.  It
has been used to control hydrogen fusion lasers, astronomical telescopes,
image processing systems, space hardware, robots, and automobiles.  It
has been used to write text editors, spread sheet programs and computer
games.  God knows what other applications Forth has been applied to.
I do not see these as only "very special cases" as you do.

   Enough of the psuedo-religious babbling.  I'll stop now.  Look for my
next message which contains the text of Mr. Pohl's infix operator code.

-- Lee Brotzman (FIGI-L Moderator)
-- BITNET:  ZMLEB@SCFVM      SPAN: CHAMP::BROTZMAN    GEnie: L.BROTZMAN
-- My opinions are my own and not those of my employer, ST Systems Corp.,
-- or their employer, NASA Goddard Space Flight Center, or their employer,
-- Ronald Reagan, or his employer, Nancy Reagan, or her employer, the
-- planets and stars.