[Lazarus] 'with' is evil, isn't it?

Alexander Klenin klenin at gmail.com
Thu Aug 4 13:10:53 CEST 2011


2011/8/4 Max Vlasov <max.vlasov at gmail.com>:
> Anyone who written something in Delphi control-related with a construction
>
> with Canvas do .... Width Height ...
>
> (meaning the bounds of the control)
> will be affected while porting something to Lazarus , because lcl Canvas has
> width and height while Delphi Canvas not. Luiz also mentioned a problem
> related to Canvas in his blog post.
>
> I just thought about the phrase Sven mentioned ("handle with care") and
> tried to imagine myself many years ago applying this rule. The only general
> rule I think of could be "never use the properties of the object you writing
> method of in the 'with' construction, because it can appear in the mentioned
> object anytime soon". I doubt anyone can really follow such rule :)
>

Note that my proposal of using aliases would prevent this problem.

-- 
Alexander S. Klenin




More information about the Lazarus mailing list