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

Xiangrong Fang xrfang at gmail.com
Sun Mar 17 02:14:08 CET 2013


>
> >  I don't know what's make it complex if there are 2 or more subject in
> the with?
>
> Context. A conflict case the two object were of the same class.
>

Are you saying this case:

with MyClassInstance1 as m, MyClassInstance2 do begin
  m.Property1 := 123;
  Property2 := 456;
end;

Here you don't know Property2 belongs to which object instance??  If so,
this is not a problem at all, because even without "as" you still cannot
distinguish, so the compiler should deny this kind of usage anyway,
however, with "as", you can do this:

with MyClassInstance1 as m1, MyClassInstance2 as m2 do begin
  m1.Property1 := 123;
  m2.Property2 := 456;
end;

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130317/93d1ee3e/attachment.html>


More information about the fpc-pascal mailing list