On Jan 25, 2007, at 11:13 AM, Sam Roberts wrote:

> On Fri, Jan 26, 2007 at 12:02:33AM +0900, Yukihiro Matsumoto wrote:
>> I think we need to summarize the current proposed schemes:
>> (a) my original proposal
>>
>>   - functional style call will look for
>>
>>     (1) private methods up from defining class to Kernel
>>     (2) public methods up from the receiver's class to Kernel if not
>>         found in step 1.
>
> A < B < C
>
> A makes function style call to foo().
> B has public foo(), C has private foo().
>
> It is C's foo that will be called?
>
> You must have a reason, why is this desireable?
>
>>   - ordinary style call will look for
>>
>>     (3) public methods up from the receiver's class to Kernel.   
>> private
>>         methods will be skipped.
>
> This is different from ruby 1.8, but makes sense to me. Today, error
> raising behaviour means private methods intefere with public method
> lookup.
>
>> (b) Charles Nutter's proposal
>>
>>   - functional style call will look for
>>
>>     (1) any methods up from defining class to Kernel
>
> This seems reasonable.
>
>>   - ordinary style call will look for
>>
>>     (2) he didn't say anything about this, either skipping private
>>         methods or raise error as we have today.
>
> Hopefully, same as (a)(3).
>
>
>> (c) Evan Phoenix's proposal
>>
>>   - functional style call will look for
>>
>>     (1) private methods in the defining class/module.
>>     (2) any methods up from the receiver's class to Kernel if not
>>         found.
>>
>>   - ordinary style call will look for
>>
>>     (3) he didn't say anything about this, either skipping private
>>         methods or raise error as we have today.
>
> Hopefully, same as (a)(3).
>
>>
>> Are above summary OK, Charles, Evan?
>
> I don't see how (b)(1) and (c)(1,2) are different, except the former
> says "defining class" and later says "defining class/module". Don't
> modules, once included, become "like" an ancestor class? Is the
> difference how this is handled:
>
> module M
>   def this()
>     that() # Calls A#that() or B#that()?
>   end
> end
>
>
> class A;
>   def that()
>   end
> end
>
> class B < A
>   include M
>   def do_it()
>     this()
>   end
>
>   def that() end
>   private :that
> end

I specified 'defining class' but it should have been 'defining class/ 
module'. That being said, in my proposal, if a functional call was  
used inside a mixin'd in module, only that module would be searched  
for the private before the normal method dispatch kicked in.

module M
   def run
      [ foo(), blah() ]
   end

   private

   def foo
     8
   end
end

class A
   include M

   def blah
     12
   end

end

class B < A
   private

   def blah
     10
   end

end

B.new.run => [8, 12]

Notice that even though B has a private called blah, it's not called
because blah is only looked for in M, since it's called from M#run.

>
> ??
>
>
>