[comp.lang.forth] RepTil I am, therefore I was

vu0141@bingvaxu.cc.binghamton.edu (vu0141) (03/07/89)

In the Journal of Forth and some coferences there have been articles
about a Forth-like language called 'RepTil' used at the University of
Ohio in Athens, Ohio, which was developed to teach programming easily.
I wrote to the person who developed it but never got a reply. I would
like to have a copy of this language as it had many unique ideas and
would be fun and interesting to use. Does anybody know how I could
get a hold of it (legally, that is--I'll pay if its gone commercial)

Fred Schiff
vu0141@bingvaxu.cc.binghamton.edu

vu0141@bingvaxu.cc.binghamton.edu (vu0141) (03/09/89)

In article <1980@bingvaxu.cc.binghamton.edu> vu0141@bingvaxu.cc.binghamton.edu (Fred Schiff) writes:
>In the Journal of Forth and some coferences there have been articles
>about a Forth-like language called 'RepTil' used at the University of
>Ohio in Athens, Ohio, which was developed to teach programming easily.
>I wrote to the person who developed it but never got a reply. I would
>like to have a copy of this language as it had many unique ideas and
>would be fun and interesting to use. Does anybody know how I could
>get a hold of it (legally, that is--I'll pay if its gone commercial)
>

Someone asked me about RepTil, so in order to tell him and so that other
people might get interested (& ask someone who goes to Ohio University to
find out) I'll write a little about RepTil.  This all comes from "REPTIL-
Bridging the Gap between Education and Application" by Israel Urieli, which
appeared in the Journal of Forth, vol 4, no 3. (Copywrite cops will
probably take me away)

Urieli's basic goal was to make a language which is easy for computer's
to understand (FORTH), but also easy for human's to understand. The
advantages of the language he lists shows his main points:

1. The postfix and stack notation if made more readable and palatable.

The prompt for this system is n <b s> where n is the number of elements
on the parameter stack, b is the current base (displayed in decimal) and
s are the contents of the symbol stack (of which more later, REPTIL has
a symbol stack in addition to the parameter and return stacks).

Here's the example:
<16>   (1 2 +, 3 4 + , 5 6 + )
3<16>  STACK?   \ display the three P-stack items in base 16
3 7 B TOP
3 <16>  DEC =  \ convert to decimal and pop-and-display TOP
11
2<10>  =?  \ are they equal? \ =
0
<10>

Better? You may ask why the compare (FORTH "=") is =? and print (".")
is =  : he says in another article that this is easier to understand,
that "." has no meaning, but that = means "show me the value."

2. The prefixed quote notation enables a more consistent and context-free
   postfix syntax.

Forth has a context dependency problem with all of "@"s and "!" and "'"s
and "[']"s all of which are basically syntactic sugar to get at information
which is already present.  Also all of these @s and !s are not strictly
postfix and are thus a bit confusing for beginners.  QUANs with their
IS notation is a bit clunky.  REPTIL puts the name of a definition before
the defining word instead of after (so names come before words, instead
of being expected as in Forth). This is accomplished by prefixing a word
with a quote to mean the token which this word is rather that its value.
(This is found in STOIC and PISTOL)

So we have:
'VALUE :HAS            \ Create the variable VALUE
5 'VALUE <-            \ assign 5 to VALUE
42 'THE-ANSWER :IS     \ create the constant THE-ANSWER

THE-ANSWER 'VALUE <+   \ add 42 to the contents of VALUE
VALUE =                \ pop the contents of VALUE
47

'VALUE =                 \ pop the cell address of VALUE
40EC

Type checking ensures that constants are not assigned values.

'RUN UNDO: \ equivalent of Forth's INTERPRET

'RUN DO:
   LOOP[
     R^RESET  \ Reset the R-stack pointer
     READ-LINE
     DO-LINE
   ]ENDLOOP
:END

3. There is a minimal (four) but nevertheless complete and powerful set of
   structured constructs, all of which can be invoked in the interpretive
   mode.

The symbol stack allows you to check for matching structure constructs; this
allows all of the structures to be run in interpretive mode.  

8 LOOP[
    DUP = " != " $=
    DUP  ! U=
    1 - DUP <0?
  ?EXIT
     NEWLINE
  ]ENDLOOP

Parentheses are used as the simplest structure constructs; they defer
execution until the matching parenthese is read in.  Commas are no-ops
used to improve the readability.

<16>		( 1 2 +, 3 + , 4 + ,
<16(>		   5 + , 6 + ) 2 * =
<16>		2A

<16>		(  (
<16((>		) ) )
		NEEDS (
<16>

There are if, else, and elseif constructs (finally an elseif - all you
needed was another stack!)  There is only one loop construct, an infinite
loop structure with multiple exit points.  The defining words DO:, :END
are themselves strucutre words--in fact they are the only words used for
defining all data structures. (ie. DO: is used for all the purposes that
CREATE is used for in Forth)

'DO-LINE DO:
    LOOP[
       SKIP-BLANKS
       EOL?		\ End-of-line?
    ?EXIT
       NAME?		\ prefixed quote?
       ?IFTRUE
          DO-NAME
       ?ELSE
          BLANK WORD^0 SCAN	\ lexical scan to Word buffer

          WORD^0 VERB?		\ is it a predefined verb?
          ?IFTRUE
             DO-VERB
          ?ELSEIF		\ a number maybe?
          WORD^0 NUMBER?
          ?IFTRUE
             DO-NUMBER
          ?ELSE
             WORD^0    UNKNOWN
             RUN		\ ignore it and back to the Outer
				\ interpreter
          ?ENDIF
       ?ENDIF
    ]ENDLOOP
:END

4. Recursion is intrinsically available.

The power of this needs no explanation, however:

'! DO: \  n |P
    DUP 1  <=?       \ the stopping rule
    ?IFTRUE
       DROP 1
    ?ELSE
       DUP 1 -  \ n, (n-1) |P
       !        \ n, (n-1)! |P (recursive step)
       *        \ n*(n-1)!  |P (recursive defn of n!)
    ?ENDIF
   :END


5. There is no source code stored in any form in the system; if required,
   source code is recreated in a structured format form the list of tokens.
6. The entire language, including the system verbs, is defined in terms of
   REPTIL algorithms and mainly coded in REPTIL.

These two are not discussed much in the paper, but concern the structured
decompiler UNDO: and editor REDO:  It should be noted that Chuck Moore
has gone to the concept on having no source code with a single decompiler/
editor word since the source is basically a redundant construct.
The decompiler would perform all indenting automatically and the dynamic
movement of the code definition when a word's definition is changed.

Fred Schiff
vu0141@bingvaxu.cc.binghamton.edu

vu0141@bingvaxu.cc.binghamton.edu (vu0141) (03/09/89)

I forgot to mention it, but comments are included within the
definition.  It wasn't that important in what I was writing but NOW verbs
(Forth's IMMEDIATEs, except the verb NOW is placed after the DO: instead 
of after the end of the definition, which Urieli says is confusing) work
by doing their job and then compiling in a "dummy" verb which is usually
a no-op, (sometimes it has a job to do, of course) but which the decompiler
is smart enough to print out as the original verb.

Thus ?IFTRUE in a definition does its business with the return and symbol
stacks and compiles ?IFTRUE% the runtime word which tests the top of the
parameter stack when it is executed within a definition.  Upon decompilation
you get the original definition back.

The article, skips lots of the implementation details but does give
definitions for the inner and outer interpreter, and all of the structure
words.

Its token threaded by the way.  Or more accurately "status-threaded" meaning
that each word has a 16-bit header which has the definition's length (so
that they can be moved around in memory) and a number of bit-flags which
give information (NOW word, indent left/right in decompilation, ROM word
which should not be moved, etc.)  Also the names of words, code for words,
and data space for variables and constants are all kept in separate areas
of memory.

Fred Schiff (vu0141@bingvaxu.cc.binghamton.edu)