[fpc-pascal] with in classes/records
Ryan Joseph
ryan at thealchemistguild.com
Tue Sep 4 17:30:37 CEST 2018
> On Sep 4, 2018, at 7:15 PM, Sven Barth via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
>
> Would you please stop thinking with the C operators? They are merely syntactic sugar and they don't exist by themselves. For this topic at least please stick to their full versions (in your example "rec := rec + 10") as that highlights better what the compiler needs to handle. In this case both the + *and* the assignment operator.
>
Sorry, please bear with me.
I think this is just a precedence issue I raised. If TWrapper has a + operator then:
wrapper := wrapper + 1
should call the + operator, because base class takes precedence over the field num: integer. Correct? If TWrapper doesn’t have a + operator then:
wrapper := wrapper + 1 should resolve to wrapper.num := wrapper.num + 1
right?
type
TWrapper = record
num: integer;
property _default: integer read num write num; default;
class operator + (left: TWrapper; right: integer): TWrapper;
end;
Regards,
Ryan Joseph
More information about the fpc-pascal
mailing list