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

Max Vlasov max.vlasov at gmail.com
Thu Aug 4 10:30:55 CEST 2011


On Thu, Aug 4, 2011 at 11:39 AM, Michael Schnell <mschnell at lumino.de> wrote:

> On 08/03/2011 10:17 PM, Reimar Grabowski wrote:
>
>>  I don't really get why this question is posted here and not on the fpc
>> list.
>>
> +1
> -Michael
>
>
Actually, this particular case was also lcl-related.
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 :)

Max
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20110804/21fef745/attachment-0003.html>


More information about the Lazarus mailing list