From: lasner@watsun.cc.columbia.edu (Charles Lasner)
Newsgroups: alt.folklore.computers
Subject: Re: Spaghetti  DO's in FOCAL (was: Re: Branching in HLL vs. Assembler)
Date: 4 Sep 92 05:02:05 GMT
Reply-To: lasner@watsun.cc.columbia.edu (Charles Lasner)
Organization: Columbia University

In article <Bu0BEy.IKt@world.std.com> dpbsmith@world.std.com (Daniel P. B. Smith) writes:
>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.

I have FOCAL, 1969 running on all DECmates currently I, II, III, III+.  The
P?S/8 version has a lot of added features as well, yet is more compatible
with the original than Jim Van Zee's OS/8 version (which won't run on the
DM's as written; he never gave out the sources so I'll have to disassemble
it to fix it).

>
>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.

I believe there actually was an 8080 FOCAL from DEC years ago, when they were
supporting a small 8080 development system that wasn't as good as Intel's.

In any case, FOCAL was available on all the DEC machines before the VAX.

>
>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.

I am not aware that Jim's can renumber; are you certain? what command is used
to do this?  One feature it certainly has is evaluated GOTO and DO, such as
DO 1+1 or GOTO I+J-9.

>
>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.  

This isn't true, return exists, but is optional.  Getting to the last line
of a group or executing the right-hand end of a single-line implies a
return, but so does an explicit one.  Incidentally, a GOTO within a group is
essentially a GOSUB because after that line is finished, it auto-returns to
the rest of the group.  (I am referring to a GOTO outside of the scope of
the current DO.  A one-line DO can GOTO another line, but after gosub-style
returning back to the rest of the one-liner the line eventually finishs or
terminates on a Return (R is enough) statement.  Any GOTO in the group for
a group-oriented DO is an ordinary GOTO.)

>
>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.

This is true.  The usual form of FOCAL was a "main" program in the 1.xx group
that ended with the Quit (Q) command at the last line or earlier as code
dictated.  In fact, a common bug was that the program fell into a higher 
group after it was otherwise "done" :-).  (Yes, if 1.29 is the last 1.xx line
and 2.01 is the lowest 2.xx line, then after 1.29 finishes, 2.01 starts.)

Then the groups from 2.xx through 31.xx are subroutines, possibly calling
each other.  The language also supports built-in functions that start with
F, which is a reserved letter and variables are not allowed to start with.
Thus there is FSIN(x) and FCOS(x), etc., although a simple hashing code
was used in the original that prevented some common names.  This is why
some are a little wierd; they are anomalous to other existent functions.
It's real easy to add assembly-written add-on functions to FOCAL.  P?S/8
FOCAL has all of the binary loader capabilities of the normal assembler
binary utilities to make it quite easy to patch/customize.  Using some
custome overlay packages, you can do some neat things here.

>
>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!)

Note that A and A(0) are in fact the same element.  There is also a patch
for FOCAL to delete variables from the space if they are currently
zero-valued.  Thus, statements like: FOR I=1,1E10; Set A(I)=0 takes no
space whatsoever :-).

>
>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."

I have seen a legal document issued by DEC's lawyers at the time of the
early IM6100 development by Intersil.  This was almost 4 years before DEC
finally got the VT-78 out to actually use the Intersil chip (actually gotten
from Harris, the second-source company, not Intersil).

In this document, the lawyers are addressing two issues:

1)	Intersil is purchasing copies of the DEC "paper-tape software" kits
for the PDP-8 for resale to it's customers for use on the Intersil systems
which are compatible with the PDP-8 and can run this software.

2)	Intersil is claiming that the IM6100 is actually compatible enough
with the PDP-8 that PDP-8 programs can run on it (such as the paper-tape
kits in item 1).

In DEC's lawyer's opinion:

a)	It is perfectly legal for Intersil to resell the paper-tape software.
While intended for purchase by end users, there was no express reason to
forbid resale.  As long as nothing was being copied, there were no problems.

[Good call by the lawyers on that one!]

b)	It doesn't matter that Intersil claims compatibility since DEC
doesn't back the claim, and they don't make the claim that DEC backs them
in the compatibility claim, thus without DEC's "approval" on this, it
simply doesn't matter!

[The World according to DEC :-)]

No wonder they had a marketing strategy as they did.  Not invented here at
its worst :-).

cjl
Newsgroups: alt.folklore.computers