[#9869] a block argument within a block which argument has the same name leaks — <noreply@...>

Bugs item #7680, was opened at 2007-01-08 22:53

34 messages 2007/01/08
[#9871] Re: [ ruby-Bugs-7680 ] a block argument within a block which argument has the same name leaks — Yukihiro Matsumoto <matz@...> 2007/01/08

Hi,

[#9872] Re: [ ruby-Bugs-7680 ] a block argument within a block which argument has the same name leaks — Evan Webb <evan@...> 2007/01/08

On Jan 8, 2007, at 2:30 PM, Yukihiro Matsumoto wrote:

[#9873] Re: [ ruby-Bugs-7680 ] a block argument within a block which argument has the same name leaks — Yukihiro Matsumoto <matz@...> 2007/01/08

Hi,

[#9876] Re: [ ruby-Bugs-7680 ] a block argument within a block which argument has the same name leaks — dblack@... 2007/01/09

Hi --

[#9878] Re: [ ruby-Bugs-7680 ] a block argument within a block which argument has the same name leaks — Yukihiro Matsumoto <matz@...> 2007/01/09

Hi,

[#9879] Re: [ ruby-Bugs-7680 ] a block argument within a block which argument has the same name leaks — dblack@... 2007/01/09

Hi --

[#9880] Re: [ ruby-Bugs-7680 ] a block argument within a block which argument has the same name leaks — Yukihiro Matsumoto <matz@...> 2007/01/09

Hi,

[#9882] Re: [ ruby-Bugs-7680 ] a block argument within a block which argument has the same name leaks — Evan Phoenix <evan@...> 2007/01/09

[#9885] Re: [ ruby-Bugs-7680 ] a block argument within a block which argument has the same name leaks — Yukihiro Matsumoto <matz@...> 2007/01/09

Hi,

[#9887] Re: [ ruby-Bugs-7680 ] a block argument within a block which argument has the same name leaks — Evan Phoenix <evan@...> 2007/01/09

[#9888] Re: [ ruby-Bugs-7680 ] a block argument within a block which argument has the same name leaks — Charles Oliver Nutter <charles.nutter@...> 2007/01/09

Evan Phoenix wrote:

[#9892] Re: [ ruby-Bugs-7680 ] a block argument within a block which argument has the same name leaks — Yukihiro Matsumoto <matz@...> 2007/01/09

Hi,

[#9899] Re: [ ruby-Bugs-7680 ] a block argument within a block which argument has the same name leaks — Charles Oliver Nutter <charles.nutter@...> 2007/01/10

Yukihiro Matsumoto wrote:

[#9904] Re: [ ruby-Bugs-7680 ] a block argument within a block which argument has the same name leaks — Yukihiro Matsumoto <matz@...> 2007/01/10

Hi,

[#9960] Scoping and locating definitions — Jos Backus <jos@...>

Consider the following:

17 messages 2007/01/18
[#9964] Re: Scoping and locating definitions — Pit Capitain <pit@...> 2007/01/19

Jos Backus schrieb:

[#9966] Re: Scoping and locating definitions — Jos Backus <jos@...> 2007/01/19

On Fri, Jan 19, 2007 at 06:40:03PM +0900, Pit Capitain wrote:

[#9972] Re: Scoping and locating definitions — Jos Backus <jos@...> 2007/01/19

On Sat, Jan 20, 2007 at 02:18:19AM +0900, Jos Backus wrote:

[#9996] new method dispatch rule (matz' proposal) — SASADA Koichi <ko1@...>

Hi,

50 messages 2007/01/23
[#10002] Re: new method dispatch rule (matz' proposal) — Daniel DeLorme <dan-ml@...42.com> 2007/01/23

SASADA Koichi wrote:

[#10003] Re: new method dispatch rule (matz' proposal) — Yukihiro Matsumoto <matz@...> 2007/01/23

Hi,

[#10004] Re: new method dispatch rule (matz' proposal) — James Edward Gray II <james@...> 2007/01/23

On Jan 23, 2007, at 7:41 AM, Yukihiro Matsumoto wrote:

[#10017] Re: new method dispatch rule (matz' proposal) — Daniel DeLorme <dan-ml@...42.com> 2007/01/24

Yukihiro Matsumoto wrote:

[#10018] Re: new method dispatch rule (matz' proposal) — Yukihiro Matsumoto <matz@...> 2007/01/24

Hi,

[#10024] Re: new method dispatch rule (matz' proposal) — Daniel DeLorme <dan-ml@...42.com> 2007/01/24

Yukihiro Matsumoto wrote:

[#10027] Re: new method dispatch rule (matz' proposal) — Yukihiro Matsumoto <matz@...> 2007/01/24

Hi,

[#10048] Re: new method dispatch rule (matz' proposal) — Evan Phoenix <evan@...> 2007/01/25

The more this discussion goes on, the more I worry that Joe Q Public

[#10019] stable branch policy & schedule for 1.8.6 — "Akinori MUSHA" <knu@...>

Core developers,

29 messages 2007/01/24
[#10021] Re: stable branch policy & schedule for 1.8.6 — Charles Oliver Nutter <charles.nutter@...> 2007/01/24

Akinori MUSHA wrote:

[#10032] Re: stable branch policy & schedule for 1.8.6 — Joel VanderWerf <vjoel@...> 2007/01/24

Charles Oliver Nutter wrote:

[#10085] Collaborative Ruby Language Specification — "John Lam (CLR)" <jflam@...>

Hi Everyone,

36 messages 2007/01/28
[#10108] Re: Collaborative Ruby Language Specification — Charles Oliver Nutter <charles.nutter@...> 2007/01/29

M. Edward (Ed) Borasky wrote:

[#10112] Re: Collaborative Ruby Language Specification — "Eustaquio Rangel de Oliveira Jr." <eustaquiorangel@...> 2007/01/30

-----BEGIN PGP SIGNED MESSAGE-----

[#10114] add usage of uri.userinfo to open-uri.rb — <noreply@...>

Patches item #8309, was opened at 2007-01-30 15:25

16 messages 2007/01/30
[#10131] Re: [ ruby-Patches-8309 ] add usage of uri.userinfo to open-uri.rb — Yukihiro Matsumoto <matz@...> 2007/01/31

[#10132] Re: [ ruby-Patches-8309 ] add usage of uri.userinfo to open-uri.rb — Paulo Kh <paulo.koch@...> 2007/01/31

On 2007/01/31, at 06:07, Yukihiro Matsumoto wrote:

[#10137] Re: [ ruby-Patches-8309 ] add usage of uri.userinfo to open-uri.rb — Yukihiro Matsumoto <matz@...> 2007/01/31

Hi,

[#10139] Re: [ ruby-Patches-8309 ] add usage of uri.userinfo to open-uri.rb — Sam Roberts <sroberts@...> 2007/01/31

On Thu, Feb 01, 2007 at 01:19:34AM +0900, Yukihiro Matsumoto wrote:

[#10143] Re: [ ruby-Patches-8309 ] add usage of uri.userinfo to open-uri.rb — Yukihiro Matsumoto <matz@...> 2007/02/01

Hi,

Re: new method dispatch rule (matz' proposal)

From: Yukihiro Matsumoto <matz@...>
Date: 2007-01-24 02:08:00 UTC
List: ruby-core #10023
Hi,

In message "Re: new method dispatch rule (matz' proposal)"
    on Wed, 24 Jan 2007 03:18:26 +0900, Charles Oliver Nutter <charles.nutter@sun.com> writes:

|> I haven't implemented this yet, so that I can't say it for sure but I
|> don't think so.  Because public method calls (with explicit receiver)
|> need only one hierarchy search and one method cache.
|
|But for calls that could result in both private and public methods being 
|searched, this would still apply. It will require two searches up the 
|hierarchy, making it even slower to find the method than it is today.

For functional style call, yes.  The increasing costs are

  * private method search that start from defining class to Kernel
  * two method cache check unless we use in-line method cache

for each functional style calls.  If cache works properly the former
cost will become nothing.  The latter is unavoidable, but its cost is
a few instructions per each invocations so that - in my opinion - it
won't be a performance factor neither.  Or you can optimize more
aggressively, since private methods are not overridden under the new
behavior.  You can call them directly without any dispatching using
in-line cache.  It may make method calls even faster than now.

|> | So, if I have:
|> |
|> |class A; def bar; end; end
|> |class B<A; end
|> |class C<B; end
|> |class D<C; end
|> |class E<D; end
|> |class F<E; def foo; bar; end; def bar; end; end;
|> |
|> |F.new.foo would result in a search of classes E, D, C, B, and A for
|> |every invocation of bar, finally settling on the bar in F. Further, if
|> |now a bar was added in any of those classes or the existing bar in A was
|> |made private, my local bar would no longer be invoked. That seems
|> |extremely counter intuitive.
|> 
|> No, it's only for functional style method calls.
|
|Ok, substitute in def foo; bar(); end above, or give bar some 
|parameters. To call bar() a full search of the hierarchy must be 
|performed for private methods, and then eventually it comes back to the 
|bar defined in F. And if the bar defined in A becomes private later on, 
|it will be invoked instead. That seems very strange.

That may be strange in the corner cases.  But it's useful for most
cases.

|But it still means that changing method visibility in the parent will 
|affect which methods are called in the child. Rule four is perfectly 
|valid for ensuring a method foo calls a private method baz contained in 
|the same class, but rule three complicates things by also making child 
|classes that call baz hit the same method. I'll try another example
|
|class A
|   def foo; bar("A foo"); end
|   def bar(x); puts "A bar #{x}"; end
|end
|class B < A
|   def foo; bar("B foo"); end
|   def bar(x); puts "B bar #{x}"; end
|end
|
|So here, as today, B.new.foo calls B's bar method. Now a change:
|
|class A
|   private :bar
|end
|
|Now, because of a change in A, B.new.foo calls A's bar. When priority is 
|given to private methods in parent clases, parent classes can 
|effectively override child classes.
|
|Now what if B's author didn't know about the "bar" method in A. Suddenly 
|a release of A comes out with "bar" private, and B's code breaks. Should 
|making a method private have the potential to break child classes? The 
|most it should do is ensure that A's foo always calls A's bar.
|
|Parent classes should not be able to affect the method search order for 
|children by making changes to private methods.

I understand the principles that you care.  But visibility are not
that fragile for most of the cases.  Is there any way that addresses
name conflict issue AND has no strange visibility issue?

							matz.

In This Thread