On Wed, 5 Sep 2018, Ryan Joseph wrote:
On Sep 4, 2018, at 7:15 PM, Sven Barth via fpc-pascal
<fpc-pascal@lists.freepascal.org> wrote:
The idea of the default property is that *all* operators (and methods) (except management operators) are hoisted from the type of the default property. The assignment of one record with default property to another of the same type is handled by the Copy management operator.
I just realized that default shouldn’t be allowed on non-object fields
right? I think that’s what was decided and makes most sense to me too.
Disregard my last email. Sorry if I make a bunch of noise while I’m
working on this but I’m probably going to have lots of questions coming
up.
No, the whole point of default is that they should be for any kind of field.
For example if you want a nullable boolean, you'll do something like
Type
TNullable<T>= Record
Private
F : T;
isAssigned : Boolean;
Function GetValue : T;
Procedure SetValue(aValue : T);
Property Value : T Read GetValue Write SetValue; default;
Property IsNull : Boolean Read GetISNull Write SetIsNull;
end;
Var
B : TNullable<Boolean>;
begin
Writeln(B.IsNull); // Should be true
B:=True; // Works due to default.
Writeln(B.IsNull); // Should be false.
end.
Michael.
Regards,
Ryan Joseph
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal