[fpc-pascal] a proposal about "with" syntax

Daniel Gaspary dgaspary at gmail.com
Sat Mar 16 19:53:22 CET 2013


On Sat, Mar 16, 2013 at 3:02 PM, 印場 乃亜 <shiruba at galapagossoftware.com> wrote:
> With BigLongThingIDontWantToWriteOutEverySingleTime do
>   begin
>      Height := 100;
>      Width := 200;
>     ...
>      SomeOtherObject.Submit(BigLongThingIDontWantToWriteOutEverySingleTime);
>   end;
>
> Notice how I have to write the long thing out again at the bottom.  There
> must be a way around that (Something like "Self", but that refers to
> whatever you are using in With).

You can use a Class Helper:

http://pastebin.com/pFL49byh

But you gonna need to use a type cast. And with a "SomethingElse" at
the with, as showed by Xiangrong, things can become messy.



More information about the fpc-pascal mailing list