From: trans Date: 2011-11-25T15:10:59+09:00 Subject: [ruby-core:41296] Re: autoload will be dead ------=_Part_112_2936395.1322201455614 Content-Type: multipart/alternative; boundary="----=_Part_113_26984676.1322201455615" ------=_Part_113_26984676.1322201455615 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit "autoloading" can still be done by putting the require within a method that is called only as needed. The downside of this is that requires get pushed down into deeper levels of code, making requirements less obvious to developers. Documentation not withstanding, it's also not hard to work around. Just link us something like: $AUTOREQ = Hash.new{|h,k|h[k]=[]} def req(key, path) $AUTOREQ[key.to_sym] << path end def use(key) $AUTOREQ[key.to_sym].each{ |path| require path } end Then req :rdoc, 'rdoc' req :markdown, 'redcarpet' class Tmpl initialize(type) use type I'm sure this can be greatly improved upon, maybe even generalized (and thread safe?) to make a useful library gem. ------=_Part_113_26984676.1322201455615 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable "autoloading" can still be done by putting the require within a method that= is called only as needed.

The downside of this is that = requires get pushed down into deeper levels of code, making requirements le= ss obvious to developers. Documentation not withstanding, it's also not har= d to work around. Just link us something like:

&nb= sp;   $AUTOREQ =3D Hash.new{|h,k|h[k]=3D[]}

&= nbsp;   def req(key, path)
      $AUTOREQ[key= .to_sym] << path
    end

    def use(key)
      $AUTOREQ[ke= y.to_sym].each{ |path| require path }
    end

Then

    req :rdoc, 'rdo= c'
    req :markdown, 'redcarpet'

    class Tmpl
      initialize(= type)
        use type

I'm sure this can be greatly improved upon, maybe even generalized (and = thread safe?) to make a useful library gem.

------=_Part_113_26984676.1322201455615-- ------=_Part_112_2936395.1322201455614--