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

Xiangrong Fang xrfang at gmail.com
Sat Mar 16 15:56:45 CET 2013


Sorry, the email was interrupted, but sent by the phone in background...

So the decision of this "feature" is that it is not worth to add, right?

Thanks.



2013/3/16 Xiangrong Fang <xrfang at gmail.com>

> In my example, you can use Items[], but in my real project it is a record
> with
>
>
> 发送自魅族MX
>
> -------- 原始邮件 --------
> 发件人:Sven Barth <pascaldragon at googlemail.com>
> 时间:3月16日 17:12 周六
> 收件人:FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
> 主题:Re: [fpc-pascal] a proposal about "with" syntax
>
>
> Am 16.03.2013 07:14 schrieb "Xiangrong Fang" <xrfang at gmail.com>:
> >
> > Suppose I have the following class:
> >
> > type
> >   TMyClass = class
> >   public
> >     property Caption: string read FCaption write FCaption;
> >     property Items[Index: Integer]: string read GetItem write SetItem;
> default;
> >     function Count: Integer;
> >   end;
> >
> > I would like to do this:
> >
> > with MyClassInstance as mci, SomethingElse do begin
> >   Caption := 'A new caption';
> >   for i := 0 to Count - 1 do
> >     mci[i] := UpperCase(mci[i]);
> > end;
> >
> > That is, to add an optional "as" clause to the with statement so that
> access array element in a structure is made easier.
>
> This was already requested multiple times and also reported on the
> bugtracker... Nevertheless in your specific case you can just use
> "Items[i]" instead of "mci[i]".
>
> Regards,
> Sven
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130316/eb0ef003/attachment.html>


More information about the fpc-pascal mailing list