Yehuda Katz
(ph) 718.877.1325


On Sat, Nov 19, 2011 at 12:06 AM, Hiroshi Nakamura <nakahiro / gmail.com>wrote:

> Hi,
>
> On Sat, Nov 19, 2011 at 16:21, Yehuda Katz <wycats / gmail.com> wrote:
> > Does this also mean that we will not enhance const_missing to support
> nested
> > modules?
>
> No, it doesn't.  I explained your request at #2740 first, and we
> discussed the way to solve it (no conclusion yet.)  I'll update #2740
> later.
>
> > I think it is still possible to make require itself threadsafe, if we
> use a
> > single lock for requires, as Charlie Nutter has previously proposed.
>
> I don't know that single lock solution is acceptable, because the
> cross-require issue is caused by developer's error we think, and
> should be easily avoidable (Just don't do!)  It would be too big
> restriction to save this error.
>

The few cases I have personally discovered in Rails were complex cases that
weren't obvious at first glance. When a lot of code is involved in the
autoload process, it's very easy for some cross-require cases to exist
(usually through intermediate code).

In my mind, making threadsafety guarantees about require, even if they come
with some caveats, is far better than simply warning developers not to do
"the wrong thing" in their apps or libraries in the case where code is
being loaded lazily in the presence of threads.


>
> In contrast to it, autoload can cause unintentional cross-require.  So
> I talked to Matz about #2740.
>
> > Honestly, if we improve const_missing and make `require` capable of being
> > threadsafe, it will be easy to implement autoload in terms of those
> > primitives.
>
> I explained exactly along the same line, not sure Matz agreed or not
> though.  Let's keep discussing in #2740.
>
>