[fpc-pascal] with statement using mulltiple objects
pascaldragon at googlemail.com
Sat Sep 13 22:03:42 CEST 2014
On 13.09.2014 21:29, vfclists . wrote:
> What then is the nesting for if the command will only apply to the last
> item with the property? Is each nested element supposed to be a property
> of the enclosing element?
> What is the rationale for such a statement, ie using multliple elements?
Consider this example:
=== code begin ===
TTest1 = class
TTest2 = class
// implementation of TTest1 and TTest2
with t1, t2 do begin
Foo; // calls t1.Foo
Bar; // calls t2.Bar
// same as:
with t1 do begin
with t2 do begin
=== code end ===
"with" simply allows you to avoid some typing and evaluatios the
expression between the "with" and "do" only once (take a function for
example instead of "t1"). So mostly it's merely syntactic sugar.
More information about the fpc-pascal