[fpc-pascal] reference model for class instances

spir denis.spir at gmail.com
Wed Jun 16 15:04:55 CEST 2010


Hello,

After having read the draft standard proposel for OO extensions for Pascal, esp. the Object Model (http://www.pascal-central.com/OOE-stds.html#sect-6.5.1), I wonder how implicite (de)referencing of class instances is actually implemented in fpc (Delphi-like OO).
In particuliar, when is (a ref to) an instance dereferenced, or not?

It seems to me the only case dereferencing does _not_ occur is direct assignement between 2 object variables:
    obj2 := obj1;
including implicite assignment of a parameter:
    doSomething(obj);

If I'm right, in all other cases deferencing must occur to access the object's actual data:
    obj.m(arg);
    x := obj.m(arg);
    obj.p := x;
    x := obj.p;
    x := 1 + f(obj.p+1, 1);
(Note: deferencing also happens on left side of ':=', since p & m are attributes of the references's target, not of the reference itself. Translating the statements to explicite dereferencing using '^' makes this clear.)

Am I right on this?
How does this happen, concretely?


Denis
________________________________

vit esse estrany ☣

spir.wikidot.com



More information about the fpc-pascal mailing list