Yehuda Katz
Developer | Engine Yard
(ph) 718.877.1325

On Mon, Feb 15, 2010 at 5:19 AM, Andrew White <an...@pixeltrix.co.uk> wrote:

>
> On 15 Feb 2010, at 12:11, Yehuda Katz wrote:
>
> > I couldn't think of or find any reason for these cases to be different.
> My guess is that the behavior was added to classes at some point (due to STI
> needs) but never added to modules (since it never came up). In any event,
> there's no way to deal with:
>
> I agree - there's no valid reason that the lookup shouldn't always go
> foo/bar/baz.rb, foo/baz.rb & baz.rb - missing out the middle one seems
> illogical. I'd keep your normalisation changes even if your patch for Ruby
> was accepted.


I wouldn't. I consider Rails' lookup from disk to be an alternate form of
constant lookup, and I'd want it to use semantics that are identical to
Ruby's semantics:

class Foo::Bar
  Baz
  # normal Ruby: will search Foo::Bar::Baz and Object::Bar
  # rails: will search Foo::Bar::Baz, Foo::Baz, and Object::Baz
end

This discrepancy means that the behavior could be different depending on
whether autoload is in effect (for instance, if all constants are preloaded,
and autoload is turned off, the behavior would be different than when it was
on). I'm not happy about that, and would remove the discrepancy if possible.


> In fact your normalisation changes will make it more likely that the "is
> not missing constant" error is raised as we're checking for more places
> where it might be found, e.g:
>
> Taking your Foo::Bar::Baz example:
>
> >> "Foo::Bar::Baz".constantize
> ArgumentError: Foo is not missing constant Baz!
>
> >> "Foo::Bar".const_get("Baz")
> ArgumentError: Foo is not missing constant Baz!
>
> If we check for the presence of the constant before calling
> load_missing_constant then we prevent these errors. Okay it may be not the
> cleanest or the correct solution but the alternatives aren't great.
>
>
> Andrew White
>
> --
> 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 rubyonrails-c...@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-core+unsubscr...@googlegroups.com<rubyonrails-core%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-core?hl=en.
>
>

-- 
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 rubyonrails-c...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-core+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to