Adriaan van Os wrote:
Any comments on http://bugs.freepascal.org/view.php?id=13210 ?
: Compiled with FPC, this produces output "1". This is in accordance : with section 6.8.3.10 of the ISO 7185:1990 Pascal standard, which : states: "The record-variable shall be accessed before the statement : of the with-statement is executed, and that access shall establish a : reference to the variable during the entire execution of the : statement of the with-statement."
Nice to see that the FPC folks actually look as ISO Pascal (other than to bash it). Quite a change since the last time I checked. :-)
: If we do the same with macpas style objects (that are implicit : references), the FPC compiled program outputs "2", where the GPC : and CodeWarrior compiled programs output "1". The FPC output : violates the ISO defined behaviour of the with statement.
The GPC/CodeWarrior behaviour seems logical to me. The Object-Oriented Extensions to Pascal (which AFAIK are quite close to Mac Pascal objects) only mention that "The with statement opens visibility into the visible fields, methods, and destructors of the specified object." (6.8), without going into specifics, so by default the standard ISO Pascal rules would sseem to apply, i.e., to "establish a reference to the variable during the entire execution of the statement of the with-statement".
Note that "variable" in ISO Pascal language also refers to something allocated with "New":
6.6.5.3: "new(p,c1,...,cn) shall create a new variable that is totally-undefined, [...]"
So, if we stick to this rule, not the object-variables (which are implicit references), but the object itself, which is created with "new( p)" is the variable to which a reference for the with-statement is established.
: Jonas Maebe (manager) : : 2009-02-19 21:16 It's because MacPascal-style objects are mapped to : Delphi-style classes by FPC, and Delphi also writes "2" in that : case.
I don't know what Delphi does, and I don't see a reason to do it this way -- even ignoring ISO Pascal, as Borland usually does, the above behaviour would make more sense to me: The "with-element" is evaluated once, for pointers that's clear, so why not for references?
: Classes are very different from records in many ways; e.g., you : cannot just dump the contents of a class to disk and then reread it : during a next execution, as a class also contains hidden pointers : (to the vmt) which may be different during a subsequent execution.
Not a relevant point IMHO. You also cannot dump record to disk and (usefully) reread them, if they contain any pointers or so. Nor a BP style object which also (usually) has an implicit VMT pointer, and where there's no question about the behaviour of "with". The relevant difference here is that between pointers and references, not of anything about that which they point/refer to.
Frank
On 21 Feb 2009, at 02:08, Frank Heckenbach wrote:
Nice to see that the FPC folks actually look as ISO Pascal (other than to bash it). Quite a change since the last time I checked. :-)
You're talking as if "the FPC folks" is a homogeneous entity with a single opinion. Hint: it's not. Second hint: those with the strongest opinion on a particular subject are likeliest to speak up about it. I don't think anyone's opinion in the FPC team has changed about how they, individually, regard ISO (Extended) Pascal and its relevance.
Anyway, the behaviour was changed, in MacPas mode only, for compatibility reasons. And compatibility is also the same reason for the different behaviour in other modes. It has nothing to do with like or dislike of ISO Pascal.
Jonas