[fpc-pascal] with statement using mulltiple objects

Ched charles.edouard.des.vastes.vignes at gmail.com
Sun Sep 14 15:39:41 CEST 2014


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.

So, they with statement has at least one aficionados: me. Was the with statement present if the first 
versions designed by Wirth himself ?

Cheers, Ched'





Le 14. 09. 14 12:20, Marius a écrit :
> Jürgen Hestermann wrote:
>
>> Realy? I love it. Consider these two varianst of code from one of my
>> programs:
>
> This is a simpler example than the one with with the 4 levels deep
> (which can be quite a puzzle if there are multiple records containing
> the same fieldname(s)). And yes you may love them but please read on..
>
>> Which one would you prefer?
>
> The second, but not for readability or typing, I would suggest a third
> solution by using a variable (like Matthias also showed).
>
> The point is you are very likely to run into refactoring problems.
> Suppose your routines are in 2 different methods in a class and there
> is class inheritance and one of the base class has a property
> errorstring. Suppose you decide to refactor the errorstring in you
> record structure to something else (and forget to adjust it properly
> which is human). Your first solution will compile but it would reset
> the wrong errorstring, your second solution will simply not compile
> because it has been prefixed (hence my preference to pick that one).
> You can argue its the fault of the programmer but why create an unsafe
> situation in the first place (and that just what the with statement
> does)...
>
> We have spend weeks (if not months) off hunting down this kind of bugs.
> And its this kind of bug what showed up frequently in teams of
> programmers and that made us decide to ban the with statement as much
> as possible. Sooner or later the with stament is going to bite you, I
> just hope you wont have to spend that much time on resolving it ;(
>
>
> Marius



More information about the fpc-pascal mailing list