[Lazarus] 'with' is evil, isn't it?

David M. Lawrence dave at fuzzo.com
Wed Aug 3 19:39:22 CEST 2011


I would suggest for you who do not like "with" is to figure out ways to 
avoid using it yourselves, but leave it alone for those of us who find 
it useful.

Dave

On 8/3/2011 10:02 AM, Hans-Peter Diettrich wrote:
> Jürgen Hestermann schrieb:
>> cobines schrieb:
>>> In case Qarray[QuaderNr]^.Teilung[R] is an object I usually do:
>>> tmp := Qarray[QuaderNr]^.Teilung[R];
>> Yes, of course. But it's just so much easier to use "with" which does 
>> the same in the background and save you from adding local variables 
>> yourself.
>
> With is only "easier" to use from the writers viewpoint. For an reader 
> it's much harder to figure out what's going on, and code is more often 
> read than written.
>
> When something has to be changed later, it's often recommended to 
> remove the With first, before trying to change anything else.
>
> When something changed in the related data types, then it's not clear 
> why the code fails now, because it's impossible to reconstruct the 
> *previous* meaning (without reverting everything to an earlier state).
>
> IMO there exist only very few situations, where With is both safe to 
> use and easy to read.
>
> DoDi
>
>
> -- 
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-- 
------------------------------------------------------
  David M. Lawrence        | Home:  (804) 559-9786
  7471 Brook Way Court     | Fax:   (804) 559-9787
  Mechanicsville, VA 23111 | Email: dave at fuzzo.com
  USA                      | http:  http://fuzzo.com
------------------------------------------------------

"All drains lead to the ocean."  -- Gill, Finding Nemo

"We have met the enemy and he is us."  -- Pogo

"No trespassing
  4/17 of a haiku"  --  Richard Brautigan





More information about the Lazarus mailing list