Component Pascal

Component Pascal is a free since 2004, developed since 1990, imperative, modular, object - and component-oriented programming language developed by Oberon microsystems, component-based development system BlackBox Component Builder. There are now under the name Gardens Point Component Pascal also versions that are running under. NET and the Java Virtual Machine.

Component Pascal has been developed from the Oberon programming language and changed its name in the publication in 1994 under the name Oberon / L. The associated framework was called Oberon / F. With the release of 1.3 ( which was released about the year 1996/1997) was obtained from the Oberon language / L Component Pascal and from the framework Oberon / F of BlackBox Component Builder.

  • 3.2.1 The program addition calculator in Component Pascal Example 1

Properties

Component Pascal has a very short and simple description language with a fully structured syntax. It allows static types and objects as well as dynamic types, and dynamic binding. There is a very strongly typed and type-safe programming language, as long as the SYSTEM module is not explicitly imported, which is usually provided only for system programming, and is therefore easily portable. Inheritance is anchored in the programming language, but not multiple inheritance in order to avoid additional burden on the compiler and to make the language semantics as clearly as possible.

Component Pascal also supports runtime garbage collection and the dynamic loading and unloading of modules respectively components.

Moreover allowed Component Pascal assertions, generic programming and the overwriting of data types and thus methods (so-called type-bound procedures). For the purposes of simplicity and clarity of the source code, however, the operator overloading or methods is not possible.

Areas of application

Component Pascal is characterized by its low demands on the hardware, high stability, simplicity and speed in both the runtime as well as in software development. It is used mainly for scientific and technical applications in teaching and research, but also for commercial applications.

Programs

Hello World

The Hello World program in Component Pascal Example 1

In the Hello World module the ( parameterless ) command output is defined. The asterisk ( *) after the procedure name defined to export the procedure output, so that it can be referenced from outside the module using the syntax HalloWelt.Output. The following code shows a simple program that the message Hello world! followed by a newline outputs:

MODULE Hello world; IMPORT Out; PROCEDURE output *; BEGIN     Out.Open;     Out.String ( "Hello World! ");     Out.Ln; END Output; END Hello world. The Hello World program in Component Pascal Example 2

In the module HalloWelt2 define a variable that is output later in a dialog box. The asterisk ( *) after the procedure name defined to export the procedure output, so that it can be referenced from outside the module using the syntax HalloWelt.Output. The following code shows a simple program that the message Hello world! outputs in a dialog box, on the "IMPORT dialogue; " was imported. Among others, are in the dialog box all output variables marked with a *. With "VAR output *: ARRAY 50 OF CHAR " is determined that a " VAR" variable " output " should be created, which is visible in the dialog first ( "*") and 2 consists of a string of 50 characters ( ARRAY 50 OF CHAR ) The line " Dialog.UpdateString ( output); " is arranged so that the contents of the variable " output " is assigned to the dialog box and is displayed immediately. :

MODULE HalloWelt2;   IMPORT dialogue;   VAR output *: ARRAY 50 OF CHAR;   PROCEDURE output *;   BEGIN     output: = " Hello world!";     Dialog.UpdateString ( output);   END Output; END HalloWelt2. computer

The program addition calculator in Component Pascal Example 1

MODULE Kurs10Rechner; IMPORT dialogue; VAR * num1, num2 *, * result, rest *: INTEGER;    PROCEDURE add *;    BEGIN       result: = ( num1 num2 );       Dialog.UpdateInt ( result);    END add; END Kurs10Rechner. Examples of the implementation of inheritance

The implementation of inherited structures has been somewhat simplified in Component Pascal over its predecessor and Oberon structured more clearly and more secure. The comments between " ( *" and "*)" are illustrative and are ignored by the compiler. Examples:

MODULE Vererbung1; TYPE (* type definitions *)     Graphical object * = POINTER TO RECORD ABSTRACT color *: INTEGER; END;     Point * = POINTER TO RECORD (graphical object) x *, y *: INTEGER; END;     Line * = POINTER TO RECORD (graphical object) Xstart *, yStart *, * xEnde, Yende *: INTEGER; END; VAR ( * Variable definitions *)     point1: Point;     Line 1: Line; PROCEDURE ( g: Graphics object ) Draw * (), NEW, EXTENSIBLE; BEGIN     (* Empty, extensible method * ) END Draw; PROCEDURE ( point: Point ) Draw * (); BEGIN     (* ... *) END Draw; PROCEDURE ( line: line ) Draw * (); BEGIN     (* ... *) END Draw; BEGIN     NEW ( point1 );     punkt1.farbe: = 0FFH; (* Object color is set to 0FF (hexadecimal ) *)     punkt1.x: = 1;     punkt1.y: = 1;     punkt1.Zeichne ();     NEW ( line1 );     linie1.farbe: = 07FH; (* Object color is set to 07F ( hex) *)     linie1.xStart: = 1;     linie1.yStart: = 1;     linie1.xEnde: = 2;     linie1.yEnde: = 2;     linie1.Zeichne (); END Vererbung1. Attributes that have only read access, (methods) can be changed by type-bound procedures. The corresponding export identifier that can only be read outside the object's own methods, not by "*", but marked by "- ". example:

MODULE Vererbung2; TYPE     Object * = POINTER TO RECORD x: INTEGER; END; VAR     object1: Object;     int: INTEGER; PROCEDURE (object: Object ) SetzeX * (value: INTEGER ), NEW; BEGIN     objekt.x: = value; END SetzeX; BEGIN     NEW ( object1 );     ( * Comment: The statement objekt1.x: = 1 is not possible *)     objekt1.SetzeX (1);     int: = objekt1.x END Vererbung2. literature

  • Karl Heinz Hug: modules, classes, contracts. A textbook for component-oriented software construction with Component Pascal, Vieweg Publishing Company, 2001
  • Markus Bautsch: Cycles of software Crises in: ENISA Quarterly on Secure Software Guide (PDF file, 2 MB)
199298
de