We all know that the WITH statement available in Delphi. A lot people cry that it’s evil and you should not use it. From my point of view using with is only reasonable for a single line or maybe just few lines of code in begin end block. Why is WITH bad? The main problem is the name space collision and the thing when you have big code sections in WITH block – you can make mistakes just because of the WITH and identifier name match.
There is one of the top voted report in Quality Central about “The infamous WITH resolution“.
Personally I dream about solution for the WITH like following:
... with Long.Identifier.Name.OtherField as A, Other.Long.Field.Access as B do begin A.Value := B.Value; B.Value := 'Something other'; ... end;
Of course as somehow conflicts with AS operator, but the idea is clear. Maybe it can be some other reserved word..
If such thing is done that will be a new life for the WITH statement.