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

Alexander Klenin klenin at gmail.com
Fri Aug 5 10:43:17 CEST 2011


On Fri, Aug 5, 2011 at 19:32, Lukasz Sokol <el.es.cr at gmail.com> wrote:
> On 04/08/2011 14:52, Alexander Klenin wrote:
>  e.g. that an alias can only be declared within the with statement:
> (and of course the whole alias business can be optional)
>
> with MyLongAndComplicatedObject [as a[:optional type declaration]]
>     [,optionally repeated for more aliases] do

"as" creates an ambiguity with existing dynamic casting syntax.
I have really chosen ":=" for a reason ;-)

> begin // 'a' can only be used as alias if not defined in header, error if it does
>
>  // without type declaration you get
>  a.Foo; // MyLongAndComplicatedObject.Foo;
>
>  // with type declaration, you get a cast:
>  a.Bar; // TFoo(MyLongAndComplicatedObject).Foo;
>
> end;  // scope of 'a' ends here

Again, if you add type declaration, it is undistinguishable from the
local variable,
so I think it is unnecesary addition.

-- 
Alexander S. Klenin




More information about the Lazarus mailing list