Ched wrote:
Hello All,
My two cents. The with statement is crystal clear for me. If newbies
prefer to use different manners to code the things, that are free to do
it. Using some kind of intermediate variable ? That's make to code
difficult to understand, need do open begin/end blocks in some
situations. With make the code very clear, probably helps the compiler a
lot. Well used, it's 100% safe - I *never* encountered any problems with
it in 25+ years of intensive programmation.
The consensus is that it has to be used with caution. You get one vote,
less a bit for calling those that disagree with you "newbies" :-)
I tend to use it if it will save more than around three repeated
prefixes, but I'd be far happier if there were provision for declaring a
temporary "shortcut" symbol:
with shortcut: TSomething= TreeRoot.SubDirs[Low(TreeRoot.SubDirs)]^ do
begin
shortcut.DirLogged := true;
shortcut.DirHatFocus := false;
shortcut.SubDirsExpanded := true;
..
So, they with statement has at least one aficionados: me. Was the with
statement present if the first versions designed by Wirth himself ?
I believe so, and he also overlooked the "dangling else" problem.
There's also this usage, which has plenty of pitfalls for the unwary or
busy:
with TSomething.Create do begin
..
Free
end;
--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist - [email protected]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal