------ art_9125_14149565.1126898731686 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 9/16/05, Ara.T.Howard <Ara.T.Howard / noaa.gov> wrote: > > > harp:~ > cat ./require.rb > require 'rbconfig.rb' > module Kernel > alias_method '__require__', 'require' > def require lib > if((ext = lib[ %r/\.[^\.]+$/ ])) > __require__ lib > else > dlext, dlext2 = ::Config::CONFIG['DLEXT'], ::Config::CONFIG['DLEXT2'] > __require__ "#{ lib }.#{ dlext }" rescue > __require__ "#{ lib }.#{ dlext2 }" rescue > __require__ "#{ lib }.rb" > end > end > end > > > Yes, that's one way of dealing with it. Another approach that I find attractive is autoload. I think in the case of the Digest namespace, one could write: module Digest autoload :MD5, 'digest/md5' end Autoloading also has the advantage of looser coupling, lazy loading and auto-determining load order in case of (almost cyclic) dependencies. It should perform better than redundant requires as well, but I doubt this is noticeable. Cheers, Han Holl ------ art_9125_14149565.1126898731686--