On Wed, Jul 16, 2003 at 08:27:04PM +0900, Mark J. Reed wrote:
> On Wed, Jul 16, 2003 at 06:41:11PM +0900, Mauricio FernŠŌdez wrote:
> > > module Kernel
> > >   def with(obj, &blk)
> > >     obj.instance_eval &blk
> > >   end
> > > end
> 
> This has apparently been proposed before.  The resistance to
> including it may simply come from the fact that, from a general
> design perspective, instance_eval is a Bad Thing(TM).  It violates
> encapsulation and removes an object's ability to manage its own data.

Possibly. Also, doing

  def bar
    some_long_variable_name.instance_eval {
      ... code ...
    }
  end

means that 'code' loses access to the instance variables of the enclosing
object, so it's not as useful as you might think.

Regards,

Brian.