Added upstream from http://ftp.icm.edu.pl/pub/loglan/
[loglan.git] / HTML / MicroMan / modulari.htm
1 <!doctype html public "-//IETF//DTD HTML//EN">\r
2 <HTML>\r
3 \r
4 <HEAD>\r
5 \r
6 <TITLE>Modularity</TITLE>\r
7 \r
8 <META NAME="GENERATOR" CONTENT="Internet Assistant for Word 1.0Z">\r
9 <META NAME="AUTHOR" CONTENT="NOM">\r
10 </HEAD>\r
11 \r
12 <BODY>\r
13 \r
14 <P>\r
15 <U><I>Loglan 82, A micro-manual of the programming language -\r
16 Basic constructs and facilities</I></U>\r
17 <H1><IMG ALIGN=MIDDLE SRC="gifs/logo2.gif"> 3) Modularity</H1>\r
18 <HR>\r
19 \r
20 <P>\r
21 Modular structure of the language is gained due to the large set\r
22 of means for module nesting and extending. Program modules (<B>unit</B>s)\r
23 are <B>blocks</B>, <A HREF="procedur.htm">procedures</A>, <A HREF="procedur.htm">functions</A>,\r
24 <A HREF="classes.htm">classes</A>, <A HREF="coroutin.htm">coroutines</A>\r
25 and <A HREF="concurre.htm">processes</A>. <B>Block</B> is the\r
26 simplest kind of <B>unit</B>. Its syntax is the following:\r
27 <P>\r
28 <IMG SRC="gifs/mo01.gif"> \r
29 <P>\r
30 The sequence of statements commences with the keyword <B>begin</B>\r
31 (it may be omitted when this sequence is empty). The lists of\r
32 declarations define the syntactic entities (variables, constants,\r
33 other <B>unit</B>s), whose scope is that block. The syntactic\r
34 entities are identified in the sequence of statements by means\r
35 of names (identifiers).\r
36 <P>\r
37 Example:\r
38 <P>\r
39 <IMG SRC="gifs/mo02.gif"> \r
40 <P>\r
41 In the lists of declarations semicolons terminate the whole lists,\r
42 not the lists elements. Any declaration list must begin with the\r
43 pertinent keyword (<B>var</B> for variables, <B>const</B> for\r
44 constants etc.). The value of an expression defining a constant\r
45 must be determinable statically (at compilation time).\r
46 <P>\r
47 Program in LOGLAN-82 may be a block or alternatively may be of\r
48 the following form:\r
49 <P>\r
50 <IMG SRC="gifs/mo03.gif"> \r
51 <P>\r
52 Then the whole program can be identified by that name (the source\r
53 as well as the object code).\r
54 <P>\r
55 A block can appear in the sequence of statements (of any <B>unit</B>),\r
56 thus it is a statement. (Main block is assumed to appear as a\r
57 statement of the given job control language.)\r
58 <P>\r
59 For the execution of a block statement the object of block is\r
60 created in a computer memory, and then, the sequence of statements\r
61 is performed. The syntactic entities declared in the block are\r
62 allocated in its object. After a block's termination its object\r
63 is automatically deallocated (and the corresponding space may\r
64 be immediately reused).\r
65 <P>\r
66 The modular structure of the language works &quot;in full steam&quot;\r
67 when not only blocks, but the other kinds of <B>unit</B>s are\r
68 also used. They will be described closer in the following points.\r
69 <P>\r
70 <B>Unit</B> nesting allows to build up hierarchies of units and\r
71 supports security of programming. It follows from the general\r
72 visibility rules; namely, a syntactic entity declared in an outer\r
73 unit is visible in an <B>inner</B> one (unless hidden by an <B>inner</B>\r
74 declaration). On the other hand, a syntactic entity declared in\r
75 an <B>inner</B> <B>unit</B> is not visible from an outer one.\r
76 <P>\r
77 Example:\r
78 <P>\r
79 <IMG SRC="gifs/mo04.gif"> \r
80 <P>\r
81 In this program, first the main block statement is executed (with\r
82 variables a,b,c,i,j,k). Next, after the read statement, the inner\r
83 block statement is executed (with variables j,k). In the inner\r
84 block the global variables j,k are hidden by the local ones. \r
85 <HR>\r
86 \r
87 <hr><P>\r
88 <A HREF="Compound.htm"><IMG SRC="gifs/PrevPage.gif"></A>\r
89 <A HREF="HomePage.htm"><IMG SRC="gifs/HomePage.gif"></A> \r
90 <A HREF="Procedur.htm"><IMG SRC="gifs/NextPage.gif"></A> <HR>\r
91 \r
92 <ADDRESS>\r
93 Last update 02/07/95 \r
94 </ADDRESS>\r
95 \r
96 <ADDRESS>\r
97 Comments, suggestions and critiques are welcome to : <A HREF="mailto:linfo062@crisv2.univ-pau.fr">linfo062@crisv2.univ-pau.fr</A>\r
98 \r
99 </ADDRESS>\r
100 \r
101 </BODY>\r
102 \r
103 </HTML>\r