On Nov 12, 12:22 am, "Mislav Marohnić" <[EMAIL PROTECTED]>
wrote:
> For Object, "parent" would be == self, but Object is special-cased in the
> first half of the condition.
> IMO, the second condition is redundant.
We need to be certain as well that if parent == self then self ==
Object.
After thinking about this a bit I think that follows clearly from the
definition of Module#parent because the name of a class is unrelated
to the constant you use to access to it. So even if you do something
perverse as
class A
A = A
end
where A::A == A holds true (1), it is *not* the case that A::A.parent
== A (which would be == self by (1)). On the contrary, it is the case
that A::A.parent == A.parent == Object because Module#parent works on
the module name.
In addition, as far as I can tell the Kernel in
[Object, Kernel].include?(self)
is also redundant because that's Class#const_missing. If self is the
Kernel module we'll go directly to Module#const_missing.
So the test would be reduced to
if self == Object # this is a top-level constant
super
else
...
end
I've uploaded this to Trac:
http://dev.rubyonrails.org/ticket/10141
-- fxn
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---