On 15.09.2014 03:06, Jim Leonard wrote:
On 9/13/2014 2:02 PM, Sven Barth wrote:
It has always worked in this manner. It's just for abbreviating typing,
not for combining properties. (and then the with-variant with multiple
elements is even more seldomly used than the single-element one...)
In the Turbo Pascal days, WITH allowed for some user-directed compiler
optimization. From the TP7 manual:
"In certain situations, Turbo Pascal's code generator can eliminate
redundant pointer-load instructions, shrinking the size of the code and
allowing for faster execution. When the code generator can guarantee
that a particular pointer remains constant over a stretch of linear code
(code with no jumps into it), and when that pointer is already loaded
into a register pair (such as ES:DI), the code generator eliminates
additional redundant pointer-load instructions in that block of code.
A pointer is considered constant if it's obtained from a variable
parameter (variable parameters are always passed as pointers) or from
the variable reference of a WITH statement. Because of this, using WITH
statements is often more efficient (but never less efficient) than
writing the fully-qualified variable for each component reference."
FPC optimizes this as well (because the with-expression is only
evaluated once). Though it's arguable in how far that is a micro
optimization with today's CPUs.
Regards,
Sven
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal