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

Lukasz Sokol el.es.cr at gmail.com
Fri Aug 5 10:32:53 CEST 2011


On 04/08/2011 14:52, Alexander Klenin wrote:
[...]

My thoughts exactly! :)

How about some explicit syntax sugar to help Code Tools understand 
this construct? 

 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
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

Hm?

L.





More information about the Lazarus mailing list