Contents | Prev | Next | Index
The design goal of Canterbury Pascal is to develop software for Java in the Pascal programming language. The programmer can use any existing Java class or create new classes for Java. Canterbury Pascal can be used for creating Java applets which are run in Internet browser based environments. Canterbury Pascal is also suitable for creating simple Java applications using standard stream input and output, text and file I/O as well as string handling. The language grammar is a large subset of Borland Object Pascal (Delphi 2). Canterbury Pascal has been neither designed nor tested with a view of other Pascal dialects such as ISO Pascal. The decision to go with an Object Pascal language rather than following other Pascal dialects was mainly made for two reasons: 1) The Object Pascal dialect is the most commonly used one by Pascal programmers. 2) The Object Pascal dialect offers object oriented language constructs which are very useful and often needed for developing Java classes.
The following list focuses on the main differences between the Borland Object Pascal language (as used in Delphi 2) and Canterbury Pascal for JVM.
- Vocabulary and Representation
INLINE and NIL are only standard identifiers, not reserved words. The INLINE procedure offers low-level Java source code insertion into Pascal statements.- Vocabulary and Representation
The following identifiers are neither standard directives nor reserved words, they do not have any predefined meaning in Canterbury Pascal (except for READ and WRITE which are standard procedure identifiers):
ABSOLUTE, DEFAULT, DISPID, EXPORT, FAR, MESSAGE, NEAR, NODEFAULT, READ, STORED, WRITE.- Typed Constants
Typed constant can be record constants, array constants or primary constant expressions only. Address or procedural constants other than NIL are not allowed.- Basic Types
CHAR is 2 bytes wide because of Java's UNICODE support. Types Extended, Comp and Currency are not implemented.- String Types
Canterbury Pascal has only one kind of string type which is almost identical in behavior to Borland's WideString type. In particular, it uses 16-bit UNICODE characters. Strings are dynamically allocated and can have up to HIGH(LONGINT) characters. The compiler always maps them to the Java class java.lang.StringBuffer. Unlike Object Pascal, Canterbury Pascal always allocates memory for string types, even for empty strings. It does the memory allocation automatically. A empty string is being regarded as a string with a zero character count. If a string type definition is followed by an explicit size limit, specified in square brackets, then its asignments and value parameters are truncated to that maximum length. String elements are indexed from 1 to the actual length of the string. The string element at index zero cannot be accessed. Expressions like ORD(S[0]) cannot be used for finding the string length. Standard function Length(S) should be used instead.- Array Types
Open arrays can also be defined as part of a pointer base type, in addition to formal parameter types.- Record Types
Record variants are allowed, they are being mapped to separate Java classes. Variants cannot be used for reinterpreting the same data as having a different layout.- Set Types
Set types are limited to 256 elements.
SET OF CHAR is not a legal type because CHAR is 2 bytes wide and has more than 256 possible values. Use SET OF CHR(0)..CHR(255) instead.- Class Types
A class member can be a method or field only. Property members are not implemented in Canterbury Pascal. A class type can also inherit members from foreign Java class interfaces. The ultimate parent class is java.lang.Object. There is no class hierachy based on SYSTEM.TObject or subclasses thereof because the latter are not implemented. Neither Borland nor Object Pascal class libraries are currently implemented in Canterbury Pascal. However, any existing foreign Java classes can be referenced from Canterbury Pascal via direct imports. Thus it is possible to make use of or extend all the available Java features such as graphics, windows, databases, remote classes, FTP, utilities etc.- Class Components
Property members are not supported.- Method Members
The parameter directives REGISTER, PASCAL, CDECL and STDCALL are syntatically supported, but they have no semantic meaning in Canterbury Pascal. This compiler always uses Java conventions for method calls and parameter passing.- Inheritance
The ultimate ancestor class is java.lang.Object. There is no SYSTEM.TObject nor SYSTEM.TClass nor any subclasses thereof.- Member Visibility
Only PUBLIC, PROTECTED and PRIVATE are implemented. PUBLISHED and AUTOMATED are always treated like PUBLIC. The default visibility for class members always is PUBLIC.- Virtual Methods
An inherited virtual method, if redeclared in a descendant class, must be overridden, it cannot be hidden by omitting the OVERRIDE specifier or by using the VIRTUAL specifier again.- Dynamic Methods
Dynamic methods are always treated like virtual methods. Both use the same virtual Java method resolution for method calls.- Constructors
Canterbury Pascal makes no distinction between virtual and static constructors. They are always mapped to Java constructors. No two constructors for a given class can have the same formal parameter lists. Direct and inherited constructor calls are only allowed as the first statement in another constructor body. Constructors can be called like functions via class references only, not via object references, returning new instances of a class.- Destructors
Destructors are obsolete in most cases because Java has an automatic garbage collection for unsued memory blocks. Destructors are always mapped to Java-virtual methods.- Class Reference Type
Borland Object Pascal implements class reference types in a different way, with metaclasses based on SYSTEM.TClass. Canterbury Pascal metaclasses are always mapped to java.lang.Class. Borland Object Pascal implements class methods as members of its metaclass, while Canterbury Pascal always maps them to Java-static members of the class itself.- Class Methods
Canterbury Pascal always maps class methods to Java-static methods. Notice, that this approach is different from Borland Pascal, where class methods are treated like members of a metaclass.- Pointer Types
Pointers to non-structured types, such as basic types, enumerations or subranges, are not supported, because the corresponding Java references are only possible for structured types.- Procedure Types
Neither method pointers nor the optional specification of a calling convention is supported for procedural type declarations.- Address Operator
The address operator always results in an expression of type POINTER, which is compatible with any other pointers. Address of a variable is only possible if the variable is of a structured type.- Procedural Expressions
The right side procedural variable or the right side procedure or function designator always has to be preceded by an address operator in order to get its procedure or function pointer value.- Typecasting
If typecasting involves structured types such as records, arrays, set types, or file types, or if it involves pointers, then typecasting in this compiler becomes subject to Java's typecast runtime checking. Also, typecasting structured types or pointers thereof are subject to very strict compile time checks. Because of Java typecasting between unrelated types is usually not possible.- Procedure Calls
Function identifiers may always be used in proper procedure calls, too, by ignoring the function return value.- Exception Handling
Exception classes are all derived from Java's java.lang.Exception or java.lang.Error classes.- Procedure Declarations
REGISTER, PASCAL, CDECL, STDCALL, and EXTERNAL directives are not supported. Procedures always use Java conventions for calls and parameter passing.- Formal Parameters
Untyped CONST parameters and open arrays thereof are not allowed.- Standard Procedures and Standard Functions
The following standard procedures are obsolete or not implemented:
- FreeMem
- GetMem
- Finalize
- ChDir
- AddExitProc
- Swap
- Ole string support routines
- Assigned
- Ptr
- Slice
- SeekEof
- SeekEoln
- SetTextBuf
- Thread support routines
- Typeinfo
- UniqueString
- Variant support routines
- Wide character support routines
- Direct Java Class Imports
Not supported in Borland Object Pascal.- Compiler Directives
Comment embedded compiler directives for Canterbury Pascal start with a @ instead of $ sign. Borland compatible directives starting with a $ sign are scanned, but not processed, except for the {$I+} or {$I-} for I/O checking.
Contents | Prev | Next | Index
Canterbury Pascal for JVM (Last documentation update
Sep 02, 2004)
Copyright © 1999-2004 J.Neuhoff - mhccorp.com
. All rights reserved.
Please send any comments or corrections to
neuhoff@mhccorp.com