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

印場 乃亜 shiruba at galapagossoftware.com
Sun Mar 17 04:07:41 CET 2013


Hi,

On 2013/03/17, at 11:37, Flávio Etrusco <flavio.etrusco at gmail.com> wrote:
> 
> No, he's saying that *his hack* using class helper wouldn't cover this
> case (two objects in the same 'with' clause).
> 
Well, more to the point, it only works with OOP.  I use WITH on structures, etc. all the time, so ... yes implementing it in the compiler/RTL would be preferable of course.

> Daniel, I find this hack as ingenious as atrocious ;-)
> But thinking about it a bit, when FPC gets generic methods you can
> make this kind of workable!

No comment, but the fact that he replied with his "solution" so quickly makes me wonder if he has actually used it before!

> 
>> (...)
>> To summarize, "as" does NOT try to eliminate context ambiguity (also it
>> won't make a clear context ambiguous), but provided some convenience when
>> needed.
> 
> As Sven said this feature has already been requested a few times.
> I don't remember whether it was permanently vetoed by FPC developers
> or just is in the to-do, but vaguely remember people arguing it's
> "un-pascal" because of the local variable/scope - which is
> unfortunate, because IMO the 'with' syntax is one of the most
> abominable un-pascal things Borland introduced in the language, and
> *forcing* the AS syntax (but probably with some other keyword like
> ALIAS) would make it much more palatable.

I'm a bit confused on this point.  To me, WITH has been around for a long time, and is to me very Pascal.  Probably because PAscal is one of the only languages that allows nested procedures, etc., and "with" seems similar to me.  (Also, pretty much to me Borland = Pascal).  Although I just wanted a keyword (like "self"), the AS proposal makes more sense if you use more than one item in the same WITH.  (I usually don't because they would have the same fields anyway...)  

I think having functions/procedures with no arguments callable with procedurename() is un-pascal-like as well, but it hardly bothers me that FPK allows it.  Just because I don't love it doesn't mean others don't.  (There is a lot of C like syntax that has creeped into FPK, but I assume that'S either because it was easy to implement and a few people wanted it, or because it made porting C stuff to Pascal easier).  One could say OOP isn't Pascal like because the original inventor didn't come up with TObject... 

Actually the only thing that makes me uncomfortable about the keyword "as", is that it strangely reminds me of SQL.  I suppose that isn't a bad thing though.  

 Thank you,
       Noah Silva
> 
> Best regards,
> Flávio
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal




More information about the fpc-pascal mailing list