Subject: FOCAL - some more questions

From: [email-masked] (Magnus Olsson)
Date: Wed, 20 Oct 1993 15:12:52 GMT

In article <[email-masked]>,
Crystobal J. Junta <[email-masked]> wrote:
>I don't have any documentation, on machine-readable or hardcopy, but
>I do remember the language.

Thanks for posting the summary - it seems to be enough to get started!

Thanks also to James Hightower ([email-masked]) for posting the
FOCAL interpreter to alt.sources. I had some difficulties compiling it
under Ultrix - apparently the code to handle the Library command isn't
BSD 4.2 compatible. I've commented it out for the time being; as soon
as I get some time, I'll rewrite it so it compiles under Ultrix (and,
preferably, MS-DOS as well - somebody asked about compiling it under
MS-DOS). 

Also, the interpreter doesn't seem to be for exactly the same version
of the language as Crystobal's description. I'll probably hack it
so it agrees with Crystobal's post. Before I start, however, some
more questions:

* The posted interpreter interprets the line numbers in the way that
  "1.1" is equivalent to "1.01". Was this the normal FOCAL behaviour?

* The interpreter types all numbers in the E format, i.e., the number
  1 is typed as "1.00000E+01". Was this the normal behaviour on the
  old FOCAL implementations?  At least I would expect a more "user-
  friendly" floating point format, like that used by most Basics,
  from a novice language like FOCAL.

* Crystobal's post says that you could do things like
  A "Enter a number", number
  to first print a prompt, and then read in a number.
  The interpreter only accepts 
  A number
  without the prompt string. WHich behaviour was the most common?

Once I get the answer to these questions, I'll start hacking the
interpreter. If no legal hurdles turn up, I'll make the code
available on the Net as soon as it's finished.

              Magnus Olsson                | \e+      /_
    Department of Theoretical Physics      |  \  Z   / q
        University of Lund, Sweden         |   >----<           
 [email-masked],  [email-masked]  |  /      \===== g
PGP key available via finger or on request | /e-      \q

---

From: [email-masked] (Frank - Hardware Hacker - Borger)
Date: Wed, 20 Oct 1993 18:03:00 GMT

In article <[email-masked]>, [email-masked] (Crystobal J. Junta) writes...
>Since it is an interpreter, you can use it in interactive mode and program 
>mode - just like BASIC.  To write a program, put line numbers before commands.
>Line numbers are, believe it or not, real with 1 or 2 digits after the decimal
>point.  So the following are valid line numbers:
> 
>1.01, 2.2, 3.41, 
>and the following are not valid:
>1, 1.00, 3.443

	Not valid as line numbers, but can be used in DO and GOTO statements

>D : Do.  Calls a subroutine, which are more like BASIC kind of subroutines than
>real procedures of structured languages.  Format: D line-number|line-group.
>This requires some explanation.  When you call D with a line number, it will go
>to that line number and start executing commands from there until it encounters
>R (or until the program ends). 

	As I remember it, D 1.23 would only execute line 1.23 and then return.

> Now, line-group concept is cute, IMO.  Line group
>is a number which an integer.  Thus 2, 3 are line groups.  Group 2 consists of all
>line numbers from 2.01 to 2.99, e.g., 2.1, 2.02, 2.33.  D called with a group 
>number as an argument, will go to the first line in the group and will execute
>lines in the group until it encounters R OR until the group ends.  

	Yes. The whole concept of floating-point line numbers made one cringe,
	but it really made for very tight code, an important point when a
	BIG machine had 12k bytes (8 k words.)
Frank R. Borger - Physicist     ___      It's 9:00 am. Do you know where your
Michael Reese - U of Chicago   |___      children are? Well, it depends on
Center for Radiation Therapy   | |_) _   whether or not the Judge opened
net: [email-masked]    | \|_)  the schools today.
ph: 312-791-8075 fa: 791-2517       |_)

---

From: jones@pyrite (Douglas W. Jones,201H MLH,3193350740,3193382879)
Date: Wed, 20 Oct 1993 19:16:24 GMT

>From article <[email-masked]>,
>   "1.1" is equivalent to "1.01". Was this the normal FOCAL behaviour?

Here's the output of a simple experiment, run under FOCAL 1969 on a PDP-8/E
emulator.  FOCAL 1969 is generally considered to be definitive.  It had
predecessors, but most later versions try for compatability with it.

*1.01 COMMENT
*1.1  COMMENT
*WRITE
C-FOCAL,1969

01.01 COMMENT
01.10 COMMENT
*

So, it's clear that 1.1 should be the same as 1.10 and not the same as 1.01

>   old FOCAL implementations?

Here's the output from another test run under FOCAL 1969 to demonstrate
the output formats:

*WRITE
C-FOCAL,1969

01.01 SET I=1
01.02 TYPE I,!
01.03 TYPE 1/I,!
01.04 SET I=I*10
01.05 GO 1.02
*GO
=    1.0000
=    1.0000
=   10.0000
=    0.1000
=  100.0000
=    0.0100
= 1000.0000
=    0.0010
= 10000.000
=    0.0001
= 100000.00
=    0.0000
= 1000000.0
=    0.0000
= 10000000
=    0.0000
= 0.10000010E+09
=    0.0000
= 0.1000?01.00 @ 01.03
*

The above run was terminated by hitting control C.  Note the clear and
understandable output diagnostics that result!  I think the ? is the
error indicator, the 01.00 is the error message, and the @ 01.03 says
it was executing line 1.03 when it was interrupted.

>   A "Enter a number", number

Here's an example illustrating this.  All I did is change the above
program and run it again:

*01.01 A "Enter a Number",I
*GO
Enter a Number:8000000
= 8000000.0
=    0.0000
= 80000000
=    0.0000
= 0.80000010E+09
=    0.0000
= 0.80000010E+10
=    0.?01.00 @ 01.02
*

And, in your hacking, don't forget to include provisions for the
following behavior (again, I edited the program and then run it):

*01.02 TYPE I,!; GOTO 01.01
*GO
Enter a Number:A
=    1.0000
Enter a Number:B
=    2.0000
Enter a Number:AB
=   12.0000
Enter a Number:1E2
=  100.0000
Enter a Number:AEB
=  100.0000
Enter a Number:YES
= 0.25000000E+21
Enter a Number:?01.00 @ 01.01
*

Note that this is as far as FOCAL 1969 goes in string handling!

					Doug Jones
					[email-masked]

---

From: [email-masked] (Crystobal J. Junta)
Date: 22 Oct 1993 12:13:33 GMT

Also, there is a post on alt.folklore.computers - FOCAL-8 - which
gives a summary of the language.  I now realize that I forgot to describe
focal functions - well, :-(.  So if you want, check it out.

---

From: [email-masked]
Date: 22 Oct 93 10:10:43 MDT

> preferably, MS-DOS as well - somebody asked about compiling it under

The library code will compile under Ultrix if you:

	- change "struct dir" to "struct dirent"
	- replace "DIRSIZ" with "MAXNAMLEN"

Don't know if it works; I haven't played with the library stuff.

The other change I had to make involved structs that ended with:

	  char whatever[];
	}

The code does this to malloc() a block of memory (for a program line or
a symbol value) with a header on the front. Ultrix disallows this. I modified
the struct to be:

	  char *whatever;
	}

and then modified the code allocating the structs to toss in the address of
the extra malloc()d space on the end.

Finally, I modified the code to not crash if the interpreter runs off the end
of the program.

With these changes, it runs under Ultrix. Still crashes under Alpha OSF/1, 
though.
-- 
----------------+------------------------------------------------------
Roger Ivie      | Don't think of it as a 'new' computer, think of it as
[email-masked] |     'obsolete-ready'

---

From: [email-masked] (gordon hlavenka)
Date: Sat, 23 Oct 1993 06:11:31 GMT

(NOTE:  I worked with FOCAL 1969 and FOCAL-8.  It's been 15 years or
so, and so these two versions may be somewhat mishmoshed in my
brain...)

Crystobal J. Junta <[email-masked]> wrote:
>Variables: The version I remember did not support
>string variables, just real and integers.
True mostly.  However, FOCAL treats text input as numbers, with the
digits continuing upward as for HEX.  In other words, 'A' has a value
of ten, 'B' is eleven, and so on.  The system is still base ten, so an
'A' in the tens place means ten tens, or one hundred.  The one
exception ti this is the letter 'E', which is used for exponentiation
in scientific notation.  So the word 'YES' has a numeric value of
3500 * 10^29, while the word 'NO' is worth 255.  These can be used in
IF statements by preceding the word with a zero to force the parser to
evaluate it as a number.  You have to be careful not to overflow,
especially since E is the most commonly-used letter in English...

>A : Ask.  Waits for input from keyboard.  Format: A ["optional
>prompt",]var[var,var......] (equivalent to BASIC's INPUT).  See also S, T.
I don't recall ever using prompts with ASK.  Perhaps this was
supported in later versions.

>R (or until the program ends).  Now, line-group concept is cute, IMO.  Line
>group is a number which an integer.  Thus 2, 3 are line groups.  Group 2
>consists of all line numbers from 2.01 to 2.99, e.g., 2.1, 2.02, 2.33.
>D called with a group number as an argument, will go to the first line in the
>group and will execute lines in the group until it encounters R OR until the
>group ends.  Then it returns control to the command after D.  (sort of
>equivalent to BASIC's GOSUB). 
I seem to recall that 'D 2.11' would return after line 2.11 _without_
requiring an 'R', while 'D 2' would execute starting at 2.00 and
continuing until encountering an 'R' _or_ line 2.99.

>E : Erase.  This is an interpreter command telling it to erase lines.
'E' by itself re-initializes all variables to zero.  'E 1.01' erases
line 1.01.  'E A' erases the whole program.  I seem to recall that
'E A' did _not_ initialize variables, but I could be wrong on this.
Also, I think 'E 2' would erase 2.00 to 2.99.

>F : For.  The looping construct for for loops.
The tough part about this one is that there is no 'NEXT' equivalent --
FOR in FOCAL will only execute the commands you can fit on an
80-character line.  This leads to heavy use of subroutines, viz
2.12 F X=1,100,5;T X,!;D 3
2.13 C (STUFF TO DO AFTER THE FOR LOOP)
3.00 C (STUFF TO DO IN THE FOR LOOP...)

>L : Library.  It actually includes a set of commands, as follows:  
Since all we had were two ASR-33s, the only use we got from 'L' was
that it suppressed the TTY echo while loading (paper) tapes.  I don't
remember how we got the echo back...  CTRL/C maybe?  Or perhaps I'm
thinking of the 'TAPE' command in EDUSYSTEM-20 BASIC.

FOCAL would only look at the first letter of the command, so the
command 'QWERTY' would end your program, and look cuter in the
listing.  Also, we used to use 'RUN AWAY' a lot to restart programs.

10.00 C END GAME ROUTINE
10.01 T "YOUR SCORE IS",S,".",!!,"PLAY AGAIN? ";A A
10.02 I (A-0YES)10.03,10.2,10.03
10.03 I (A-0NO)10.04,10.3,10.04
10.04 T "PLEASE ANSWER YES OR NO.",!;G 10.01
10.20 C PLAY IT AGAIN
10.21 RUN AWAY!
10.30 C ALL DONE
10.31 QWERTY

-- 
----------------------------------------------------
Gordon S. Hlavenka           [email-masked]
Proud father of Daniel Scott     born August 9, 1993

---

From: [email-masked] (James Hightower)
Date: Sat, 23 Oct 1993 23:08:22 GMT

>interpreter. If no legal hurdles turn up, I'll make the code

Speaking of legal, I think it's high time to finger someone as the
author of this fine thing what I posted to alt.sources...

Lenny Gray <[email-masked]>(famed author of DEC's EduSystem/10 BASIC
and RT/11 BASIC,) wrote that the author was Rick Merrill, once of DEC. 

Ozan S. Yigitl <[email-masked]>(famed author of much hip stuff) wrote
that the author is David Conroy, famous for his public domain PDP-11
DECUS C compiler.

This morning I dug through the pile of RK05 packs from whence this came,
(a job which required re-assembling my trusty ol' PDP-11/03) and found
the FOCAL source living on a disk that did indeed appear to contain some
part of a DECUS C distribution, so perhaps DC did have something to
do with it. Or perhaps he got it from RM. Either way, they both
deserve a hand! (clap clap)

This is almost as much fun as the Three Stooges marathon on TBN.

JJH
-------------------------------------------------------------------------------
Oh Yeah: Disclaimer, Disclaimer, Disclaimer, The views expressed belong
only to me (and maybe Courtny). It should not reflect on any others
(except Mario from Canada, a real perv).

---

From: [email-masked] (Brett Person)
Date: Wed, 20 Oct 1993 20:34:18 GMT

Was anyone able to get this to compile out-of-the-box?  I've tried on two
machines now, with lots o' compiler errors.  I've tried both Sun  and Linux. 

Seems to have a problem with DIRSIZ and a couple of structs not being
properly declared. 
-- 
Brett Person
North Dakota State University
[email-masked] || [email-masked]

---

From: [email-masked]
Date: 25 Oct 93 07:30:59 PDT

In article <[email-masked]>, 
[email-masked] (James Hightower) writes:

> the FOCAL source 

I'm glad to see that someone other than me still has an operating
RKV11-D controller.   I used mine on my PDP-11/03 for many years
before moving it to my 11/73.   This required "hot-wiring" the
extra two DMA address bits that DEC neglected to include.  I
still use it several times a month.

Several years ago, a certain well-known RT-11 developer was
visiting me.   Said developer declared that DEC had never made
such a product, even after seeing it.

--  Alan E. Frisbie               [email-masked]
--  Flying Disk Systems, Inc.
--  4759 Round Top Drive          (213) 256-2575 (voice)
--  Los Angeles, CA 90065         (213) 258-3585 (FAX)

---

From: [email-masked]
Date: 25 Oct 93 09:39:32 MDT

> Seems to have a problem with DIRSIZ and a couple of structs not being

Compiled out of the box under Alpha/VMS. Given the tweaks I had to make to
get it to compile under Ultrix (I posted them a few days ago), I'm not sure
that I know why it compiled....
-- 
----------------+------------------------------------------------------
Roger Ivie      | Don't think of it as a 'new' computer, think of it as
[email-masked] |     'obsolete-ready'

---

From: [email-masked] (Charles Lasner)
Date: 28 Oct 1993 06:30:28 GMT

>and RT/11 BASIC,) wrote that the author was Rick Merrill, once of DEC. 

Rick Focal was indeed the author of FOCAL.  (Well, some people called Merrill
that!)

However, EDU-10 is the product of Lenny Elekman.  8K-BASIC and LAB-8/e BASIC
are based on it, and are enhanced by Jack Burness.  (They are actually both
the same program with conditionals for the LAB-8/e added functions, etc.)
There is also a CAPS-8 variant of it as well.

cjl

ps: While I don't have the time right now to discuss it in detail, there
seems to be a lot of the "deaf leading the dumb leading the blind" discussion
about FOCAL going on here, and a lot of it is just plain wrong.  FOCAL-8 is
more a marketing ploy than a different program from FOCAL, 1969.  And people
are misremembering features, etc.  A lot of it stems from either confusing
FOCAL with other languages, or remembering non-standard implementations or
worse.  Perhaps we need a definitive spec for just what FOCAL actually is.

---

From: jones@pyrite (Douglas W. Jones,201H MLH,3193350740,3193382879)
Date: Thu, 28 Oct 1993 14:04:29 GMT

>From article <[email-masked]>,
by [email-masked] (Charles Lasner):
> 
> .... And people are misremembering features, etc.  A lot of it stems
> from either confusing FOCAL with other languages, or remembering
> non-standard implementations or worse.  Perhaps we need a definitive
> spec for just what FOCAL actually is.

Well, why not just use FOCAL 1969 as the reference standard.  The object
code (BIN format) is still available, and anyone with a PDP-8 or a
halfway decent PDP-8 emulator can run it and get the real thing, as
opposed to halfway implementations in C.  The only trouble with an
emulated PDP-8 running FOCAL is that it's a bit slower than the C
version, but on a modern processor (such as a Sun SPARC IV) emulators
run almost as fast at a PDP-8/E and a whole lot faster than a PDP-8/S.

					Doug Jones
					[email-masked]

---

From: [email-masked] (Charles Lasner)
Date: 30 Oct 1993 15:56:52 GMT

In article <[email-masked]>,
>run almost as fast at a PDP-8/E and a whole lot faster than a PDP-8/S.

I agree.  The need to be compatible is one of the design objectives of the
P?S/8 FOCAL implementation.  A lot of FOCAL programs need to take advantages of
just about every quirk of the language, etc.

To clear up a piece of the FOCAL spec:

The output format of FOCAL is controlled by a format control variable called %
The initial setting is %8.03, thus accounting for the attempts to output up to
8 digits with three decimal points, resorting to floating notation where it
doesn't fit, etc.  But this is merely the default.  The % operation can be
set from any TYPE (or ASK!) statement using such as:

1.01 TYPE %10.04,1+1

The format control applies until changed again.  % with no args means to always
use floating notation.  Due to a quirk of the implementation, the leading zero
is required on the decimal point portion of the format control statement, thus
%8.03 is *not* %8.3 !  (This could be easily fixed, but would then make the
binary not position-specific compatible, and could possibly make existing
programs not work correctly.  Changing the position of code is unacceptable
due to the enormous amount of patches written to FOCAL, 1969 depending on
absolute binary locations, etc.  P?S/8 FOCAL touches no part of the code,
except for certain areas bodily moved or excised out altogether, primarily
stuff that tends not to get patched, and the space is then used to implement
the interface to the system, etc.)

As to emulators, I am puzzled by the notion that an allegedly fast machine
with tons of MIPS could have trouble emulating a sub-1-MIP PDP-8/e.  I guess
either MIPS overstates the alleged "power" (Meaningless Instructions Per
Second which implies fast NOP's but not useful instruction rate) and/or gross
overhead in C-generated object code.

As a reference point, I would choose the PDP-15-based PDP-8 emulator.  This is
a single-accumulator machine that is essentially an 18-bit cousin of the PDP-8
and is about twice as fast as an 8/e.  Yet, the emulator runs PDP-8 software
at about 1/6 the speed of the real PDP-8!

cj "How about a SPARC-8" l

---

From: [email-masked] (Greg Ewing)
Date: Fri, 29 Oct 1993 04:23:24 GMT

In article <[email-masked]>, jones@pyrite (Douglas
W. Jones,201H MLH,3193350740,3193382879) writes:
|> Well, why not just use FOCAL 1969 as the reference standard.  The object
|> code (BIN format) is still available, and anyone with a PDP-8 or a
|> halfway decent PDP-8 emulator can run it and get the real thing

Where can one get this from? I have a crazy idea for an adventure
game with an embedded fully-functional PDP-8, and a genuine language
implementation from the period would be just the thing to go with it.

Are there any other pieces of PDP-8 software around? A BASIC and/or
operating system would be neat.

|> 
|> 					Doug Jones
|> 					[email-masked]

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of Japan Inc.|
[email-masked]	   +--------------------------------------+

---

From: [email-masked] (Magnus Olsson)
Date: Sun, 31 Oct 1993 11:53:33 GMT

In article <[email-masked]>,
krause <[email-masked]> wrote:
>We have compiled and tested the FOCAL compiler on a PC. 
 (i suppose you mean "interpreter" and not "compiler")

>We found a lot of
>discrepancies to the original 4K FOCAL (1969). We tried to run the 'perpetual
>calendar' and the 'towers of hanoi' which both run as well on our pdp8/e as
>on a existing pdp8/e emulator.
>
>Some of the 'defects' we found:
>* No math-functions implemented. We did this, with the restriction, that the 
>  exponentiation has the same priority as * and /.
>* In expressions the various enclosure symbols had to match: ( < [ ] > ).
>  in 'real' FOCAL it is also possible to write:
>  S A = 5 * (3+1]
>* It is also allowed to write:
>  T "HELLO
>* Line numbering did not conform to the original:
>  Entering
>  1.1 T "HELLO
>  produced 
>  1.01 T "HELLO
>  correct is:
>  1.10 T "HELLO
>* We added a rudimentary trace feature, which lists the current line numbers.
>* The behaviour of the DO within and outside the current line group differed
>  also from the original.

I also found some of these problems. Another problem is I/O: The
posted interpreter (I mean the original version, not your patched one,
which I wasn't able to compile; see below) seems to take the easy way
out, just using the C library's I/O functions. As a result, all
output is printed in a desperately ugly "E format" (probably just the
output of a 'printf ("%e",x)').

Also, which is more important, the interesting "letters as digits"
feature of FOCAL doesn't seem to work. I'm of course referring to the
fact that all letters except 'E' should be interpreted as digits, so
that 'A'=1, 'B'=2 and so on, and that it should be possible to use
numerical literals such as "0YES" and "0NO".

If you haven't already fixed this, IMHO you definitely should!

>The patched FOCAL.C along with two example programs from the book 'programming
>languages part 2 (C 1970 by Digital Equipment Corporation) is put to 
>alt.sources.

Thanks a lot! However, this won't compile under Ultrix (which, I
suppose, means it won't compiler under 4.2BSD either).

I get the following errors:

>% cc focal.c -lm
>"focal2.c", line 54: warning: illegal zero sized structure member: l_text
>"focal2.c", line 95: warning: illegal zero sized structure member: s_id
>Undefined:
>_randomize
>_stricmp
>%

Obviously, you're using two library functions randomize and stricmp that
aren't part fo the standard Unix library. 

The first two error messages have been discussed here before: they were
fixed in the first patched version of the interpreter that was posted
on alt.sources. Maybe you should have a look at that.

Finally, an observation:

Intending no disrespect to the original author of the Focal
interpreter, I must conclude that it was a quick-and-dirty hack that
obviously never has been tested with real Focal code. Unfortunately,
it was taken by us unfortunate Focal-deprived newbies [:-)] as
defining the real language, which means that a lot of people are now
running around with the wrong ideas about Focal (for example that the
line number "1.1" is equivalent to "1.01" rather than to "1.10"). 

I really appreciate the efforts to put this right. 

              Magnus Olsson                | \e+      /_