perm filename RLISP.F70[206,LSP] blob sn#381624 filedate 1978-09-20 generic text, type T, neo UTF8
                         STANFORD UNIVERSITY



	In the first part of this course the exercises to be  run  on
the  machine  are  to  be  written in the RLISP language.  This is an
input language for LISP close to the notation used in class.  We will
use it because the notation is more convenient than the internal LISP
language described in the LISP 1.6 Manual which  we  shall  be  using

	The  RLISP  primer  describes  how  to  use RLISP for someone
already familiar with LISP and with the Stanford time-sharing  system
for the PDP-10.  The familiarity with LISP is to be obtained from the
lectures and the course notes, and this memo is intended to tell  you
enough about the time-sharing system to use RLISP.

	The   first   thing  it  is  necessary  to  understand  about
time-sharing systems is that at different times you will  be  talking
to  different  programs, and the rules for interpreting what you type
depends on what program you are talking  to.   In  order  to  do  the
exercises  you  will  have  to  talk  to  three different programs at
different times, namely: the time sharing system, the SOS text editor
which is used to prepare RLISP programs, and RLISP itself.  Later you
may  find  yourself  talking  to  RLISP  programs  you  have  written

1. The time sharing system.

	The  time  sharing system is quite complex, but we shall need
to know only a few of its commands and other properties.

	1.1. To ensure you are talking  to  the  time-sharing  system
type  <control  C>.  This is accomplished by typing %C% while holding
down the key marked "CTRL".  (This key is like a shift  key  in  that
pressing  it  does not transmit information to the computer.  It only
modifies the information transmitted by pressing other keys if it  is
held  down).   We  shall  abbreviate this ↑C because this is what the
computer types back when you type <control C>.

	No matter what program you are talking  to  initially,  after
↑C, you will be talking to the time sharing system. Always begin your
session by turning on the teletype and typing ↑C.

	1.2. Each command to the system is  terminated  by  <carriage
return>,  abbreviated  <cr>.    Until  <cr> is typed, the line can be
cancelled by typing  <control  U>,  abbreviated  ↑U,  and  individual
characters  can be erased by typing <rubout>.  Several characters can
be erased by several <rubout>s.

	1.3. Another important special character is <ALT MODE>.  Like
<cr>,  this character causes the information typed up to that time to
be transmitted to the program you are talking to, and therefore, that
information  cannot  be taken back by ↑U or <rubout>. When <ALT MODE>
is typed, $ is printed, but  the  effect  of  <ALT  MODE>  cannot  be
achieved  by  typing  $.  The uses of <ALT MODE> will be described in
the sections on SOS and RLISP, both  of  which  use  it  for  certain
control functions.

	1.4.  The first step in using the system is to "log in". Type
↑C to be sure you are talking to the system.  The system will respond
with  <cr> and a . to tell you it is ready to be commanded. Then type
L<cr>, and the system will respond with # to tell you that  it  wants
your  <Project,programmer number> combination. Type 206,<The initials
assigned you><cr>, and the computer will type back ↑C<cr> and another
.  to  show  it  is ready for your next command.  If it types ARE YOU
SURE?, this means you have typed a wrong <Project,programmer number>,
and you can continue by typing the correct one.

	1.5. When you are done using the system you must  "log  out".
The command for this is K<cr>, and the system will respond with KJOB.
Turn the teletype off to increase its life, which  otherwise  may  be
less  than a quarter.  Be sure and logout, since the system will keep
track of the time you use.

	1.6. There are  two  system  commands  for  calling  the  SOS
editor.   The  first is CREATE <file name><cr> which is used when you
want to create a new RLISP program.  The  system  will  turn  control
over  to  SOS  which will type back 100, meaning to say that it is in
text mode and it is ready for you to type in your program. The second
SOS  calling system command is ED <file name><cr>.  This is used when
the file name in question already exists, and you want to modify  the
file.   SOS  will  type back * to tell you it is ready for a command.
NOTE:  the  commands  to  SOS,  to  be  described  later,   must   be
distinguished  from  the system commands.  The system types . when it
wants a command and SOS types *. RLISP also types *.

	1.7. A very important system command is DEL <file  name><cr>.
This  command  deletes  the  named file.  If you have more than 4K of
files, some of them are subject to random deletion  unless  you  have
special permission to have more.  This limit does not apply while you
are actually on the machine.

	1.8. The system command DIR<cr> will tell you what files  you

	1.9 The system command HELP <name of concept><cr> will type a
short message about how the concept is used.  It is doubtful  whether
these messages will be of much use to you.

	2.0.  The  system  command SEND JMC<cr> can be used to send a
message to the instructor, and SEND GG<cr> can  be  used  to  send  a
message  to  the  teaching assistant.  The SEND command will tell you
what to do next.

2. The SOS editor.

	Editor  programs  are used in time-sharing systems instead of
obsolete devices like key punches for preparing  programs  and  data.
They  are  much more convenient than key punches once you get used to

	SOS has very many features described in the SOS  manual,  but
only  a  few of them should be learned at first.  SOS manuals will be
kept in the rooms with the consoles, and later you will have a chance
to buy them if you want.

	Here are the basic features of SOS sufficient for the present

	2.1. SOS has three modes of operation -  text  mode,  command
mode,  and  a-mode.  The effects of characters typed are different in
the three cases.  a-mode is associated with the a-command and can  be
skipped for the time being although it is quite useful.

	2.2.  Text mode.  When you are in text mode, characters typed
go into the file being created or edited.  When you enter text  mode,
the  system  will  type  a  line  number, and you can type your text.
Every time you type <cr> the system will give you a new line  number,
and  you  can continue typing.  The <control U> and <rubout> features
work as described above for taking back  partially  typed  lines  and
individual characters.  If you get ahead of the machine's response to
<cr>, no harm will be done.

	To go from text mode to control mode type  <ALT  MODE>.   You
will  lose  any  partially  typed line so be sure and finish the last
used line with <cr>.

	2.3. Control mode.  In this mode there are numerous commands.
Each  of  them  consists  of  a  single character followed by certain
parameters followed by <cr>.

	2.4. The most important  kind  of  parameter  is  the  range.
300:1400  designates  the  range  from line number 300 to line number
1400.  If the range is a single line we can just use the line number,
e.g. 300 if the range is the single line 300. In forming the range, .
denotes the current line, e.g. the  last  line  referred  to,  and  *
denotes the last line of the file.

	2.5. Here are the most important commands.

	2.6. e<cr>.  This command terminates editing, returns control
to the system, and makes the edited file the current file  associated
with  the  <file name> of the CREATE or ED command that initiated the
edit. <control C> will cause a return to the  system,  but  the  edit
will  not  take  effect,  i.e.  the file will be as it was before the
current ED command or non-existent if the edit was initiated  with  a
CREATE command.

	2.7. i<line number>(,<increment>)<cr>.  Here, the parentheses
around ,<increment> indicate that an  increment  is  optional.   This
command  causes SOS to enter text mode right after the indicated line
number and to enter successive lines at the  given  increment.   This
increment  is  initially 100, but is reset if the increment parameter
of an i command is used.  The i command is the main way  of  entering
text  mode.   i*<cr> will enter text mode at the end of the file.  If
you enter the file in the middle for the purpose of inserting  lines,
SOS will interpolate line numbers in an ingenious way.

	2.8.  p<range><cr>  will print the text in that range on your
console.  p/1<cr> will print your whole  file  assuming  you  haven't
read  the  SOS  manual  and  learned  the facts about pages that I am
trying to spare you.

	2.9. d<range><cr> will delete  the  lines  in  the  indicated

	2.10.     s<old     string><ALT     MODE><new     string><ALT
MODE><range><cr> will subsitute <new string> for each  occurrence  of
<old  string>  in  the  given  range, and will print the lines it has
changed.  You can't do this using a key punch.

	2.11. w<cr> will save the state of the edit up to now on  the
file name edited.  This is valuable if the system is in an unreliable
state or if you fear making a catastrophic blunder in  editing  after
investing  considerable effort.  The distinction between prudence and
neuroticism is not always easy to make.

	2.12. n<cr> will renumber your file with increments  of  100,
thus  smoothing  out  any insertions you have made.  You must then be
prepared to  type  out  the  file  using  the  p  command.  Here  the
distinction to be made is between esthetics and neurosis.

	2.13. a<line number><cr> will put you into a-mode editing the
named  line.   This  convenient  command  has  a  confusing  host  of
subcommands, some of which are as follows:

<space>  moves one space through the line.  The character spaced over
will be printed.  7<space> will space over 7 characters.

<rubout> will move backwards along the line not erasing.

c<character> will change the next character to <character>.

d will delete a character.  7d will delete 7 characters.

i will enter a sub-mode in which successive characters typed will  be
inserted.   The  i  sub-mode  is  terminated  by  typing  <ALT MODE>.
<rubout> works in the i sub mode.

<cr> will end the a-mode, type the rest  of  the  characters  in  the
line, and return to control mode.

s<character>  will  skip  over  characters  to the next occurrence of
<character>.  This is a very useful command.

k<character> will kill  characters  up  to  the  next  occurrence  of

	2.14.  SOS has many more features, but don't bother with them
until you have had some experience with these.


	In  general,  the  RLISP primer is an adequate description of
the workings of RLISP, but I want to emphasize that RLISP can
be used in two ways.

The simplest way to use RLISP is to type


to the system, and when RLISP types *, type


and  then  give  commands to RLISP.  These commands are of two kinds:
defining functions and using them.  Thus, if if we type


we will have defined the function %alt% of the lecture  notes,  which
there is written

	alt x ← if nx ∨ n d x then x else a x . alt dd x.

If we now type

ALT '(A B C D E F);<cr>

then RLISP will type back

(A C E)


The  *  indicates RLISP is ready for another command.  You can define
and redefine and use functions to your heart's content, and when  you
are  done,  type  <control  C> to get back to the system and log out.
What could be simpler?

	This way of using RLISP has two disadvantages.   First,  when
you are done, all you have is your teletype paper. Your functions are
not on a file for future reference.  Secondly, the only way  you  can
change  a  function  once it is typed in (except that ↑U and <rubout>
work while entering lines) is to retype it completely.

	The  other  way  of  using  RLISP  is  to  prepare  a file of
functions using SOS, then enter RLISP, and then get your functions in
by  using  the  RLISP  command  IN <file name>;.   You then apply the
functions to examples, and when you find a mistake, type <control  C>
and  then  ED<cr>,  and then re-edit the file with your functions and
start over with a new copy of RLISP.  This way you always have a copy
of your functions and can get back to them the next day.

	A more convenient way of going back and forth  between  RLISP
and SOS will shortly be provided.

	The  example  on  page  22  of  the  RLISP  primer  is  quite
informative about the  first  method  of  operation,  but  needs  the
following amendments.

Before the beginning put in

<control C>



Change the statement R REDUCE to R RLISP if this has not already been
done in your primer.

After this, type

<control C>


and when the system types KJOB, turn off the teletype.