Added upstream from http://ftp.icm.edu.pl/pub/loglan/
[loglan.git] / HTML / quick.htm
1 <html>\r
2 <head>\r
3 <title>Quick Reference Card </title>\r
4 </head>\r
5 <body>\r
6 \r
7 <H1><img align=middle src="loglanmm.gif"> LOGLAN'82</H1>\r
8 <H2>Quick Reference Card</H2>\r
9 \r
10 <table border>\r
11 <tr>\r
12 <td> <em> Syntax Form </em> </td>\r
13 <td> <em> its (informal) meaning </em> </td>\r
14 </tr>\r
15 <tr><td></td><td></td></tr>\r
16 \r
17 <tr>\r
18 <td><strong>program</strong> &lt;<EM> name</em>&gt;;<br> <em>&lt;declarations</em>&gt;<br>\r
19 <strong>begin</strong><br> <em>&lt;instructions</em>&gt;<br> <strong>end</strong>  </td>\r
20 <td>Program is a module (=unit).<br> It is the root of a tree of nested units. <br>During an execution of a program this tree is used as a collection of patterns for <em>instances </em>. An instance of a unit is either an <em> activation record</em> of a procedure, a function, a block unit, or an <em> object</em> of a class, a coroutine, a process.   </td>\r
21 </tr>\r
22 \r
23 <tr>\r
24 <th colspan=2><em>DECLARATIONS </em> </th>\r
25 </tr>\r
26 \r
27 <tr>\r
28 <td><em>there are five forms of a declaration </em> </td>\r
29 <th>var, const, unit, signal, handlers </th>\r
30 </tr>\r
31 \r
32 <tr>\r
33 <td><strong>var </strong> x:T, y,z: U </td>\r
34 <td>declaration of variables: x of type T, y,z of type U </td>\r
35 </tr>\r
36 \r
37 <tr>\r
38 <td>There exist <strong>units</strong> in several colours i.e. <strong><em>kind</em></strong>s </td>\r
39 <td><strong>procedure, class, coroutine, process, block, handler, function</strong> </td>\r
40 </tr>\r
41 <tr>\r
42 <td><strong>unit</strong> A: &lt;<strong><em>kind</em></strong>&gt;(&lt;<em>params</strong></em>&gt;);<br>\r
43  &lt;<em>declarations</em>&gt;<br>\r
44 <strong>begin</strong><br>\r
45 &lt;<em>instructions</em>&gt;;<br> <strong>end </strong> A; </td>\r
46 <td>declaration of a module A.<br>\r
47 \r
48 <em> params</em> is a list of formal parameters.</td>\r
49 </tr>\r
50 \r
51 <tr>\r
52 <td colspan=2>\r
53 <h7>Remarks</h7>\r
54 <h7>- block has no name</h7>\r
55 <h7>- - its first line is: <strong>block</strong> or <strong>pref</strong> C <strong>block</strong></H7>\r
56 <h7>- function has a type of result after parameters,</H7>\r
57 <h7>- handler has a different form, see below,<H7>\r
58 <h7>- lastwill instructions are executed exceptionally.</h7> </td>\r
59 </tr>\r
60 \r
61 <tr>\r
62 <td><strong> const</strong> cc=82 </td>\r
63 <td>declaration of a constant </td>\r
64 </tr>\r
65 \r
66 <tr>\r
67 <td><strong>signal</strong> S;<br><strong>signal</strong> Alarm(x:T, y:Q); </td>\r
68 <td>declaration of a signal S<br> a signal may have a list of formal parameters </td>\r
69 </tr>\r
70 \r
71 <tr>\r
72 <td><strong>handlers</strong><br>\r
73  <strong>when </strong> <em>sig1, SIGN3<em>: <em>Inst</em>; <strong>return</strong><br>\r
74 <strong>when </strong> <em>sig2</em>: instructions2; <strong>wind</strong>;<br>\r
75 <strong>others </strong> <em>instr2</em>; <strong>terminate</strong><br>\r
76 <strong> end handlers </strong></td>\r
77 <td>declaration of a module which handles exceptions,<br>\r
78 <em>sig1, sig2, SIGN3</em> are names of exceptions or signals<br>\r
79 <em>Inst, instructions2, instr2</em> are sequences of instructions,<br>\r
80 <em> handler appears as the last declaration in a unit!! </td>\r
81 </tr>\r
82 \r
83 <tr>\r
84 <td colspan=2><em>Parametrisation of Units</em> </td>\r
85 \r
86 </tr>\r
87 \r
88 \r
89 <tr>\r
90 <td><em>modes</em> of transmission of values of expressions are: </td>\r
91 <td><strong>input, output, inout</strong> </td>\r
92 </tr>\r
93 \r
94 <tr>\r
95 <td><strong> procedure, function, type</strong> can be transmitted as parameter as well </td>\r
96 <td> <u>formal procedures and functions</u> should be specified i.e. the types of arguments and results should be given.<br> A <u>formal type </u> T alone is of limited use, however it may accompany other parameters using T. </td>\r
97 </tr>\r
98 \r
99 <tr>\r
100 <td>Processes are <em>distributed</em>, 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. </td>\r
101 <td>Processes can reside on <em>different</em> 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. </td>\r
102 </tr>\r
103 \r
104 <tr>\r
105 <th colspan=2><strong>INSTRUCTIONS </strong> </th>\r
106 </tr>\r
107 \r
108 <tr>\r
109 <td colspan=2><strong>Atomic instructions </strong></td>\r
110 </tr>\r
111 \r
112 <tr>\r
113 <td>x := &lt;<em>expression</em>&gt; </td>\r
114 <td>assignment instruction </td>\r
115 </tr>\r
116 \r
117 <tr>\r
118 <td>x := <strong>copy</strong>(&lt;<em>expression</em>) </td>\r
119 <td>a copying assignment instruction, has sense only for object expressions </td>\r
120 </tr>\r
121 \r
122 <tr>\r
123 <td><strong>call</strong> Aprocedure(params) </td>\r
124 <td>procedure call instruction </td>\r
125 </tr>\r
126 \r
127 <tr>\r
128 <td><strong>return</strong> </td>\r
129 <td>leaving procedure or function </td>\r
130 </tr>\r
131 \r
132 <tr>\r
133 <td><strong>exit</strong> or <strong>exit exit</strong> or <strong>exitexitexit</strong> ... </td>\r
134 <td>leaving one, two or more nested loops <strong>do ...od</strong> </td>\r
135 </tr>\r
136 \r
137 <tr>\r
138 <td><strong> new</strong> Aclass(params) </td>\r
139 <td>instruction generating an object </td>\r
140 </tr>\r
141 \r
142 <tr>\r
143 <th colspan=2>Objects </th>\r
144 </tr>\r
145 \r
146 <tr>\r
147 <td>x := <strong>new</strong> Aclass(params) </td>\r
148 <td>creates an object of class Aclass with params and stores it under the name of x </td>\r
149 </tr>\r
150 \r
151 <tr>\r
152 <td><strong>end</strong> Aclass <br> also <strong>return</strong> </td>\r
153 <td>terminating initialisation of a newly created object </td>\r
154 </tr>\r
155 \r
156 <tr>\r
157 <td><strong>kill</strong>(x) </td>\r
158 <td>deallocation instruction, causes x=none and kill x<br> REMARK<br> No dangling references!<br>{x=y & x=z}=>kill(x){x=none & y=none & z =none} </td>\r
159 </tr>\r
160 \r
161 <tr>\r
162 <td><strong>inner</strong> </td>\r
163 <td>pseudoinstruction; it is a slot to put the instructions of an <em>inheriting</em> unit; </td>\r
164 </tr>\r
165 \r
166 <tr>\r
167 <th colspan=2>Coroutines </th>\r
168 </tr>\r
169 \r
170 <tr>\r
171 <td>x := <strong>new </strong>Cor(params) </td>\r
172 <td>creates a coroutine object x of type Cor, the coroutine-object x is passive </td>\r
173 </tr>\r
174 \r
175 <tr>\r
176 <td><strong>attach</strong>(x) </td>\r
177 <td>makes the current coroutine chain passive and activates coroutine x </td>\r
178 </tr>\r
179 \r
180 <tr>\r
181 <td><strong>detach</strong> </td>\r
182 <td>undoes the last attach </td>\r
183 </tr>\r
184 \r
185 <tr>\r
186 <td colspan=2> <h7>You can combine coroutines and recursive procedures.</h7><br>\r
187 <h7>Coroutines enable quasi-parallel programming - of importance for SIMULATION and games. </h7><br>\r
188 </td>\r
189 </tr>\r
190 <tr>\r
191 <th colspan=2>Processes & Concurrency </th>\r
192 </tr>\r
193 \r
194 <tr>\r
195 <td colspan=2>Loglan'82 offers truly object oriented processes and an object oriented communication mechanism <em>alien call</em> just by calling methods of a distant process </td>\r
196 </tr>\r
197 \r
198 <tr>\r
199 <td>process5 := <strong>new</strong> prcsTyp(...) </td>\r
200 <td>creates an object-process of<br><strong>unit</strong> prcsTyp:<strong>process</strong>(&lt;params&gt;) </td>\r
201 </tr>\r
202 \r
203 <tr>\r
204 <td><strong>resume</strong>(process5) </td>\r
205 <td>activate a passive process <em>process5</em> </td>\r
206 </tr>\r
207 \r
208 <tr>\r
209 <td><strong>stop</strong> </td>\r
210 <td>the current process passivates </td>\r
211 </tr>\r
212 \r
213 <tr>\r
214 <td><strong>enable </strong> <em>hisProcedure</em> </td>\r
215 <td> process adds the name of hisProcedure to the MASK of the process, enabling other processes to communicate with the process by means of hisProcdure. </td>\r
216 </tr>\r
217 \r
218 <tr>\r
219 <td><strong>disable </strong> <em>aProcedure, aFunction</em> </td>\r
220 <td> deletes the names: aProcedure, aFunction from the MASK.</td>\r
221 </tr>\r
222 <tr>\r
223 <td><strong>accept </strong> aProc1, aProc2, AFun </td>\r
224 <td>process waits (<em>inactively</em>) for another process calling a method.<br>\r
225 accept makes possible rendez-vous of this process and another process calling a method  from the MASK or the list aProc1, aProc2, aFun. </td>\r
226 </tr>\r
227 \r
228 <tr>\r
229 <td><strong>return disable</strong> aProc1 <strong>enable</strong> aProc2 </td>\r
230 <td>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. </td>\r
231 </tr>\r
232 \r
233 <tr>\r
234 <td><strong>call</strong> process5.hisProcedure(par)<br>\r
235 <h2>this is ALIEN CALL</h2> </td>\r
236 <td>The current process demands <em>process5</em> process to execute <em>hisProcedure</em> with the <em>par</em> parameters transmitted and waits for the results, eventually gets outputs.<br>\r
237 1) this instruction may meet with an <strong>accept</strong> instruction of <em>process5</em> processs - in such a case there is a rendez-vous of two processes,<br>\r
238 2) otherwise the <strong>call</strong> tents to interrupt the normal flow of execution of the called process. </td>\r
239 </tr>\r
240 \r
241 <tr>\r
242 <th colspan=2>Exception handling </th>\r
243 </tr>\r
244 \r
245 <tr>\r
246 <td><strong>raise </strong> <em> aSignal</em> </td>\r
247 <td>A signal is raised. This lances the research of a module <strong>handler</strong> of the <em>aSignal</em> signal along the chain of DL links i.e. along dynamic fathers of instances. </td>\r
248 </tr>\r
249 \r
250 <tr>\r
251 <td colspan=2>3 forms of terminating an exception handling are provided:</td>\r
252 </tr>\r
253 \r
254 <tr>\r
255 <td><strong>return</strong> </td>\r
256 <td>returns to after raise statement </td>\r
257 </tr>\r
258 \r
259 <tr>\r
260 <td><strong>wind</strong> </td>\r
261 <td>destructs several instances of units (cf.lastwill) but the instance containing the handler. </td>\r
262 </tr>\r
263 \r
264 <tr>\r
265 <td><strong>terminate</strong> </td>\r
266 <td>destructs several instances of units (cf.lastwill) and the instance containing the handler. </td>\r
267 </tr>\r
268 \r
269 <tr>\r
270 <th colspan=2>Composed Instructions </th>\r
271 </tr>\r
272 \r
273 <tr>\r
274 <td><strong>if </strong> <em>Cond </em> <strong>then </strong> I <strong>else </strong> J <strong>fi</strong> </td>\r
275 <td><em>Cond </em> is a Boolean expression, I,J are sequences of instructions,<br>\r
276 (<em>else J is optional</em> ) </td>\r
277 </tr>\r
278 \r
279 <tr>\r
280 <td><strong>do </strong> I <strong>od </strong> </td>\r
281 <td>looping instruction, it is suggested to put an <strong>exit </strong> instruction among the instructions I. </td>\r
282 </tr>\r
283 \r
284 <tr>\r
285 <td><strong>while </strong> <em>Cond </em> <strong>do </strong> I <strong>od</strong></td>\r
286 <td>is equivalent to<br>\r
287 <strong>do </strong><br> <strong>if </strong> <em>Cond </em> <strong>then </strong> I <strong>else exit fi<br> od</strong>  </td>\r
288 </tr>\r
289 \r
290 <tr>\r
291 <td><strong>for </strong> i := A <strong>to </strong> B <strong>do </strong> I <strong>od </strong> </td>\r
292 <td>i - an integer variable, A, B integer expressions, I a sequence of instructions </td>\r
293 </tr>\r
294 \r
295 <tr>\r
296 <td><strong>case </strong> c<br>\r
297  <strong>when </strong> c1: I1;<br>\r
298  <strong>when </strong> c2: I2;<br>\r
299  <strong>otherwise </strong> J <br>\r
300 <strong>esac</strong> </td>\r
301 <td> case instruction,<br>\r
302 I, J are sequences of instructions,<br>\r
303 c an integer expression, c1, c2 integer constants </td>\r
304 </tr>\r
305 \r
306 <tr>\r
307 <th colspan=2>EXPRESSIONS </th>\r
308 </tr>\r
309 \r
310 <tr>\r
311 <td> Arithmetic expressions </td>\r
312 <td> they are as you believe they should be </td>\r
313 </tr>\r
314 \r
315 <tr>\r
316 <td>Boolean expressions </td>\r
317 <td>NOTE object relations <strong>in </strong> and <strong>is </strong>, e.g. <strong>if </strong> x <strong>in </strong> Class2 </td>\r
318 </tr>\r
319 \r
320 <tr>\r
321 <td colspan=2>Object expressions </td>\r
322 </tr>\r
323 \r
324 <tr>\r
325 <td><strong>new </strong> T(actual_params)</td>\r
326 <td>returns a new object of class (coroutine, process) T </td>\r
327 </tr>\r
328 \r
329 <tr>\r
330 <td><strong>this </strong> T </td>\r
331 <td>returns as a value the object of type T containing this expression  </td>\r
332 </tr>\r
333 \r
334 <tr>\r
335 <td>E <strong>qua </strong> A </td>\r
336 <td>qualifies the value of object expression E as of type A<br>\r
337 <em>Raises error </em> if not E <strong>in </strong> A </td>\r
338 </tr>\r
339 \r
340 <tr>\r
341 <td><strong>copy</strong>(E) </td>\r
342 <td>returns a copy of the value of the object expression E </td>\r
343 </tr>\r
344 \r
345 <tr>\r
346 <td>Character expressions </td>\r
347 <td>as usual </td>\r
348 </tr>\r
349 \r
350 <tr>\r
351 <td>String expressions </td>\r
352 <td>no operations on strings </td>\r
353 </tr>\r
354 \r
355 <tr>\r
356 <td> </td>\r
357 <td> </td>\r
358 </tr>\r
359 \r
360 <tr>\r
361 <td><H1>INHERITANCE & NESTING</H1> </td>\r
362 <td>2 fundamental methods of unit's composition </td>\r
363 </tr>\r
364 \r
365 <tr>\r
366 <td><em>Multi-level inheritance </em> permits to make extensions of classes, coroutines, processes defined on different levels of the nesting structure of units. </td>\r
367 <td><em>Multi-kind inheritance </em> permits to inherit in a block, procedure, function, class, coroutine or process. </td>\r
368 </tr>\r
369 \r
370 <tr>\r
371 <td><em>Multiple inheritance </em> is emulated by means of multi-level inheritance and other ingredients of Loglan'82 </td>\r
372 <td><em>Generic modules </em> are doable in various ways: by formal types, by multi-level inheritance combined with nesting, to say nothing about <em>virtuals</em>. </td>\r
373 </tr>\r
374 \r
375 <tr>\r
376 <td> </td>\r
377 <td> </td>\r
378 </tr>\r
379 \r
380 </table>\r
381 <hr>\r
382 <a href="whylog.htm"><img src="prevpage.gif"></a>\r
383 <a href="loghome.htm"><img src="homepage.gif"></a>\r
384 <a href="tablica3.htm"><img src="nextpage.gif"></a> \r
385 <hr>\r
386 <address>\r
387 <a href="GMyAS.html">AS </a> Last update Sat 4 Feb 1995\r
388 </address>\r
389 \r
390 </body>\r
391 </html>pp