>> On Sep 26, 2018, at 1:14 AM, Benito van der Zander <[hidden email]> wrote:
>> perhaps everything would be clearer, if the default property was accessed with ^ ?
>> wrapper: TWrapper;
>> wrapper := TWrapper.Create;
>> wrapper^ := THelperA.Create;
> Sorry, back to working on this today.
> That’s an idea. Probably the other way around though since initializing
> the class is the less common operation. The compiler team is busy I guess
> because I haven’t got any answers recently on questions. I suspect
> appropriating the ^ symbol will not be ok with them since it has another
> reserved meaning.
Technical issues aside, it kind of defeats the purpose of the default
>> On Oct 4, 2018, at 8:34 PM, Michael Van Canneyt <[hidden email]> wrote:
>> Technical issues aside, it kind of defeats the purpose of the default
> Then just tolerate the fact we have a dual meaning for assignments? Looks wrong but maybe not a problem.
> wrapper: TWrapper;
> wrapper := TWrapper.Create;
> wrapper := THelperA.Create;
And was this not the whole idea of introducing a default property in the first place ?
> On Oct 4, 2018, at 9:19 PM, Michael Van Canneyt <[hidden email]> wrote:
> And was this not the whole idea of introducing a default property in the first place ?
It is but I just wanted to make sure that this particular ambiguity with initializing classes wasn’t concerning for anyone.
So far I’ve identified 2 instances where the default needs to be ignored:
1) Assigning the same type i.e. during copies for records or init’ing classes
2) When passing into functions (like in writeln below we need to specify the default property so we don’t try to write the actual class)
Just making sure this is ok.
TWrapper = class
property value: integer read m_value write m_value; default;
wrapper := TWrapper.Create;
wrapper := 100;
wrapper := wrapper + 1;
i := wrapper; // error, this passes the class TWrapper