Added upstream from http://ftp.icm.edu.pl/pub/loglan/
[loglan.git] / HTML / quickref.txt
1 LOGLAN'82\r
2 Quick Reference Card\r
3 Syntax Form\r
4  its meaning (informal)\r
5 \r
6     program <name>;\r
7          <declarations>\r
8     begin\r
9          <instructions>;\r
10   end\r
11 Program is a unit. It is the root of a tree of units.\r
12 During an execution of the program this tree is \r
13 used as a collection of patterns for instances. An \r
14 instance of a unit is either an activation record (of \r
15 a procedure) or an object(of a class).\r
16 \r
17 Declarations\r
18 \r
19 \r
20 there are five forms of a declaration: \r
21 \r
22 \r
23 \r
24 var, const, unit, signal, handlers  \r
25 \r
26    var x: T, y,z: U;\r
27 declaration of variables x of type T, y,z of type U\r
28 \r
29    unit A: B<kind>(params);\r
30       <declarations>\r
31    begin\r
32        <instructions>;\r
33        last_will: <instructions>\r
34    end A;\r
35 \r
36 evidently you need not to inherit from a module \r
37 declaration of a module A which inherits from B. \r
38 kind may be one of: procedure, class, coroutine, \r
39 process, block, handler, function\r
40 params is a list of formal parameters,\r
41 REMARKS\r
42 - block has no name \r
43        its first line is: block  or pref C block\r
44 - function has a type of result after parameters,\r
45 - handler has a different form., see below,\r
46 - last_will instruction are executed exceptionally.\r
47 \r
48    const cc=80\r
49 declaration of a constant\r
50 \r
51    signal S;\r
52    signal Alarm(x: T, y: Q);\r
53 declaration of a signal S\r
54 it may have a list of formal parameters \r
55 \r
56 \r
57    handlers\r
58       when sig1,SIGN3: Inst; return;\r
59       when sig2: instructions2; wind;\r
60       others  in; terminate\r
61    end handlers\r
62 declaration of a module handling exceptions,\r
63 sig1, sig2, SIGN3 are names of exceptions,\r
64 Inst, instructions2,in are sequences of instructions\r
65 \r
66 handlers appear as the last declaration in a unit\r
67 \r
68 \r
69 \r
70 \r
71 Parametrisation of Units\r
72 \r
73 \r
74 modes of transmission: \r
75 input, output, inout  values of expressions\r
76 \r
77 also  procedure, function, type can be \r
78 transmitted as a parameter\r
79 formal procedures(functions) should be specified \r
80 i.e. the types of arguments and results should be \r
81 given.\r
82 a formal type T alone is of limited use, however it \r
83 may accompany other parameters using T.\r
84 \r
85 Processes are distributed it means that \r
86 they cannot share objects. You can \r
87 transmit only values of simple types and \r
88 names of processes or formal procedures \r
89 to be used for alien calls.\r
90 Processes can reside on different systems of your \r
91 network. This explains the reasons for the \r
92 restrictions. \r
93 The present implementation of processes has \r
94 several limitations. Sorry.\r
95 \r
96 Instructions\r
97 \r
98 \r
99 Atomic instructions\r
100 \r
101 \r
102    x := <expression>\r
103 assignment instruction\r
104 \r
105    x := copy (<expression>)\r
106 copying assignment instruction, has sense only for \r
107 object expressions\r
108 \r
109    call Aprocedure(params)\r
110 procedure call instruction\r
111 \r
112    return\r
113 leaving procedure or function\r
114 \r
115    exit   or  exit exit or  exit exit exit\r
116 leaving one, two or three nested loops do   od\r
117 \r
118    new Aclass(params)      \r
119 instruction generating an object\r
120 \r
121   Objects\r
122 \r
123 \r
124    x := new Aclass(params)\r
125 creates an object of class Aclass with params\r
126 and stores it under the name of x\r
127 \r
128    end Aclass      or     return\r
129 terminating initialisation of a newly created object\r
130 \r
131    kill(x)\r
132 deallocation instruction, causes{x=none}and kills x\r
133 REMARK. No dangling references!\r
134 {x=y&x=z} => kill(x) {x=none&y=none&z=none}\r
135 \r
136    inner\r
137 pseudoinstruction: a slot for the instructions of an \r
138 inheriting unit\r
139 \r
140   Coroutines\r
141 \r
142 \r
143    x := new Cor(params)\r
144 creates a coroutine object x of type Cor\r
145 \r
146    attach(x)\r
147 activates  coroutine  x, and then makes the current \r
148 coroutine chain passive \r
149 \r
150    detach\r
151 undoes the last attach \r
152 \r
153   Processes & Concurrency\r
154 truly object oriented processes and an objective com-\r
155 munication mechanism just by calling methods of  a \r
156 distant process\r
157 \r
158     proces5:=new procesType(...);\r
159 creates an object of \r
160    unit procesType: process(<formParams>); ...\r
161 \r
162    resume(proces5)\r
163 activate a passive process process5\r
164 \r
165    stop\r
166 the current process passivates\r
167 \r
168    enable hisprocedure\r
169 adds the name hisprocedure to the MASK of the \r
170 process, enabling other processes to communicate \r
171 with the process by means of hisprocedure\r
172 \r
173    disable aProcedure,aFunction\r
174 deletes aProcedure,aFunction from the MASK\r
175 \r
176    accept aProc1, aProc2, aFnctn\r
177 process waits (inactively) for another process \r
178 calling a method; \r
179 accept makes possible rendez-vous of this process \r
180 and another process calling his method\r
181 \r
182    return disable aProc1 enable aQ\r
183 return from a rendez-vous reestablishes the MASK \r
184 of the called process; it is posible to modify its \r
185 MASK disabling some procedures and enabling \r
186 others\r
187 \r
188    call proces5.hisprocedure(par)\r
189 \r
190                 *\r
191 \r
192       this is ALIEN CALL\r
193 the current process demands process5 process to \r
194 execute hisprocedure with the transmitted par \r
195 parameters and waits for the eventual outputs;\r
196 1   this instruction may meet with an accept \r
197 instruction of process5 process - in such case there \r
198 is a rendez-vous of two process,\r
199 2   otherwise the call tents to interrupt the normal \r
200 flow of execution of the called process5 process.\r
201 \r
202  \r
203  Exception handling\r
204 \r
205 \r
206    raise Asignal\r
207 Asignal is raised. This lances the research of a \r
208 module handling the signal along the chain of DL \r
209 links i.e. along dynamic fathers of instances. \r
210 \r
211    return\r
212 *                       returns to after raise statement\r
213 \r
214    wind\r
215 *   3 forms of  terminating an exception handling\r
216 \r
217    terminate\r
218 *      destructs (lastwill) several instances of units\r
219 \r
220 \r
221 Composed instructions\r
222 \r
223 \r
224    if * then I else J fi\r
225 * is a Boolean expression\r
226 I, J are sequences of instructions {else J is optional}\r
227 \r
228    do  I  od\r
229 looping instruction; it is suggested to put an exit \r
230 instruction among the instructions I, see below\r
231 \r
232    while * do I od\r
233 * is a Boolean expression\r
234 I a sequence of instructions\r
235 equivalent to\r
236 do\r
237    if * then I else exit fi\r
238 od\r
239 \r
240    for i:= A to B do I od\r
241 i integer variable, A, B integer expressions,\r
242 I a sequence of instructions\r
243 \r
244    case c\r
245       when c1: I;\r
246       otherwise  J\r
247    esac\r
248 case instruction\r
249 I, J are sequences of instructions\r
250 c is an expression, c1 is a constant\r
251            \r
252 \r
253 \r
254 Expressions\r
255 \r
256 \r
257 Arithmetic expressions\r
258 \r
259 \r
260 Boolean expressions\r
261 remark in and is object relations, e.g. if x in Clas2 \r
262 \r
263 Object expressions\r
264 \r
265 \r
266    new T(actual_params)\r
267 create new object of class (coroutine, process) T \r
268 passing the actual_params list to it\r
269 \r
270    this T\r
271 returns as a value the object of type T containing \r
272 this expression\r
273 \r
274    E qua A\r
275 qualifies the value of E as of type A\r
276 Raises error if not E in A\r
277 \r
278    copy(E)\r
279 returns a copy of value of the object expression E \r
280 \r
281 Character expressions\r
282 \r
283 \r
284 String expressions\r
285 only constant strings!\r
286 \r
287 \r
288 Inheritance & Nesting  * \r
289 \r
290 2 fundamental methods of unit's composition\r
291 \r
292 Multi-level inheritance permits to make \r
293 extensions of classes, coroutines, \r
294 processes defined on different level of  \r
295 the nesting structure of units.\r
296 Multi-kind inheritance permits to inherit in a \r
297 block, procedure, function, class, coroutine or \r
298 process.\r
299 \r
300 \r
301 Multiple inheritance is doable by means \r
302 of  multi-level inheritance and other \r
303 ingredients of Loglan.\r
304 Generic modules are doable in various ways: by \r
305 formal types, by multi-level inheritance combined \r
306 with nesting, to say nothing about virtuals.\r
307 \r
308 \r
309 Loglan'82 Quick Reference Card  - 3 -   December, 94\r
310 \r
311 \r