.title ^^DECsystem-10 SIMULA GAZETTE, NO. 5, VOL. 3, AUGUST 1977
.variable qz q z
.paper size 60,70;.left margin 0;.right margin 67
.figure 3;.nofill
                      DDDD   EEEEE   CCC
                      D   D  E      C   C
                      D   D  EEE    C
                      D   D  E      C   C
                      DDDD   EEEEE   CCC
.figure 5
    SSSS  Y   Y   SSSS  TTTTT  EEEEE  M   M          1   000
   S       Y Y   S        T    E      MM MM         11  0   0
    SSS     Y     SSS     T    EEE    M M M  -----   1  0   0
       S    Y        S    T    E      M   M          1  0   0
   SSSS     Y    SSSS     T    EEEEE  M   M          1   000
.figure 5
             SSSS  IIIII  M   M  U   U  L      AAAAA
            S        I    MM MM  U   U  L      A   A
             SSS     I    M M M  U   U  L      AAAAA
                S    I    M   M  U   U  L      A   A
            SSSS   IIIII  M   M   UUU   LLLLL  A   A
.figure 5
         GGG   AAAAA  ZZZZZ  EEEEE  TTTTT  TTTTT  EEEEE
        G   G  A   A     Z   E        T      T    E
        G      AAAAA    Z    EEE      T      T    EEE
        G  GG  A   A   Z     E        T      T    E
         GGGG  A   A  ZZZZZ  EEEEE    T      T    EEEEE
.figure 5
               NUMBER 5 - VOLUME 3 - AUGUST 1977
.blank
                      Editor: Jacob Palme
                 Contributions by: Mats Ohlin
.blank
                        Published by the
          Swedish National Defense Research Institute
                     Section 142 (Datalogy)
                      S-10450 Stockholm 80
                             SWEDEN
.left margin 3;.fill;.page
.fill
This Gazette was produced using the RUNOFF and VIDED systems
for layout and text production on a DECsystem-10 computer.
.skip
Printed by the Swedish National Defense Research Institute,
Reproduction section.
.page
.fill
.skip 2;.test page 7;.left margin 3;.center
SIMULA NOW AVAILABLE ON THE DECSYSTEM-20
.p 0,1,3
The DECsystem-10 SIMULA compiler has now been converted
to the DECsystem-20. The compiler runs under the compatibility
package. We believe that all features of DEC 10 SIMULA
are also available on the DEC 20 with very few exceptions.
.p
The "REAL TIME" facilities (see the Handbook part III)
are not yet implemented on the DEC 20.
.p
Digital Equipment Corp. in Scandinavia has paid for the
conversion costs. Thank you very much!
.p
The resources for maintenance of DEC 20 SIMULA are
as yet very limited, since the Swedish National Defense
Research Institute only pays for its own maintenance of DEC 10 SIMULA.
.p
DEC 20 Simula will be submitted to the DECUS library,
probably before the end of 1977.
.skip 2;.test page 7;.left margin 3;.fill;.center
ORDERING KI10 AND KL10 SIMULA
.skip
The KI10 and KL10 versions of the DECsystem-10 SIMULA system can be
ordered from the DECUS library or from section 142, Swedish National
Defense Research Institute, S-104 50 Stockholm 80, Sweden. Note that
the price of the magtapes is much cheaper from DECUS than from
Stockholm.
.skip
If you send your order to the DECUS library, please indicate if
you want the release 3 in case the release 4 is not yet available,
or if you want your order to wait for availability of release 4.
Release 4 will probably be available before the end of 1977.
.left margin 3;.nofill;.blank
                                Price in       Price in
                                Swedish Kronor Dollars
                                when ordering  when ordering
   Entity                       from Sweden    from DECUS
                                     No.           No.
   2400' MT with full SIMULA
   system for KI and KL10-s
   running under TOPS-10
   User supplied tape          900             70  10-223A
   We deliver tape            1000             47  10-223A
.b
   Handbook part I              85   C8398     20  10-223B
.b
   Handbook part II             60   C8399     20  10-223C
.b
   Handbook part III            40   C10045    Will be available
.b
   Reference Card               15   C10039    Not available
.b
   Implementation guide         20   C8400
.b
   Technical documentation      1200
.left margin 3;.b;.fill
The prices quoted do not include postage. Please indicate
with your order if you want the material shipped by air or
surface.
.skip
The handbooks part I, II and III and the Implementation guide
are also available as runoff files on the magtape. Copying is
allowed but only for use with the DECsystem-10 and DECsystem-20 computer.
.skip 2;.test page 7;.left margin 3;.fill;.center
ORDERING KA10 AND DECSYSTEM-20 SIMULA
.skip
The prices and numbers above do NOT apply to the KA10 and the
DECsystem-20 versions of SIMULA. Both these systems will be
submitted to the DECUS library. The MAG-tape with KA10 SIMULA can
also be ordered from the University of Western Ontario, Computing
Centre, London, Ontario, Canada for a price of 100 Canadian Dollars.
.skip 2;.test page 7;.left margin 3;.fill;.center
NEW FACILITIES IN RELEASE 4 OF DECSYSTEM-10 SIMULA
.skip
TEXT constants can now be divided between lines
with a doublequote (") before and after the
new line. Example:
.p;.nofill
     t:- copy("This is a very long TEXT#"
         "constant covering three lines#"
         "in the source program.");
.p;.fill
SIMDDT enhancements:
.p
The DISPLAY, USE and @ commands can now be used
at CONTROL-C-REENTER-breaks, whereafter execution
can be continued.
.p
Several new ways of giving line numbers to the DISPLAY
command in SIMDDT.
.br
"DISPLAY 500,10" displays 10 source lines beginning at line 500. "_^"
can be used to represent the first line and "*" to represent the
last line.
.br
Thus, "DISPLAY _^:*" will display the whole source program. "."
represents the next line. "." may be omitted before "," or ":".
.br
"DISPLAY" without any parameters defaults to the ten next lines
of the source program.
.p
Further examples:
.br
D,5 or DISPLAY .,5 displays the next five lines
.br
D:100 or DISPLAY .:100 displays all lines from the next
line until line 100.
.br
D INLINE or DISPLAY INLINE:.,10 displays the first ten lines
of the source module "inline".
.p
The switch /START:<octal number> can be given to the ALL and
VARIABLES commands in SIMDDT. All data from this core address will
be dumped. If the number is negative, the number will be subtracted
from the address of the top of the stack (pool).
.p
The SIMDDT command INSPECT/START at a CONTROL-C-REENTER or error
interrupt will repeat information about where your source program
was interrupted.
.p
The value of a <type> procedure can be output with
the OUTPUT command of SIMDDT.
.p
The random-number-generator NORMAL will now give antithetic
random numbers.
.p
Most of these additions were programmed by Lars Enderin.
.skip 2;.test page 7;.left margin 3;.fill;.center
OPTIMIZATIONS IN RELEASE 4 OF DECSYSTEM-10 SIMULA
.skip
The performance of SIMULA programs when running in
virtual memory has been vastly improved. The SIMULA
run time system will now recognize when a program
goes virtual, and switch to a new set of memory
allocation procedures. These procedures try to
minimize page swapping, instead of minimizing
the core and CPU cost as for non-virtual programs.
This work was done by Stefan Arnborg.
.p
The searching of the .ATR libraries by
the compiler has been optimized by Lars Enderin.
.skip 2;.test page 7;.left margin 3;.fill;.center
BUGS CORRECTED IN RELEASE 4 OF DECSYSTEM-10 SIMULA
.skip
Several small and a few serious bugs have been
corrected in release 4 of DECsystem-10 SIMULA.
Most important are some severe bugs which only
occured for very large programs (70 K or larger).
These bugs made some programs stop with illegal
memory reference.
.p
A bug in the NORMAL random number generator,
giving too low variance, has been corrected.
.p
The system now accepts sub-file-directories
more fully than previously.
.p
Most of this work was done by Lars Enderin.
.p
For complete information on changes in the system,
see the file SIMULA.DOC on the SIMULA distribution
tape.
.skip 2;.test page 7;.left margin 3;.fill;.center
AMERICAN SIMULA COURSES NEEDED
.skip
SIMULA courses are regularly given in Europe, but not in
North America. We believe that the growing number of American
SIMULA users will create a demand for regular SIMULA courses there.
Probably the best is to have commercially priced courses
marketed to customers interested in using SIMULA
for simulations and other uses, and with marketing
of the course to e.g. readers of "Simulation" and
"Simuletter". We can also probably supply a list
of SIMULA users known to us. In addition to American
SIMULA users, there are British people with experience
in SIMULA teaching who could teach at such a course.
.skip
Who is interested in providing this service? Perhaps
one of the service bureaus offering SIMULA on DECsystem-10?
Or a University using SIMULA?
.skip 2;.test page 7;.left margin 3;.fill;.center
DECSYSTEM-20 SIMULA MAINTAINER NEEDED
.skip
Since we at the Swedish National Defense Research Institut do not
have regular access to a DECsystem-20 installation, we cannot
provide as good DEC-20 Simula maintenance as we would like. Is there
any DEC-20 installation interested in doing such maintenance? This
is a highly qualified systems programming job.
Unfortunately, you will have to find the benefit for your own
installation worth the job, unless you can persuade DIGITAL to pay
for the maintenance.
.skip 2;.test page 7;.left margin 3;.center
NEW ROUTINES IN THE SIMULA EXTERNAL PROCEDURE LIBRARY
.skip
Here is a short description of some of the new routines
in the DECsystem-10/20 SIMULA external procedure library.
For further information about these programs, see the
DECsystem-10 SIMULA Language Handbook Part III,
April 1977 edition. (Available in the file SIMLH3.MAN.)
.p 0,1,5
Most of the routines described here were written
by Lars Enderin or Mats Ohlin.
.p
RADIX and GETRADIX are procedures to input and output
integers with other number systems than the decimal.
.p
BOKSTAV, INORD, LITENBOKSTAV, MENY, STORBOKSTAV, TAGORD
are Swedish language versions of the corresponding
English procedures LETTER, INITEM, LOWCASE, MENU, UPCASE
and GETITEM. The difference is that the Swedish procedures
accept the swedish language letters $, _# and @ (AA, AE and OE)
as letters. Note that since the DECsystem-10/20 SIMULA compiler
also accepts these characters as letters, these procedures
are useful when processing SIMULA source program files.
.p
RESCAN allows you to read from a SIMULA program the monitor
command line which invoked the SIMULA program. This is used
for example by SIMED, so that the user need only write
.skip
_.R SIMED-PROG
.skip
to get SIMED to process his program file PROG.SIM.
.p
EXIT is a procedure to allow direct exit from a SIMULA
program. You can use EXIT to skip the final messages
and the final warning for non-closed files, that is
EXIT can work as if the user had typed CONTROL-C on
his terminal.
.p
SCAN is an alternative to DECCOM for scanning user
commands with parameters.
.p
IASHIFT will shift the elements in an INTEGER ARRAY.
.p
TMPIN and TMPOUT will read and write files in TMPCOR.
TMPCOR can be used to transfer messages between
programs. Example: Before using the RUN procedure to
transfer from a SIMULA program to the PIP program,
you can write a TMPCOR file to tell PIP what you
want done.
.p
TMPIN and TMPCOR will now automatically read and write
_.TMP files if TMPCOR is full.
.p
If you want to write a program which sends to the terminal
and receives from the terminal short sequences of
characters, the library procedure GETCH, OUTCHR,
OUTSTRING and FORCEOUT may be useful.
.skip
GETCH reads a character from the terminal without
waiting for end of line. OUTCHR puts characters in the
output buffer. OUTSTRING puts a text in the output
buffer without the blanking and stripping done by
breakoutimage, and without the FORCEOUT built into
breakoutimage. FORCEOUT ensures that all characters
output by OUTCHR or OUTSTRING are put to the
terminal before doing terminal input.
.skip
These procedures may be much faster than ordinary SIMULA output,
since the file image is bypassed, and since output is only
forced to the terminal when necessary (before terminal input).
A text editor written in
SIMULA became 25% faster using these procedures.
.skip 2;.test page 7;.left margin 3;.center
CONDITIONAL COMPILATION IN SIMULA
.skip
The SIMULA programming language does not have any
conditional compilation facility, but it is easy
to write a preprocessor for this purpose.
.skip
A conditional compilation facility means that by
differing settings of compile time variables,
a program is compiled partly different. A mini and
a maxi version may for example be compiled, or different
versions for different external devices.
.skip
A simple such preprocessor will be included on
the Release 4 distribution tape under the name
COCOS (COnditional COmpilation in Simula).
.skip
The SIMULA Development Group may standardize such
a preprocessor in a different way than the COCOS
program.
.fill;.skip 2;.test page 7;.left margin 3;.center
CONTINUE AND REENTER MONITOR COMMANDS WITH SIMULA
.skip;.nofill
1) Before start of execution, following a GET or LOAD command:
   REENTER gets you into SIMDDT so that you can set breakpoints
   before execution, START starts directly.
2) After CONTROL-C or call to the EXIT(0) procedure:
   CONTINUE continues execution where interrupted. REENTER
   enters SIMDDT. After using SIMDDT, the PROCEED command can be
   used to continue execution. START starts from the beginning
   of the program again.
3) After the end of execution:
   CONTINUE enters SIMDDT where some data still are available to
   look at from the previous execution. REENTER starts from the
   beginning but enters SIMDDT before the new execution. START
   starts from the beginning.
4) IF SIMDDT was entered intially (GET-REENETER or via the
   DEBUG monitor command), START will always start with SIMDDT.



.skip;.fill
See also the description of the SAVE procedure in the handbook
part III.
.skip 2;.test page 7;.left margin 3;.fill;.center
NEW VERSION OF SIMED
.skip
The Simula release 4 distribution tape includes a new
version of SIMED. SIMED can now read and produce
linenumbered files. Commands to SIMED are given in the
format
.skip
outfil.ext=infil.ext/s1/s2
.skip
SIMED will also read switches from SWITCH.INI.
For more information see SIMED.HLP.
.skip 2;.test page 7;.left margin 3;.fill;.center
SCANNING USER COMMANDS
.skip
Do you want to write programs which take user commands
in the DEC 10 standard format:
.skip
outfil.ext=infil.ext/s1/s2...
.skip
A simple SIMULA procedure to simplify this is SCAN,
which is included in the SYS:LIBSIM library.
An example of the use of SCAN is included as a comment
in the file SCAN.SIM, and in the latest edition of
the DECsystem-10 SIMULA Language Handbook part III.
.skip 2;.test page 7;.left margin 3;.fill;.center
PROGRAMMING SIMPLE TERMINAL INPUT DIALOGUE
.skip
To ask a question and get an answer from the terminal,
you can use
.nofill;.skip
TEXT PROCEDURE inline(prompt,inf); VALUE prompt;
TEXT promt; REF (infile) inf;
.fill;.skip
This procedure will ask the question
"prompt" to the terminal and return the answer,
stripped but not frontstripped.
Note: "inline" returns a copy of the text received from
the user terminal.
.p 0,1,7
Example of use:
.skip;.nofill
FOR speed:= inline("Give speed: ",sysin).getreal
WHILE speed <= 0 DO
BEGIN outtext("? Speed must be positive."); outimage;
END speed loop;
.fill
.skip 2;.test page 7;.left margin 3;.center
NEW IMPROVED VERSION OF FQC
.skip
FQC is a program to help you optimize a given SIMULA program
by finding those places in the program which are executed
most often.
FQC takes as input a given SIMULA main source program, and outputs a
similar source program except that the program also counts the
number of times that each statement is executed.
.p
A new improved release 2 of FQC is available with release 4
of DECsystem-10 SIMULA. The improved version can handle
full DECsystem-10 SIMULA, including tabs, long text constants,
exponentiation sign (_^), the OPTIONS-statement, !-comments etc.
.p
The new version of FQC is also much easier to run, since
the modified program will automatically be compiled and
executed by FQC. Facilities for measuring the CPU time and for tracing
are also included. For more information, see FQC.HLP.
.skip 2;.test page 7;.left margin 3;.center
NEW IMPROVED VERSION OF SIMEXP
.skip
SIMEXP copies a number of separately compiled SIMULA modules
into one large main program. SIMEXP can for example be used:
.break
a) Before the running of FQC (see above) since FQC only
counts frequencies in the main program.
.break
b) Before exporting a SIMULA program to a SIMULA system
which does not include separate compilation. (In this
case, run SIMIBM after SIMEXP.)
.skip
A new improved version of SIMEXP is available with release 4
of DECsystem-10 SIMULA. The improved SIMEXP can handle
full DECsystem-10 SIMULA and does not require that all
separately compiled modules are copied together.
.skip 2;.test page 7;.left margin 3;.center
AN EXERCISE IN TEXT HANDLING
.skip
Problem: A text variable contains a DECsystem-10 file
specification, e.g. "DSKB:#fil.ext[13,120]<155>". Write
a short and efficient code segment in SIMULA
                           to blank the part between
the square parentheses (in the example convert the
string to "DSKB:#fil.ext[######]<155>".
Assume availability of all the text handling procedures
described in the DECsystem-10 SIMULA Language Handbook
part III.
.skip
A solution to the problem will be found later in this
gazette.
.skip 2;.test page 7;.left margin 3;.center
NEW INTERPRETATION OF HIDDEN IN AN AMBIGUOUS CASE
.skip
If a HIDDEN specification contains an identifier
which is ambiguous, because the same identifier has been
used for different attributes within the prefix chain,
then the HIDDEN specification will take effect
for the innermost PROTECTED attribute with this identifier.
This means that the outer attribute will become visible because
of the HIDDEN specification, so that a HIDDEN in a further subclass
will protect that attribute.
.skip
Example:
.skip;.left margin 5;.nofill
###CLASS c1(q); REAL q; PROTECTED q;;
c1 CLASS c2(q); REAL q; PROTECTED q;;
c2 CLASS c3(q); REAL q; PROTECTED q;;
c3 CLASS c4; HIDDEN q;
COMMENT hides q of c3, makes q of c2 visible;;;
c4 CLASS c5; HIDDEN q;
COMMENT hides q of c2, makes q of c1 visible;;;
.left margin 3;.fill;.skip
This is a change since release 3. In release 3, HIDDEN would instead
hide all the attributes at the same time.
.skip 2;.test page 7;.left margin 3;.center
TEXT CONSTANTS IN IF-STATEMENTS
.skip
The DEC 10 SIMULA system accepts TEXT constants in
conditional statements in the following four cases:
.p;.nofill
a) As right-hand-side in a TEXT-VALUE-RELATION.
#######Example: t:= IF bool THEN "yes" ELSE "no";
.p
b) As actual parameter in a procedure called by VALUE:
#######Example: PROCEDURE p(t); TEXT t; VALUE t;...
################p(IF bool THEN "yes" ELSE "no");
.p
c) As actual parameter to certain system procedures,
OUTTEXT, COPY and NEW ... FILE.
########Example: t:= COPY(IF bool THEN "yes" ELSE "no");
.p
d) In a TEXT-value-relation.
########Example: IF x = (IF uc THEN "C" else "c") THEN
.p;.fill
Note that this is a restriction compared to release 3
of DEC 10 SIMULA, but an extension compared
to the standard (Common Base) definition of SIMULA.
.skip 2;.test page 7;.left margin 3;.center
A HINT ON INPUTTING TEXTS
.p 0,1,4;.fill
Just because there is a SIMULA built-in PROCEDURE "intext", you may
find it natural to use it for inputting texts. However, in most
cases other ways of inputting texts are better.
.p
Examples:
.p;.nofill
     WHILE NOT endfile DO
     BEGIN COMMENT successive lines;
        inimage; t:- copy(sysin.image);
        .....
     END;
.p
     WHILE NOT lastitem DO
     BEGIN COMMENT successive non-blank line parts;
        t:- copy(sysin.image.
           sub(sysin.pos,sysin.length-sysin.pos+1).strip);
        ....
        sysin.setpos(0); ! Will set pos to length+1;
     END;
.p
     WHILE NOT endfile DO
     BEGIN COMMENT successive items separated by space;
       WHILE sysin.image.more DO
       BEGIN
         skip(sysin.image,' ');
         t:- copy(scanto(sysin.image,' '));
         ....
       END;
       inimage;
     END;
.fill;.skip
The examples above include "copy" to copy the text items
read. The procedure "copy" is however rather expensive to use.
Often the text is only needed while residing in image.
Subtext (without copying) will then suffice.
.skip 2;.test page 7;.left margin 3;.center
ATTRIBUTES OF SIMSET AND SIMULATION ARE PROTECTED
.skip
All the attributes of the system classes SIMSET and SIMULATION are
predefined as PROTECTED in release 4. This allows you to use HIDDEN on them.
This means that if you write NOT HIDDEN or NOT HIDDEN PROTECTED
in a subclass to SIMSET and SIMULATION, then you will hide all
attributes of SIMSET and SIMULATION not included in your specification.
To avoid this, you can include the following line of code in
your CLASS heading:
.skip
NOT HIDDEN process, current, time, hold, passivate, wait,
cancel, accum, main, linkage, link, head;
.index process, HIDDEN specification on
.index current, HIDDEN specification on
.index time, HIDDEN specification on
.index hold, HIDDEN specification on
.index passivate, HIDDEN specification on
.index wait, HIDDEN specification on
.index cancel, HIDDEN specification on
.index accum, HIDDEN specification on
.index main, HIDDEN specification on
.index linkage, HIDDEN specification on
.index link, HIDDEN specification on
.index head, HIDDEN specification on
.skip 2;.test page 7;.left margin 3;.fill;.center
ARE YOU AWARE OF THE ASSOCIATION OF SIMULA USERS
.skip
If you are using SIMULA and not a member of the Association
of SIMULA Users, we recommend you to become a member.
There is presently no membership fee, and you will get
a quarterly newsletter and invitations to courses
and conferences on the use of SIMULA.
.skip
Write to: Association of SIMULA Users, Norwegian Computing
Center, Forskningsveien 1b, Oslo 3, Norway.
.skip 2;.test page 7;.left margin 3;.center
OPTIMIZE SIMULA PROGRAMS BY AVOIDING GARBAGE GENERATION
.skip
By garbage generation is meant the allocation of data that will
soon be deallocated, and that must be reclaimed by the garbage collector
built into the SIMULA system.
.skip
Garbage generation is costly both in CPU time and core requirement.
.skip
As an example, I tried to optimize the following piece of code
in the VISTA package:
.skip;.nofill;.left margin 5
PROCEDURE outtext(t); VALUE t; TEXT t;
....
PROCEDURE outint(i,j); INTEGER i, j;
BEGIN TEXT t;
  t:- blanks(j); t.putint(i); outtext(t);
END;
.skip;.fill;.left margin 3
I made the following optimization:
.skip
1) "outint" does not generate a new text with the procedure "blanks".
This new text will soon become garbage.
Instead an existing text is used.
.skip
2) The parameter "t" to "outtext" is specified by NAME instead of by
VALUE, so that no garbage text has to be generated.
.skip
3) "outint" does not use the SIMULA-programmed version of "outtext".
.skip
Results:
CPU-time for a small program was reduced by 20%, and core requirement
was reduced by 4K words.
.skip
NOTE: In my original program, not only the text "t" but also the
procedure block "outint" became garbage. When I removed the call
to "blanks", neither of these two blocks had to become garbage.
.skip
The explanation for this is that the SIMULA run-time-system may
deallocate blocks at the top of the stack at procedure exit
if no new TEXT or CLASS object was generated within the
procedure or procedures called by it.
.skip 2;.test page 7;.left margin 3;.center
WHICH IS THE FASTEST WAY?
.p
Many times, you may ask yourself questions like:
What is faster in SIMULA, "IF bool THEN" or "IF i == 0 THEN"?
PRETIM is a utility program to help you answer such
questions. For further information,
see PRETIM.HLP.
.skip 2;.test page 7;.left margin 3;.center
INPUTTING AND OUTPUTTING DEC 10 TEXT FILES
.skip
The release 4 distribution tape contains a skeleton program FILED
containing a class FILED (which can be separately compiled) to input
and output DEC 10 ASCII-7-formatted text files in SIMULA. The
program can handle both unnumbered and line numbered text files. For
numbered files, the program will ensure that the output file has the
format on line numbers required by other DEC 10 text handling
programs like for example SOS. Lines lacking line numbers will be
given such numbers.
.skip
     The good facilities for text handling in SIMULA makes it a
     useful language for text handling programs like editors,
     programming language translators, compilers, pre-compilers etc.
.skip
     However, reading and writing text files on the DEC 10,
     especially line numbered files, is rather tricky in SIMULA. By
     using this program, you avoid those problems.
.skip
     The program can be found in a file with the name FILED.SIM on
     the SIMULA distribution tape.
.skip
The proper way to output a page delimiter acceptable to SOS is
the following, if t is the text of the first line after the
page delimiter:
.test page 8;.skip;.nofill
editout:- NEW outfile("FIL.EXT/NUMBERED");
editout.open(blanks(line_length));
.......
INSPECT editout DO
BEGIN
  image.setpos(6); outchar(carriagereturn);
  outchar(formfeed); breakoutimage; ! Ensures word alignment;
  outtext(five_digits); outchar(tab);
  outtext(t); outimage;
END;
.fill
.skip 2;.test page 7;.left margin 3;.center
WRITING VERY LARGE PROGRAMS
.p 0,2,2
When you begin writing a program which may in the end be larger than
1000 or 2000 lines, you can save much trouble by planning the
program carefully before starting to program.
.p 0,1,5
To save compilation time when the program grows large, it is
advisable to divide the program into separately compiled modules.
This division must be planned BEFORE starting to write the program.
When a program already has grown large, it is often difficult
or impossible to find a satisfactory decomposition.
.p 0,1,5
The best way to divide a program into separately compiled modules
is usually to divide it into a not too large number of rather
large (about 100-500 lines) separately compiled classes.
.p
Use the facilities of SIMULA that one class may extend the
concepts defined in a prefixing class, and that the main
program may combine the facilities of several such
separately compiled classes or class chains.
.p;.test page 7
Example: Your program may be divided into the following
modules:
.nofill;.break
1) Analyzing user input commands
2) Interpreting formulas input by the user
3) Handling help requests from the user
4) Processing of the data base
.p;.fill;.test page 10
If none of these four modules uses data or procedures
from another module, you can write the four modules as
four independent separately compiled classes, all
accessible only from the main program:
.p;.nofill
Command    Formula           Help request    Data base
analysis   interpretation    handling        handling
     !            !            !               !
     --------------Main program-----------------
.p;.fill;.test page 18
If, however, the module "Formula interpretation" uses
facilities defined in the module "Command analysis", the
following structure may be appropriate:
.p;.nofill
Command
analysis
   !
Formula            Help request     Data base
interpretation     handling         handling
   !                  !                !
   -------------Main program------------
.p;.fill
This has the disadvantage that changes in the data
definitions in "command analysis" may force recompilation
of "Formula interpretation", but the advantage that
"Formula interpretation" has access to the data
structures and operations defined in "Command analysis".
.p;.test page 19
Suppose now that "Data base handling" can be divided into
two modules, "Reading records" and "Handling records".
Both these modules require access to the data structure
definitions used to represent "records" in core.
.p
One solution is then to make one of these two a subclass
to the other:
.p;.nofill
                                    Defining
                                    records
                                       !
Command                             Reading
analysis                            records
   !                                   !
Formula            Help request     Handling
interpretation     handling         records
   !                  !                !
   -------------Main program------------
.p;.fill;.test page 18
Another solution is to make "reading records" and
"handling records" two parallel subclasses to "Defining
records":
.p;.nofill
Command                              Defining
analysis                             records
   !                                 !     !
Formula          Help request   Reading   Handling
interpretation   handling       records   records
   !                   !          !         !
   --------------------Main program----------
.p;.fill
The latter solution has the advantage that no changes in
"reading records" can cause recompilation of "handling
records", but the disadvantage that "defining records"
becomes more limited. It works best if "defining records"
is a class with no internal class definitions in it.
.p
In some cases, the only solution for you is to decompose your
program into a long chain of separately compiled classes,
each a subclass to the previous one. This is the only
solution for code which has to be inside "SIMSET" or
"SIMULATION". The disadvantage with this solution is
that a change in the data definitions in the outermost
class may force recompilation of the whole chain.
.skip 2;.test page 7;.left margin 3;.center
SAVE SPACE BY AVOIDING REPETITION OF COMMON DATA
.skip 1
Do not repeat the same information in many blocks. Suppose, for
example, that you have a large number of instances of the same class,
and if some of the data is the same in many or all of these
instances.
You can then instead of copying this information in all the
block instances, put the information into one separate class
object, with a reference from the partly similar objects to
the single object containing the common part.
.skip 1
Example: Suppose that you have 1000 records of people with only
four different work addresses. Instead of including the work
adress in each of the 1000 class instances, you can have
just four instances of a class "address", with references
from each of the 1000 records to one of the four "address" instances.
.fill;.skip 2;.test page 7;.left margin 3;.center
HOW TO PROGRAM SELECTION SEQUENCES
.left margin 3;.fill;.blank
Suppose that your SIMULA program should execute different
code depending of the value of an integer variable, e.g.
corresponding to a CASE statement in some other programming
languages.
.skip
This can be programmed in many ways. Four common solutions in SIMULA
are to use (1)#a SWITCH, (2)#a sequential series of IF-THEN-ELSE statements
(3)#a binary test structure of IF-THEN-ELSE statements and (4)#a CALL
statement.
.skip;.nofill;.test page 10
THE SWITCH SOLUTION:
.skip
    SWITCH s:=l1,l2,l3,l4,l5;
    GOTO s(i);
    l1: action;
    GOTO out;
    l2: action;
    GOTO out;
    etcetera.
.skip;.test page 6
THE SEQUENTIAL IF-THEN-ELSE SOLUTION:
.skip
    IF i = 1 THEN action
    ELSE IF i = 2 THEN action
    etcetera.
.skip;.test page 6
THE BINARY IF-THEN-ELSE TEST STRUCTURE SOLUTION:
.skip
    IF i < 16 THEN
    BEGIN
      IF i < 8 THEN
    etcetera.
.skip;.test page 22
THE CALL SOLUTION:
.skip
  CLASS cc;
  BEGIN
    loop:detach;
    INNER;
    GOTO loop;
  END;
  cc CLASS c1;
  BEGIN action;
  END;
  cc CLASS c2;
  BEGIN action;
  END;
  REF (cc) ARRAY ca(1:5);
  etcetera
  ca(1):- NEW c1;
  ca(2):- NEW c2;
  etcetera.
  call(ca(i));
.skip;.fill
Which is the fastest solution? The SWITCH and CALL solution
are independent of the number of alternatives, while the
IF-THEN-ELSE solutions are faster with few alternatives and
if the tests can be orderded so that the most common alternatives
are tested first.
.skip;.test page 12
I made some test runs using DECsystem-10 SIMULA version 3A:
.skip;.nofill
SWITCH solution:  0.12 ms
CALL solution:    0.29 ms
IF-THEN-ELSE solution:
  5 equally probable alternatives: 0.02 ms
 10 equally probable alternatives: 0.04 ms
 20 equally probable alternatives: 0.06 ms
 50 equally probably alternatives: 0.10 ms
100 equally probable alternatives: 0.23 ms
BINARY IF-THEN-ELSE solution with 64 alternatives: 0.02 ms
.skip;.fill
Conclusion: the IF-THEN-ELSE solutions are fastest. The binary test
structure is fastest of the IF-THEN-ELSE solutions. If the number of
alternatives is larger than 50 and if the binary test structure is
not possible, then the SWITCH solution may be fastest.
.skip
Note, in case the activity to be done in the different cases
is a procedure call, then the CALL solution above can be faster
if the PROCEDURE is rewritten into a CLASS to be CALLed.
.fill;.skip 2;.test page 7;.left margin 3;.center
A HINT ON THE USE OF SIMDDT
.skip
Maybe you have tried to give the following commands
to SIMDDT:
.break
STOP AT nnn IF bool
.break
STOP AT nnn IF NOT bool
.break
where "bool" is a Boolean variable. This does not work,
but you can instead use the following equivalent SIMDDT
commands:
.break
STOP AT nnn IF bool EQV TRUE
.break
STOP AT nnn IF bool EQV FALSE
.break
to stop when the Boolean variable is true or false.
.fill;.skip 2;.test page 7;.left margin 3;.center
FULL CONTROL OF DISPLAY TERMINAL
.skip
Do you want full control of the screen on an alphanumeric
display terminal - the ability to move the cursor
around the screen and change the screen contents
in arbitrary order.
.skip
A package for doing this in SIMULA is available in
LIBSIM under the name "VISTA". The package is terminal
independent - it will work on most alphanumeric display
terminals: Infoton, Datamedia Elite, DEC, Tec, Beehive
Tandberg etc. (Not Tektronix!) When a program uses this
package, the program can be moved to a new kind of terminal
without reprogramming.
.skip
To test the program, some demo programs are available
on the SIMULA distribution tape:
.nofill;.p 0,1,6
CAT   = cat hunts rat in cage with ratholes
SHIP  = troop transport simulation across a lake
        shown on the screen
FORMT = form-driven terminal input
TABLE - table-driven terminal input
.fill
.fill;.skip 2;.test page 7;.left margin 3;.center
CALL MIC FROM SIMULA
.skip
Do you want your SIMULA programs to do things
difficult to to in SIMULA? By using the library
procedure CALLMIC, you can start MIC from
a SIMULA program, and MIC can do what you
want and then return control to the SIMULA
program again.
.skip 2;.test page 7;.left margin 3;.center
SOME FACTS ON THE DEVELOPMENT OF DECSYSTEM-10 SIMULA
.skip
A preliminary study was made in 1971 by CAP in London
and Stefan Arnborg from Swedish National Defense Research
Institute.
.p
The development began when we got our DEC 10 in January 1973.
A team was collected with two programmers from the Swedish
National Defense Research Institute, one from the Stockholm
University Computing Centre and five from the software house
ENEA. Development was ready in December 1974. 
.skip;.nofill
Total effort until now:
Personyears  Effort
     1       Pre-study
     2       Preparation of delivery tests etc.
    14       Main development and testing
     2       Additions made later
     2       Maintenance
.fill
.skip 2;.test page 7;.left margin 3;.fill;.center
SIMULA COMPATIBILITY
.skip
SIMULA programs are usually easier to move between computers
of different models than in most other languages. If you
want your programs to be portable, then read carefully
chapter 10.2 in the DECsystem-10 Simula Language Handbook
part II, and also avoid using "breakoutimage" and
avoid using the procedures described in chapters 4 and
7 of the DECsystem-10 Simula Language Handbook Part III.
.p 0,1,3
A paper entitled "Experience from the Standardization
of the SIMULA Programming Language" was published
in Software Practice and Experience, vol. 6(1976),
pp 405-409.
.fill;.skip 2;.test page 7;.left margin 3;.center
MINICOMPUTER SIMULA AVAILABLE
.skip
The first minicomputer SIMULA system is now ready.
It was written for the Norwegian NORD-10 computer. This SIMULA
system is almost entirely written in SIMULA itself,
to simplify bootstrapping to other minis.
.skip
When will we see a PDP-11 bootstrap? Write to
G. Philippot, EDB-Sentret,
University of Oslo, Postbox 1059, Blindern, Oslo 3, Norway.
.skip 2;.test page 7;.left margin 3;.center
SPECIFYING NEW OPERATING SYSTEMS IN SIMULA
.p 0,1,3
Small and medium-sized computers will be used more frequently
for control of different physical processes in real time.
Testing of software through simulation is of great value when
designing such computer systems.
.p
A Simula model of an operating
system kernel for processor control has been develloped at the
Swedish National Defense Research Institute [1]. The details in
the kernel are to a great extent based on algorithms found in [2].
In the kernel are found e.g. functions for operations on semaphores
and events and functions for handling of interrupts. Using kernel
operations it is possible to picture signalling between different
programs executing in pseudo-parallel.
.p
This kernel has later been
used to study the program logic in a navigations system with
components fixed to the body (a strap-down system) [3]. The Simula
code in the kernel has also been translated by hand to assembly
code for a mini-computer [4].
.p
 The idea has been: "First test
the logic in Simula, then translate into assembly-code." This method
has been found very good.
.p
.nofill;.skip
[1] Lars-Aake Larsson: A Simula model of an operating system
    kernel for processor administration. FOA Rapport A 20013-E5
    Mars 1976.
[2] Per Brinch Hansen: Operating System Principles.
    Prentice-Hall 1973.
[3] Svante Jahnberg: Strukturering av programvara foer ett
    navigeringssystem med skrovfasta komponenter. FOA Rapport C
    20119-E4(E5) Juni 1976. (Structuring of software for a
    navigations system with components fixed to the body. Will
    probably soon be translated into English.)
[4] Staffan Starrin: Implementering av en operativ-systemkaerna
    foer processorstyrning paa en minidator. Working paper.
    (Implementation of a operating system kernel for processor
    control on a minicomputer. Will possibly also be published
    in English.)
.skip;.fill
[1] and [3] can be ordered from Swedish National Defence
Research Institute,  Inst 220, Fack, S-104 50 Stockholm,
Sweden.

.fill
.skip 2;.test page 7;.left margin 3;.center
GPSSS - A GPSS SYSTEM WRITTEN IN SIMULA
.skip
GPSSS is a GPSS-like system entirely written
in SIMULA. The SIMULA programmer just writes
.nofill
EXTERNAL CLASS gpsss;
gpsss BEGIN
.fill
and can then directly use GPSS-like commands.
.skip
For more information see GPSSS.MAN. GPSSWE.MAN is a Swedish
translation of GPSSS.MAN. GPSSS.SIM is the original
Canadian GPSSS system, GPSSST.SIM is an extended version with more
automatic tracing and statistics facilities.
.skip 2;.test page 7;.left margin 3;.center
CADSIM - FOR CONTINUOUS SIMULATIONS IN SIMULA
.skip
The release 4 distribution tape contains a copy of CADSIM, which is
a system for continous simulations in SIMULA (like CSMP or
DYNAMO). CADSIM was originally developed by R.J. Cunningham at the
Imperial College in London, and was moved to DECsystem-10 by Mats
Ohlin.
.skip
R.J. Cunnigham states that you are free to use the CADSIM system
distributed on the release tape, but that he takes no responsibility
for the accuracy of results and that the program may not be
redistributed without his permission.
.fill;.skip 2;.test page 7;.left margin 3;.center
PACKAGE FOR THE SIMULATION OF DIGITAL CIRCUITS
.skip
The university of Linkoeping, Sweden, has developed
a general-purpose package for the simulation of digital circuits - DIGSIM.
The package is used by the Swedish computer manufacturer
SAAB.
.skip
The package is a utility for use during the development
and production of complex digital electronic circuitry.
Some properties of the system:
.indent -2
-#An advanced system for verifying the reliability
of the system when the components have small random
errors in speed.
.indent -2
-#Synchronous and asynchronous sequential nets.
.indent -2
-#Detailed functional modelling of complex dynamic components.
.indent -2
-#Detection and checking of race phenomena, short pulses
and other fault conditions.
.indent -2
-#A library of more than a hundred TTL components.
.skip
The system is available (not free, though)
                        in DECsystem-10 and Univac 1100 Simula.
For more information, write to
Bengt Magnhagen, Linkoeping Institute of Technology, System technology
institute, 581 83 Linkoeping, Sweden.
.skip 2;.test page 7;.left margin 3;.center
NEW SIMULATION OF DEC 10 OPERATING SYSTEM
.skip
A group at the Technical University of Berlin has written
a simulation program of the DEC-system-10 operating system.
The program investigates the effects of different loads
on a DEC 10 computer. The effect of configuration changes
on performance can be tested using the model. The model
was written by a group of students using the DECsystem-10
SIMULA system.
.skip
The report is entitled "EIN SIMULATIONSMODELL ZUR LEISTUNGSANALYSE
DER TIME-SHARING-ANLAGE DEC-SYSTEM-10" and can be ordered
from "Technische Universitaet Berlin, Fachbereich 20, Kybernetik,
1 Berlin 12, Strasse des 17. Juni 135, Berlin, Bundesrepublik
Deutschland", report no. 76-14, July 1976.
.skip 2;.test page 7;.left margin 3;.fill;.center
REPORTS ON THE USE OF DECSYSTEM-10/20 SIMULA
.skip
Dr. Walter Maner at the Old Dominion University
in Norfolk, Virginia has written several sets
of programs for teaching logic to students
in SIMULA.
For example, his VENN program generates counterexamples
to about 75% of all invalid syllogisms.
.p
He finds that one main advantage with SIMULA compared
to LISP for this kind of work is that it is easier
to program a nice student-computer interface
in SIMULA.
.skip 2;.test page 7
Naftaly Minsky at Rutgers University has developed a secure data
base system in DECsystem-10 SIMULA.
.skip
The basis of the system is that the objects output to a
data base are instances of separately compiled SIMULA classes.
The attributes of these classes may be protected so that the
applications programmer can only access the attributes through
procedures (operations) within the class.
.skip
The data base system provides facilities to open a file
for a certain user (with certain access rights) and to get
and store class instances into this file. Get and store
operations on the file will automatically invoke "demons"
to monitor the operations and encipher the records.
.skip
More information is available in the report "Files with
Semantics" in Proceedings of the SIGMUD International Conference 1976.
You can also write to Professor Naftaly Minsky,
Department of Computer Science, Rutgers University, Hill Center,
Busch Campus, New Brunswick, New Jersey 08903, U S A.
.skip 2;.test page 7
Sallie S. Nelson and Gary E. Lindstroem at the
university of Pittsburgh have developed a
prototype for a conversational simulation
language. The development was done using
DECsystem-10 SIMULA.
.variable copynmail a b
.ifnot copynmail
.skip 2;.test page 7;.left margin 3;.center
WARNING: YOU ARE BEING RECORDED!
.skip
This notice has been added to the gazette because of
instructions given to us by the Swedish Computer Inspectorate in
accordance with the Swedish Data Act:
.skip
You are hereby notified that if you received this gazette in an
envelope with a computer-written label, that was because
you have been recorded in a computer. You can at any time ask
for this record to be erased, and once a year you can get a full
transcript of your entry.
.endif copynmail
.endif copynmail
.fill;.skip 2;.test page 7;.left margin 3;.center
BACKUP OF ATR FILES
.skip
The new SIMULA system will rename the old
_.ATR file to .QTR instead of deleting it.
This is useful if you want to restore the
old .ATR file after compiling an erroneous
program.
.fill;.skip 2;.test page 7;.left margin 3;.center
A NOTE ON THE USE OF OPTIONS(/-ARRAY)
.skip
The command "OPTIONS(/-ARRAY)" can be used to
partly inhibit the generation of code for array
bound checking. However, this command usually takes
effect from the previous statement, not from
the next statement. Thus, if you write
.skip;.nofill
OPTIONS(/A); a[i]:= a[i]; OPTIONS(/-A);
.skip;.fill
you will not get any array bound checking
on the statement in the middle! To get array
bound checking on it, write instead:
.skip;.nofill
OPTIONS(/A); a[i]:= a[i];; OPTIONS(/-A);
.fill;.skip
introducing a dummy statement by the extra semicolon.
.fill;.skip 2;.test page 7;.left margin 3;.center
SIMULA-GASP COMPARISON
.skip
ARL in Australia have made a test comparison
between SIMULA and the FORTRAN-based GASP simulation
system. SIMULA was four times faster and required
only a quarter of the core needed by GASP for the
same simulation.
.fill;.skip 2;.test page 7;.left margin 3;.center
SIMULATION AND SIMSET ENTIRELY WRITTEN IN SIMULA
.skip
A version of the SIMULA system classes SIMSET and
SIMULATION which is entirely written in SIMULA
is available on the SIMULA distribution tape
under the names ZIMSET and ZIMULATION.
Their advantage is that you can easily insert
tracings into the simulation scheduler.
See file ZIMSET.MAN.
.fill;.skip 2;.test page 7;.left margin 3;.center
MULTIPLE PRECISION IN SIMULA
.skip
A package for fast manipulation of real numbers with
almost unlimited size and precision has been
written in SIMULA. For more information, write
to the Institute for Numerical Analysis,
Royal Institute of Technology, S-10044 Stockholm,
Sweden.
.fill;.skip 2;.test page 7;.left margin 3;.center
SOLUTION TO THE TEXT EXERCISE
.skip;.nofill
t.setpos(1); scanto(t,'[');
scanto(t,']'):= NOTEXT;
.fill;.skip
Note the use of a text procedure at the left side of :=.
.fill;.skip 2;.test page 7;.left margin 3;.center
SOUTHERN CALIFORNIA GROUP DISCUSSES SIMULA
.skip
The DEsystem-10 Southern California User Group
discussed SIMULA in November 1976. Some quotations:
"one of the best implementations done on any
machine"... "documentation is generally considered
to be excellent"... "The richest, most flexible
language ever seen"... "The DEC-10 implementation
has everything. Good error diagnostics, an excellent
interactive debugger, a superset to IBM 360/370 SIMULA"...
"The best DECsystem-10 language implementation ever done"...
"a veriatable cornucopia of library support software"...
"eveything you never got for Christmas".
