Pascal (programming language)

From Wikipedia for FEVERv2
Jump to navigation Jump to search

Pascal (programming language)_table_infobox_0

PascalPascal (programming language)_table_caption_0
ParadigmPascal (programming language)_header_cell_0_0_0 Pascal (programming language)_cell_0_0_1
FamilyPascal (programming language)_header_cell_0_1_0 Wirth PascalPascal (programming language)_cell_0_1_1
Designed byPascal (programming language)_header_cell_0_2_0 Niklaus WirthPascal (programming language)_cell_0_2_1
First appearedPascal (programming language)_header_cell_0_3_0 1970; 50 years ago (1970)Pascal (programming language)_cell_0_3_1
Typing disciplinePascal (programming language)_header_cell_0_4_0 Pascal (programming language)_cell_0_4_1
Pascal (programming language)_header_cell_0_5_0 .pp, .pas, .inc,Pascal (programming language)_cell_0_5_1
Major implementationsPascal (programming language)_header_cell_0_6_0
DialectsPascal (programming language)_header_cell_0_7_0
Influenced byPascal (programming language)_header_cell_0_8_0
InfluencedPascal (programming language)_header_cell_0_9_0

Pascal is an imperative and procedural programming language, designed by Niklaus Wirth as a small, efficient language intended to encourage good programming practices using structured programming and data structuring. Pascal (programming language)_sentence_0

It is named in honour of the French mathematician, philosopher and physicist Blaise Pascal. Pascal (programming language)_sentence_1

Based on Wirth's book, Algorithms + Data Structures = Programs, Pascal was developed on the pattern of the ALGOL 60 language. Pascal (programming language)_sentence_2

Wirth was involved in the process to improve the language as part of the ALGOL X efforts and proposed a version known as ALGOL W. Pascal (programming language)_sentence_3

This was not accepted, and the ALGOL X process bogged down. Pascal (programming language)_sentence_4

In 1968, Wirth decided to abandon the ALGOL X process and further improve ALGOL W, releasing this as Pascal in 1970. Pascal (programming language)_sentence_5

On top of ALGOL's scalars and arrays, Pascal enabled defining complex datatypes and building dynamic and recursive data structures such as lists, trees and graphs. Pascal (programming language)_sentence_6

Pascal has strong typing on all objects, which means that one type of data cannot be converted or interpreted as another without explicit conversions. Pascal (programming language)_sentence_7

Unlike C (and most languages in the C-family), Pascal allows nested procedure definitions to any level of depth, and also allows most kinds of definitions and declarations inside subroutines (procedures and functions). Pascal (programming language)_sentence_8

A program is thus syntactically similar to a single procedure or function. Pascal (programming language)_sentence_9

This is similar to the block structure of ALGOL 60, but restricted from arbitrary block statements to just procedures and functions. Pascal (programming language)_sentence_10

Pascal became very successful in the 1970s, notably on the burgeoning minicomputer market. Pascal (programming language)_sentence_11

Compilers were also available for many microcomputers as the field emerged in the late 1970s. Pascal (programming language)_sentence_12

It was widely used as a teaching language in university-level programming courses in the 1980s, and also used in production settings for writing commercial software during the same period. Pascal (programming language)_sentence_13

It was displaced by the C programming language during the late 1980s and early 1990s as UNIX-based systems became popular, and especially with the release of C++. Pascal (programming language)_sentence_14

A derivative known as Object Pascal designed for object-oriented programming was developed in 1985; this was used by Apple Computer and Borland in the late 1980s and later developed into Delphi on the Microsoft Windows platform. Pascal (programming language)_sentence_15

Extensions to the Pascal concepts led to the languages Modula-2 and Oberon. Pascal (programming language)_sentence_16

History Pascal (programming language)_section_0

Earlier efforts Pascal (programming language)_section_1

Much of the history of computer language design during the 1960s can be traced to the ALGOL 60 language. Pascal (programming language)_sentence_17

ALGOL was developed during the 1950s with the explicit goal to be able to clearly describe algorithms. Pascal (programming language)_sentence_18

It included a number of features for structured programming that remain common in languages to this day. Pascal (programming language)_sentence_19

Shortly after its introduction, in 1962 Wirth began working on his dissertation with Helmut Weber on the Euler programming language. Pascal (programming language)_sentence_20

Euler was based on ALGOL's syntax and many concepts but was not a derivative. Pascal (programming language)_sentence_21

Its primary goal was to add dynamic lists and types, allowing it to be used in roles similar to Lisp. Pascal (programming language)_sentence_22

The language was published in 1965. Pascal (programming language)_sentence_23

By this time, a number of problems in ALGOL had been identified, notably the lack of a standardized string system. Pascal (programming language)_sentence_24

The group tasked with maintaining the language had begun the ALGOL X process to identify improvements, calling for submissions. Pascal (programming language)_sentence_25

Wirth and Tony Hoare submitted a conservative set of modifications to add strings and clean up some of the syntax. Pascal (programming language)_sentence_26

These were considered too minor to be worth using as the new standard ALGOL, so Wirth wrote a compiler for the language, which became known as ALGOL W. Pascal (programming language)_sentence_27

The ALGOL X efforts would go on to choose a much more complex language, ALGOL 68. Pascal (programming language)_sentence_28

The complexity of this language led to considerable difficulty producing high-performance compilers, and it was not widely used in the industry. Pascal (programming language)_sentence_29

This left an opening for newer languages. Pascal (programming language)_sentence_30

Pascal Pascal (programming language)_section_2

Pascal was influenced by the ALGOL W efforts, with the explicit goals of producing a language that would be efficient both in the compiler and at run-time, allow for the development of well-structured programs, and to be useful for teaching students structured programming. Pascal (programming language)_sentence_31

A generation of students used Pascal as an introductory language in undergraduate courses. Pascal (programming language)_sentence_32

One of the early successes for the language was the introduction of UCSD Pascal, a version that ran on a custom operating system that could be ported to different platforms. Pascal (programming language)_sentence_33

A key platform was the Apple II, where it saw widespread use. Pascal (programming language)_sentence_34

This led to the use of Pascal becoming the primary high-level language used for development in the Apple Lisa, and later, the Macintosh. Pascal (programming language)_sentence_35

Parts of the original Macintosh operating system were hand-translated into Motorola 68000 assembly language from the Pascal sources. Pascal (programming language)_sentence_36

The typesetting system TeX by Donald E. Knuth was written in WEB, the original literate programming system, based on DEC PDP-10 Pascal. Pascal (programming language)_sentence_37

Successful commercial applications like Adobe Photoshop were written in Macintosh Programmer's Workshop Pascal, while applications like Total Commander, Skype and Macromedia Captivate were written in Delphi (Object Pascal). Pascal (programming language)_sentence_38

Apollo Computer used Pascal as the systems programming language for its operating systems beginning in 1980. Pascal (programming language)_sentence_39

Variants of Pascal have also been used for everything from research projects to PC games and embedded systems. Pascal (programming language)_sentence_40

Newer Pascal compilers exist which are widely used. Pascal (programming language)_sentence_41

Object Pascal Pascal (programming language)_section_3

During work on the Lisa, Larry Tesler began corresponding with Wirth on the idea of adding object oriented extensions to the language. Pascal (programming language)_sentence_42

This led initially to Clascal, introduced in 1983. Pascal (programming language)_sentence_43

As the Lisa program faded and was replaced by the Mac, a further version known as Object Pascal was created. Pascal (programming language)_sentence_44

This was introduced on the Macintosh in 1985 as part of the MacApp application framework, and became Apple's primary development language into the early 1990s. Pascal (programming language)_sentence_45

The Object Pascal extensions were added to Turbo Pascal with the release of version 5.5 in 1989. Pascal (programming language)_sentence_46

Over the years, Object Pascal became the basis of the Delphi system for Microsoft Windows, which is still used for developing Windows applications, and can cross-compile code to other systems. Pascal (programming language)_sentence_47

Free Pascal is an open source, cross-platform alternative. Pascal (programming language)_sentence_48

Implementations Pascal (programming language)_section_4

Early Pascal compilers Pascal (programming language)_section_5

The first Pascal compiler was designed in Zürich for the CDC 6000 series mainframe computer family. Pascal (programming language)_sentence_49

Niklaus Wirth reports that a first attempt to implement it in FORTRAN 66 in 1969 was unsuccessful due to FORTRAN 66's inadequacy to express complex data structures. Pascal (programming language)_sentence_50

The second attempt was implemented in a C-like language (Scallop by Max Engeli) and then translated by hand (by R. Schild) to Pascal itself for boot-strapping. Pascal (programming language)_sentence_51

It was operational by mid-1970. Pascal (programming language)_sentence_52

Many Pascal compilers since have been similarly self-hosting, that is, the compiler is itself written in Pascal, and the compiler is usually capable of recompiling itself when new features are added to the language, or when the compiler is to be ported to a new environment. Pascal (programming language)_sentence_53

The GNU Pascal compiler is one notable exception, being written in C. Pascal (programming language)_sentence_54

The first successful port of the CDC Pascal compiler to another mainframe was completed by Welsh and Quinn at the Queen's University of Belfast (QUB) in 1972. Pascal (programming language)_sentence_55

The target was the ICL 1900 series. Pascal (programming language)_sentence_56

This compiler, in turn, was the parent of the Pascal compiler for the Information Computer Systems (ICS) Multum minicomputer. Pascal (programming language)_sentence_57

The Multum port was developed – with a view to using Pascal as a systems programming language – by Findlay, Cupples, Cavouras and Davis, working at the Department of Computing Science in Glasgow University. Pascal (programming language)_sentence_58

It is thought that Multum Pascal, which was completed in the summer of 1973, may have been the first 16-bit implementation. Pascal (programming language)_sentence_59

A completely new compiler was completed by Welsh et al. Pascal (programming language)_sentence_60

at QUB in 1977. Pascal (programming language)_sentence_61

It offered a source-language diagnostic feature (incorporating profiling, tracing and type-aware formatted postmortem dumps) that was implemented by Findlay and Watt at Glasgow University. Pascal (programming language)_sentence_62

This implementation was ported in 1980 to the ICL 2900 series by a team based at Southampton University and Glasgow University. Pascal (programming language)_sentence_63

The Standard Pascal Model Implementation was also based on this compiler, having been adapted, by Welsh and Hay at Manchester University in 1984, to check rigorously for conformity to the BSI 6192/ISO 7185 Standard and to generate code for a portable abstract machine. Pascal (programming language)_sentence_64

The first Pascal compiler written in North America was constructed at the University of Illinois under Donald B. Gillies for the PDP-11 and generated native machine code. Pascal (programming language)_sentence_65

The Pascal-P system Pascal (programming language)_section_6

To propagate the language rapidly, a compiler porting kit was created in Zürich that included a compiler that generated so called p-code for a virtual stack machine, i.e., code that lends itself to reasonably efficient interpretation, along with an interpreter for that code – the Pascal-P system. Pascal (programming language)_sentence_66

The P-system compilers were named Pascal-P1, Pascal-P2, Pascal-P3, and Pascal-P4. Pascal (programming language)_sentence_67

Pascal-P1 was the first version, and Pascal-P4 was the last to come from Zürich. Pascal (programming language)_sentence_68

The version termed Pascal-P1 was coined after the fact for the many different sources for Pascal-P that existed. Pascal (programming language)_sentence_69

The compiler was redesigned to enhance portability, and issued as Pascal-P2. Pascal (programming language)_sentence_70

This code was later enhanced to become Pascal-P3, with an intermediate code backward compatible with Pascal-P2, and Pascal-P4, which was not backward compatible. Pascal (programming language)_sentence_71

The Pascal-P4 compiler–interpreter can still be run and compiled on systems compatible with original Pascal. Pascal (programming language)_sentence_72

However, it only accepts a subset of the Pascal language. Pascal (programming language)_sentence_73

Pascal-P5, created outside the Zürich group, accepts the full Pascal language and includes ISO 7185 compatibility. Pascal (programming language)_sentence_74

UCSD Pascal branched off Pascal-P2, where Kenneth Bowles used it to create the interpretive UCSD p-System. Pascal (programming language)_sentence_75

It was one of three operating systems available at the launch of the original IBM Personal Computer. Pascal (programming language)_sentence_76

UCSD Pascal used an intermediate code based on byte values, and thus was one of the earliest byte code compilers. Pascal (programming language)_sentence_77

Pascal-P1 through Pascal-P4 was not, but rather based on the CDC 6600 60-bit word length. Pascal (programming language)_sentence_78

A compiler based on the Pascal-P4 compiler, which created native binaries, was released for the IBM System/370 mainframe computer by the Australian Atomic Energy Commission; it was named the AAEC Pascal Compiler after the abbreviation of the name of the commission. Pascal (programming language)_sentence_79

Object Pascal and Turbo Pascal Pascal (programming language)_section_7

Apple Computer created its own Lisa Pascal for the Lisa Workshop in 1982, and ported the compiler to the Apple Macintosh and MPW in 1985. Pascal (programming language)_sentence_80

In 1985 Larry Tesler, in consultation with Niklaus Wirth, defined Object Pascal and these extensions were incorporated in both the Lisa Pascal and Mac Pascal compilers. Pascal (programming language)_sentence_81

In the 1980s, Anders Hejlsberg wrote the Blue Label Pascal compiler for the Nascom-2. Pascal (programming language)_sentence_82

A reimplementation of this compiler for the IBM PC was marketed under the names Compas Pascal and PolyPascal before it was acquired by Borland and renamed Turbo Pascal. Pascal (programming language)_sentence_83

Turbo Pascal became hugely popular, thanks to an aggressive pricing strategy, having one of the first full-screen IDEs, and very fast turnaround time (just seconds to compile, link, and run). Pascal (programming language)_sentence_84

It was written and highly optimized entirely in assembly language, making it smaller and faster than much of the competition. Pascal (programming language)_sentence_85

In 1986, Anders ported Turbo Pascal to the Macintosh and incorporated Apple's Object Pascal extensions into Turbo Pascal. Pascal (programming language)_sentence_86

These extensions were then added back into the PC version of Turbo Pascal for version 5.5. Pascal (programming language)_sentence_87

At the same time Microsoft also implemented the Object Pascal compiler. Pascal (programming language)_sentence_88

Turbo Pascal 5.5 had a large influence on the Pascal community, which began concentrating mainly on the IBM PC in the late 1980s. Pascal (programming language)_sentence_89

Many PC hobbyists in search of a structured replacement for BASIC used this product. Pascal (programming language)_sentence_90

It also began to be adopted by professional developers. Pascal (programming language)_sentence_91

Around the same time a number of concepts were imported from C to let Pascal programmers use the C-based API of Microsoft Windows directly. Pascal (programming language)_sentence_92

These extensions included null-terminated strings, pointer arithmetic, function pointers, an address-of operator and unsafe typecasts. Pascal (programming language)_sentence_93

Turbo Pascal, and other derivatives with units or module concepts are modular languages. Pascal (programming language)_sentence_94

However, it does not provide a nested module concept or qualified import and export of specific symbols. Pascal (programming language)_sentence_95

Other variants Pascal (programming language)_section_8

Super Pascal is a variant that added non-numeric labels, a return statement and expressions as names of types. Pascal (programming language)_sentence_96

TMT Pascal was the first Borland-compatible compiler for 32-bit DOS protected mode, OS/2 and Win32 operating systems. Pascal (programming language)_sentence_97

The TMT Pascal language was the first one to allow function and operator overloading. Pascal (programming language)_sentence_98

The universities of Wisconsin-Madison, Zürich, Karlsruhe and Wuppertal developed the Pascal-SC and Pascal-XSC (Extensions for Scientific Computation) compilers, aimed at programming numerical computations. Pascal (programming language)_sentence_99

Development for Pascal-SC started in 1978 supporting ISO 7185 Pascal level 0, but level 2 support was added at a later stage. Pascal (programming language)_sentence_100

Pascal-SC originally targeted the Z80 processor, but was later rewritten for DOS (x86) and 68000. Pascal (programming language)_sentence_101

Pascal-XSC has at various times been ported to Unix (Linux, SunOS, HP-UX, AIX) and Microsoft/IBM (DOS with EMX, OS/2, Windows) operating systems. Pascal (programming language)_sentence_102

It operates by generating intermediate C source code which is then compiled to a native executable. Pascal (programming language)_sentence_103

Some of the Pascal-SC language extensions have been adopted by GNU Pascal. Pascal (programming language)_sentence_104

Pascal Sol was designed around 1983 by a French team to implement a Unix-like system named Sol. Pascal (programming language)_sentence_105

It was standard Pascal level-1 (with parameterized array bounds) but the definition allowed alternative keywords and predefined identifiers in French and the language included a few extensions to ease system programming (e.g. an equivalent to lseek). Pascal (programming language)_sentence_106

The Sol team later on moved to the ChorusOS project to design a distributed operating system. Pascal (programming language)_sentence_107

IP Pascal was an implementation of the Pascal programming language using Micropolis DOS, but was moved rapidly to CP/M-80 running on the Z80. Pascal (programming language)_sentence_108

It was moved to the 80386 machine types in 1994, and exists today as Windows/XP and Linux implementations. Pascal (programming language)_sentence_109

In 2008, the system was brought up to a new level and the resulting language termed "Pascaline" (after Pascal's calculator). Pascal (programming language)_sentence_110

It includes objects, namespace controls, dynamic arrays, along with many other extensions, and generally features the same functionality and type protection as C#. Pascal (programming language)_sentence_111

It is the only such implementation that is also compatible with the original Pascal implementation, which is standardized as ISO 7185. Pascal (programming language)_sentence_112

Language constructs Pascal (programming language)_section_9

Pascal, in its original form, is a purely procedural language and includes the traditional array of ALGOL-like control structures with reserved words such as if, then, else, while, for, and case ranging on a single statement or a begin-end statements block. Pascal (programming language)_sentence_113

Pascal also has data structuring constructs not included in the original ALGOL 60 types, like records, variants, pointers, enumerations, and sets and procedure/pointers. Pascal (programming language)_sentence_114

Such constructs were in part inherited or inspired from Simula 67, ALGOL 68, Niklaus Wirth's own ALGOL W and suggestions by C. Pascal (programming language)_sentence_115 A. R. Hoare. Pascal (programming language)_sentence_116

Pascal programs start with the program keyword with a list of external as parameters (not required in Turbo Pascal etc.); then follows the main block bracketed by the begin and end keywords. Pascal (programming language)_sentence_117

Semicolons separate statements, and the full stop (i.e., a period) ends the whole program (or unit). Pascal (programming language)_sentence_118

Letter case is ignored in Pascal source. Pascal (programming language)_sentence_119

Here is an example of the source code in use for a very simple "Hello, World!" Pascal (programming language)_sentence_120 program: Pascal (programming language)_sentence_121

Pascal (programming language)_description_list_0

  • Pascal (programming language)_item_0_0

Data types Pascal (programming language)_section_10

A type in Pascal, and in several other popular programming languages, defines a variable in such a way that it defines a range of values which the variable is capable of storing, and it also defines a set of operations that are permissible to be performed on variables of that type. Pascal (programming language)_sentence_122

The predefined types are: Pascal (programming language)_sentence_123

Pascal (programming language)_table_general_1

Data typePascal (programming language)_header_cell_1_0_0 Type of values which the variable is capable of storingPascal (programming language)_header_cell_1_0_1
integerPascal (programming language)_cell_1_1_0 integer (whole) numbersPascal (programming language)_cell_1_1_1
realPascal (programming language)_cell_1_2_0 floating-point numbersPascal (programming language)_cell_1_2_1
booleanPascal (programming language)_cell_1_3_0 the values True or FalsePascal (programming language)_cell_1_3_1
charPascal (programming language)_cell_1_4_0 a single character from an ordered character setPascal (programming language)_cell_1_4_1
stringPascal (programming language)_cell_1_5_0 a sequence or "string" of charactersPascal (programming language)_cell_1_5_1
setPascal (programming language)_cell_1_6_0 equivalent to an array of boolean valuesPascal (programming language)_cell_1_6_1

The range of values allowed for each (except boolean) is implementation defined. Pascal (programming language)_sentence_124

Functions are provided for some data conversions. Pascal (programming language)_sentence_125

For conversion of real to integer, the following functions are available: round (which rounds to integer using banker's rounding) and trunc (rounds towards zero). Pascal (programming language)_sentence_126

The programmer has the freedom to define other commonly used data types (e.g. byte, string, etc.) in terms of the predefined types using Pascal's type declaration facility, for example Pascal (programming language)_sentence_127

Pascal (programming language)_description_list_1

  • Pascal (programming language)_item_1_1

(Often-used types like byte and string are already defined in many implementations.) Pascal (programming language)_sentence_128

Subrange types Pascal (programming language)_section_11

Subranges of any ordinal data type (any simple type except real) can also be made: Pascal (programming language)_sentence_129

Pascal (programming language)_description_list_2

  • Pascal (programming language)_item_2_2

Set types Pascal (programming language)_section_12

In contrast with other programming languages from its time, Pascal supports a set type: Pascal (programming language)_sentence_130

Pascal (programming language)_description_list_3

  • Pascal (programming language)_item_3_3

A set is a fundamental concept for modern mathematics, and they may be used in many algorithms. Pascal (programming language)_sentence_131

Such a feature is useful and may be faster than an equivalent construct in a language that does not support sets. Pascal (programming language)_sentence_132

For example, for many Pascal compilers: Pascal (programming language)_sentence_133

Pascal (programming language)_description_list_4

  • Pascal (programming language)_item_4_4

executes faster than: Pascal (programming language)_sentence_134

Pascal (programming language)_description_list_5

  • Pascal (programming language)_item_5_5

Sets of non-contiguous values can be particularly useful, in terms of both performance and readability: Pascal (programming language)_sentence_135

Pascal (programming language)_description_list_6

  • Pascal (programming language)_item_6_6

For these examples, which involve sets over small domains, the improved performance is usually achieved by the compiler representing set variables as bit vectors. Pascal (programming language)_sentence_136

The set operators can then be implemented efficiently as bitwise machine code operations. Pascal (programming language)_sentence_137

Type declarations Pascal (programming language)_section_13

Types can be defined from other types using type declarations: Pascal (programming language)_sentence_138

Pascal (programming language)_description_list_7

  • Pascal (programming language)_item_7_7

Further, complex types can be constructed from simple types: Pascal (programming language)_sentence_139

Pascal (programming language)_description_list_8

  • Pascal (programming language)_item_8_8

File type Pascal (programming language)_section_14

As shown in the example above, Pascal are sequences of components. Pascal (programming language)_sentence_140

Every file has a buffer variable which is denoted by f^. Pascal (programming language)_sentence_141

The procedures get (for reading) and put (for writing) move the buffer variable to the next element. Pascal (programming language)_sentence_142

Read is introduced such that read(f, x) is the same as x := f^; get(f);. Pascal (programming language)_sentence_143

Write is introduced such that write(f, x) is the same as f^ := x; put(f); The type text is predefined as file of char. Pascal (programming language)_sentence_144

While the buffer variable could be used for inspecting the next character to be used (check for a digit before reading an integer), this leads to serious problems with interactive programs in early implementations, but was solved later with the "lazy I/O" concept. Pascal (programming language)_sentence_145

In Jensen & Wirth Pascal, strings are represented as packed arrays of chars; they therefore have fixed length and are usually space-padded. Pascal (programming language)_sentence_146

Pointer types Pascal (programming language)_section_15

Pascal supports the use of pointers: Pascal (programming language)_sentence_147

Pascal (programming language)_description_list_9

  • Pascal (programming language)_item_9_9

Here the variable NodePtr is a pointer to the data type Node, a record. Pascal (programming language)_sentence_148

Pointers can be used before they are declared. Pascal (programming language)_sentence_149

This is a forward declaration, an exception to the rule that things must be declared before they are used. Pascal (programming language)_sentence_150

To create a new record and assign the value 10 and character A to the fields a and b in the record, and to initialise the pointer c to the null pointer ("NIL" in Pascal), the statements would be: Pascal (programming language)_sentence_151

Pascal (programming language)_description_list_10

  • Pascal (programming language)_item_10_10

This could also be done using the with statement, as follows: Pascal (programming language)_sentence_152

Pascal (programming language)_description_list_11

  • Pascal (programming language)_item_11_11

Inside of the scope of the with statement, a and b refer to the subfields of the record pointer NodePtr and not to the record Node or the pointer type pNode. Pascal (programming language)_sentence_153

Linked lists, stacks and queues can be created by including a pointer type field (c) in the record. Pascal (programming language)_sentence_154

Unlike many languages that feature pointers, Pascal only allows pointers to reference dynamically created variables that are anonymous, and does not allow them to reference standard static or local variables. Pascal (programming language)_sentence_155

Pointers also must have an associated type, and a pointer to one type is not compatible with a pointer to another type (e.g. a pointer to a char is not compatible with a pointer to an integer). Pascal (programming language)_sentence_156

This helps eliminate the type security issues inherent with other pointer implementations, particularly those used for PL/I or C. Pascal (programming language)_sentence_157

It also removes some risks caused by dangling pointers, but the ability to dynamically deallocate referenced space by using the dispose function (which has the same effect as the free library function found in C) means that the risk of dangling pointers has not been entirely eliminated as it has in languages such as Java and C#, which provide automatic garbage collection (but which do not entirely eliminate the related problem of memory leaks). Pascal (programming language)_sentence_158

Some of these restrictions can be lifted in newer dialects. Pascal (programming language)_sentence_159

Control structures Pascal (programming language)_section_16

Pascal is a structured programming language, meaning that the flow of control is structured into standard statements, usually without 'goto' commands. Pascal (programming language)_sentence_160

Pascal (programming language)_description_list_12

  • Pascal (programming language)_item_12_12

Procedures and functions Pascal (programming language)_section_17

Pascal structures programs into procedures and functions. Pascal (programming language)_sentence_161

Pascal (programming language)_description_list_13

  • Pascal (programming language)_item_13_13

Procedures and functions can be nested to any depth, and the 'program' construct is the logical outermost block. Pascal (programming language)_sentence_162

By default, parameters are passed by value. Pascal (programming language)_sentence_163

If 'var' precedes a parameter's name, it is passed by reference. Pascal (programming language)_sentence_164

Each procedure or function can have its own declarations of goto labels, constants, types, variables, and other procedures and functions, which must all be in that order. Pascal (programming language)_sentence_165

This ordering requirement was originally intended to allow efficient single-pass compilation. Pascal (programming language)_sentence_166

However, in some dialects (such as Embarcadero Delphi) the strict ordering requirement of declaration sections has been relaxed. Pascal (programming language)_sentence_167

Semicolons as statement separators Pascal (programming language)_section_18

Pascal adopted many language syntax features from the ALGOL language, including the use of a semicolon as a statement separator. Pascal (programming language)_sentence_168

This is in contrast to other languages, such as PL/I, C etc. which use the semicolon as a statement terminator. Pascal (programming language)_sentence_169

No semicolon is needed before the end keyword of a record type declaration, a block, or a case statement; before the until keyword of a repeat statement; and before the else keyword of an if statement. Pascal (programming language)_sentence_170

The presence of an extra semicolon was not permitted in early versions of Pascal. Pascal (programming language)_sentence_171

However, the addition of ALGOL-like empty statements in the 1973 Revised Report and later changes to the language in ISO 7185:1983 now allow for optional semicolons in most of these cases. Pascal (programming language)_sentence_172

A semicolon is still not permitted immediately before the else keyword in an if statement, because the else follows a single statement, not a statement sequence. Pascal (programming language)_sentence_173

In the case of nested ifs, a semicolon cannot be used to avoid the dangling else problem (where the inner if does not have an else, but the outer if does) by putatively terminating the nested if with a semicolon – this instead terminates both if clauses. Pascal (programming language)_sentence_174

Instead, an explicit begin...end block must be used. Pascal (programming language)_sentence_175

Resources Pascal (programming language)_section_19

Compilers and interpreters Pascal (programming language)_section_20

Several Pascal compilers and interpreters are available for general use: Pascal (programming language)_sentence_176

Pascal (programming language)_unordered_list_14

  • Delphi is Embarcadero's (formerly Borland/CodeGear) flagship rapid application development (RAD) product. It uses the Object Pascal language (termed 'Delphi' by Borland), descended from Pascal, to create applications for Windows, macOS, iOS, and Android. The .NET support that existed from D8 through D2005, D2006 and D2007 has been terminated, and replaced by a new language (Prism, which is rebranded Oxygene, see below) that is not fully backward compatible. In recent years Unicode support and generics were added (D2009, D2010, Delphi XE).Pascal (programming language)_item_14_14
  • Free Pascal is a multi-platform compiler written in Object Pascal (and is self-hosting). It is aimed at providing a convenient and powerful compiler, both able to compile legacy applications and to be the means of developing new ones. It is distributed under the GNU GPL, while packages and runtime library come under a modified GNU LGPL. Apart from compatibility modes for Turbo Pascal, Delphi and Mac Pascal, it also has its own procedural and object-oriented syntax modes with support for extended features such as operator overloading. It supports many platforms and operating systems. Current versions also feature an ISO mode.Pascal (programming language)_item_14_15
  • Modern Pascal is a multi-platform interpreter and p-code compiler written in Free Pascal. It is aimed at providing alternative solutions for PHP and node.js, using either an ISO standard pascal dialect or a hybrid supporting JavaScript/C operators. From the CLI it is useful as a Free Pascal interpreter.Pascal (programming language)_item_14_16
  • Turbo51 is a free Pascal compiler for the 8051 family of microcontrollers, with Turbo Pascal 7 syntax.Pascal (programming language)_item_14_17
  • Oxygene (formerly known as Chrome) is an Object Pascal compiler for the .NET and Mono platforms. It was created and is sold by RemObjects Software, and sold for a while by Embarcadero as the backend compiler of Prism.Pascal (programming language)_item_14_18
  • Kylix was a descendant of Delphi, with support for the Linux operating system and an improved object library. It is no longer supported. Compiler and IDE are available now for non-commercial use.Pascal (programming language)_item_14_19
  • GNU Pascal Compiler (GPC) is the Pascal compiler of the GNU Compiler Collection (GCC). The compiler itself is written in C, the runtime library mostly in Pascal. Distributed under the GNU General Public License, it runs on many platforms and operating systems. It supports the ANSI/ISO standard languages and has partial Turbo Pascal dialect support. One of the more painful omissions is the absence of a 100% Turbo Pascal-compatible (short)string type. Support for Borland Delphi and other language variations is quite limited. There is some support for Mac-pascal however.Pascal (programming language)_item_14_20
  • Virtual Pascal was created by Vitaly Miryanov in 1995 as a native OS/2 compiler compatible with Borland Pascal syntax. Then, it had been commercially developed by fPrint, adding Win32 support, and in 2000 it became freeware. Today it can compile for Win32, OS/2 and Linux, and is mostly compatible with Borland Pascal and Delphi. Development was canceled on April 4, 2005.Pascal (programming language)_item_14_21
  • P4 compiler, the basis for many subsequent Pascal-implemented-in-Pascal compilers. It implements a subset of full Pascal.Pascal (programming language)_item_14_22
  • P5 compiler, is an ISO 7185 (full Pascal) adaption of P4.Pascal (programming language)_item_14_23
  • Smart Mobile Studio is a Pascal to HTML5/Javascript compilerPascal (programming language)_item_14_24
  • Turbo Pascal was the dominant Pascal compiler for PCs during the 1980s and early 1990s, popular both because of its powerful extensions and extremely short compilation times. Turbo Pascal was compactly written and could compile, run, and debug all from memory without accessing disk. Slow floppy disk drives were common for programmers at the time, further magnifying Turbo Pascal's speed advantage. Currently, older versions of Turbo Pascal (up to 5.5) are available for free download from Borland's site.Pascal (programming language)_item_14_25
  • IP Pascal Implements the language "Pascaline" (named after Pascal's calculator), which is a highly extended Pascal compatible with original Pascal according to ISO 7185. It features modules with namespace control, including parallel tasking modules with semaphores, objects, dynamic arrays of any dimensions that are allocated at runtime, overloads, overrides, and many other extensions. IP Pascal has a built-in portability library that is custom tailored to the Pascal language. For example, a standard text output application from 1970's original Pascal can be recompiled to work in a window and even have graphical constructs added.Pascal (programming language)_item_14_26
  • Pascal-XT was created by Siemens for their mainframe operating systems BS2000 and SINIX.Pascal (programming language)_item_14_27
  • PocketStudio is a Pascal subset compiler and RAD tool for Palm OS and MC68xxx processors with some own extensions to assist interfacing with the Palm OS API. It resembles Delphi and Lazarus with a visual form designer, an object inspector and a source code editor.Pascal (programming language)_item_14_28
  • MIDletPascal – A Pascal compiler and IDE that generates small and fast Java bytecode specifically designed to create software for mobilesPascal (programming language)_item_14_29
  • Vector Pascal is a language for SIMD instruction sets such as the MMX and the AMD 3d Now, supporting all Intel and AMD processors, and Sony's PlayStation 2 Emotion Engine.Pascal (programming language)_item_14_30
  • Morfik Pascal allows the development of Web applications entirely written in Object Pascal (both server and browser side).Pascal (programming language)_item_14_31
  • WDSibyl – Visual Development Environment and Pascal compiler for Win32 and OS/2Pascal (programming language)_item_14_32
  • PP Compiler, a compiler for Palm OS that runs directly on the handheld computer.Pascal (programming language)_item_14_33
  • CDC 6000 Pascal compiler is the source code for the first (CDC 6000) Pascal compiler.Pascal (programming language)_item_14_34
  • Pascal-SPascal (programming language)_item_14_35
  • AmigaPascal is a free Pascal compiler for the Amiga computer.Pascal (programming language)_item_14_36
  • VSI Pascal (originally VAX Pascal) is an ISO Standard Pascal compliant compiler for the OpenVMS operating system.Pascal (programming language)_item_14_37
  • Stony Brook Pascal+ was a 16-bit (later 32-bit) optimizing compiler for DOS and OS/2, marketed as a direct replacement for Turbo Pascal, but producing code that executed at least twice the speed.Pascal (programming language)_item_14_38

IDEs Pascal (programming language)_section_21

Pascal (programming language)_unordered_list_15

Libraries Pascal (programming language)_section_22

Pascal (programming language)_unordered_list_16

  • WOL Library for creating GUI applications with the Free Pascal Compiler.Pascal (programming language)_item_16_41

Standards Pascal (programming language)_section_23

ISO/IEC 7185:1990 Pascal Pascal (programming language)_section_24

In 1983, the language was standardized, in the international standard IEC/ISO 7185, and several local country specific standards, including the American ANSI/IEEE770X3.97-1983, and ISO 7185:1983. Pascal (programming language)_sentence_177

These two standards differed only in that the ISO standard included a "level 1" extension for conformant arrays (an array where the boundaries of the array are not known until run time), where ANSI did not allow for this extension to the original (Wirth version) language. Pascal (programming language)_sentence_178

In 1989, ISO 7185 was revised (ISO 7185:1990) to correct various errors and ambiguities found in the original document. Pascal (programming language)_sentence_179

The ISO 7185 was stated to be a clarification of Wirth's 1974 language as detailed by the User Manual and Report [Jensen and Wirth], but was also notable for adding "Conformant Array Parameters" as a level 1 to the standard, level 0 being Pascal without conformant arrays. Pascal (programming language)_sentence_180

This addition was made at the request of C. Pascal (programming language)_sentence_181 A. R. Hoare, and with the approval of Niklaus Wirth. Pascal (programming language)_sentence_182

The precipitating cause was that Hoare wanted to create a Pascal version of the (NAG) Numerical Algorithms Library, which had originally been written in FORTRAN, and found that it was not possible to do so without an extension that would allow array parameters of varying size. Pascal (programming language)_sentence_183

Similar considerations motivated the inclusion in ISO 7185 of the facility to specify the parameter types of procedural and functional parameters. Pascal (programming language)_sentence_184

Niklaus Wirth himself referred to the 1974 language as "the Standard", for example, to differentiate it from the machine specific features of the CDC 6000 compiler. Pascal (programming language)_sentence_185

This language was documented in The Pascal Report, the second part of the "Pascal users manual and report". Pascal (programming language)_sentence_186

On the large machines (mainframes and minicomputers) Pascal originated on, the standards were generally followed. Pascal (programming language)_sentence_187

On the IBM PC, they were not. Pascal (programming language)_sentence_188

On IBM PCs, the Borland standards Turbo Pascal and Delphi have the greatest number of users. Pascal (programming language)_sentence_189

Thus, it is typically important to understand whether a particular implementation corresponds to the original Pascal language, or a Borland dialect of it. Pascal (programming language)_sentence_190

The IBM PC versions of the language began to differ with the advent of UCSD Pascal, an interpreted implementation that featured several extensions to the language, along with several omissions and changes. Pascal (programming language)_sentence_191

Many UCSD language features survive today, including in Borland's dialect. Pascal (programming language)_sentence_192

ISO/IEC 10206:1990 Extended Pascal Pascal (programming language)_section_25

In 1990, an extended Pascal standard was created as ISO/IEC 10206, which is identical in technical content to IEEE/ANSI 770X3.160-1989 As of 2019, Support of Extended Pascal in FreePascal Compiler is planned. Pascal (programming language)_sentence_193

Variations Pascal (programming language)_section_26

Niklaus Wirth's Zürich version of Pascal was issued outside ETH in two basic forms, the CDC 6000 compiler source, and a porting kit called Pascal-P system. Pascal (programming language)_sentence_194

The Pascal-P compiler left out several features of the full language that were not required to bootstrap the compiler. Pascal (programming language)_sentence_195

For example, procedures and functions used as parameters, undiscriminated variant records, packing, dispose, interprocedural gotos and other features of the full compiler were omitted. Pascal (programming language)_sentence_196

UCSD Pascal, under Professor Kenneth Bowles, was based on the Pascal-P2 kit, and consequently shared several of the Pascal-P language restrictions. Pascal (programming language)_sentence_197

UCSD Pascal was later adopted as Apple Pascal, and continued through several versions there. Pascal (programming language)_sentence_198

Although UCSD Pascal actually expanded the subset Pascal in the Pascal-P kit by adding back standard Pascal constructs, it was still not a complete standard installation of Pascal. Pascal (programming language)_sentence_199

In the early 1990s, Alan Burns and Geoff Davies developed Pascal-FC, an extension to Pl/0 (from the Niklaus' book 'Algorithms+Data Structures=Programs'). Pascal (programming language)_sentence_200

Several constructs were added to use Pascal-FC as a teaching tool for Concurrent Programming (such as semaphores, monitors, channels, remote-invocation and resources). Pascal (programming language)_sentence_201

To be able to demonstrate concurrency, the compiler output (a kind of P-code) could then be executed on a virtual machine. Pascal (programming language)_sentence_202

This virtual machine not only simulated a normal – fair – environment, but could also simulate extreme conditions (unfair mode). Pascal (programming language)_sentence_203

Borland-like Pascal compilers Pascal (programming language)_section_27

Borland's Turbo Pascal, written by Anders Hejlsberg, was written in assembly language independent of UCSD or the Zürich compilers. Pascal (programming language)_sentence_204

However, it adopted much of the same subset and extensions as the UCSD compiler. Pascal (programming language)_sentence_205

This is probably because the UCSD system was the most common Pascal system suitable for developing applications on the resource-limited microprocessor systems available at that time. Pascal (programming language)_sentence_206

The shrink-wrapped Turbo Pascal version 3 and later incarnations, including Borland's Object Pascal and Delphi and non-Borland near-compatibles became popular with programmers including shareware authors, and so the SWAG library of Pascal code features a large amount of code written with such versions as Delphi in mind. Pascal (programming language)_sentence_207

Software products (compilers, and IDE/Rapid Application Development (RAD) in this category: Pascal (programming language)_sentence_208

Pascal (programming language)_unordered_list_17

  • Turbo Pascal - "TURBO.EXE" up to version 7, and Turbo Pascal for Windows ("TPW") and Turbo Pascal for Macintosh.Pascal (programming language)_item_17_42
  • Borland Pascal 7 (essentially Turbo Pascal 7 for Windows).Pascal (programming language)_item_17_43
  • Object Pascal - an extension of the Pascal language that was developed at Apple Computer by a team led by Larry Tesler in consultation with Niklaus Wirth, the inventor of Pascal; its features were added to Borland's Turbo Pascal for Macintosh and in 1989 for Turbo Pascal 5.5 for DOS.Pascal (programming language)_item_17_44
  • Delphi - Object Pascal is essentially its underlying language.Pascal (programming language)_item_17_45
  • Free Pascal compiler (FPC) - Free Pascal adopted the de facto standard dialect of Pascal programmers, Borland Pascal and, later, Delphi. Freepascal also supports both ISO standards.Pascal (programming language)_item_17_46
  • PascalABC.NET - is a new generation Pascal programming language including compiler and IDEPascal (programming language)_item_17_47
  • Borland Kylix is a compiler and IDE formerly sold by Borland, but later discontinued. It is a Linux version of the Borland Delphi software development environment and C++Builder.Pascal (programming language)_item_17_48
  • Lazarus - similar to Kylix in function, is a free cross-platform visual IDE for RAD using the Free Pascal compiler, which supports dialects of Object Pascal, to varying degrees.Pascal (programming language)_item_17_49
  • Virtual Pascal - VP2/1 is a fully Borland Pascal and Borland Delphi compatible 32-bit Pascal compiler for OS/2 and Win 32 (with a Linux version "on the way").Pascal (programming language)_item_17_50
  • Sybil is an open source Delphi-like IDE and compiler; implementations include WDSibyl for Microsoft Windows and OS/2, a commercial Borland Pascal compatible environment released by a company called Speedsoft that was later developed into a Delphi like RAD environment called Sybil and then open sourced under the GPL when that company closed down; Open Sybil is an ongoing project, an Open source Pascal RAD (Rapid Application Development) Tool for OS/2 and eCS that was originally based on Speedsoft's WDsybl SPCC (Sibyl Portable Component Classes) and SVDE (Sibyl Visual Development Tool) sources but now the core is SOM, WPS and OpenDoc.Pascal (programming language)_item_17_51

List of related standards Pascal (programming language)_section_28

Pascal (programming language)_unordered_list_18

  • ISO 8651-2:1988 Information processing systems – Computer graphics – Graphical Kernel System (GKS) language bindings – Part 2: PascalPascal (programming language)_item_18_52

Reception Pascal (programming language)_section_29

Pascal generated a wide variety of responses in the computing community, both critical and complimentary. Pascal (programming language)_sentence_209

Early criticism Pascal (programming language)_section_30

While very popular in the 1980s and early 1990s, implementations of Pascal that closely followed Wirth's initial definition of the language were widely criticized as being unsuitable for use outside teaching. Pascal (programming language)_sentence_210

Brian Kernighan, who popularized the C language, outlined his most notable criticisms of Pascal as early as 1981 in his article "Why Pascal is Not My Favorite Programming Language". Pascal (programming language)_sentence_211

The most serious problem described by him was that array sizes and string lengths were part of the type, so it was not possible to write a function that would accept variable-length arrays or even strings as parameters. Pascal (programming language)_sentence_212

This made it unfeasible to write, for example, a sorting library. Pascal (programming language)_sentence_213

Kernighan also criticized the unpredictable order of evaluation of boolean expressions, poor library support, and lack of static variables, and raised a number of smaller issues. Pascal (programming language)_sentence_214

Also, he stated that the language did not provide any simple constructs to "escape" (knowingly and forcibly ignore) restrictions and limitations. Pascal (programming language)_sentence_215

More general complaints from other sources noted that the scope of declarations was not clearly defined in the original language definition, which sometimes had serious consequences when using forward declarations to define pointer types, or when record declarations led to mutual recursion, or when an identifier may or may not have been used in an enumeration list. Pascal (programming language)_sentence_216

Another difficulty was that, like ALGOL 60, the language did not allow procedures or functions passed as parameters to predefine the expected type of their parameters. Pascal (programming language)_sentence_217

Despite initial criticisms, Pascal continued to evolve, and most of Kernighan's points do not apply to versions of the language which were enhanced to be suitable for commercial product development, such as Borland's Turbo Pascal. Pascal (programming language)_sentence_218

As Kernighan predicted in his article, most of the extensions to fix these issues were incompatible from compiler to compiler. Pascal (programming language)_sentence_219

Since the early 1990s, however, most of the varieties seem condensed into two categories: ISO and Borland-like. Pascal (programming language)_sentence_220

Extended Pascal addresses many of these early criticisms. Pascal (programming language)_sentence_221

It supports variable-length strings, variable initialization, separate compilation, short-circuit boolean operators, and default (otherwise) clauses for case statements. Pascal (programming language)_sentence_222

See also Pascal (programming language)_section_31

Pascal (programming language)_unordered_list_19


Credits to the contents of this page go to the authors of the corresponding Wikipedia page: en.wikipedia.org/wiki/Pascal (programming language).