rails/rails — pull request #14893 by kaspth (2014-04-28 20:38:00+00:00)
Title: Refactoring Autoloading in dependencies.rb

Hi everyone!

After being inspired by @fxn's talk at RailsConf about Autoloading in Rails ([here's an older version of it](http://www.youtube.com/watch?v=8lYR9WxIRH0)), I'd like to try to simplify what is going on in this file.

Autoloading is a cornerstone of Rails, but it's very hard to grasp. I think there's a lot, we can do to improve this.

A few points compared with the aforementioned talk:
- Ruby's constant lookup is different from Rails' autoloading, but I can't get this from the file.
- The determinism of what can be autoloaded doesn't shine through.

Specifically I'd like to:
- [ ] Clarify how Rails' autoloading is different from Ruby's constant lookup (and why it can't be the same).
- [ ] Improve readability. The autoloading is lost in lots of different parts and doesn't communicate well to a reader.
...other tasks I haven't thought of yet.

Questions:
I'm having a hard time grasping exactly what's public or private here.
For instance the mattr_accessor `constant_watching_stack` is public, but a comment says it's internal?

Also I'm having trouble understanding what the entry points are here. Many methods are doing some form of normalization on the data here, if we knew where the data entered, we could normalize it there and only deal with the ideal inputs.
For example the autoload_paths are enumerated several places *and* expanded. If we could store them expanded, we wouldn't have to keep doing that.
What are your thoughts?

How valuable is the logging here?

Thanks everyone :heart: