From: dpbsmith@world.std.com (Daniel P. B. Smith)
Subject: Spaghetti  DO's in FOCAL (was: Re: Branching in HLL vs. Assembler)
Organization: The World Public Access UNIX, Brookline, MA
Date: Thu, 3 Sep 1992 14:40:07 GMT

FOCAL was a delightful language. It was current around the mid seventies in
DEC environments. It was reputed to have roots in MUMPS and in JOSS, but I 
can't speak to that since I never used them. It was extensively improved
by Jim van Zee of the University of Washington.  It was also used 
commercially by the Coca-Cola company in a version called COKE.  DEC sort
of abandoned it, I believe because of legal questions regarding Richard
Merrill's (name?) contributions -- i.e. Digital wasn't sure they could
prove they owned the language.

It was similar to BASIC in terms of the sorts of systems it ran on and the
sorts of things it was good for.  IMHO it was superior to BASIC -- that is,
at equivalent points in time, implemented on machines with equivalent
resources, I liked FOCAL better.  I thought it was a small tragedy that
it never found its way into the micro world.  

Anyway, one of the characteristics of FOCAL was that statements were
all numbered, but the numbering had a predefined STRUCTURE.  They were
of form I.DD where I was an integer from 1 to 31 and DD was a pair of
digits in the range 00 to 99.  As with BASIC, statements could be typed in
with any line number, were executed in order, and the normal technique
was to leave gaps in anticipation of later insertions.  Jim van Zee's
version certainly allowed renumbering, but I don't know if "classic" FOCAL
did.

Anyway, the interesting characteristic of the language was that there was
no return statement.  The equivalent of a subroutine call was the "DO"
statement.  Oh, maybe I should mention that FOCAL statements tended to be
very compact -- all statement names can, and in practice usually were,
appreviated to their FIRST character (yes, there were only 26 statements),
and of course you could, and usually did, have many statements per line.

The statement "DO 3.14" meant to execute the statements on line 3.14 and
then return.

The statement "DO 3", however, meant to do group 3 -- that is, execute
ALL of the statements in group 3, in numerical order, then return.

In other words, every line was potentially a subroutine -- with an 
implied return at the end of the line.  But DO 3 would execute all of
the statements in the group sequentially.

Remember, there were no statement NAMES.  

Believe it or not, I still stand by my earlier statement -- I thought FOCAL
was better.  And in practice, I believe there was LESS trouble with
spaghetti DO's than there was with the sort of BASIC coding practices
Charlie Lasner mentions.  The knowledge that any line MIGHT be a subroutine
made you kind of think.  There was a strong tendency to modularize
functionality on a per-line basis.

Another delectable property of FOCAL was that there were no DIM statements.
ANY variable name could be subscripted, the subscript could be any integer
within some meager range (probably 0-4095), and you didn't have to declare
anything.  Just mention Q(123) and Q(621) and individual entries for them
would be created in the symbol table -- sparse storage, those TWO elements
existed but Q(122) didn't yet -- simple linear lookup (and why not?
the time for linear lookup was minuscule compared to the awful grinding
effort of the floating-point calculations!)

I liked FOCAL. FOCAL was neat.  It coulda been a contenda!  If Digital
had only marketed Intersil-chip PDP-8's ... twelve bits when everyone
had eight, and OS/8 when everyone had CP/M, and FOCAL when everyone else
had BASIC... Of all sad words of tongue or pen, the saddest are these:
"that's not our marketing strategy."



-- 
Daniel P. B. Smith
dpbsmith@world.std.com
Newsgroups: alt.folklore.computers