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? 

var
        wrapper: TWrapper;
        other: TWrapper;

// 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;

type
        TWrapper = record
                obj: TObject;
                property _default: TObject read obj write obj; default;
                class operator + (left: TWrapper; right: integer): TWrapper;
        end;

class operator TWrapper.+ (left: TWrapper; right: integer): TWrapper;
begin
        // error here
        result := left;
end;



Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to