Hi,

Also with using the "longobj" below, you have to declare it first (yet more 
manual temporary/helper variables).  
Also, once you do that, you don't need with as much to begin with since you 
could use a single char. variable name.

BTW, I don't think Daniel was suggesting that we actually use a class helper 
for such cases - just demonstrating that it's possible.  I have to admit I 
didn't even think of using a class helper, so that's fairly creative.  It could 
also be a possible implementation pathway if someone decides to implement it - 
but I doubt it since if you have access to internal compiler structures, you 
already know what "with" is referring to.

I am not sure anyone has decided that "as" is specifically a bad idea. (Correct 
me if I am wrong).  Look at it the opposite way, though.  For every request, 
there has to be somebody capable of implementing it in the compiler who has 
free time and considers it to be more important than all of the other things 
outstanding.  

I fully support having an "as" operator or something effectively similar, 
however I also know than submitting a patch is better than making a feature 
request.  

Also, I am happy just to have "with" at all.  My "other" main language (ABAP) 
has lots of awesome stuff like Native DB integration, but somehow doesn't have 
WITH!  (From the my limited Java experience, it seems Java doesn't have an easy 
alternative either).

Thank you,
    Noah Silva

On 2013/03/17, at 7:55, Xiangrong Fang <xrf...@gmail.com> wrote:

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

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to