Pascal operation of notes. History of the development of language programming Pascal. Zminni. Standard types

Buv of disintegration in 1970. Niklaus Werth yak mov, which will ensure strict typing and intuitively sensible syntax. They are named after the French mathematician, physicist and philosopher Blaise Pascal.

One of the purposes of the creation of the language by Pascal Niklaus Wert is to emphasize the students' knowledge of structured programming. Dosi Pascal is deservedly considered one of the best tools for basic programming. These modern modifications, such as Object Pascal, are widely used in industrial software (Delphi core).


Blaise Pascal
Launched in 1995 As a continuation of the Turbo Pascal middleware, the Delphi programming system has become one of the best middleware for the rapid creation of add-ons. Delphi has introduced low object-oriented extensions into Pascal language; The language was updated and the name was changed to Object Pascal. Starting with version Delphi 7.0, the language Delphi Object Pascal began to be called simply Delphi, the old name is often vikorized. The remaining version of the middleware is Delphi XE.
Delphi 7 environment

I am most pleased with the free implementation of Pascal and Free Pascal. In addition to the openness of the output code, its main advantage is multi-platform, as well as support for various Pascal dialects. Based on FreePascal, a unique multi-platform Lazarus middleware was created, similar to the Delphi middleware. However, the console interface of the integrated Free Pascal middleware, which is poor and has not changed for decades, has little in common with the current desktop interfaces of operating systems, and is more similar to the ones that are incorrectly formed in They reveal that Pascal is an outdated language.

On the other hand, the Delphi environment has become increasingly cumbersome and unsuitable for basic programming throughout the world. In addition, there is a daily free version of Delphi for academic research. These factors have led to Delphi’s almost complete popularity in the sphere of illumination, and for the middle of Lazarus, regardless of its integrity, such episodes are the same.

The advent of the Java and .NET platforms, which include heavy language programming and heavy standard libraries, has weakened the position of Delphi language. For basic programming, languages ​​such as Java, C, C++, C#, Visual Basic, Python, Haskell have become more frequently used.

One of the brightest developments associated with the development of Pascal was the appearance of the Oxygene compiler from RemObjects, which the creators deservedly called the modern Pascal of the 21st century. Oxygene can generate code for a variety of platforms, including the .NET and Java platforms. Its main disadvantage is the lack of a costless compiler and a middle ground for light purposes. In addition, Oxygene can be very different from the canonical language of Pascal (class methods instead of procedures and functions), which reflects its professional directness.

Language and programming system website Click on the button to change the situation that has developed, and turn on Pascal, which is extremely useful both for beginners and for professional programming, multiplying it with the .NET platform.

Alphabet language Pascal consists of several sections:

Latin letters: A a B b…

Digits: 0 1 2..9

Signs of mathematical operations: + - * /

Mathematical symbols:<> =

Division signs: . , : ;

Special characters: ( ) () $ ^

The program, written by my Pascal, can be divided into the following sections.

Heading

Mark division

Section of constants

Types section

Division of the eminent

Section of procedures and functions

Operator section

All programs necessarily work in the header section and operator section. Other warehouses may be open daily. In the absence of certain parts of the program, the original order of its directness is preserved.

They are separated by the sign ";"
The operator section is located in the operator arms. These reserved words begin, end. The operator section ends with a dot. Recording in the middle of operator arms is usually carried out with an entrance of three signs.

1) Sew the operator arms with the same opening on the left edge, and the operators behind the insertion levels

operator1;

operator2;

operator3;

2) Use small letters to record operators, designate changes, procedures, functions and other program components. Although the Pascal translator allows you to use both great and small letters, in practice the stagnation of the remaining ones is wider;

3) Create substitute comments for operators and program fragments. This will simplify the understanding of the principles of work by programs, both by other developers, and by the author himself after a significant period of time.

The "header" section begins with a reserved word, followed by the name of the program. How can I figure out any set of characters in the alphabet with a number of culprits.

§ Reserved words cannot be vikorized.

§ You cannot start a business using numbers.

§ If the name is chosen, the gap is not corrected.



Apply: program one; program to_be_or_not_to_be; program x5;

Forgive the data type.

Whether Pascal's data are characterized by their types. The type means: the format of data supply in the computer's memory, no valid value that is accepted as a changeable or constant value that must be applied to the selected type and no valid operations that will be assigned to that type.

The type of change is indicated in its description. One of Pascal's basic concepts lies in the rigid reversal of types in assignment operations.

Data types in the Pascal language are divided into five main classes.

1. Simply tipi

2. Structured types

3. Possible types

4. Procedural types

5. Object types

Before the simple types there are: integer types, speech types, logical type, character type, over-caution type, interval type.

Among these species there are a subset of types, distinct from the speech type, called the ordinal type.
Order types have many characteristics.

1. All possible values ​​of a given ordinal type are an ordered multiply and every possible value is associated with an ordinal number, which is an integer number.

2. The value of any ordinal type, after all, begins with the ordinal number zero (the next ordinal number is 1, 2, 3...).

3. The ordinal number of the value of an integer type is the value itself.

4. For any ordinal type, the skin value, in addition to the first one, is anterior and the skin value, in addition to the remaining one, is the next one.

Until then, in any order, you can do it in five operations.

Standard operation Ord Turns the serial number of the entered value. The meaning is indicated at the temples.

Standard operation Pred rotates the value that is transferred to the designated one, if this function is set to the first value of this type, then a notification about the reset is displayed.

Standard operation Succ Also rotates the values ​​after the input, if the operation is completed until the remaining element of the type, a notification about the reset is displayed.

The standard Low operation rotates the lowest value of the range of the ordinal type assigned to it.

The standard High operation rotates the highest value in the range of the ordinal type assigned to it.

Our Pascal has five valued, integer types (Table 6). Skin type means a submultiple of whole numbers.

Table 6 - Integer types of the Pascal movie

As a rule, the integer type is chosen for all data.

The upper limit value and lower limit value of all types are specified as constants and have different names. In program text, data of certain types is recorded in tens or hexadecimal format and without any obligation to include tens dots.

Butt:
1 - whole type
1.0 - speech type
100 – tens format (100)
#100 - hexadecimal format (256)

The operations of addition, addition and multiplication, as well as the operation of equalization, are possible over all data. The type of an integer constant is an integer type with the smallest range that includes the values ​​of the given constant. The value of the right hand in the operator assigned is calculated regardless of the size or type of exchangeable material.

The logical type must be of the Boolean type.
Values ​​of the Boolean type can have two values: true(1) that false(0). For a logical type of stagnation, there are only two adjustment operations: and non-adjustment. Serious type boolean occupy one byte.

Character type char- the type of data, the purpose for storing one character (letter, sign or code). You may have any premises with 256 characters of extended ASCII code. Zminna type char takes up one byte of memory. Values ​​for the Char type are specified in apostrophes. In addition, you can specify values ​​and codes from the ASCII table. Equalization operations can be performed on character type data.

The type that is over-insurance is indicated as the ordering of the set of identifiers, tasks in the way of their over-insurance. In this case, the list of identifiers of the divisions of the coma is indicated in the round arms. The type to be reinsured in the type section is specified.

Butt:
type A=(2, 4, 1, 7);
B=("c", "L", "3", "|");

Values ​​of the type that are overreacted cannot be entered from the keyboard or displayed on the screen.

The interval type of data is indicated by additionally specifying a subset of the value of one of the previously defined types. You can vikoristuvat all simple types, behind the blame of speech. For a given range, the smallest and largest values ​​are indicated, separated by two dots. In this case, the offense is of the same type.

The speech type includes a subset of real numbers represented in the format with a floating point and a fixed number of digits.

Pascali has five types of speech types (Table 7).

Table 7 – Pascal speech types

Actions on types with single, double, sliding precision and

The folding type may not be supported by all Pascal implementations. Therefore, it is important that the Real type is accessible.

The Pascal program was created by Niklaus Wirth, and named after the French philosopher and mathematician of the 17th century. Blaise Pascal. At that time, Wert was a professor of computer science at the Federal Technical University in Switzerland and demanded a language that could help students begin programming.

Pascal's concept was expanded upon by N. Wirt around 1970 and Pascal quickly discovered a wide increase in the ease of application, the accuracy of the texts of programs written on new ones. The fragments of Pascal served as the basis for the development of other programming, such as Ada and Modula-2, and the fragments are rich in structures similar to Pascal, knowledge of Pascal is a solid basis for the development of other programming.

In the 1970s, an attempt was made to develop an international standard for Pascal. As a result of 1982, the ISO 7185 standard appeared.

Through the efforts of Anders Hejlsberg, Mova Pascal was transformed into the professional Turbo Rascal programming system. After version 1.0, which had been around for quite some time and had not been widely expanded, version 2.0 appeared in mid-1984. The expansion has proceeded at a rapid pace. Until the fall of 1985, version 3.0 appeared, which was upgraded from version 2.0 with new features: the compiler and editor began to become more efficient, it became possible to transfer parameters to a program using the additional RUN command, We remove the MS-DOS click from programs, it has become manual robot with files. Since 1988, version 4.0 has been expanded.

Here is Turbo Pascal presentation in a new form. Not only is it still an advanced compiler, but it is a completely new software program. It became possible to split programs into parts (modules) that could be compiled together. Until the fall of 1988, version 5.0 appeared with even more advanced software improvements. Here the first person who deserves credit for all the successes is the supervisor. Turbo Pascal can be used on most operating systems for personal computers.

The advent of Borland Pascal with Objects and Delphi tools for developing Windows programs has once again shown the truly incredible capabilities Pascal has. Borland Pascal and vikorist in Delphi language Pascal is based on Turbo Pascal and develops its ideas.

Delphi is a Pascal movie compiler. Delphi 1 was the first Windows extension tool to combine an optimizing compiler, a visual middleware, and advanced database capabilities. Fate later, Delphi 2 established all the same, but on the new level of the current 32-bit operating system Windows 95 and Windows NT. In addition, Delphi 2 provided the program with a 32-bit compiler, which created more efficient and effective programs and stronger object libraries.

The work of the Delphi development team has led to the appearance in the third version of the product of an expanded set of tools for creating programs, the ability to use COM technologies for developing WWW programs and a wealth of other current programming technologies.

Delphi 4 has been a milestone in the evolution of Pascal compilers since Anders Hejlsberg created the first Turbo Pascal compiler 16 years ago.

Pascal) – Vysokorivneva language programming of zagalny significance. One of the most well-known programs is widely found in industrial programming, which began at the school, and is the basis for many other programs. Books of works by Niklaus Wert in 1968-69 (published in 1970) after his participation in the committee for the development of the ALGOL-68 language standard.

Prehistory

Pascal of the creations of Yakmov for learning procedural programming (although, according to Virt, language cannot be considered beyond the initial one, fragments of the language are not suitable for writing real programs, for learning it is not necessary to be vikorist). The name of the movie is given in honor of the prominent French mathematician, physicist, writer and philosopher Blaise Pascal.

Implementations

UCSD Pascal

In 1978, at the University of San Diego (California, USA), the UCSD p-System was developed, which included a compiler for the Pascal language into portable p-code and implemented a number of extensions of the Pascal language, such as modules, symbol rows And in the changeover, directives broadcasts, processing of input-output processing, downloading to files named after each other. Over the years, the main implementations of the Pascal language have been based on this dialect.

Object Pascal from Apple

Turbo Pascal and Object Pascal from Borland, Microsoft Pascal

The most famous implementation of Pascal, which ensured a wide expansion of the language, Turbo Pascal from Borland, which then grew into the Pascal object for DOS (starting with version 5.5) and Windows and then Delphi, in What important expansions of language have been introduced?

Pascal dialects, found in Turbo Pascal for DOS and Delphi for Windows, have become popular through the presence of other successful commercial implementations.

Standard

After the beginning of Pascal's work in 1970, implementations appeared that diverged not only in additions, but also in syntax, and the need for language standardization was destroyed. The standard of the movie was developed by Niklaus Wert in 1974 together with Kathleen Jensen. Later, the international standard ISO and the American standard ANSI were adopted. At the moment, there are three fundamentally different standards: Unextended Pascal, Extended Pascal, Object-Oriented Extensions to Pascal.

Pascal language standards: weekend, international ISO and American ANSI
NameoptionKim/de rozroblenoRiver of creation
Pascal StandardcobN. Virt, Ketlin Jensen
Pascal StandardcobISO 7185:1983
ANSI/IEEE 770X3.97:1983
Unextended PascalcobISO 7185:1990
Extended PascalextensionsANSI/IEEE 770X3.160:19891989
ISO/IEC 10206
Object-Oriented
Extensions to Pascal
object-oriented extensionsANSI/X3-TR-13:1994

One of the main additional features of the object-oriented extension of Extended Pascal is its modularity and features that facilitate separate compilation.

The standardization of language was late in relation to the actual appearance of such and other possibilities in language. Commercial sales expanded standard Pascal; This is how it was compiled in UCSD Pascal, a modification of Object Pascal by Apple, Turbo Pascal by Borland (a slightly modified version of Apple) and in the same way. The most widespread commercial implementations of Pascal do not meet the accuracy of official language standards.

Syntax of this construction

Pascal, in its primary view, is purely procedural and includes a number of algorithm-like structures and constructions with reserved words for the command if, then, else, while, for, etc. Tim no less, Pascal is also great There are possibilities for structure Information and abstraction that are present in the first Algol-60, such as the designated types, records, indicators, over-interpretation, and impersonality. These structures were often collapsed or reinvented from Simula-67, Algol-68, created by Niklaus Wert AlgolW and reponized by Hoare.

In current dialects (Free Pascal), operations such as reversing operators and functions are available.

Hello world

Programs in Pascal begin with the keyword program followed by the name of the program with a dot (in most dialects this is not required), followed by a list of external file descriptors as parameters; it is followed by the body of the program, which consists of a section describing variables, types and constants, procedures and functions, and the block of statements that follows them, which is the entry point into the program. In movie Pascal, the block is separated by the keywords begin and end. Operators share points with a dot, after the body there is a dot, which marks the end of the program. The register of symbols in Pascal has no meaning.

So, the simplest program in Pascal would look like this: beginend. The program does not cancel daily operations and place an empty block of operators.

Butt program to display the row Hello, World! Program HelloWorld(output);begin

WriteLn("Hello, World!"); (row operator)

end.

Tipi tributes

Primitive Pascal's data types: numbers with a floating coma (real), integers (integer), symbolic (char), logical (boolean) and re-interpretation (constructor of a new type, introductions from Pascal):

R: Real; (Zminna speech type) i: Integer; (Zmіnna whole type) c: Char; (Zminna-character) b: Boolean; (logical change) e: (apple, pear, banana, orange, lemon); (Zminna tipu-perehrahuvannya)

It seems clear ordinal data types (ordinal), before them the purpose of types (signed and unsigned), logical (boolean), character (char), overflow types and range types.

Ordinal types are specified by an integer number (code), which can be removed using the additional function ord. All operations that are associated with ordinal types are associated with their codes.

X: 1..10; y: "a".."z"; z:pear..orange;

For ordinal types, the operations inc, dec, succ, pred, ord, equalization operations (=>< => <= <>), they can be used in operators case , for (as a loop operator), as between arrays, for specifying elements of a multiplicity and range types.

In Pascal, in addition to C-like languages, with types boolean and char, arithmetic integer operations are not defined.

In addition to its rich extensions, Pascal supports a special data type impersonal:var

Set1: set of 1..10; set2: set of "a".."z"; set3: set of pearl..orange;

Rich is a fundamental concept in modern mathematics, which can be used in rich algorithms.

In Pascal, the type of multiplicity can be compared to elements of the same type of the ordinal type. This feature is widely admired and called for the equivalent construction in the language, which does not support impersonality. For example, most Pascal compilers: if i in then (checking for the identity of the impersonal element). obrobatsya shvidshe, nіzh if (i>4) and (i<11) then { проверка логическими условиями }... To set the value of the multiplicity, a list of elements of the multiplicity, reinforced with comas and placements at the square arch is displayed (as has already been shown above): var (section of stunning changes)

D:set of char;

begin (cob to block)

D:=["a","b"];

... In Pascal Jensen and Virt, rows were represented as a packed array of symbols; From now on, the stench of the fixed dowzhin was canceled and was supplemented until this day with gaps.

In modern Pascal, for working with rows, the type string is used, which supports the operations of concatenation (+) and alignment (>< = <> >= <=). Строки сравниваются в лексикографическом порядке . Например, строки считаются равными если они имеют одинаковую длину и коды всех символов с одинаковыми индексами совпадают.

Type string [n] or simply string in language dialects of the 1970s-1990s, appearing as an array of characters in an array of char (n took the value 80 in UCSD Pascal and 255 in Turbo/Borland Pascal), the code for a null character with this input Serve as a prerequisite for the last row, especially the row immediately, with a maximum size of 255 characters. In Delphi and FreePascal, the AnsiString type is used as String, the memory for which is seen and allocated dynamically by the compiler, and the maximum row size in current implementations is set to 2 gigabytes. In addition, in Delphi and Free Pascal, the WideString type can be used as a string, but the 16-bit character expressions in the UCS-2 encoding are blocked, which allows conversion from single-byte rows in large-byte ones and back in the standard library and your daily language.

New types may be identified due to:

X = Integer; y = x;

... Moreover, warehouses can be constructed from the following types: type (type decoupling section)

A = Array of Integer; (Designated array) b = record (Designated record) x: Integer; y:Char; end; c = File of a; (Assignment to the file)

File types in Pascal are divided into typed, text and files without types.

As shown in the above example, typed files in Pascal are a sequence of similar elements. For the skin file there is a change-indicator to the buffer, which is indicated by f ^. Procedures get (for reading) and put (for writing) move the indicator to the next element. Reading is implemented in the same way as read(f, x) is the same as get(f); x:=f^. Apparently, the recording is implemented in such a way that write(f, x) is the same as f^: = x; put(f). Text files are designated as an extension of the file of char type and, in addition to standard operations on typed files (reading, writing to a character), allow symbolic input-output in files of all data types, similar to console input-output.

Files without types are voted as being of the file type. With them, you can perform byte-by-byte untyped I/O operations on a number of block bytes of a designated period through a buffer, for which special procedures blockread and blockwrite (UCSD extension) are used.

Vkazivniki

Pascal supports a variety of indicators (typed and untyped pointer): type

A = ^b; b = record x: Integer; y:Char; z: a; end;

Pointer_to_b:a;

Here the change is pointer_to_b - an indicator of the data type b, and the record. The type of a typical indicator can be assigned to the type that is being asked. This is not a rule, but it is clear that no matter what the speech may be, she is stunned before the fact that she is being victorious. The introduction of this exclusion made it possible to organize recurrent values ​​of data structures, including linear lists, stacks and drawers, including an indicator for a record in the inventory of a record (also: null indicator - nil).

For a typed indicator, the operation "rosiname" is assigned (syntax: indicator^).

To create a new record and assign the value 10 and character A to fields a and b, the following operators are required: new(pointer_to_b); (Vision in memory of the showman)

pointer_to_b^.x:= 10; (pointer_to_b^.y:= "A";pointer_to_b^.z:= nil;...dispose(pointer_to_b); (memory from the indicator) For the purpose of scaling up to fields of records and objects, you can also use the with operator, as shown in the application: new(pointer_to_b);

with pointer_to_b^ dobegin

X: = 10; y:= "A"; z:= nil

end;...dispose(pointer_to_b);

Procedural type

In the original film by Pascal Jensen and Virta, the procedural type was used only when describing a formal parameter. Already TP has become a full-fledged procedural type. The specified type contains the title of the procedure and function (without a name), which clearly describes the interface of the subprograms. For the relevant type, place an indicator on the subprogram with a title that corresponds to the type described above. You can click on a specific procedure or function for the additional change ID. type myfunc=function:string;

function func1:string;begin

Func1:="func N 1"

function func2:string;begin

Func2:="func N 2"

var fun:myfunc;begin

Fun:=@func1;writeln(fun) (the function func1 is clicked)

end.

Operators keruvannya vikonannyam programs

Pascal is a structured programming language, which means that the program consists of a number of standard statements that are added sequentially, ideally without the need for a GOTO command. while a<>b do (cycle iz change of mind)

Writeln("Coining");

if a > b then (mental operator)

Writeln("Umova vikonala")

else (else-section - may be different)

Writeln("Umova did not vikonal");

for i:= 1 to 10 do ( iteration loop )

Writeln("Iteration No", i:1);

repeat (cycle from post-thumb)

A:=a+1

case i of (mental multiplicity operator)

0: write("null"); 1: write("one"); 2: write("two") else write("unknown number") (else section - may be daily)

end; In the operators while , for , if , case in the scope of the operator you can use block. Such a construction, which is the primary operator or block, is called folding operator.

To handle the compilation process, Pascal requires compiler directives. They are located in the comments and allow you to switch the compiler’s operating modes, for example, enable and disable the verification of input-output operations, verification of re-exchange:

Assign(inp, "text.txt"); ($I-) (enabling the IO checking mode - generating program completion code at the time of input-output execution) ( (for cases where the file is not found)) reset (inp); ($I+) (enabled IO checking mode) if IOresult=0 then begin (values ​​are verified by changing ioresult(<>0 at the time of introduction-viewing) ... close (inp); end else writeln("file not found")

There are directives similar to the C/C++ preprocessor directives ($ifdef , $define , $include ) that are compiled by the compiler during the compilation process.

Procedures and functions

In Pascal, subprograms are divided into procedures and functions:

Syntactically, procedures and functions are composed of header(which includes the keyword procedure or function , names that can be followed by a description of passing parameters in the arms, the type of value that is rotated through the double symbol for the function and the dot with it), after the title there is a trace body after which a symbol is placed; . program mine(output);

procedure print(var j: integer);

Function next(k: integer): integer; begin next: = k + 1 end;

Writeln("Usyogo: ", j); j:= next(j)

I:= 1; while i<= 10 do print(i)

end. The body of a procedure, as well as a program, can contain a description of procedures and functions. In this way, procedures and functions can be nested one into the other as always in depth, in which case the body of the program is most tightly integrated.

Moreover, instead of sections, there is a description of variables, types, constants, external bodies (procedures, functions, programs), which are expanded before the description of the procedure/function available in the middle of it. Also, in most dialects from a procedure, you can change to the parameters of an external procedure.

The keyword forward can be placed after the title of the procedure/function instead of the body, so that the description of the procedure/function is in the program after the call, and due to the possibility of compilation grams in one pass, which is supported in Pascal.

Procedures as functions mean that functions rotate values, but procedures do not.

Modules

Before the advent of modules, Pascal's implementations emphasized modularity through the mechanism for including header files, similar to the #include mechanism in C: with the help of a special directive, which is issued in Look at the pseudo-comment, for example, ($INCLUDE "file") , instead the designated file was directly included in the text of the program in the output, text view. In this way, it was possible to divide the program code into separate fragments for ease of editing, and before compilation, they were automatically combined into one program file, which, as a result, was compiled by the compiler. This implementation of modularity is primitive and has no obvious shortcomings, so it was quickly replaced.

Current implementations of Pascal (starting with UCSD Pascal) support modules. Program modules can be of two types: the main program module, which starts with the keyword program and the body of which contains code, which is launched after the program is loaded into memory, and additional modules, which are of the type constant these, changeable, procedures These functions are intended for use in other modules, including the head module.

Structure

The basic structure of the module that connects to Pascal looks like this: unit UnitName1;interface

... ...

begin (can be used as a wiki if it is necessary to place initialization statements)

...

end. Another possible option: unit UnitName2;interface

... ... ... ...

end. When subordinated to the main program, the module file begins with the keyword UNIT, followed by the name of the module at that point. Current implementations typically require that the name of the module match the name of the output code in which the module fits. The module consists of three sections: the interface section, the implementation section and the body of the module.

The interface section comes first, starting with the INTERFACE keyword and ending there in the module, where the implementation section and body begin. In the interface section, those objects are announced (types, constants, variables, procedures and functions - headers are placed for them) that are available to the module calls. In this case, a frequent confusion of types is allowed: stinks can be voiced without a designated structure, without meaning. When choosing this type of control, the external program is allowed to disclose the changes to the parameters of the type assigned to the value, rather than being able to deny access to the details of its implementation. Procedures and functions in the interface section are presented in the form of forwards - headers with parameters, or without a body. The storage of the interface section of the module is such that it is sufficient to generate the code of the vicorist module. Changes are made in the interface section, and are global, so that they appear in a single copy and are available in all parts of the program, which is part of this module.

The implementation section follows the interface section and begins with the IMPLEMENTATION keyword. In the Nomom, the inventory of the procedures is that functions, the head in the ilnerefic security, and such a description of the type, constant, snakes, the procedures of that functions, yakі non -ііdnі for realist procedures that functions. The description of the procedure or function announced in the interface section is due to the title itself, which is responsible for the confusion. The body may be affected by other procedures and functions of this module, both in the interface part and in the implementation section. The changes mentioned in the implementation section are, in fact, global (that is, there is only one copy of such a change for the entire program), and are not available without the procedures and functions described in the section alization of this module, as well as its body. However, in the interface section there is a short description of the types, these types will be described in the implementation section.

The body of the module begins with the keyword BEGIN, which is at the top level of the content. You must place a program code that is compiled once when the module is installed. The body can be frozen for initialization, appropriation of cob values ​​by a changeable module, allocation of resources for its work, and so on. The body of the module can be different. In a number of Pascal implementations, for example, Delphi, instead of the body of the module, there can be two sections (also required) - INITIALIZATION and FINALIZATION. The stink appears at the end of the module after the specified keyword. The first is the initialization section, - the code that will be displayed when the module is installed, the other - the finalization section, - the code that will be displayed when the module is uninstalled. The finalization section can exit actions, exit and initialize – delete objects from memory, close files, delete resources.

The module ends with the keyword END followed by a period.

Vikoristannya

To vikorize a module, the main program or another module at fault, import the module to avoid confusion about your vikorist. It is important to look for additional instructions for connecting modules, which is the USES keyword, followed by the names of the modules that need to be connected. The connection instruction must go directly after the program header, or after the INTERFACE keyword, as the connection is active in the module.

Modules connected to the interface section can be selected from each module - both the implementation section and the body. Alternatively, the implementation section can use the connection instruction (the one that follows the IMPLEMENTATION keyword) to enter the names of the modules that are connected in the interface section , whatever is needed for the implementation section. One of the reasons for selecting a separate connection list for the implementation section is a situation where two or more modules are connected to each other. So that cyclical messages do not blame the confusion of such modules, one of them is responsible for connecting the other to the implementation section.

Any noise in the interface sections of the object modules can be checked in the program where the module is connected. The names of objects imported from connected modules are stripped of their own names, and they can be modified at any time. If two or more connected modules contain new objects, and the compiler cannot separate them, then when you try the vicor of such an object, you will see a compilation error - an ambiguous name. In this case, the programmer must set the qualification of the name - specify the name in the format "<имя_модуля>.<имя_объекта>».

Problems may arise when it becomes necessary to replace two different modules of the same name. Since the modules are only available in the compiled view (it is impossible to change their names), they cannot be imported instantly. There is no standard solution to such a problem locally, but specific compilers may come up with other ways to bypass it, except for the way of assigning aliases to imported modules and direct insertion, such as module for any file.

Compilation and arrangement

The modules are designed to ensure separate compilation - the compiler does not compile imported modules in order to compile the module that is their vikoryst. However, in order to correctly compile a module, the compiler must have access to the interface section of all modules that are being compiled. There are two differences, including complex approaches to organizing such access.

  • Modulі is composed in the Binarni files of a special format (at the skin compound), in the Yaki zberezen, a report on the OB'kti, checked in the ilinterfate security, and the tacot is more than the bouty of the compiles of the module of the oxide code. When compiling a module, the compiler will ensure that all modules that are imported are already compiled and available. In this case, since the modules are correctly compiled, their output texts are not required at the compilation stage.
  • Modules are compiled into initial binary files and are included by the linker only at the stage of composing the end file of the program that is being compiled. To process the development of modules, the compiler processes the text of these modules directly into the output language, and then converts only the interface section of the module. Since the library module is supplied in a compiled form (without new output texts), then the output code file of the module is included with the binary file, which places the interface section. This is enough for the compiler to correctly parse the output of modules, and at the stage of compiling the program, the linker simply includes the binary file in the program.

For normal operation of the module, you may need to complete the following steps: initialize changes, open required files, see memory and other resources. Everything can be organized in the body of the module or in the initialization section. Actions that have ended in initialization must be collected from the finalization section.

The Pascal language program was dismantled in 1968-1971. Niklaus Wirth at the Zurich Institute of Informatics (Switzerland). Pochatkova meta developments of the PASCAL language – the need for a tool “for the beginning of programming as a systematic discipline.” However, the extreme effectiveness of the PASCAL language was quickly revealed in a wide variety of applications, from small tasks of a computational nature to the development of complex software systems - compilers, databases, operating systems, etc. Today Pascal belongs to the group of the most widespread and most popular programs in the world. The numerical implementation of the language is practical for all machine architectures; dozens of dialects and problem-oriented extensions of the Pascal language have been developed.

The peculiarities of the language are its typification and the obviousness of the features of structural (procedural) programming. Pascal was one of the first such languages. In the opinion of M. Wirth, she may adopt a disciplined program, therefore, due to strict typification, Pascal has reduced possible syntactic ambiguities to a minimum, and the syntax itself is intuitively understandable Here's to the first time I met you.

Tim is not less, initially there are a few shortcomings: the impossibility of transferring the functions of arrays of changeable life, the absence of normal functions of work with dynamic memory, the limited input-output library, features for connecting functions written by other languages, the presence of separate compilation features, etc. . It is necessary to note that many over-insurance shortfalls do not appear, but may become advantages with the beginning of the program. In addition, my main program in the academic mid-70s was Fortran, What Volodyov is rich in sumptuous shortcomings, and Pascal is a significant croque ahead.

Tim no less, the progress of the language was stirred by a lot of commercial and non-profit organizations developing programming systems based on the language Pascal.

A company can be seen between the others Borland, Turbo Pascal(later Borland Pascal) which was significantly expanded, a lot of short language was added, and new possibilities were added. Mova became rich, but suddenly lost her tolerance and strength.

An important croque at the development of the language and the appearance of a free language Pascal GNU Pascal, which, having removed from itself the rices of other Pascals, which allowed people to be completely motivated by the “brutal” methods of programming, especially the powerful ones, let’s say, Turbo Pascal, And ensuring extremely wide portability of programs written in a new program (over 20 different platforms, under more than 10 different operating systems).

At the moment, the popularity of such versions of the movie is being explored. TMT Pascal, Free Pascalі GNU Pascal. Continues to vikorist and Borland Pascal. Rozvitkom movie Borland Pascalє Object Pascal- the Pascal version of the movie has been extended with object-oriented programming features. Remaining versions Borland Pascal form the basis of the core programming Delphi.