On Thu, 08 Dec 2005 18:52:24 -0000, William E. Rubin  
<williamerubin / dodgeit.com> wrote:

>> What would it do about this (silly) code:
>>
>>         # russian roulette
>>         require 'facet/kernel/maybe'
>>         maybe { require 'fileutils' }
>>
>>         FileUtils.rm_rf '/'
>>
>> At that particular line, is FileUtils loaded, or not?
>
> You're asking it a question - "does FileUtils exist or not" - that it
> is not intended to answer, and that it doesn't claim to be able to
> answer.
>
> What it can do, however, is tell you that it looks like FileUtils might
> not exist.  And that would help in a whole lot of cases, no matter how
> many pathological counterexamples you can come up with.
>

Well, I don't see how it could really do that, without executing all code  
up to a certain point. Again, bear in mind that at the same point in that  
script, FileUtils may or may not be loaded, depending on what's already  
happened. How about if you had another script using the above:

def suicide
   begin
     eval File.read('roulette.rb')
   rescue
     unless FileUtils
       require 'fileutils'
       retry
     end
   end
end

Regardless of what the example does, my point is, how should it warn you?  
When? If it worked just by looking at whether it _may_ be undefined, then  
surely it'd always warn you in the above situation?

I can see that it would probably help in a lot of cases, but it would be  
an annoying gripe in a lot of the more complex cases, which is where Ruby  
shines. It's that dynamicity that attracted me to Ruby, the fact that  
pretty much everything is executable code, and I think it'd be an enormous  
shame to start imposing static-language requirements on it so a few people  
can avoid writing a few testcases ...

Just my opinion...

-- 
Ross Bamford - rosco / roscopeco.remove.co.uk
"\e[1;31mL"