Well, if your first point is true, then I don’t think you can be sure
the second point is true 
true in the sense that the only difference should be that in the very rare
case there may be a require that succeeds where before it would have thrown
an error --and a very very rare exception indeed. i don’t think that this is
significant enough to warrant it an unacceptable consequence.
Why not just rename the method? There’s no need to compete with Ruby
for this namespace.
well, for me that would defeat the purpose. the whole point is to make my life
easier. i.e. use less brain power to get more done. but that is the
alternative if this proves to have unacceptable back-compatability
consequences.
That means that you want to be able to have two file placements which
are evaluated identically by ‘require’. You want “require ‘xxx’” to
be able to mean either of two different things.
However, problems arise when both of those things exist. Let’s say
you start with:
…/site-ruby/1.6/my_lib/
…/site-ruby/1.6/my_lib/my_lib.rb
and you rewrite require so you can do:
require ‘my_lib’
and it loads my_lib/my_lib.rb. What happens now if you add a new file:
…/site-ruby/1.6/my_lib.rb
This isn’t a very likely scenario, but my point is that if you use one
expression to represent two things, then you cannot later fully
recover the difference between those things.
yes there is this consideration, but i would want it to behave with
precedence, is all. that is to say the file should get required, not the dir,
in such a case, as it would currently.
‘require’ actually deals with things like this already, in some
situations (like file.rb and file.so both existing). But by changing
it, you risk introducing incompatible solutions to new problems.
i think, as stated above and before in not-so-many-words, is that the risk can
be exactly determined. i believe, from what i can thus phathom, is that the
singular case as given above (i.e. the very rare exception) is the only
possible incompatability and as such is almost mute since an error would be
thrown anyway.
At the very least (or the very most), you’d probably want to write
a superset of ‘require’. If ‘require’ succeeds, stop. If it fails,
apply your new set of extra rules.
i agree and threw this together. note i did this in two seconds, it hasn’t
been fully tested. do you see any problem with this approach?
alias :require_basic :require
def require(file_or_directory)
begin
fp = File.dirname(File.expand_path(file_or_directory))
$: << fp
r = require_basic file_or_directory
i = $LOAD_PATH.index(fp)
$LOAD_PATH.delete_at(i) if i
return r
rescue
if FileTest.directory?(file_or_directory)
require “#{file_or_directory}/#{file_or_directory}”
else
raise
end
end
end
···
On Saturday 11 January 2003 07:33 pm, dblack@candle.superlink.net wrote:
–
tom sawyer, aka transami
transami@transami.net
.''.
.''. . *''* :_\/_: .
:_\/_: _\(/_ .:.*_\/_* : /\ : .'.:.'.
.‘’.: /\ : ./)\ ‘:’* /\ * : ‘…’. -=:o:=-
:/:‘.:::. | ’ ‘’ * ‘.'/.’ (/’.‘:’.’
: /\ : ::::: = / -= o =- /)\ ’ *
‘…’ ‘:::’ === * /\ * .‘/.'. ‘._____
* | … : |. |’ .—"|
* | _ .–’| || | _| |
* | .-‘| __ | | | || |
.-----. | |’ | || | | | | | || |
__’ ’ /“\ | '-.”". ‘-’ ‘-.’ '` |.