[fpc-devel] Re: CodeGear abandons Delphi.NET
klenin at gmail.com
Thu Nov 6 14:35:17 CET 2008
On Thu, Nov 6, 2008 at 16:41, Graeme Geldenhuys <graemeg.lists at gmail.com> wrote:
> The following code is just confusing as hell...
> with b: Button := new Button do
> with c: Color := b.BackColor do begin
> b.Text := 'Hello World';
> self.Text := c.ToString;
Maybe, but consider the alternative in today's FPC:
with Button.Create do
with BackColor do begin
Text := 'Hello World';
Self.Text := ToString;
It is easy to miss which properties refer to which objects,
and hard to read the code even if you manage to remember it correctly.
Another common usage would be:
with p := MyForm.Canvas.ClipRect do
Draw(p.Right - p.Left, p);
I.e. referring to object itself inside the 'with' statement.
Now it requires a temporary variable.
Note that I would prefer abbreviated form without explicit type.
Full syntax has IMO too little advantage over the temporary.
Alexander S. Klenin
Insight Experts Ltd.
More information about the fpc-devel