Peter N Lewis wrote:
As mentioned, all that is minimally required is allowing (with an option turned on)
objectptr.field as a synonym for objectptr^.field
And extra nicety would be to allow:
type newobject = object(objectptr) ... end;
With these two, it would be relatively trivial to write compatible code, the only changes needed would be:
type myobject = object(superobject) ... end;
converts to type myobject = ^myrealobject; myrealobject = object(superobject) ... end;
(that would be the final nicety, but would be incompatible semantics for compatible syntax).
I think after that everything would "just work", since:
var o: myobject; new(o);
would be unchanged, as would dispose(o) and o.method or o.variable
This seems relatively simple, very safe, and within the GPC's goal of being a super set of all Pascals without introducing incompatible semantics for compatible syntax.
I'm still undecided whether it's better to extend BP objects in this way, or make a separate kind of objects which have those properties. The latter will be more work initially, but depending on what will be required later, it might be better to distinguish them. So I think I need more complete information about the Mac objects, compared to GPC's objects. Up to now we have:
1. Object types are pointers
2. Those pointers are implicitly dereferenced
[3. All methods are virtual -- done in the next release, by `--methods-always-virtual', on by default in `--mac-pascal']
[4. No constructors/destructors -- done, by not recognizing `constructor' and `destructor' as keywords in `--mac-pascal]
What else?
E.g., a test program Peter sent me contained `override' which hadn't been mentioned here so far. So please (all who use Mac Pascal) check carefully if there are any more differences because they might influence the implementation.
BTW, about `override': I'm not quite sure I really understand it (also after looking in OOE). Does it do the same as BP/GPC methods without any special directive which happen to override an inherited method? What happens (in MP/OOE) if a method of the same name as an inherited methods is not declared `override', is it just an error? (Or if an `override' method does not actually override?) IOW, is there actually any behaviour (with or without this directive) that doesn't correspond to BP, or is it just different syntax?
BTW, does MP have `virtual'? Otherwise we should disable this keyword in `--mac-pascal', shouldn't we?
BTW, A quick idea for the object pointers: If we allow `Parent' in `type Foo = object (Parent)' to be an object pointer type, it *may* (still doubtful) be useful to make `Foo' a pointer as well. This way the syntactic difference would be limited to the root object types. This would be particularly useful if there's (by convention or requirement) only one root object type (presumable in a standard unit then), so user programs wouldn't see any difference. But I'm not sure if that's useful or rather a kludge ...
Adriaan van Os wrote:
As long as Peter's proposal is an option that can be turned on and off, I think everybody can be perfectly happy with it. I suggest that the option is turned off by default, except for --mac-pascal (and maybe for --delphi).
Sure.
Frank