Wiki copymirror

This is a mirror of the wiki at pascal.chat. Editing, history and sign-in are there.

Object-Oriented Extensions to Pascal

Object Oriented Extensions to Pascal (abbreviated OOE) is an ANSI draft to extend Extended Pascal to support object-oriented programming. A Compiler Mode ooextpas is planned to cover this language mode (after Extended Pascal is implemented). It's similar to but different from the Object Pascal dialect of Free Pascal 3.0 and earlier.

Enhancements to Extended Pascal

Normative enhancements

Already supported features

These features are already supported in Free Pascal 3.0 and earlier with the modes OBJFPC and DELPHI.

Root class

The class from which all other classes derive is called Root, instead of TObject. Root has two methods: Clone and Equal. Equal is equivalent to TObject's Equals. There's also a Copy function that does the same thing as the Clone method.

Virtual methods

All methods are virtual in OOE and thus the override directive must be used when replacing or augmenting them in descendant classes.

Multiple inheritance

OOE supports multiple inheritance with a defined resolution mechanism.

Class types

Concrete classes

These are classes made with the keyword class (already supported).

Abstract classes

These are classes made with abstract class. They're different from concrete classes in that they can't be constructed; instead, only a descendant class inheriting them can be constructed.

Property classes

These are classes that contain only the interface for its methods. The methods must be implemented in descendant classes. Property classes can only inherit from other property classes. They are declared via property class.

TextWritable

OOE specifies a TextWritable property class with two methods: WriteObj and ReadObj, both taking a variable parameter of type text.

Deferred classes

Classes can be declared before they're defined via [abstract|property] class .. end;.

Class views

Class views specify which methods can be visible to whom. It's used instead of the public, private, and protected sections of a class. They are declared via view of classname(inheritance-list).

Null

OOE specifies Null to be used with classes like nil is for pointers.

Changes to modules

Modules can export and rename classes and class members, make certain members protected, etc. It's expected that this expanded use of export will be generalized in future revisions of Extended Pascal. OOE also suggests that Extended Pascal be changed to allow parameter lists to be repeated in implementation modules so that function overloading will be possible.

Non-normative enhancements

Generic types

These weren't included in the normative specification because of their complexity, but their implementation is recommended. Generics in OOE are defined as being an application of schemata with the discriminant's type having the syntax type (type-list). These generic types would include generic classes.

Exception handling

This and the related procedure Assert are mentioned, but no mechanism for using them is defined.

Procedural variables

This is discussed and dismissed. Free Pascal of course already supports procedural variables.

Default parameters

The value keyword is extended to include default parameters.

Set extensions

set of class

Overloading methods

This would go naturally with the suggested module extensions.

Persistent objects, object evolution, object roles

These aren't included in the specification due to their dubious usefulness.

Access abstraction

A mechanism for this isn't specified.

Operator overloading and definition

Overloading existing operators or creating new ones is deemed useful, but there's no specified mechanism. Free Pascal supports PXSC-style operator overloading, but not operator definition. GNU Pascal permits defining new operators through operator overloading.


From the Free Pascal wiki, page "Object-Oriented Extensions to 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.

Revision 1, last changed by WikiArchive .