The language pascaline - Moorecadcom

By Benjamin Martinez,2014-01-29 06:41
13 views 0
The language pascaline - Moorecadcomthe,THE,The






    "Standards are great. Everyone should have one of their own" - Anon.

    Pascaline is a formal statement of a language that was created over the period 1993 to 2008 in a series of extensions to ISO 7185 Pascal. The name "Pascaline" was chosen both to show that the language is designed to be %100 compatible with the original language, and to continue the language Pascal’s tribute to Blaise Pascal. The Pascaline being Pascal’s calculator, Pascaline the language is "The machine Pascal built", or the "Machine that runs Pascal".

    In 2008, there are several defacto standards for an extended Pascal, and one official one, the ISO 10206 standard. I have been dissatisfied with these existing extensions for the simple reason that instead of extending Pascal, they are more akin to redesigns of the language. In particular, the addition of the ability to coin pointer addresses to any variable and perform "type escapes" at will remove at a stroke all of the type security Niklaus Wirth designed into Pascal. I think a good definition of what I mean by "redesign" would be the introduction of a feature that is designed to replace or duplicate a construct of original Pascal.

    At the same time, I wanted Pascaline to achieve a level of completeness that the language never achieved in its original form. My goal was not to create an instructional language, but a complete and practical implementation that could address current problems in computing without further extensions or special support packages.

    To design Pascaline I have enumerated a set of goals for the language design:

    To be completely upward and downward compatible with ISO 7185 Pascal.

    To be a "logical extension" of original Pascal. That is, to extend Pascal using the same working

    theories and means as the original language, and poses no element that does not interoperate

    completely with the original language.

    To provide a reasonable upgrade to the language capability, that can be implemented using an

    existing standard compiler with minor effort compared to the original implementation of the


    To implement only features that could be implemented efficiently using existing computing


    Pascaline was designed in a series of steps starting in 1993. For each feature, one or more proposals were made. Then, the proposals were evaluated, a winner chosen, and a test implementation in the compiler was made. Then, any adjustments required by the experience of actual use were performed. Every element in Pascaline is backed by a real implementation that is efficient and tested.As for most modern languages, the major theme of Pascaline is for extending the language via libraries, objects and code reuse. Pascaline will, and should, "obsolete itself" by allowing user written extensions to such a point that the major thrust of development with the language would become that of developing libraries of functions to cover new areas in computer applications.


    This very ability to extend the language also forms the basis of a new problem in standard implementation that, although it has existed from the time Pascal was originally designed in the 1970s, has become ever more pressing. That is the definition of standard libraries and platforms. Towards this end, the Pascaline standard, as in the standard for most of today’s languages, is divided into the base standard and a "platform", consisting of a series of libraries that handle common I/O and support problems in a machine and system independent way.

    These libraries are attached here as annexes. There is also a series of annexes covering issues such as character handling, string escapes and other "recommended practices" for Pascaline. The result should greatly aid the ability to write non-trivial Pascaline programs that are truly portable across machines, systems and implementations.

    The second, but no less important theme in Pascaline, is parallel language execution. Pascaline is a thoroughly parallel language, and completes the idea that strong type security is a fundamental building block to parallel language implementation. Indeed, Pascaline now exists as one of the only languages that offers parallel execution security in a language, instead of being added in as a library with security left to the user.

    As I have offered in the past for Pascal, I extend the offer now, that I will evaluate Pascaline implementations for conformance to the Pascaline standard, no matter what the purpose of that implementation, public or private, profit or nonprofit. I only make the conditions that my access to the implementation be reasonable, that the authors provide me with a list of annexes that are complied with, and that an option exists in the implementation to enforce strict compliance with Pascaline regardless of any other extensions that might be present over and above Pascaline. This last is the same requirement that the ISO 7185 Pascal standard states.

    This author further respectfully requests that the name "Pascaline" be applied only to an implementation that has been found to comply with the language specification here, and by the tests I provide free of charge or restriction. Further, unlike the ISO 7185 standard, I ask that no exceptions be allowed for the language (ISO 7185 5.1). A language may well comply with part of this specification, and be called a Pascal, or some other name. I only ask that it not be called "Pascaline" unless it can process the full language, aside from the annexes, without exception.

    Scott A. Moore

    July, 2008


2Summary of Pascaline extensions to Pascal

    Pascal defined a program as a series of nested blocks, one inside the other. The most basic block was the program block, which could contain any nested series of procedure and function blocks. Each block can contain a series of declarations containing labels, constants, types, variables, procedures and functions. Each block contains the code that executes the algorithms contained in the block.

    The blocks of Pascal define a closed collection of these declarations with an interface that consists of a parameter list. In Pascaline terminology, this is a "top" interface, as the block communicates with the outside of the block via an interface at the "top" of the block:

     +-----<> Parameter list



    | |

    | Block |

    | |


    In Pascaline, each block can also interface, informally, with declarations in the surrounding block. This is referred to in Pascaline terminology as the "side" interface:


    | |

    | Surrounding block |

    | |

    | --------- |

    | | | ---< Variable declarations |

    | | Block | ---< Procedures |

    | | | ---< ... |

    | --------- |

    | |



    Each block can import declarations from the surrounding block.

    Pascal envisioned a program as a tower of blocks resting one atop the other. This paradigm is a good one, but views the program as a monolithic whole. The provision of fixed types without the ability to extend them with change also contributes to the model of a program created as a static structure of code.Pascaline's main thrust is to add extensibility to Pascal, and this is done by greatly augmenting the methods to create side blocks. Pascaline views programs as a series of adjoining tiles:--------- ---------

    | | ---<> Variable declarations <>--- | |

    | Block | ---<> Procedures <>--- | Block |

    | | ---<> ... <>--- | |

    --------- ---------

    In Pascaline, the program block is such an adjoining block, and adds several other block types that have this ability to export their declarations directly to other blocks. The primary of these is the module, which has all the powers of a program block, but adds the ability to specify both code that executes when the program starts, and code that executes when the program ends. In this way, modules appear as "service blocks" whose point is to provide constants, types, variables, procedures and functions to the program, along with a method both to set up such items as well as shut them down.

    The program and module blocks form a group executing the same thread of execution for a program. Another module is the process, which defines a new thread of execution aside from the main program. Process modules cannot directly access program or module blocks, but the two can communicate via a monitor or channel block, which automatically implements the multitasking primitives needed to coordinate such an exchange. A share block gives a way to define constants, types, procedures and functions that are usable by any task without the overhead of multitask coordination.Pascaline also defines a new level of block that is an intermediate between a so-called "global" block such as a program, module, monitor, channel, etc. Those blocks are static, with variables that are allocated for the duration of the program. This is a natural outermost block, since any program ultimately is rooted in such program constructs. The class block fits between the level of global blocks and procedure and function blocks. A class block has the ability to share its declarations via the "side", but also can have its variables created dynamically, or as part of the local variables in a block. Further, classes have the ability to be extended to any level. Any new class has the ability to be based on a previously defined class, and to have that class accepted as compatible with the base class.Because classes define both declarations such as constants and types that have no allocation, as well as variables that do, the class must be instantiated either as part of the variable data, or via a reference. Any


    number of instances of a class may exist associated with such references. The instance of a class is called an object, and it is the set of the data associated with a class. The class contains the declaration of the format of the object it creates, and thus it is a "class" or "kind" for all of the objects created using it.Because a class defines both a series of constants, types, variables, and also procedures and functions that can operate on those declarations, which are known as "methods", An object forms an instance of a module. Classes complete the idea of "object orientation" which dictates that data exists as paired with the procedures or functions that form its methods, needed to manipulate that data. Because classes that inherit from each other also have references that are compatible, classes can extend each other to any number of levels to implement program concepts.

    As a dynamic corollary to a module, classes also can have a separate thread of execution as a thread class, and perform as a tasking communications block as an atom or liaison class.

    To allow the static idea of parameter lists in Pascal to be extended, Pascaline implements the "overload" concept. Procedures, functions and methods can form "groups" under the same name that are differentiated by kind, type and number such that calls to such procedures and functions are sent to the instance that has the correct interface to operate on them. Built in expression operators can be overloaded, thus completing a full circle of data abstraction.

    The concept of extendibility is further enhanced by the ability to override existing procedures, functions and methods. New modules and classes can override the previous meaning of them, and also extend them by performing new operations and calling the original definitions.

    Pascaline has "container" types for arrays that do not specify an exact size. These types can be used to form a template to create such arrays of a runtime determined size at runtime. This allows procedures and functions to accept arbitrarily sized arrays to any dimension, and allows such arrays to be dynamically created as variables and pointer types as well.

    The common case of an integer indexed array can be specified by a short form, which also underscores the idea of container types.

    Pascaline introduces the break character, "_", for both identifiers and numbers. This aids readability for long identifiers and numbers.

    Goto labels are freed from the restriction that they must appear as numbers, and can assume the same form as an identifier. Goto labels both retain their status as an interprocedure deep nested branching, but also allow for intermodular branching via a procedure or function call.

    Pascaline implements the method of structured exception handling to handle deep nested returns. This allows code to be written that delivers exceptions to higher level code without needing knowledge of the surrounding code. This further enhances extendibility, and allows for complete replacement of “goto”s.Constant expressions can be used wherever constants were used in Pascal. This makes it possible to use formulas for these constants instead of precalculated numbers.

    Boolean operations on integers are permitted, and a new operator, "xor", is implemented for both boolean and integer operands.


    For procedures, functions and methods, a new parameter "mode" is implemented, the "view" mode. This is identical to value parameter semantics, except that the parameter is protected from all modification. This makes certain compiler optimizations possible.

    Case statements now have an "else" clause, and ranges of case constants are possible.Case variant declarations can also use ranges of case constants.

    Write/writeln can specify left justified fields, and a special mode allows the output of right padded strings in their natural length.

    Read/readln can specify fields on read variables, and can specify literal strings to be matched to the input. A special mode allows the input of right padded strings in their natural length.A new declaration exists, "fixed", which can be used anywhere a variable can, but cannot be modified. This allows the compile time specification of fixed tables, and ameliorates the need to create blocks of assignments at the start of a program.

    Pascaline introduces a limited type conversion/restriction operation to convert between scalar types. This relieves the need to produce special handling to convert enumerated types to integer. It also introduces the ability to directly specify the precision needed within integer expressions, instead of always promoting such operations to the full size of integer. This allows more efficient numeric processing on small word size processors and arbitrary word length processors.

    Pascaline standardizes a series of procedures and functions for files, such as binding to external file names, opening and closing a series of files, indexing within files, finding the length of a file, updating existing files, and appending to the end of such files, checking the existence of a file, and deleting and changing the name of a file.

    A few new standard header parameters are introduced, including an error output, a list (or print) output, and a command line or file input.

    The strict order of declarations from Pascal is relaxed in Pascaline. label, const, type, var and fixed declarations can occur in any order. This aids in the modular structure of Pascaline.When a forwarded procedure, function or method appears as the actual declaration, the parameter list can be repeated. It is checked for congruence with the original. This allows such declarations to be created by cut and paste, and is more readable than the original method of having the actual declarations far from their forwarded declarations.

    Procedures and functions can be declared as static, or non-recursive. This allows the creation of more efficient code on some processors.

    Asserts are implemented, allowing the incorporation of runtime checks for code being debugged that can be removed without modifying the source.

    Pascaline allows "subrange" types to be created that are larger than the natural Pascal range of an integer (-maxint..maxint). This allows an implementation to implement types that utilize double more precision while taking longer to perform them, so called "extended range" types. It also implements a set of predefined types that give an implementation defined set of unsigned and signed extended range types.


There is a predefined constant for the maximum character value in an implementation.

Matrix mathematics is supported with one dimensional and two dimensional arrays.

    A way to specify a function result that obeys the rule of single entry/single exit with the result formed at the end. This is also required for operator overloads.

    Function results are extended to allow most types, including structured, to be returned as a result.Properties specify a program object that appears as a variable, but has its read and write actions completely program defined. Properties are also a building block to advanced multitasking structures.Besides the extensions to the base Pascal language, Pascaline defines a set of optional extension modules that define the Pascaline "platform". This is a nod to the fact that the set of support calls for an implementation make as much difference to portability for a program as the base language does.


3EBNF and syntax used in this document

    For the purpose of describing syntax elements of Pascaline, the EBNF or Extended Backus-Naur Format as used in the ISO 7185 standard is used. The syntax that appears here consists of the syntax elements from the ISO 7185 standard as modified for Pascaline use.

    name = syntax-description .

    Describes the syntax expansion of the syntax element by name of "name", which is terminated by '.'.

     a | b

    Either construct a or constructor b may appear, but not both.

    { a }

    Construct a is repeated 0 or more times.

    [ a ]

    Construct a is repeated 0 or 1 times (it is optional).


    The characters "abc" appear literally.

    ( a b )

    The elements a and b are grouped together.

    The syntax expansions that appear in this document mirror the same by name in the ISO 7185 document. If a syntax element by name matches a name used in the document, and is different from the one contained there, then it represents a Pascaline extension to ISO 7185 Pascal, and replaces the original syntax definition.

    Note the ISO 7185 use of ">" or "alternate" is not used here, because Pascaline does not use the "level 1" extensions of ISO 7185. The syntax for the level 1 extensions was removed.

    Annex A contains a full syntax for Pascaline.


4Relationship to ISO 7185

    4.1Pascaline as a series of extensions

    The Pascaline standard accepts the entire language defined in the standard defined in ISO 7185 such that the set of features defined by Pascaline qualify as extensions under ISO 7185 3.2 “Extension”.4.2Additional reserved word-symbols

    As allowed in ISO 7185 “extension”, the following additional spellings of identifiers are prohibited because of their use as word-symbols in the Pascaline standard:








    These word-symbols are all new word-symbols defined by Pascaline. The fact that certain identifiers are prohibited in Pascal may cause ISO 7185 compliant programs to fail to compile for this reason. To use a Pascaline implementation for such programs, one of two methods are used:

    1.The ISO 7185 compliance switch is enabled (see ISO 7185 5.1 “Processors” note 2).

    2.The identifiers in the program that overlap the above list are changed.

    4.3Character escapes

    Annex L “Character Escapes”, if implemented by the target system, can affect the behavior of character strings in an ISO 7185 implementation. Although ISO 7185 does not specify the character set or contents of strings in a complying program, it is reasonable for a given program to assume that all visible characters are treated equally.

    If the program contains the character ‘\’, the escape sequence introduction character, this will be treated differently than other characters. To use a Pascaline implementation that implements Annex L for such programs, one of three methods are used:

    1.The ISO 7185 compliance switch is enabled (see ISO 7185 5.1 “Processors” note 2).

    2.A switch that enables or disables character escapes is set to disable.

    3.All instances of ‘\’ within character strings are changed to ‘\\’.


Report this document

For any questions or suggestions please email