Autoload_delete

e$B1J0f!wCNG=!%6e9)Bg$G$9!%e(B

e$B8=>u$Ne(B 1.9 e$B$G$O!$e(Bautoload e$BEPO?$7$F$$$k%U%!%$%k$re(B
e$BL@<(E*$Ke(B require e$B$7$h$&$H$9$k$HNc30$,H/@8$7$^$9!%e(B

1.8 e$B$G$3$l$r$d$k$H!$BP>]%U%!%$%k$r#22sFI$s$G$7$^$&$i$7$$$3$H$Ke(B

e$B=i$a$F5$$,IU$-$^$7$?!%e(B(^_^;

e$B$3$N;EMM$N>l9g!$!VMxJX@-$N$?$a$Ke(B autoload
e$BEPO?$O$7$F$$$k$b$N$N!$e(B
e$BD>@\e(B require e$B$9$k?M$b$$$k!W$H$$$&%1!<%9$G:$$C$F$7$^$$$^$9!%e(B

e$BMW$O!$BP>]%U%!%$%kCf$NDj?tDj5A$KBP$7$Fe(B autoload
e$B$,5/F0$7$F$7$^$&$N$,e(B
e$BLdBj$G$9$+$i!$BP>]%U%!%$%k$NF,$Ge(B autoload e$BDj5A$r;&$7$F$d$l$Pe(B
e$BMxMQ<T$NMxJX@-$rAK32$9$k$3$H$J$/2sHr$G$-$k$O$:$G$9!%e(B
e$B$7$+$7!$8=>u$G$OL@<(E*$Ke(B autoload e$BDj5A$r<h$j=|$/%a%=%C%I$,e(B
e$BB8:_$7$J$$$h$&$K8+<u$1$i$l$^$9!%e(B
e$B$=$3$Ge(B Kernel#autoload_delete, Module#autoload_delete e$B$re(B
e$BDI2C$9$k$H$$$&$N$O$$$+$,$G$7$g$&$+!)e(B

e$B$3$l$rMQ$$$l$P!$Nc$($Pe(B
----<zzz.rb>-----------------------------------------
autoload_delete(:ZZZ)

class ZZZ
$XXX ||= 0
$XXX += 1
p $XXX

… defs …

end

e$B$KBP$7$F!$e(B

autoload(:ZZZ, ‘zzz’)
ZZZ.new

e$B$G$be(B

require ‘zzz’
ZZZ.new

e$B$G$be(B

autoload(:ZZZ, ‘zzz’)
require ‘zzz’
ZZZ.new

e$B$G$b%(%i!<$K$J$i$:$KF0$$$F$/$l$^$9!%e(B

e$B$D$$$G$K!$e(B1.8 e$B$N$h$&$Ke(B $XXX e$B$,e(B 2

e$B$K$J$C$?$j$9$k$3$H$b$J$/!%e(B(^_^)

e$B%Q%C%A$r0J2<$KE:IU$7$^$9!%e(B
e$B$J$*!$e(Bautoload(name, nil) e$B$G:o=|$H$$$&$N$b9M$($^$7$?$,!$e(B
e$BEPO?Ku>C;~$K0JA0$KEPO?$5$l$F$$$?%U%!%$%k$rJV$7$?J}$,JXMx$He(B
e$B;W$o$l$^$7$?$N$G!$La$jCM$N@-3J$N0c$$$+$iJL%a%=%C%I$H$7$F$$$^$9!%e(B


Index: eval_load.c

— eval_load.c (revision 13825)
+++ eval_load.c (working copy)
@@ -512,6 +512,27 @@
}

/*

    • call-seq:
    • mod.autoload_delete(name)   => filename or nil
      
    • Unregisters the autoload definition about name.
    • Returns the unregisterd filename (when registered by autoload) or
    • nil (when no registered).
    • module A
      
    • end
      
    • A.autoload(:B, "b")
      
    • A.autoload_delete(:B)  # returns "b"
      
    • A.autoload_delete(:C)  # returns nil
      
  • */

+static VALUE
+rb_mod_autoload_delete(VALUE mod, VALUE sym)
+{

  • return rb_autoload_delete(mod, rb_to_id(sym));
    +}

+/*

  • MISSING: documentation
    */

@@ -543,6 +564,31 @@
}

/*

    • call-seq:
    • autoload_delete(module)   => filename or nil
      
    • Unregisters the autoload definition about module.
    • the first time that module (which may be a String or
    • a symbol) is accessed.
    • Returns the unregisterd filename (when registered by autoload) or
    • nil (when no registered).
    • autoload(:MyModule, "/foo/modules/my_module.rb")
      
    • autoload_delete(:MyModule)    # returns 
      

“/foo/modules/my_module.rb”

    • autoload_delete(:MyNoModule)  # returns nil
      
  • */

+static VALUE
+rb_f_autoload_delete(VALUE mod, VALUE sym)
+{

  • VALUE klass = ruby_cbase();
  • if (NIL_P(klass)) {
  • rb_raise(rb_eTypeError, “Can not set autoload on singleton class”);
  • }
  • return rb_mod_autoload_delete(klass, sym);
    +}

+/*

  • MISSING: documentation
    */

@@ -572,8 +618,10 @@
rb_define_global_function(“load”, rb_f_load, -1);
rb_define_global_function(“require”, rb_f_require, 1);
rb_define_method(rb_cModule, “autoload”, rb_mod_autoload, 2);

  • rb_define_method(rb_cModule, “autoload_delete”,
    rb_mod_autoload_delete, 1);
    rb_define_method(rb_cModule, “autoload?”, rb_mod_autoload_p, 1);
    rb_define_global_function(“autoload”, rb_f_autoload, 2);

  • rb_define_global_function(“autoload_delete”, rb_f_autoload_delete,
    1);
    rb_define_global_function(“autoload?”, rb_f_autoload_p, 1);

    ruby_dln_librefs = rb_ary_new();
    Index: include/ruby/intern.h
    ===================================================================
    — include/ruby/intern.h (revision 13825)
    +++ include/ruby/intern.h (working copy)
    @@ -570,6 +570,7 @@
    VALUE rb_class_name(VALUE);
    void rb_autoload(VALUE, ID, const char*);
    VALUE rb_autoload_load(VALUE, ID);
    +VALUE rb_autoload_delete(VALUE, ID);
    VALUE rb_autoload_p(VALUE, ID);
    void rb_gc_mark_global_tbl(void);
    VALUE rb_f_trace_var(int, VALUE*);
    Index: variable.c
    ===================================================================
    — variable.c (revision 13825)
    +++ variable.c (working copy)
    @@ -1398,6 +1398,18 @@
    }

VALUE
+rb_autoload_delete(VALUE klass, ID id)
+{

  • VALUE file;
  • NODE *load = autoload_delete(klass, id);
  • if (!load || !(file = load->nd_lit) ||
    rb_provided(RSTRING_PTR(file))) {
  • return Qnil;
  • }
  • return file;
    +}

+VALUE
rb_autoload_p(VALUE mod, ID id)
{
struct st_table *tbl = RCLASS_IV_TBL(mod);

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Nobuyoshi N. wrote:

autoloade$B$OF)2aE*$K;H$($k$Y$-$@;W$&$N$G!"$=$&$$$&2sHrJ}K!$OK>$^$7e(B
e$B$/$O$J$$$H;W$$$^$9$,!"e(Bautoloade$B$r<h$j=|$/%a%=%C%I$NDI2C<+BN$K$OH?e(B
e$BBP$7$^$;$s!#e(B

autoloade$BMm$_$G!“e(B[ruby-core:13149]e$B$H$$$&$N$,$”$k$s$G$9$,!"$I$&;W$$$^$9e(B?
e$B$b$A$m$se(B1.9e$B$G!#e(B

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)

iQEVAwUBRzAiwh9L2jg5EEGlAQLcagf/b59h3lT5Gho5BCo0YLtjYQWmx2Lr3RD3
cQTUvN9OFRZO+CM/gyWwSaz/lFK6hxpG20Wz2T7EQBLYVhqskNdgWiLim84lNOQ/
NI19ORbnLqMbPivACdNNaTHisEhfeumVrFq3qeJfkDBAEGysMik/ns5Caiyc06fL
Wn8w9hpCt7MXEJFcYd5mud3wjFrOUA0ND1Kgx1qMfFH0lPfKWPcmuF/mL4T1++3/
rltj0zMHcLsXeyhknSOEQKKQczSORs0Y3jZThBnG/iCiII0jHtwK0pljwUt1nVfD
r3c21G4qJCRjDhBOapWdXuW+P3lDLkKJibOtrpW/XHlp5FKF+LIxoQ==
=Boc+
-----END PGP SIGNATURE-----

e$B$J$+$@$G$9!#e(B

At Tue, 6 Nov 2007 12:41:02 +0900,
Hidetoshi NAGAI wrote in [ruby-dev:32171]:

e$B8=>u$Ne(B 1.9 e$B$G$O!$e(Bautoload e$BEPO?$7$F$$$k%U%!%$%k$re(B
e$BL@<(E*$Ke(B require e$B$7$h$&$H$9$k$HNc30$,H/@8$7$^$9!%e(B

e$B$3$l$Oe(B[ruby-dev:31932]e$B$HF1$8$/%P%0$G$9!#D>$7$?$D$b$j$@$C$?$s$G$9e(B
e$B$,!"%3%_%C%H$7$F$$$^$;$s$G$7$?!#e(B

1.8 e$B$G$3$l$r$d$k$H!$BP>]%U%!%$%k$r#22sFI$s$G$7$^$&$i$7$$$3$H$Ke(B

e$B=i$a$F5$$,IU$-$^$7$?!%e(B(^_^;

1.8e$B$G$O$=$&$$$&LdBj$O:F8=$G$-$J$$$h$&$J$s$G$9$,!"$$$D$N%P!<%8%ge(B
e$B%s$G$7$g$&$+!#e(B

e$BMW$O!$BP>]%U%!%$%kCf$NDj?tDj5A$KBP$7$Fe(B autoload e$B$,5/F0$7$F$7$^$&$N$,e(B
e$BLdBj$G$9$+$i!$BP>]%U%!%$%k$NF,$Ge(B autoload e$BDj5A$r;&$7$F$d$l$Pe(B
e$BMxMQ<T$NMxJX@-$rAK32$9$k$3$H$J$/2sHr$G$-$k$O$:$G$9!%e(B
e$B$7$+$7!$8=>u$G$OL@<(E*$Ke(B autoload e$BDj5A$r<h$j=|$/%a%=%C%I$,e(B
e$BB8:_$7$J$$$h$&$K8+<u$1$i$l$^$9!%e(B
e$B$=$3$Ge(B Kernel#autoload_delete, Module#autoload_delete e$B$re(B
e$BDI2C$9$k$H$$$&$N$O$$$+$,$G$7$g$&$+!)e(B

autoloade$B$OF)2aE*$K;H$($k$Y$-$@;W$&$N$G!"$=$&$$$&2sHrJ}K!$OK>$^$7e(B
e$B$/$O$J$$$H;W$$$^$9$,!"e(Bautoloade$B$r<h$j=|$/%a%=%C%I$NDI2C<+BN$K$OH?e(B
e$BBP$7$^$;$s!#e(B

e$B1J0f!wCNG=!%6e9)Bg$G$9!%e(B

From: Nobuyoshi N. [email protected]
Subject: [ruby-dev:32173] Re: autoload_delete
Date: Tue, 6 Nov 2007 16:38:43 +0900
Message-ID: [email protected]

e$B$3$l$Oe(B[ruby-dev:31932]e$B$HF1$8$/%P%0$G$9!#D>$7$?$D$b$j$@$C$?$s$G$9e(B
e$B$,!"%3%_%C%H$7$F$$$^$;$s$G$7$?!#e(B

e$B$"!$$=$&$@$C$?$s$G$9$M!%e(B
[ruby-dev:31932] e$B$N=$@5$,$J$5$l$J$$$h$&$@$C$?$3$H$K2C$(!$e(B
e$BN`;wNc$Ge(B 1.8 e$B$GFs=Ee(B load e$B$,H/@8$7$?$b$N$G!$e(B
e$B!V;EMM!W$H$7$F9M$($J$1$l$P$J$i$J$$$N$+$J$H;W$C$F$N$3$H$G$7$?!%e(B

1.8 e$B$G$3$l$r$d$k$H!$BP>]%U%!%$%k$r#22sFI$s$G$7$^$&$i$7$$$3$H$Ke(B

e$B=i$a$F5$$,IU$-$^$7$?!%e(B(^_^;

1.8e$B$G$O$=$&$$$&LdBj$O:F8=$G$-$J$$$h$&$J$s$G$9$,!"$$$D$N%P!<%8%ge(B
e$B%s$G$7$g$&$+!#e(B

e$B$“$l!)$H;W$C$F$b$&0lEY;n$7$F$_$?$s$G$9$,!$H/@8>r7o$,$”$k$h$&$G$9!%e(B

e$B%F%9%HMQ$N%U%!%$%k$Oe(B
----------<zzzz.rb>----------------------------------
class ZZZ
$XXX ||= 0
$XXX += 1
p [‘$XXX’, $XXX]
end

e$B$G!$e(Bruby e$B$N%P!<%8%g%s$Oe(B

$ ruby -v
ruby 1.8.6 (2007-09-26 patchlevel 5000) [i686-linux]

e$B$G$9!%e(B

e$BNc$($Pe(B

autoload(:ZZZ, ‘./zzzz.rb’)
require ‘zzzz.rb’

e$B$Oe(B

[“$XXX”, 1]
[“$XXX”, 2]

e$B$H$J$j$^$9!%e(B

e$B$=$l$KBP$7!$e(B

autoload(:ZZZ, ‘./zzzz.rb’)
require ‘./zzzz.rb’

e$B$Oe(B

[“$XXX”, 1]

e$B$G$9!%e(B

e$B5U$Ke(B

autoload(:ZZZ, ‘zzzz.rb’)
require ‘./zzzz.rb’

e$B$Oe(B

[“$XXX”, 1]
[“$XXX”, 2]

e$B$G!$e(B

autoload(:ZZZ, ‘zzzz.rb’)
require ‘zzzz.rb’

e$B$Oe(B

[“$XXX”, 1]

e$B$G$9!%e(B

e$B$^$?!$e(B

autoload(:ZZZ, “#{Dir.pwd}/zzzz.rb”)
require ‘./zzzz.rb’

e$B$be(B

[“$XXX”, 1]
[“$XXX”, 2]

e$B$K$J$j$^$9!%e(B

e$BF10l@-$N%A%'%C%/$,IT40A4$H$$$&$3$H$G$7$g$&$+!%e(B

e$BBP$7$^$;$s!#e(B
e$B!V2sHr:v!W$K$D$$$F$O;d$N8m2r$+$i$NOC$G$9$N$Ge(B
e$BK>$^$7$/$J$$J}K!$G$“$k$H$$$&$3$H$KF10U$7$^$9!%e(B
e$B$7$?$,$C$F!$%P%0$H$7$F=$@5$5$l$k$N$G$”$l$Pe(B
autoload_delete e$B$bI,MW$G$O$"$j$^$;$s!%e(B

e$B$^$!!$$"$C$F$b$$$$$N$G$O$H$O;W$$$^$9$,!%e(B(^_^)

e$B$J$+$@$G$9!#e(B

At Tue, 6 Nov 2007 17:18:37 +0900,
NAKAMURA, Hiroshi wrote in [ruby-dev:32174]:

autoloade$BMm$_$G!“e(B[ruby-core:13149]e$B$H$$$&$N$,$”$k$s$G$9$,!"$I$&;W$$$^$9e(B?
e$B$b$A$m$se(B1.9e$B$G!#e(B

autoloade$B$G$O!"%m!<%I$9$k$H$-$Ne(Bsafe
levele$B$be(Bautoloade$B$rDj5A$7$?$H$-e(B
e$B$NCM$r;H$&$3$H$K$J$C$F$$$^$9!#e(B-re$B$de(Brequiree$B$N$h$&$KC1=c$JOC$G$O$9e(B
e$B$^$J$$$N$G$O$J$$$+$H;W$$$^$9!#e(B

e$B$J$+$@$G$9!#e(B

At Tue, 6 Nov 2007 18:50:22 +0900,
Hidetoshi NAGAI wrote in [ruby-dev:32175]:

e$B$H$J$j$^$9!%e(B
e$B$=$l$Oe(Bautoloade$B$H$OL54X78$G$9$M!#e(B
require “./zzzz.rb”
require “zzzz.rb”
e$B$G$bF1$8$G$9!#e(B

e$BF10l@-$N%A%’%C%/$,IT40A4$H$$$&$3$H$G$7$g$&$+!%e(B

e$B$G$9$M!#e(B1.9e$B$G$Oe(B$LOADED_FEATURESe$B$K$O%U%k%Q%9$KE83+$5$l$?$b$N$,F~$Ce(B
e$B$F$$$k$N$G!“e(B”./zzzz.rb"e$B$G$be(B"zzzz.rb"e$B$G$bF10l;k$5$l$^$9$,!#e(B

e$B1J0f!wCNG=!%6e9)Bg$G$9!%e(B

From: Nobuyoshi N. [email protected]
Subject: [ruby-dev:32177] Re: autoload_delete
Date: Tue, 6 Nov 2007 19:25:07 +0900
Message-ID: [email protected]

e$B$=$l$Oe(Bautoloade$B$H$OL54X78$G$9$M!#e(B
require “./zzzz.rb”
require “zzzz.rb”
e$B$G$bF1$8$G$9!#e(B

e$B$J$k$[$I!%G<F@$7$^$7$?!%e(B
e$B$H$O$$$(!$e(Bautoload e$B$N>l9g$OD>@\e(B require
e$B$7$F$$$k$o$1$G$O$J$$$@$1$K!$e(B
e$B<B:]$K0lEY$Ne(B require e$B$GFsEYFI$9~$^$l$k$N$K=P2q$&$He(B
e$B$A$g$C$H$S$C$/$j$7$F$7$^$$$^$9$M!%e(B(^
^)

e$BFsEYFI$KI;$?$a$NBP:v$rIU$12C$($F$*$$$?J}$,$$$$$N$+$J$!!%!%!%e(B

e$BF10l@-$N%A%'%C%/$,IT40A4$H$$$&$3$H$G$7$g$&$+!%e(B

e$B$G$9$M!#e(B1.9e$B$G$Oe(B$LOADED_FEATURESe$B$K$O%U%k%Q%9$KE83+$5$l$?$b$N$,F~$Ce(B
e$B$F$$$k$N$G!“e(B”./zzzz.rb"e$B$G$be(B"zzzz.rb"e$B$G$bF10l;k$5$l$^$9$,!#e(B

e$B$G$O!$e(B1.9 e$B$N>l9g$K$OH/@8$7$J$$$H9M$($F$h$$$o$1$G$9$M!)e(B

e$BL$%3%_%C%H$N%P%0=$@5$K$D$$$F$O$h$m$7$/$*4j$$CW$7$^$9!%e(B