At 8:04 +0200 14/6/05, Frank Heckenbach wrote:
Peter N Lewis wrote:
I agree with Frank. Pascal usually has exactly one way to access something, which follows from the logical construction of that something.
Umm, except for:
- Case variant records
I don't understand this one. Variant record fields and selectors are accessed with `.', like normal records.
This is getting a bit far off topic now. But case variant records can generally have overlapping fields that are referenced by different names but which refer to the same location, akin to:
record case boolean of (true: a: UInt32); (false: b: SInt32); end;
(excuse me if I've got the syntax wrong, I didn't look it up and rarely use them).
Then r.a and r.b are two ways to access the same thing.
I seem to remember that GPC does not actually support this overlaying of memory, but it is fairly standard in traditional Pascals.
Frankly I don't care whether only one or the other is legal (as long as the appropriate one is legal for a given object technology), but I also don't see any need to restrict it, since for any object o, and any method m, o.m and o^.m unambiguously mean the same thing and cannot mean anything else, whether both are legal or not. Allowing both means one less compiler switch,
If you mean that doing this would eliminate the difference between BP and Mac objects, I don't think so. There are other cases which conflict more directly. E.g., assignments between objects copy the reference in Mac and Delphi (AFAIK), but copy the object itself in BP. So we need that difference anyway, and blurring it in some cases (where it might not be a direct conflict) seems to lead to a more confusing whole in the end ...
No, it would not eliminate the difference, and yes, you are correct, the assignment copies the pointer reference only, and so yes, there will be a blurring regardless, since under Mac Objects
o.a references a method o1 := o2 copies a reference to the object
and under BP Objects
o^.a references a method o1 := o2 copies the object
So if you're going to support both Mac/Delphi objects and BP objects, there is going to be some blurring. And the problematic area is the assignment, not the reference.
Regardless, this really is getting off topic and it really doesn't trouble me one way or the other how it is implemented or what is and isn't allowed (my only concern is the writing Mac objects is enabled, and even that I'm willing to do a fair amount of source changes as required). Peter.