[Lazarus] Extending TRect breaks Lazarus

Ondrej Pokorny lazarus at kluug.net
Fri Nov 6 18:26:32 CET 2015


On 06.11.2015 17:42, Michael Van Canneyt wrote:
> Ehm. How can "with" ever be safe ?

You can make sure that if some property is ADDED into the with scope, it 
doesn't break anything by explicitely using Self (or the unit name or 
whatever):

procedure TForm1.DoMySize;
begin
   //...
   with MyRect do
     Self.Width := Right - Left;
end;

But you cannot do anything if a property is REMOVED (e.g. Right in this 
case)...

So yes, let's not use with :)

+ I don't use with in my code any more. I confess that in the beginning 
I did use it, but decided to ignore the with statement at all. There is 
no problem with long variable names at all. There are CodeTools :)

Ondrej




More information about the Lazarus mailing list