[Lazarus] Extending TRect breaks Lazarus

Marco van de Voort marcov at stack.nl
Fri Nov 6 17:59:09 CET 2015


On Fri, Nov 06, 2015 at 05:42:39PM +0100, Michael Van Canneyt wrote:
> > by Delphi compatibility...
> 
> Ehm. How can "with" ever be safe ?

Btw the case that I fixed was like this

procedure TSomeForm.Getwind...

procedure setwidthheight(const r : TRect); inline;
begin
 with R do
   begin
    width:=right-left;
    height:=bottom-top;
  end;
end;

begin
 ... 
  setwidtheight(r);
end

In such case fixing with SELF doesn't work, because self isn't allowed in
the nested function. I had to strip the WITH.

Luckily it wasn't as bad as expected, and only this one in the win32 widget
set.

> 
> Don't get me wrong:
> 
> I use it abundantly. If I have QMYQueryObjectWithAVeryLongName then being able to write

Me too, but I like to qualify fieldnames with self when the they are short,
common words.
 


> With QMYQueryObjectWithAVeryLongName do
>    try
>      // Really nice code
>    finally
>      Close;
>    end;
> 
> is really good (tm).
> 
> NOT being able to use with would seriously impede on the readability of my code.
> 
> Add this to the observation that the lazarus team demands 'clear' variable names,
> and does not like/accept i,m,f,p,q or whatever as variable names, and using "with" 
> becomes very attractive indeed...
> 
> Michael.
> 
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus




More information about the Lazarus mailing list