[fpc-pascal] with in classes/records
ryan at thealchemistguild.com
Tue Sep 4 08:57:42 CEST 2018
I started in on this already and here’s the first conflict I found when trying operators.
What should happen if you assign a record to another record with a default property?
// this should assign to ‘obj’ via the default property
wrapper := TObject.Create;
// what happens here? is this a wrong type error (TObject is expected but got TWrapper) or do we assign directly to the base record? I can see it both ways so I’m not sure what principle to fall back on. Allow it because we can or prevent it because it’s not intended functionality?
wrapper := other;
TWrapper = record
property _default: TObject read obj write obj; default;
class operator + (left: TWrapper; right: integer): TWrapper;
class operator TWrapper.+ (left: TWrapper; right: integer): TWrapper;
// error here
result := left;
More information about the fpc-pascal