# Require from a method

**URL:** <https://rubytalk.org/t/require-from-a-method/59814>\
**Category:** ruby-talk\
**Created:** [29 August 2010 10:25 UTC](https://rubytalk.org/t/require-from-a-method/59814 "2010-08-29T10:25:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ammar\_Ali](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@Ammar\_Ali](https://rubytalk.org/u/Ammar_Ali)\
**Post date:** [29 August 2010 10:25 UTC](https://rubytalk.org/t/require-from-a-method/59814/1 "2010-08-29T10:25:52Z")

</div>

Hello,

Are there any gotchas in requiring files from within a method? It  
seems to work, but I have a sinking feeling that I'm missing something  
here.

def require\_relative(start, path)  
&nbsp;&nbsp;require File.expand\_path( File.join( File.dirname(start), path ) )  
end

require\_relative \_\_FILE\_\_, %w{.. tests tester.rb}

1.upto(3) {|i|  
&nbsp;&nbsp;Tester.run i, "some", [3,6,9], :foo =\> :bar  
}

Thanks,  
Ammar

---

<div class="post-metadata">

**Author:** ![Robert\_K1](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/robert_k1/32/1830_2.png) [@Robert\_K1](https://rubytalk.org/u/Robert_K1)\
**Post date:** [29 August 2010 10:40 UTC](https://rubytalk.org/t/require-from-a-method/59814/2 "2010-08-29T10:40:28Z")

</div>

Not technically. It might even be more efficient if you require a particular functionality only rarely and include the "require" in the method that needs that functionality. OTOH I find "require" in the middle of the code difficult to spot which makes it harder to keep track of dependencies. Also, errors might surface later (e.g. you copy your app to a different machine, start it and believe it works while in reality you forgot to install a gem or lib which is only used for particular use cases).

Kind regards

&nbsp;&nbsp;robert

> **···**
>
> On 29.08.2010 12:25, Ammar Ali wrote:
> 
> > Are there any gotchas in requiring files from within a method? It  
> > seems to work, but I have a sinking feeling that I'm missing something  
> > here.
> 
> --  
> remember.guy do |as, often| as.you\_can - without end  
> [http://blog.rubybestpractices.com/](http://blog.rubybestpractices.com/)

---

<div class="post-metadata">

**Author:** ![Tim\_R](https://avatars.discourse-cdn.com/v4/letter/t/ecc23a/32.png) [@Tim\_R](https://rubytalk.org/u/Tim_R)\
**Post date:** [29 August 2010 14:48 UTC](https://rubytalk.org/t/require-from-a-method/59814/3 "2010-08-29T14:48:01Z")

</div>

Hi Ammar,  
I recently wrote a script to graph out (using a .dot file and Graphviz  
for visualization) what files load when a given gem is loaded. When I  
started looking at gems this way I realized that it was not uncommon  
for one file to require a second more than once. When I inspect in the  
code, there is usually two require statement within separate method  
calls. The logic is just as Robert explained, better efficiency by  
only loading something when you need it. I can give you a quick  
example from the yadis gem. requiring 'yadis' causes a chain reaction  
of file loading resulting in 73 files loading! One of those is a  
'cgi.rb' file, which itself loads tempfile twice. Looking in cgi.rb  
shows the following def for the read\_multipart method definition. Note  
the two require 'tempfile' statements in one method definition.  
Regards,  
Tim

&nbsp;&nbsp;&nbsp;&nbsp;def read\_multipart(boundary, content\_length)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;params = Hash.new()  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;boundary = "--" + boundary  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;quoted\_boundary = Regexp.quote(boundary, "n")  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buf = ""  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bufsize = 10 \* 1024  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;boundary\_end=""

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# start multipart/form-data  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stdinput.binmode if defined? stdinput.binmode  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;boundary\_size = boundary.size + EOL.size  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;content\_length -= boundary\_size  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;status = stdinput.read(boundary\_size)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if nil == status  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;raise EOFError, "no content body"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elsif boundary + EOL != status  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;raise EOFError, "bad content body"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loop do  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;head = nil  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if 10240 \< content\_length  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;require "tempfile"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;body = Tempfile.new("CGI")  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;require "stringio"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;body = StringIO.new  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rescue LoadError  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;require "tempfile"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;body = Tempfile.new("CGI")  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;body.binmode if defined? body.binmode

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;until head and /#{quoted\_boundary}(?:#{EOL}|--)/n.match(buf)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (not head) and /#{EOL}#{EOL}/n.match(buf)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buf = buf.sub(/\A((?:.|\n)\*?#{EOL})#{EOL}/n) do  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;head = $1.dup  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;""  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if head and ( (EOL + boundary + EOL).size \< buf.size )  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;body.print buf[0 ... (buf.size - (EOL + boundary +  
EOL).size)]  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buf[0 ... (buf.size - (EOL + boundary + EOL).size)] = ""  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c = if bufsize \< content\_length  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stdinput.read(bufsize)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stdinput.read(content\_length)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if c.nil? || c.empty?  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;raise EOFError, "bad content body"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buf.concat(c)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;content\_length -= c.size  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buf = buf.sub(/\A((?:.|\n)\*?)(?:[\r\n]{1,2})?#{quoted\_boundary}  
([\r\n]{1,2}|--)/n) do  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;body.print $1  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if "--" == $2  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;content\_length = -1  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;boundary\_end = $2.dup  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;""  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;body.rewind

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/Content-Disposition:.\* filename=(?:"((?:\\.|[^\"])\*)"|([^;  
\s]\*))/ni.match(head)  
&nbsp;&nbsp;filename = ($1 or $2 or "")  
&nbsp;&nbsp;if /Mac/ni.match(env\_table['HTTP\_USER\_AGENT']) and  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/Mozilla/ni.match(env\_table['HTTP\_USER\_AGENT']) and  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(not /MSIE/ni.match(env\_table['HTTP\_USER\_AGENT']))  
&nbsp;&nbsp;&nbsp;&nbsp;filename = CGI::unescape(filename)  
&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/Content-Type: ([^\s]\*)/ni.match(head)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;content\_type = ($1 or "")

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(class \<\< body; self; end).class\_eval do  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alias local\_path path  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;define\_method(:original\_filename) {filename.dup.taint}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;define\_method(:content\_type) {content\_type.dup.taint}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/Content-Disposition:.\* name="?([^\";\s]\*)"?/ni.match(head)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name = $1.dup

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if params.has\_key?(name)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;params[name].push(body)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;params[name] = [body]  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break if buf.size == 0  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break if content\_length == -1  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;raise EOFError, "bad boundary end of body part" unless  
boundary\_end=~/--/

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;params  
&nbsp;&nbsp;&nbsp;&nbsp;end # read\_multipart

> **···**
>
> On Aug 29, 3:25 am, Ammar Ali \<ammarabu...@gmail.com\> wrote:
> 
> > Hello,
> > 
> > Are there any gotchas in requiring files from within a method? It  
> > seems to work, but I have a sinking feeling that I'm missing something  
> > here.
> > 
> > def require\_relative(start, path)  
> > require File.expand\_path( File.join( File.dirname(start), path ) )  
> > end
> > 
> > require\_relative \_\_FILE\_\_, %w{.. tests tester.rb}
> > 
> > 1.upto(3) {|i|  
> > Tester.run i, "some", [3,6,9], :foo =\> :bar
> > 
> > }
> > 
> > Thanks,  
> > Ammar

---

<div class="post-metadata">

**Author:** ![Markus\_Fischer](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@Markus\_Fischer](https://rubytalk.org/u/Markus_Fischer)\
**Post date:** [29 August 2010 11:11 UTC](https://rubytalk.org/t/require-from-a-method/59814/4 "2010-08-29T11:11:15Z")

</div>

Hi,

> **···**
>
> On 29.08.2010 12:40, Robert Klemme wrote:
> 
> > On 29.08.2010 12:25, Ammar Ali wrote:
> > 
> > > Are there any gotchas in requiring files from within a method? It  
> > > seems to work, but I have a sinking feeling that I'm missing something  
> > > here.
> > 
> > Not technically. It might even be more efficient if you require a  
> > particular functionality only rarely and include the "require" in the  
> > method that needs that functionality.
> 
> Sorry for hijacking, but I'm wondering how require exactly works in the  
> context of a class or method; does scoping play any role if I've defined  
> classes/modules in the required file?
> 
> thanks,  
> - Markus

---

<div class="post-metadata">

**Author:** ![Robert\_K1](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/robert_k1/32/1830_2.png) [@Robert\_K1](https://rubytalk.org/u/Robert_K1)\
**Post date:** [29 August 2010 12:55 UTC](https://rubytalk.org/t/require-from-a-method/59814/5 "2010-08-29T12:55:07Z")

</div>

No. It would be bad because then if the require statements would be executed in a different order totally unpredictable behavior would occur.

Robert@babelfish ~  
$ echo 'p self' \>x.rb

Robert@babelfish ~  
$ ruby19 -r x -e 1  
main

Robert@babelfish ~  
$ ruby19 -r x -e 'class X; def m;require "x"; end; end; X.new.m'  
main

Robert@babelfish ~  
$

Cheers

&nbsp;&nbsp;robert

> **···**
>
> On 29.08.2010 13:11, Markus Fischer wrote:
> 
> > Hi,
> > 
> > On 29.08.2010 12:40, Robert Klemme wrote:
> > 
> > > On 29.08.2010 12:25, Ammar Ali wrote:
> > > 
> > > > Are there any gotchas in requiring files from within a method? It  
> > > > seems to work, but I have a sinking feeling that I'm missing something  
> > > > here.
> > > 
> > > Not technically. It might even be more efficient if you require a  
> > > particular functionality only rarely and include the "require" in the  
> > > method that needs that functionality.
> > 
> > Sorry for hijacking, but I'm wondering how require exactly works in the  
> > context of a class or method; does scoping play any role if I've defined  
> > classes/modules in the required file?
> 
> --  
> remember.guy do |as, often| as.you\_can - without end  
> [http://blog.rubybestpractices.com/](http://blog.rubybestpractices.com/)

---

<div class="post-metadata">

**Author:** ![Jorg\_W\_Mittag1](https://avatars.discourse-cdn.com/v4/letter/j/91b2a8/32.png) [@Jorg\_W\_Mittag1](https://rubytalk.org/u/Jorg_W_Mittag1)\
**Post date:** [29 August 2010 13:35 UTC](https://rubytalk.org/t/require-from-a-method/59814/6 "2010-08-29T13:35:09Z")

</div>

Markus Fischer wrote:

> > > Are there any gotchas in requiring files from within a method? It  
> > > seems to work, but I have a sinking feeling that I'm missing something  
> > > here.
> > 
> > Not technically. It might even be more efficient if you require a  
> > particular functionality only rarely and include the "require" in the  
> > method that needs that functionality.
> 
> Sorry for hijacking, but I'm wondering how require exactly works in the  
> context of a class or method; does scoping play any role if I've defined  
> classes/modules in the required file?

No. Required files always get evaluated in the global context. Which  
is actually another gotcha: if you call require inside a module or  
class, then it \*looks like\* you jail the library into a namespace,  
when in fact you don't. Code that looks like it's doing one thing, but  
does another thing, is always dangerous.

Note that Kernel#load takes an optional boolean argument telling it to  
load the file into an anonymous module instead of the global  
namespace. (Unfortunately, there doesn't seem to be any way to  
actually \*get\* at that module[1], so this API looks rather useless.  
Also, the code in that file can always use ::Object to gain access to  
the global namespace.)

jwm

[1] except for ugly hacks with ObjectSpace

> **···**
>
> > On 29.08.2010 12:40, Robert Klemme wrote:
> > 
> > > On 29.08.2010 12:25, Ammar Ali wrote:

---

<div class="post-metadata">

**Author:** ![Robert\_K1](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/robert_k1/32/1830_2.png) [@Robert\_K1](https://rubytalk.org/u/Robert_K1)\
**Post date:** [31 August 2010 06:15 UTC](https://rubytalk.org/t/require-from-a-method/59814/7 "2010-08-31T06:15:10Z")

</div>

> Markus Fischer wrote:
> 
> > > > Are there any gotchas in requiring files from within a method? It  
> > > > seems to work, but I have a sinking feeling that I'm missing something  
> > > > here.
> > > 
> > > Not technically. It might even be more efficient if you require a  
> > > particular functionality only rarely and include the "require" in the  
> > > method that needs that functionality.
> > 
> > Sorry for hijacking, but I'm wondering how require exactly works in the  
> > context of a class or method; does scoping play any role if I've defined  
> > classes/modules in the required file?
> 
> No. Required files always get evaluated in the global context. Which  
> is actually another gotcha: if you call require inside a module or  
> class, then it \*looks like\* you jail the library into a namespace,  
> when in fact you don't. Code that looks like it's doing one thing, but  
> does another thing, is always dangerous.

Which is one good reason for not doing it at all. 🙂

> Note that Kernel#load takes an optional boolean argument telling it to  
> load the file into an anonymous module instead of the global  
> namespace. (Unfortunately, there doesn't seem to be any way to  
> actually \*get\* at that module[1], so this API looks rather useless.  
> Also, the code in that file can always use ::Object to gain access to  
> the global namespace.)
> 
> jwm
> 
> [1] except for ugly hacks with ObjectSpace

The usage of load with module I can think of is to load a file which registers instances or classes somewhere in some kind of global registry (hence you need global scope access). That way you do not have to care how everybody names their classes and they don't interfere with each other - which is good for this plugin like scenario.

But I agree, more direct access to the scope used would increase utility of that feature a lot.

Kind regards

&nbsp;&nbsp;robert

> **···**
>
> On 08/29/2010 03:34 PM, Jörg W Mittag wrote:
> 
> > > On 29.08.2010 12:40, Robert Klemme wrote:
> > > 
> > > > On 29.08.2010 12:25, Ammar Ali wrote:
> 
> --  
> remember.guy do |as, often| as.you\_can - without end  
> [http://blog.rubybestpractices.com/](http://blog.rubybestpractices.com/)
