> On Oct 4, 2018, at 9:19 PM, Michael Van Canneyt <mich...@freepascal.org> 
> 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.

type
        TWrapper = class
                m_value: integer;
                property value: integer read m_value write m_value; default;
        end;

var
        wrapper: TWrapper;
        i: integer;
begin
        wrapper := TWrapper.Create;
        wrapper := 100;
        wrapper := wrapper + 1;
        writeln(wrapper.value);
        i := wrapper; // error, this passes the class TWrapper
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