In my experience, autoloads often reflect an existing hierarchical structure.
If a project does not use Zeitwerk, and the user declares autoloads for a class or module, chances are they are for child constants. As an example, see the
ActiveRecord module. (Those ones do not have a second argument because we define wrapper that derives it by convention, here).
I think it would be convenient to have an
autoload_relative in the line of
Kernel#require_relative. It would make existing patterns more concise, and as a practical consequence, you skip
$LOAD_PATH lookups too.
Updated by ioquatix (Samuel Williams) 7 months ago
Yes, great idea, and I can confirm I've run into issues with autoload loading the wrong files if you combine
Also, since this does not exist yet, we can be more strict on how this works, as in
autoload_relative can raise an exception if the constant is not defined correctly.