[Lazarus] AutoCommit

Ondrej Pokorny lazarus at kluug.net
Sun Nov 15 06:38:04 CET 2020


On 14.11.2020 18:02, Michael Van Canneyt via lazarus wrote:
> On Sat, 14 Nov 2020, Sven Barth via lazarus wrote:
>> No, cause their intended default value could be True. Thus no special
>> handling for them.
>
> You can of course say the same for all other types for which an 
> implicit 'default'
> is implemented. The more so because a class is initialized with 0 in 
> which
> case every enumerated and boolean will be ord(0) unless otherwise
> initialized in the constructor.
>
> So I don't see why this rule is not applied to all properties, I don't 
> think
> it is logical.

I agree. One would not expect the implicit default values for 
string/real/pointer properties.

And then people wonder why their empty string properties are not streamed:

TMyClass = class
published
   property MyString: string read FString write FString stored 
IsMyStringStored;
end;

constructor TMyClass.Create;
begin
   FMyString := 'abc';
end;

function TMyClass.IsMyStringStored: Boolean;
begin
   Result := FMyString<>'abc';
end;

What's wrong?
-> The nodefault is missing in order the empty string be streamed:
   property MyString: string read FString write FString stored 
IsMyStringStored nodefault;

Not logical, not intuitive, but that is how it works and is documented :/

Ondrej



More information about the lazarus mailing list