--0-1162556895-11445907430038
Content-Type: MULTIPART/MIXED; BOUNDARY="0-1162556895-1144590743=:20038"

  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--0-1162556895-11445907430038
Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed
Content-Transfer-Encoding: QUOTED-PRINTABLE

Hi --

On Sun, 9 Apr 2006, Florian Growrote:

> dblack / wobblini.net wrote:
>
>>> I think you are looking for Object#instance_eval.
>>> 
>>> Note that in 1.8 there is no way to build-in way to execute a block in a 
>>> different context and at the same time providing it with arguments.
>>> 
>>> In 1.9 it will be possible to do that with Object#instance_exec.
>> 
>> Do you know why there are going to be two methods, instead of just
>> adding argument capabilites to instance_eval?  I'm also not sure how
>> 'eval' vs. 'exec' expresses arguments vs. no arguments.  Do you know
>> the reasoning behind it?
>
> Object#instance_eval used to pass self AFAIK. Making it pass arguments would 
> either be an incompatible change or lead to a overly complex API.
>
> I'm not sure about the exact reasoning about the names. I guess it is just 
> because all eval methods don't pass arguments. And instance_exec kind of 
> sounds related to instance_eval.

Yeah, "kind of"... :-)

> I can't think of a good name that expresses argument passing. 
> instance_eval_with_args would work, but isn't good.

I'm hoping there won't be too many of these "you just have to know it"
things in 2.0.  Yes, Matz, I trust you!  But there's been talk, at
least, of send vs. funcall, and instance_eval vs. instance_exec, both
being pairs of methods that do similar things but whose names don't
tell you which is which.  It's easy for experienced Rubyists to
remember that "the new one is the one that does new stuff", but I
think that even a little of this could make learning Ruby a lot
harder.

Then again, I can't think of any perfect names (well, I liked send and
send! but Matz didn't :-) so I should shut up.


David

-- 
David A. Black (dblack / wobblini.net)
Ruby Power and Light, LLC (http://www.rubypowerandlight.com)

"Ruby for Rails" coming in PDF April 15, and in paper May 1!
http://www.manning.com/black
--0-1162556895-11445907430038--
--0-1162556895-11445907430038--