shiruba <shir...@galapagossoftware.com>'s example is better than mine, and was exactly the reason I posted this suggestion.
I don't think a class helper is worth for this stuff, if I need to write a helper I would rather do this: longobj := BigLongThingIDontWantToWriteOutEverySingleTime; With longobj do begin Height := 100; Width := 200; ... SomeOtherObject.Submit(longobj); end; That's not elegant, but it is really not worth for a helper in this case, IMHO. "with" itself is a convenience syntax anyway, why adding an "as" to make it more convenient a bad idea? I don't know what's make it complex if there are 2 or more subject in the with? 2013/3/17 Daniel Gaspary <dgasp...@gmail.com> > On Sat, Mar 16, 2013 at 3:02 PM, 印場 乃亜 <shir...@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. >
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal