That needs an answer beyond "quick" :). Let me write to you later.

But still, with a way to reproduce if possible we would have something
concrete to study.


On Friday, February 21, 2014, Gary Weaver <[email protected]> wrote:

> Xavier,
>
> Thanks for the example, but I'm confused because:
>
> 1. Classes couldn't load in the first place if there was no way to load
> them because of interdependency problems. Rails initially autoloads these
> files without problems.
>
> 2. I would think that you shouldn't get an infinite loop in this case if
> you keep track of what needs to be loaded, and because of that, it is aware
> that there is a circular reference I assume by checking that without
> letting a SystemStackError occur before you find that out.
>
> So why not:
>
> A. Keep that list of things to load.
> B. Try to load them in as sane an order as possible based on dependencies
> that are known.
> C. For things with circular dependency, put those in a bucket of unknown
> order (hopefully there aren't too many) and use the "try and try again"
> approach iterating through things that need to be loaded, only stopping
> when you cannot load anything else in the list to be loaded in that
> iteration.
>
> I know it is *much* more complicated than that and there is a lot of
> history that goes with Rails autoloading and why things are the way they
> are, but you have to admit, it makes no sense that Rails can autoload
> everything on start and you can manually load (via load) files after you
> remove_const'd it, but it just "gives up" if it detects a circular
> reference when trying to autoload a single (class) constant you
> remove_const'd.
>
> But my lame suggestion there I know does not help as much since you need
> something to use to reproduce. I'm just not sure yet how to do that simply.
>
> The more worrying thing to me is that this is not just a "Circular
> dependency detected while autoloading constant" problem, but also possibly
> (unless is a different problem that is also related to autoloading)
> InverseOfAssociationNotFoundError problem, so it is definitely mucking
> things up.
>
>
> On Friday, February 21, 2014 10:56:46 AM UTC-5, Xavier Noria wrote:
>>
>> OK.
>>
>> The basic idea of the circular dependency control is to detect this:
>>
>> $ cat a.rb
>> B
>> A = 1
>>
>> $ cat b.rb
>> A
>> B = 1
>>
>> If some code triggers autoloading of A (or B), you'd get an infinite
>> loop. To halt the loop you'd need to get an object defined to the constant
>> somehow, but the code wouldn't ever reach that point.
>>
>> In any case, if you guys could open an issue in GitHub with a minimal way
>> to reproduce the problem we'd look into it.
>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to 
> [email protected]<javascript:_e(%7B%7D,'cvml','rubyonrails-core%[email protected]');>
> .
> To post to this group, send email to 
> [email protected]<javascript:_e(%7B%7D,'cvml','[email protected]');>
> .
> Visit this group at http://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to