Object Pascal For The Macintosh
Object Pascal For The Macintosh
Macintosh · PDF
| Filename | Object_Pascal_For_The_Macintosh_19850214.pdf |
|---|---|
| Size | 0.81 MB |
| Subsection | developer / MacApp |
| Downloads | 0 |
Contents
Object Pascal
For. the Macintosh
Larry Tesler
February 14, 1985
lntroduction
The specification of the. language Object Pascal appears in theObject Pascal Report,
~ttached. The present memo specifies differences between the current Macintosh
imp_lementation änd the specification. In cases noted as "temporary deviations", we
intend to bring the implementation into conformance shortly.
Multi-Level "inherited"
According to the standard, the statement "inherited Draw" activates a method of the
immediate ancestor of the type whose method contains the statement. In the
Macintosh versicin~ if a more remote ancestral type, T, has a different implementation
of the same method, then that method can be invoked by T. Draw. This feature is rarely
used.
Object Type Declaratlons
According to the standard. an obj~ct type declaration may appear in a main program,
in the interfäce of ä unit, or in_ the implementation of a unit. In the Macintosh version, it
can_.on,fy appear.in fhe interface of a unit. Method declarations can only appear in the
i~plementation of ttie same untt. These d~viations are temporary.
· ··. According·to the standard; it i·s an error if a method is declared override in the type
·dectaration and then not implemented, or if an override method is implemented but not
decfared override. In the Macintosh Version, the compiler does not check for these
errors. This is a temporary deviation.
Aqcording to the standard, the oame of a method in a method header is qualified by
· the type name when the method body is introduced but not in the type declaration. In
the Macintosh version, qualification is permitted in the type declaration.
Range Checklng
Accordi.ng·to the standard, it is an error to coerce a value to an object type if it is not in
the domain ofthat type.· In the Macintosh version, if and only if the compiler switch
{$R+} is in effect, the compiler generates code to test the validity of object-type
coercions.
Object Pascal for the Macintosh
Page
2
Unsafe Use of Handles
According to the standard, the implementation of a reference is not specified, and may
be machine dependent. In the Macintosh version, an object reference is implemented
as a handle, i.e., as a pointer to a pointer to an object. The object itself can change its
memory address during execution as part of a compaction process that is invoked to
prevent heap fragmentation.
Because an object can change its location, it is unsafe to save a pointer to it in a
variable or register and then later to access the object through the saved pointer. lf a
procedure call should intervene, then the heap might compact to make room for a
newly allocated object or to swap the procedure itself into memory, invalidating the
pointer.
Where possible, the compiler takes care to access objects only through handles
and not through pointers. Examples:
type
T = object
F:
Integer;
S:
String[lO];
end;
var Y:
T;
Y.F := Func;
Proc(Y.F);
with Y do
begin
F := Func;
Proc(F);
F := F + 1;
DrawString(S);
end…
Showing first 3,000 characters of 29,607 total. Open the full document →