LOGLAN'82

Quick Reference Card

Syntax Form its (informal) meaning
program < name>;
<declarations>
begin
<instructions>
end
Program is a module (=unit).
It is the root of a tree of nested units.
During an execution of a program this tree is used as a collection of patterns for instances . An instance of a unit is either an activation record of a procedure, a function, a block unit, or an object of a class, a coroutine, a process.
DECLARATIONS
there are five forms of a declaration var, const, unit, signal, handlers
var x:T, y,z: U declaration of variables: x of type T, y,z of type U
There exist units in several colours i.e. kinds procedure, class, coroutine, process, block, handler, function
unit A: <kind>(<params>);
<declarations>
begin
<instructions>;
end A;
declaration of a module A.
params is a list of formal parameters.
Remarks - block has no name - - its first line is: block or pref C block - function has a type of result after parameters, - handler has a different form, see below, - lastwill instructions are executed exceptionally.
const cc=82 declaration of a constant
signal S;
signal Alarm(x:T, y:Q);
declaration of a signal S
a signal may have a list of formal parameters
handlers
when sig1, SIGN3: Inst; return
when sig2: instructions2; wind;
others instr2; terminate
end handlers
declaration of a module which handles exceptions,
sig1, sig2, SIGN3 are names of exceptions or signals
Inst, instructions2, instr2 are sequences of instructions,
handler appears as the last declaration in a unit!!
Parametrisation of Units
modes of transmission of values of expressions are: input, output, inout
procedure, function, type can be transmitted as parameter as well formal procedures and functions should be specified i.e. the types of arguments and results should be given.
A formal type T alone is of limited use, however it may accompany other parameters using T.
Processes are distributed, it means that they cannot share objects. You can transmit only values of simple types and names of processes or formal procedures to be used for alien calls. Processes can reside on different processors of your computer or network. Or several processes may share one processor (UNIX and DOS systems). This explains the reasons for the restrictions. The present implementation of processes has several limitations. Sorry.
INSTRUCTIONS
Atomic instructions
x := <expression> assignment instruction
x := copy(<expression) a copying assignment instruction, has sense only for object expressions
call Aprocedure(params) procedure call instruction
return leaving procedure or function
exit or exit exit or exitexitexit ... leaving one, two or more nested loops do ...od
new Aclass(params) instruction generating an object
Objects
x := new Aclass(params) creates an object of class Aclass with params and stores it under the name of x
end Aclass
also return
terminating initialisation of a newly created object
kill(x) deallocation instruction, causes x=none and kill x
REMARK
No dangling references!
{x=y & x=z}=>kill(x){x=none & y=none & z =none}
inner pseudoinstruction; it is a slot to put the instructions of an inheriting unit;
Coroutines
x := new Cor(params) creates a coroutine object x of type Cor, the coroutine-object x is passive
attach(x) makes the current coroutine chain passive and activates coroutine x
detach undoes the last attach
You can combine coroutines and recursive procedures.
Coroutines enable quasi-parallel programming - of importance for SIMULATION and games.
Processes & Concurrency
Loglan'82 offers truly object oriented processes and an object oriented communication mechanism alien call just by calling methods of a distant process
process5 := new prcsTyp(...) creates an object-process of
unit prcsTyp:process(<params>)
resume(process5) activate a passive process process5
stop the current process passivates
enable hisProcedure process adds the name of hisProcedure to the MASK of the process, enabling other processes to communicate with the process by means of hisProcdure.
disable aProcedure, aFunction deletes the names: aProcedure, aFunction from the MASK.
accept aProc1, aProc2, AFun process waits (inactively) for another process calling a method.
accept makes possible rendez-vous of this process and another process calling a method from the MASK or the list aProc1, aProc2, aFun.
return disable aProc1 enable aProc2 return from a rendez-vous reestablishes the MASK of the called process; it is possible to modify its MASK disabling some procedures and enabling others.
call process5.hisProcedure(par)

this is ALIEN CALL

The current process demands process5 process to execute hisProcedure with the par parameters transmitted and waits for the results, eventually gets outputs.
1) this instruction may meet with an accept instruction of process5 processs - in such a case there is a rendez-vous of two processes,
2) otherwise the call tents to interrupt the normal flow of execution of the called process.
Exception handling
raise aSignal A signal is raised. This lances the research of a module handler of the aSignal signal along the chain of DL links i.e. along dynamic fathers of instances.
3 forms of terminating an exception handling are provided:
return returns to after raise statement
wind destructs several instances of units (cf.lastwill) but the instance containing the handler.
terminate destructs several instances of units (cf.lastwill) and the instance containing the handler.
Composed Instructions
if Cond then I else J fi Cond is a Boolean expression, I,J are sequences of instructions,
(else J is optional )
do I od looping instruction, it is suggested to put an exit instruction among the instructions I.
while Cond do I od is equivalent to
do
if Cond then I else exit fi
od
for i := A to B do I od i - an integer variable, A, B integer expressions, I a sequence of instructions
case c
when c1: I1;
when c2: I2;
otherwise J
esac
case instruction,
I, J are sequences of instructions,
c an integer expression, c1, c2 integer constants
EXPRESSIONS
Arithmetic expressions they are as you believe they should be
Boolean expressions NOTE object relations in and is , e.g. if x in Class2
Object expressions
new T(actual_params) returns a new object of class (coroutine, process) T
this T returns as a value the object of type T containing this expression
E qua A qualifies the value of object expression E as of type A
Raises error if not E in A
copy(E) returns a copy of the value of the object expression E
Character expressions as usual
String expressions no operations on strings

INHERITANCE & NESTING

2 fundamental methods of unit's composition
Multi-level inheritance permits to make extensions of classes, coroutines, processes defined on different levels of the nesting structure of units. Multi-kind inheritance permits to inherit in a block, procedure, function, class, coroutine or process.
Multiple inheritance is emulated by means of multi-level inheritance and other ingredients of Loglan'82 Generic modules are doable in various ways: by formal types, by multi-level inheritance combined with nesting, to say nothing about virtuals.


AS Last update Sat 4 Feb 1995
pp