The With statement is considered harmful by many Delphi developers. I agree only partially. The with TMyClass.Create do construct can come handy at times. Truly, this code looks simple but is often harder to read, as you don't know if a member has to be applied to the object within the with statement or the current object. This is because we don't tend to write code with the Java-style of prefixing local fields with this (or self).
Anyway you feel about the with statement, using a double one is really a little too much. In theory, you can write:
with Object1, Object2 do
but at this point if the code is within a method the field name you type can belong the current object or one of the two in the with statement. THis is why I wasn't happy to read in the VCL source code (of Delphi 2007) the following:
with LMargins, GlassFrame do begin if Enabled then begin if not SheetOfGlass then begin cxLeftWidth := Left; cxRightWidth := Right;
The assignments int he last two lines I've quoted are not too bad, but what about Enabled? Which object does it belong to? And what about SheetOfGlass? They are both part of TGlassFrame, but this is not very readable. To make matters worse, the LMargins data structure referenced here is declared as:
The unit name is there because there is another (totally different) TMargins data type, a new class of the VCL used for the Margins property of the form (which the current class of the method displayed above). Oh, my!