Sign in Join
Wiki copytemporary

Extended Pascal: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-**Extended Pascal** is the name given to the version of Pascal specified in International Organization for Standardization (ISO) standard 10206. It specifies an enhanced version of the [[Standard Pascal]] language that was specified in the ISO 7185 specification. The 214-page ISO 10206 document was published in May 1991 and not been revised since.
1+**Extended Pascal** is the name given to the version of Pascal specified in International Organization for Standardization (ISO) standard 10206. It specifies an enhanced version of the [[Standard Pascal]] language that was specified in the ISO 7185 specification. The 214-page ISO 10206 document was published in May 1991 and not been revised since.
22
3-Support in Free Pascal for Extended Pascal is planned, and will be via [[Mode extendedpascal|compiler mode extendedPascal]].
3+Support in Free Pascal for Extended Pascal is planned, and will be via [[Mode extendedpascal|compiler mode `extendedPascal`]].
44
55## Enhancements to Standard Pascal
66
7-- Modularity and separate compilation (implemented with new keywords **module**, **import**, **export**, **only**, **qualified** and **protected**).
8-- Direct access file handing (via **SeekRead**, **SeekWrite**, **SeekUpdate** and **update** procedures, and the **position**, **LastPosition** and **empty** functions as well as an *update file mode*).
9-- The procedure **extend** prepares an existing file for appending data
10-- The declaration parts of a program (labels, constants, types, variables, procedures, and functions) can appear in any order
11-- Complex numbers
7+ * Modularity and separate compilation (implemented with new keywords **module** , **import** , **export** , **only** , **qualified** and **protected**).
8+ * Direct access file handing (via **SeekRead** , **SeekWrite** , **SeekUpdate** and **update** procedures, and the **position** , **LastPosition** and **empty** functions as well as an _update file mode_).
9+ * The procedure **extend** prepares an existing file for appending data
10+ * The declaration parts of a program (labels, constants, types, variables, procedures, and functions) can appear in any order
11+ * Complex numbers
1212
1313## Reserved Words
1414
15-In addition to all the [[Standard Pascal|reserved words of Standard Pascal]] the following (referred to as *word-symbols* in the ISO 10206 document) have been added to Extended Pascal:
15+In addition to all the [[Standard Pascal|reserved words of Standard Pascal]] the following (referred to as _word-symbols_ in the ISO 10206 document) have been added to Extended Pascal:
1616
17-- and_then (short circuit version of "and"; right side not evaluated if not necessary)
18-- bindable
19-- export
20-- import
21-- module
22-- only
23-- or_else (short circuit version of "or"; right side not evaluated if not necessary)
24-- otherwise (used with the **case** statement and *variant records*)
25-- pow (exponentiation for integer, real and complex numbers to real and integer powers)
26-- protected
27-- qualified
28-- restricted
29-- value
17+ * and_then (short circuit version of "and"; right side not evaluated if not necessary)
18+ * bindable
19+ * export
20+ * import
21+ * module
22+ * only
23+ * or_else (short circuit version of "or"; right side not evaluated if not necessary)
24+ * otherwise (used with the **case** statement and _variant records_)
25+ * pow (exponentiation for integer, real and complex numbers to real and integer powers)
26+ * protected
27+ * qualified
28+ * restricted
29+ * value
3030
3131## Symbols
3232
33-In addition to all the [[Standard Pascal|symbols of Standard Pascal]] the following have been added to Extended Pascal:
33+In addition to all the [[Standard Pascal|symbols of Standard Pascal]] the following have been added to Extended Pascal:
3434
35-- ** (exponentiation for integer, real and complex numbers to real and integer powers)
36-- \>\< (computes a set symmetric difference)
37-- =\>
35+ * ** (exponentiation for integer, real and complex numbers to real and integer powers)
36+ * >< (computes a set symmetric difference)
37+ * =>
3838
3939## Free Pascal support for Extended Pascal
4040
41-Free Pascal has traditionally only supported the Borland dialects of Pascal, but Extended Pascal support will be available via [[Compiler Mode|compiler mode]] [[Mode extendedpascal|extendedpascal]]. [Bug 0032549](https://bugs.freepascal.org/view.php?id=32549) has been set up to track its progress. Below is a list of things that have been implemented (if only in unapplied patches) and things that are planned. The planned features are subject to change.
41+Free Pascal has traditionally only supported the Borland dialects of Pascal, but Extended Pascal support will be available via [[Compiler Mode|compiler mode]] [[Mode extendedpascal|extendedpascal]]. [Bug 0032549](<https://bugs.freepascal.org/view.php?id=32549>) has been set up to track its progress. Below is a list of things that have been implemented (if only in unapplied patches) and things that are planned. The planned features are subject to change.
4242
4343### Already supported features
4444
45-These features are already supported in Free Pascal 3.0 and some earlier versions.
45+These features are already supported in Free Pascal 3.0 and some earlier versions.
4646
47-- The declaration parts of a program (labels, constants, types, variables, procedures, and functions) can appear in any order
48-- The **ReadStr** and **WriteStr** procedures.
49-- The **Halt** procedure.
50-- The **otherwise** clause of case statements.
51-- The [[for-in loop|for ... in]] loop
52-- Array and string slices (mostly working, though assigning to them doesn't).
53-- The * and \>\< operators of sets.
54-- The ** operator (requires the Math unit)
55-- Various features from ISO 7185 not supported in the Borland dialects (requires ISO mode)
47+ * The declaration parts of a program (labels, constants, types, variables, procedures, and functions) can appear in any order
48+ * The **ReadStr** and **WriteStr** procedures.
49+ * The **Halt** procedure.
50+ * The **otherwise** clause of case statements.
51+ * The [[for-in loop|**for** ... **in**]] loop
52+ * Array and string slices (mostly working, though assigning to them doesn't).
53+ * The * and >< operators of sets.
54+ * The ** operator (requires the Math unit)
55+ * Various features from ISO 7185 not supported in the Borland dialects (requires ISO mode)
5656
5757### Conformant arrays (not yet implemented)
5858
59-This is the standard way to pass arrays of various sizes to routines.
59+This is the standard way to pass arrays of various sizes to routines.
6060
6161### Set improvements (not yet implemented)
6262
63-In addition to the * and \>\< operators, ISO 10206 also has a **Card** function, for retrieving the number of elements in a set. In Free Pascal, sets will still be limited to 256 elements for the foreseeable future (see [Future Plans](https://freepascal.org/future.var)).
63+In addition to the * and >< operators, ISO 10206 also has a **Card** function, for retrieving the number of elements in a set. In Free Pascal, sets will still be limited to 256 elements for the foreseeable future (see [Future Plans](<https://freepascal.org/future.var>)).
6464
6565### Generalized ordinal functions (not yet implemeted)
6666
67-- **Succ** and **Pred** can take a second argument, making them essentially equivalent to Borland's **Inc** and **Dec**.
67+ * **Succ** and **Pred** can take a second argument, making them essentially equivalent to Borland's **Inc** and **Dec**.
6868
6969### Modules (not yet implemented)
7070
71-Modules are the standard way for modular programs, covering the same domain as UCSD units. There are two types of modules: those written in a single file and those written in two files. For modules written in one file, Free Pascal will search for them as it does for units (*modulename*.{p,pp,pas}). Suggestion for those written in two files as this is not provided in the standard: the compiler will search for the implementation file normally and then search for *modulename*.imp.{p,pp,pas}. The interface is in *modulename*.int.{p,pp,pas}, unless otherwise specified by a {\$INTERFACE} directive.
71+Modules are the standard way for modular programs, covering the same domain as UCSD units. There are two types of modules: those written in a single file and those written in two files. For modules written in one file, Free Pascal will search for them as it does for units (_modulename_.{p,pp,pas}). Suggestion for those written in two files as this is not provided in the standard: the compiler will search for the implementation file normally and then search for _modulename_.imp.{p,pp,pas}. The interface is in _modulename_.int.{p,pp,pas}, unless otherwise specified by a {$INTERFACE} directive.
7272
73-- The **import** section specifies modules to import (much like UCSD's **uses**) and can be used with the keywords **only** (to only import certain identifiers (functions, procedures, types, variables, constants)), and **qualified** (qualified identifiers; that is, *modulename*.*identifier*, rather than just *identifier*). Identifiers can be renamed on import. An example:
73+ * The **import** section specifies modules to import (much like UCSD's **uses**) and can be used with the keywords **only** (to only import certain identifiers (functions, procedures, types, variables, constants)), and **qualified** (qualified identifiers; that is, _modulename_._identifier_ , rather than just _identifier_). Identifiers can be renamed on import. An example:
7474
75-``` pascal
75+```
7676program PathTest;
77-
78-import
79- SysUtils qualified only (GetEnvironmentVariable => GetEnv);
80-
81-begin
82- WriteLn(SysUtils.GetEnv('PATH'));
83-end.
77+
78+ import
79+ SysUtils qualified only (GetEnvironmentVariable => GetEnv);
80+
81+ begin
82+ WriteLn(SysUtils.GetEnv('PATH'));
83+ end.
8484```
8585
86-- Modules must export identifers for them to be usable to programs or other modules.
87-- On export, identifers can also be renamed and the **protected** keyword can be specified so that other programs and modules can't change the variable's value.
88-- In the module, the **restricted** keyword can be used to make opaque types. To use the example given in the standard:
86+ * Modules must export identifers for them to be usable to programs or other modules.
87+ * On export, identifers can also be renamed and the **protected** keyword can be specified so that other programs and modules can't change the variable's value.
88+ * In the module, the **restricted** keyword can be used to make opaque types. To use the example given in the standard:
8989
90-``` pascal
90+```
9191type
92- real_widget = record
93- f1: integer;
94- f2: real
95- end;
96- widget = restricted real_widget;
92+ real_widget = record
93+ f1: integer;
94+ f2: real
95+ end;
96+ widget = restricted real_widget;
9797```
9898
99-- The **to begin do** statement specifies what happens when the module loads (equivalent to Delphi's **initialization** section).
100-- The **to end do** statement specifies what happens when the module unloads (equivalent to Delphi's **finalization** section). The example in the standard uses **to begin do** to bind a text file on module load, writes to the text file during runtime, and then closes the text file in **to end do**.
99+ * The **to begin do** statement specifies what happens when the module loads (equivalent to Delphi's **initialization** section).
100+ * The **to end do** statement specifies what happens when the module unloads (equivalent to Delphi's **finalization** section). The example in the standard uses **to begin do** to bind a text file on module load, writes to the text file during runtime, and then closes the text file in **to end do**.
101101
102-Two extensions from [[GNU Pascal]] are also planned:
102+Two extensions from [[GNU Pascal]] are also planned:
103103
104-- The **all** keyword to export all identifers from a module's interface (specified identifers can be renamed).
105-- [[PXSC]]-style modules, which are essentially implementation modules without an interface part. (Free Pascal already supports PXSC-style operator overloading, as does GNU Pascal.)
104+ * The **all** keyword to export all identifers from a module's interface (specified identifers can be renamed).
105+ * [[PXSC]]-style modules, which are essentially implementation modules without an interface part. (Free Pascal already supports PXSC-style operator overloading, as does GNU Pascal.)
106106
107107#### Required interfaces
108108
109-The modules **StandardInput** and **StandardOutput** are equivalent to **input** and **output** in a program's header.
109+The modules **StandardInput** and **StandardOutput** are equivalent to **input** and **output** in a program's header.
110110
111111### Schemata (not yet implemented)
112112
113-The standard defines a schema as a collection of similar types. Essentially, though, a schema is a data type that takes one or more arguments (called discriminants).
113+The standard defines a schema as a collection of similar types. Essentially, though, a schema is a data type that takes one or more arguments (called discriminants).
114114
115-- The ISO 10206 string type is a schema type.
116-- The **New** procedure can be used to set a schema's discriminants at runtime.
117-- The **New** procedure can also be used to set a variant record's discriminant.
115+ * The ISO 10206 string type is a schema type.
116+ * The **New** procedure can be used to set a schema's discriminants at runtime.
117+ * The **New** procedure can also be used to set a variant record's discriminant.
118118
119119### File routines
120120
121-- The **bindable** keyword allows the binding of a variable to an external resource (not implemented, and it might stay that way; GNU Pascal also doesn't allow binding non-files)
122-- Indexed files (not yet implemented)
123-- The **Bind** procedure to bind a variable to an external resource
124-- **Unbind**
125-- **Binding** returns a **BindingType** record, whose Bound field tells if the file was successfully bound
126-- **Empty**
127-- **Extend**
128-- **SeekRead**
129-- **SeekWrite**
130-- **SeekUpdate**
131-- **Update**
132-- **Position**
133-- **LastPosition** (currently, it always returns 0, as its functioning requires support of indexed files)
121+ * The **bindable** keyword allows the binding of a variable to an external resource (not implemented, and it might stay that way; GNU Pascal also doesn't allow binding non-files)
122+ * Indexed files (not yet implemented)
123+ * The **Bind** procedure to bind a variable to an external resource
124+ * **Unbind**
125+ * **Binding** returns a **BindingType** record, whose Bound field tells if the file was successfully bound
126+ * **Empty**
127+ * **Extend**
128+ * **SeekRead**
129+ * **SeekWrite**
130+ * **SeekUpdate**
131+ * **Update**
132+ * **Position**
133+ * **LastPosition** (currently, it always returns 0, as its functioning requires support of indexed files)
134134
135135### Date/Time
136136
137-The **GetTimeStamp** procedure fills a **TimeStamp** record with details about the current time, which can be converted to a human-readable format via the **Date** and **Time** functions.
137+The **GetTimeStamp** procedure fills a **TimeStamp** record with details about the current time, which can be converted to a human-readable format via the **Date** and **Time** functions.
138138
139139### String functions
140140
141-- **Substr**, equivalent to **Copy**.
142-- **Index**, equivalent to **Pos**.
143-- **Trim**.
144-- String comparison through **EQ**, **NE**, **LT**, **GT**, **LE**, and **GE** (equal to, not equal to, less than, greater than, less than or equal to, greater than or equal to).
141+ * **Substr** , equivalent to **Copy**.
142+ * **Index** , equivalent to **Pos**.
143+ * **Trim**.
144+ * String comparison through **EQ** , **NE** , **LT** , **GT** , **LE** , and **GE** (equal to, not equal to, less than, greater than, less than or equal to, greater than or equal to).
145145
146146### Complex Numbers
147147
148-- There's a **complex** data type. In Free Pascal, it's implemented as a record with two fields, but you shouldn't count on that. Instead use the **Re** and **Im** functions to get the real and imaginary parts, respectively.
149-- Use **Cmplx** to create a complex number from Cartesian arguments or **Polar** to create one from polar arguments.
150-- The standard operators and functions (**abs**, **arctan**, **cos**, **exp**, **ln**, **sin**, **sqr**, and **sqrt**) are overloaded to take complex arguments.
151-- The function **arg** gets the complex number's argument.
148+ * There's a **complex** data type. In Free Pascal, it's implemented as a record with two fields, but you shouldn't count on that. Instead use the **Re** and **Im** functions to get the real and imaginary parts, respectively.
149+ * Use **Cmplx** to create a complex number from Cartesian arguments or **Polar** to create one from polar arguments.
150+ * The standard operators and functions (**abs** , **arctan** , **cos** , **exp** , **ln** , **sin** , **sqr** , and **sqrt**) are overloaded to take complex arguments.
151+ * The function **arg** gets the complex number's argument.
152152
153153### Number bases (not yet implemented)
154154
155-It's possible to use any number base from 2 to 36.
155+It's possible to use any number base from 2 to 36.
156156
157157### Exponents
158158
159-The ** operator for real exponents has existed in Free Pascal for a while, but the **pow** operator for integer exponents remains unimplemented.
159+The ** operator for real exponents has existed in Free Pascal for a while, but the **pow** operator for integer exponents remains unimplemented.
160160
161161### New constants
162162
163-- **maxchar** - The highest codepoint supported by a Pascal implementation.
164-- **minreal** - The minimum real value supported.
165-- **maxreal** - The maximum real value supported.
166-- **epsreal** - The precision of reals.
163+ * **maxchar** \- The highest codepoint supported by a Pascal implementation.
164+ * **minreal** \- The minimum real value supported.
165+ * **maxreal** \- The maximum real value supported.
166+ * **epsreal** \- The precision of reals.
167167
168168### Ensuring the proper order of Boolean expressions (not yet implemented)
169169
170-ISO 10206 introduces the **and_then** and **or_else** operators when you need your expression to evaluated left to right. The **and** and **or** operators, on the other hand, can evaluate the Boolean expressions in any order. These new operators are especially useful for pointer operations, where you need to know whether a pointer is assigned before trying to dereference it.
170+ISO 10206 introduces the **and_then** and **or_else** operators when you need your expression to evaluated left to right. The **and** and **or** operators, on the other hand, can evaluate the Boolean expressions in any order. These new operators are especially useful for pointer operations, where you need to know whether a pointer is assigned before trying to dereference it.
171171
172172### The value keyword (not yet implemented)
173173
174-The **value** keyword specifies the default value for a variable, type, parameter, or record field.
174+The **value** keyword specifies the default value for a variable, type, parameter, or record field.
175175
176-- For variables and default parameters, this is equivalent to the Delphi operator =.
177-- For record fields and types, there's no direct equivalent in the Borland dialects, but the [[management operators|initialize “management operator”]] could perform the same task.
176+ * For variables and default parameters, this is equivalent to the Delphi operator =.
177+ * For record fields and types, there's no direct equivalent in the Borland dialects, but the [[management operators|`initialize` “management operator”]] could perform the same task.
178178
179-Note: Default parameters aren't defined in ISO 10206, but are in Appendix C.4 of the [[Object-Oriented Extensions to Pascal|OOE]] draft.
179+Note: Default parameters aren't defined in ISO 10206, but are in Appendix C.4 of the [[Object-Oriented Extensions to Pascal|OOE]] draft.
180180
181181### Function result variables (not yet implemented)
182182
183-Allows to bind a function's result to a variable, sort of like Delphi's **Result**.
183+Allows to bind a function's result to a variable, sort of like Delphi's **Result**.
184184
185185### Protected parameters (not yet implemented)
186186
187-The **protected** keyword can also be used with parameters to indicated that they can't be changed in the routine, giving the compiler hints to aid optimization. To use the example given in the standard:
188-
189-``` pascal
187+The **protected** keyword can also be used with parameters to indicated that they can't be changed in the routine, giving the compiler hints to aid optimization. To use the example given in the standard:
188+```
190189procedure illustrate(a: integer; var b: integer; protected c: integer; protected var d: integer);
191-begin
192- a := 1; { value param }
193- b := 1; { variable param }
194-{ c := 1; not legal }
195-{ d := 1; not legal }
196-end;
190+ begin
191+ a := 1; { value param }
192+ b := 1; { variable param }
193+ { c := 1; not legal }
194+ { d := 1; not legal }
195+ end;
197196```
198197
199198### Type inquiry (not yet implemented)
200199
201-Allows you to make the type of one variable or parameter the same as another variable or parameter.
200+Allows you to make the type of one variable or parameter the same as another variable or parameter.
202201
203202### Value constructors (not yet implemented)
204203
205-This provides a cleaner alternative to Borland's typed constants (which aren't really constants at all) and gives a shortcut to constructing arrays and records at runtime.
204+This provides a cleaner alternative to Borland's typed constants (which aren't really constants at all) and gives a shortcut to constructing arrays and records at runtime.
206205
207206### Local variables with dynamic size (not yet implemented)
208207
209-This should work but doesn't currently:
210-
211-``` pascal
208+This should work but doesn't currently:
209+```
212210procedure p(n: integer);
213-var
214- v: 1..n;
215-begin
216- ...
217-end;
211+ var
212+ v: 1..n;
213+ begin
214+ ...
215+ end;
218216```
219217
220218### Acceptable Identifiers (not yet implemented)
221219
222-- An underscore (`_`) may neither begin or end an identifier.
223-- Two underscores may not appear in succession, thus `Foo__bar` (*two* underscores) is illegal.
224-- Merely all-numeric [[Label|labels]] are allowed and have a maximum length of four digits.
220+ * An underscore (`_`) may neither begin or end an identifier.
221+ * Two underscores may not appear in succession, thus `Foo__bar` (_two_ underscores) is illegal.
222+ * Merely all-numeric [[Label|`label`s]] are allowed and have a maximum length of four digits.
225223
226224## External links
227225
228-- [ISO/IEC 10206:1991](http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=18237), [PDF](http://www.pascal-central.com/docs/iso10206.pdf): Extended Pascal standard
226+ * [ISO/IEC 10206:1991](<http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=18237>), [PDF (Archive.org copy)](<https://web.archive.org/web/20210820153846/www.pascal-central.com/docs/iso10206.pdf>): Extended Pascal standard
229227
230228---
231-*From the Free Pascal wiki, page "Extended Pascal", as it stood on 2024-02-28 after a change by Alextp, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
232-Category: Pascal
229+*From the Free Pascal wiki, page "Extended Pascal", as the Internet Archive kept it on 2025-08-13, last changed on 2024-08-11. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history