Re: "Circular require considered harmful"

Leam Hall <[email protected]>
Newsgroups gmane.comp.lang.ruby.general
Message-ID <[email protected]>
Hey Andy, thanks!

I'm reading Ousterhout's "A Philosophy of Software Design" and seeing 
the need to reduce the complexity of my program. Looks like this is 
another area to work on!

Leam

On 9/21/18 4:57 AM, Andy Jones wrote:
> Under normal circumstances it's fine to require the same file twice, because require keeps a record of the libraries it has loaded and ignores a second call.
> 
> It looks as if you get this error if the library you are requiring requires itself somehow, which is not something that require can cope with -- the require operation presumably needs to complete before the library is added to the list.
> 
> So if in a.rb you require b.rb and in b.rb you require a.rb. then when you write `require "a"` Ruby will
> 
> * start to require a.rb
> * start to require b.rb
> * start to require a.rb again and realise there is something terribly wrong.
> 
> 
> 
> 
> Click here to view Company Information and Confidentiality Notice.<http://www.jameshall.co.uk/index.php/small-print/email-disclaimer>
> 
> Please note that we have updated our privacy policy in line with new data protection regulations. Please refer to our website to view the ways in which we handle your data.
> 
> Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
> 

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.