IP Pascal

Uses your system voice; voice and rate in settings.

Snapshot

≈ 10 min read

Names in other languages

No names in other languages are held for this entry yet.

Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.

IP Pascal is an implementation of the Pascal programming language using the IP portability platform, a multiple machine, operating system and language implementation system. It implements the language "Pascaline" (named after Blaise Pascal's calculator), and has passed the Pascal Validation Suite. This article follows a fairly old version of Pascaline. A newer version of Pascaline exists as Pascal-P6, part of the Pascal-P series. See the references below.

IP Pascal is an implementation of the Pascal programming language using the IP portability platform, a multiple machine, operating system and language implementation system. It implements the language "Pascaline" (named after Blaise Pascal's calculator), and has passed the Pascal Validation Suite. This article follows a fairly old version of Pascaline. A newer version of Pascaline exists as Pascal-P6, part of the Pascal-P series. See the references below. const one = 1; type string = packed array of char; procedure s: string); private var s: string; procedure s: string); var i: integer; begin for i := 1 to max(s) do write(s[i]) end; begin { initialize monitor } end; begin { shutdown monitor } end. Modules have entry and exit sections. Declarations in modules form their own interface specifications, and it is not necessary to have both interface and implementation sections. If a separate interface declaration file is needed, it is created by stripping the code out of a module and creating a "skeleton" of the module. This is typically done only if the object for a module is to be sent out without the source. Modules must occupy a single file, and modules reference other modules via a uses or joins statement. To allow this, a module must bear the same name as its file name. The uses statement indicates that the referenced module will have its global declarations merged with the referencing module, and any name conflicts that result will cause an error. The joins statement will cause the referenced module to be accessible via the referencing module, but does not merge the name spaces of the two modules. Instead, the referencing module must use a so-called "qualified identifier": A program from ISO 7185 Pascal is directly analogous to a module, and is effectively a module without an exit section. Because all modules in the system are "daisy chained" such that each are executed in order, a program assumes "command" of the program simply because it does not exit its initialization until its full function is complete, unlike a module which does. In fact, it is possible to have multiple program sections, which would execute in sequence. A process module, like a program module, has only an initialization section, and runs its start, full function and completion in that section. However, it gets its own thread for execution aside from the main thread that runs program modules. As such, it can only call monitor and share modules. A monitor is a module that includes task locking on each call to an externally accessible procedure or function, and implements communication between tasks by semaphores. A share module, because it has no global data at all, can be used by any other module in the system, and is used to place library code in. Because the module system directly implements multitasking/multithreading using the Monitor concept, it solves the majority of multithreading access problems. Data for a module is bound to the code with mutexes or Mutually Exclusive Sections. Subtasks/subthreads are started transparently with the process module. Multiple subtasks/subthreads can access monitors or share modules. A share module is a module without data, which does not need the locking mechanisms of a monitor. type string = packed array of char; var s: string; procedure s: string); var i: integer; begin for i := 1 to max(s) do write(s[i]) end; begin , 12); s := 'Hello, world'; end. Such "container" arrays can be any number of dimensions. const b = a+10; a := 1234_5678; The '_' (break) character can be included anywhere in a number except for the first digit. It is ignored, and serves only to separate digits in the number. const str = 'the rain in Spain\cr\lf'; Using standard ISO 8859-1 mnemonics. program extfile(output); var f: file of integer; begin assign(f, 'myfile'); { set name of external file } update(f); { keep existing file, and set to write mode } position(f, length(f)); { position to end of file to append to it } writeln('The end of the file is: ', location(f)); { tell user location of new element } write(f, 54321); { write new last element } close(f) { close the file } end. fixed table: array [1..5] of record a: integer; packed array [1..10] of char end = array record 1, 'data1 ' end, record 2, 'data2 ' end, record 3, 'data3 ' end, record 4, 'data4 ' end, record 5, 'data5 ' end end; a := a and b; b := b or $a5; a := not b; b := a xor b end. xx:= 1 end; Overload "groups" allow a series of procedures and/or functions to be placed under the same name and accessed by their formal parameter or usage "signature". Unlike other languages that implement the concept, Pascaline will not accept overloads as belonging to the same group unless they are not ambiguous with each other. This means that there is no "priority" of overloads, nor any question as to which routine of an overload group will be executed for any given actual reference. type alpha_ref = reference to alpha; var a, b: integer; next: alpha_ref; virtual procedure : integer); begin aa:= d; selfl:= next end; private var q: integer; begin end. var r: alpha_ref; begin new(r); ... if r is alpha then r.a := 1; r.x(5); ... end. In Pascaline, classes are a dynamic instance of a module (and modules are a static instance of a class). Classes are a code construct (not a type) that exists between modules and procedures and functions. Because a class is a module, it can define any code construct, such as constants, types, variables, fixed, procedures and functions (which become "methods"), and make them public to clients of the class, or hide them with the "private" keyword. Since a class is a module, it can be accessed via a qualified identifier. Classes as modules have automatic access to their namespace as found in C# and C++ in that they do not require any qualification. Outside of the class, all members of the class can be accessed either by qualified identifier or by a reference. A reference is a pointer to the object that is created according to the class. Any number of instances of a class, known as "objects" can be created with the new() statement, and removed with the dispose() statement. Class members that have instance data associated with them, such as variables (or fields) and methods must be accessed via a reference. A reference is a type, and resembles a pointer, including the ability to have the value nil, and checking for equality with other reference types. It is not required to qualify the pointer access with "^". Pascaline implements the concept of "reference grace" to allow a reference to access any part of the object regardless of whether or not it is per-instance. This characteristic allows class members to be "promoted", that is moved from constants to variables, and then to "properties" (which are class fields whose read and write access are provided by "get" and "set" methods). Both overloads and overrides are provided for and object's methods. A method that will be overridden must be indicated as virtual. Object methods can change the reference used to access them with the self keyword. Single inheritance only is implemented. program hello(input, output); uses gralib; var er: evtrec; begin bcolor(output, green); curvis(output, false); auto(output, false); page(output); fcolor(output, red); frect(output, 50, 50, maxxg(output)-50, maxyg(output)-50); fcolorg(output, maxint, maxint-(maxint div 3), maxint-maxint div 3); frect(output, 50, 50, 53, maxyg(output)-50); frect(output, 50, 50, maxxg(output)-50, 53); fcolorg(output, maxint div 2, 0, 0); frect(output, 52, maxyg(output)-53, maxxg(output)-50, maxyg(output)-50); frect(output, maxxg(output)-53, 52, maxxg(output)-50, maxyg(output)-50); font(output, font_sign); fontsiz(output, 100); binvis(output); fcolor(output, cyan); cursorg(output, maxxg(output) div 2-strsiz(output, 'hello, world') div 2+3, maxyg(output) div 2-100 div 2+3); writeln('hello, world'); fcolor(output, blue); cursorg(output, maxxg(output) div 2-strsiz(output, 'hello, world') div 2, maxyg(output) div 2-100 div 2); writeln('hello, world'); repeat event(input, er) until er.etype = etterm end. Because IP Pascal modules can "override" each other, a graphical extension module (or any other type of module) can override the standard I/O calls implemented in a module below it. Thus, paslib implements standard Pascal statements such as read, write, and other support services. overrides these services and redirects all standard Pascal I/O to graphical windows. The difference between this and such libraries in other implementations is that you typically have to stop using the standard I/O statements and switch to a completely different set of calls and paradigms. This means that you cannot "bring forward" programs implemented with the serial I/O paradigm to graphical systems. Another important difference with IP Pascal is that it uses procedural language methods to access the Windowed graphics library. Most graphics toolkits force the use of object-oriented programming methods to the toolkit. One reason for this is because object oriented programming is a good match for graphics, but it also occurs because common systems such as Windows force the application program to appear as a service program to the operating system, appearing as a collection of functions called by the operating system, instead of having the program control its own execution and call the operating system. This is commonly known as callback design. Object-oriented code often works better with callbacks because it permits an object's methods to be called as callbacks, instead of a programmer having to register several pointers to functions to event handling code, each of which would be an individual callback. IP Pascal makes object-oriented programming an optional, not required, methodology to write programs. IP Pascal's ability to use procedural methods to access all graphics functions means that there is no "cliff effect" for older programs. They don't need to be rewritten just to take advantage of modern programming environments. The IP porting platform supports a character mode, even in graphical environments, by providing a "character grid" that overlays the pixel grid. Programs that use only character mode calls (that would work on any terminal or telnet connection) work under graphical environments automatically.

Text derived from https://en.wikipedia.org/w/index.php?oldid=1333454690 under CC BY-SA 4.0; modifications have been made.

Sources cited in this revision

2 named source(s) extracted from the cited revision. A source with no author is shown by its publication; nothing is invented.