[Lazarus] 'with' is evil, isn't it?
Mark Morgan Lloyd
markMLl.lazarus at telemetry.co.uk
Wed Aug 3 15:53:52 CEST 2011
Michael Van Canneyt wrote:
> On Wed, 3 Aug 2011, Graeme Geldenhuys wrote:
>
>> On 08/03/2011 02:00 PM, Alexander Klenin wrote:
>>> Anyway, my preferred solution would be to allow aliases in 'with'
>>> statement,
>>> which would improve readability even further while sacrificing only a
>>> few characters:
>>>
>>> with a := MyCompomentList[0] do begin
>>> Rectangle(0, 0, a.Width, a.Height);
>>> end;
>>
>>
>> A simple solution to something which I don't think is a problem either.
>> [I fully agree with Michael van Canneyt here]
>
> I agree the above is indeed an acceptable solution.
>
> But I do think it is a corner case, because it goes against pascal
> philosophy which says that all identifiers must be declared prior to
> being used.
How about
with const a = MyCompomentList[0] do begin
Rectangle(0, 0, a.Width, a.Height);
end;
a is, after all, a constant: it can't be changed and doesn't occupy any
storage.
--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
More information about the Lazarus
mailing list