[Lazarus] 'with' is evil, isn't it?
Luiz Americo Pereira Camara
luizmed at oi.com.br
Wed Aug 3 03:54:49 CEST 2011
On 2/8/2011 11:38, Max Vlasov wrote:
> Hi,
>
> Personally I stopped using 'with' keyword long time ago, but there are
> code fragments from the past and today I fixed a little bug showing
> again that it's a evil. TCanvas in lazarus has width and height
> properties while in Delphi it hasn't (at least some time ago). So the
> code below leads to different results in lazarus and Delphi, at least
> for design-time drawing.
>
> procedure TControlDescendant.Paint;
> begin
> with Canvas do
> begin
> Rectangle(0, 0, Width, Height);
> edn;
> end;
>
> So not only the 'with' context can silently change while the project
> is evolving, it can also change while it's being ported...
I also ran into this problem while porting Delphi code
http://lazarusroad.blogspot.com/2007/02/traps-of-delphi-to-lazarus-conversion.html
Luiz
More information about the Lazarus
mailing list