Send/__send__ and private method


#1

e$B!!$5$5$@$G$9!#e(B

e$B!!8=:_!"e(Btrunk e$B$G$Oe(B send/send e$B%a%=%C%I$Oe(B private
e$B$J%a%=%C%I$r0l@Z8F$Ye(B
e$B$J$$$h$&$K$J$C$F$$$k$?$a!"e(Btest-all
e$B$,Bt;3DL$j$^$;$s!Je(Blib/scanf.rb e$B$He(B
lib/rss e$B$KB?$/8+$i$l$k$N$G$9$,!K!#e(B

e$B!!e(BYARV e$B%^!<%8A0$Oe(B send(:m) e$B$O!“e(Bm()
e$B$HF15A$G$”$k$?$a!“e(Bprivate e$B$J%a%=%C%Ie(B
e$B$r8F$Y$k$h$&$K$9$k$Y$-$G$”$k!"$H$$$&$3$H$G!"FCJL$JBP=h$r$7$F$$$^$9!#e(B

e$B!!$3$l$O!"$=$&$"$k$Y$-$G$7$g$&$+!#e(Bfuncall(:m)
e$B!Je(B__send!(:m)e$B!K$H$9$l$Pe(B
private
e$B$J%a%=%C%I$,8F$Y$k$N$G!"$=$A$i$rMxMQ$7$F2<$5$$!"$H$$$&$o$1$K$O$$e(B
e$B$-$^$;$s$G$7$g$&$+!#e(B

e$B!!e(Bsend e$B$r;H$&?M$O!"!Ve(Breceiver e$B$,$"$l$Pe(B private
e$B$J%a%=%C%I$,8F$Y$J$$!"$Je(B
e$B$1$l$P8F$Y$k!W$H3P$($kI,MW$,$"$k$N$O;H$$$E$i$=$&$@$J$!$H;W$$$^$9!#>e5-O"e(B
e$BA[$+$i!VLdBj$J$$!W$H$$$&0U8+$b$"$k$+$b$7$l$J$$$s$G$9$,!#e(B


#2

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:30072] send/send and private method”
on Thu, 4 Jan 2007 21:05:11 +0900, SASADA Koichi removed_email_address@domain.invalid
writes:

|e$B!!8=:_!“e(Btrunk e$B$G$Oe(B send/send e$B%a%=%C%I$Oe(B private e$B$J%a%=%C%I$r0l@Z8F$Ye(B
|e$B$J$$$h$&$K$J$C$F$$$k$?$a!“e(Btest-all e$B$,Bt;3DL$j$^$;$s!Je(Blib/scanf.rb e$B$He(B
|lib/rss e$B$KB?$/8+$i$l$k$N$G$9$,!K!#e(B
|
|e$B!!e(BYARV e$B%^!<%8A0$Oe(B send(:m) e$B$O!“e(Bm() e$B$HF15A$G$”$k$?$a!“e(Bprivate e$B$J%a%=%C%Ie(B
|e$B$r8F$Y$k$h$&$K$9$k$Y$-$G$”$k!”$H$$$&$3$H$G!“FCJL$JBP=h$r$7$F$$$^$9!#e(B
|
|e$B!!$3$l$O!”$=$&$”$k$Y$-$G$7$g$&$+!#e(Bfuncall(:m) e$B!Je(B__send!(:m)e$B!K$H$9$l$Pe(B
|private e$B$J%a%=%C%I$,8F$Y$k$N$G!"$=$A$i$rMxMQ$7$F2<$5$$!"$H$$$&$o$1$K$O$$e(B
|e$B$-$^$;$s$G$7$g$&$+!#e(B

e$B$3$NJU$O$b$&0lEY$$$8$k$D$b$j$,$"$k$N$GJ|CV$7$F$*$$$F$/$@$5$$e(B
e$B$^$;$s$G$7$g$&$+!#e(B


#3

e$B!!$5$5$@$G$9!#e(B

SASADA Koichi wrote:

e$B!!e(BYARV e$B%^!<%8A0$Oe(B send(:m) e$B$O!“e(Bm() e$B$HF15A$G$”$k$?$a!“e(Bprivate e$B$J%a%=%C%Ie(B
e$B$r8F$Y$k$h$&$K$9$k$Y$-$G$”$k!"$H$$$&$3$H$G!"FCJL$JBP=h$r$7$F$$$^$9!#e(B

e$B!!$3$l$O!"$=$&$"$k$Y$-$G$7$g$&$+!#e(Bfuncall(:m) e$B!Je(B__send!(:m)e$B!K$H$9$l$Pe(B
private e$B$J%a%=%C%I$,8F$Y$k$N$G!"$=$A$i$rMxMQ$7$F2<$5$$!"$H$$$&$o$1$K$O$$e(B
e$B$-$^$;$s$G$7$g$&$+!#e(B

e$B!!e(Bsend e$B$r;H$&?M$O!"!Ve(Breceiver e$B$,$"$l$Pe(B private e$B$J%a%=%C%I$,8F$Y$J$$!"$Je(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k$N$+$,8+$($^$;$s!#6qBNNc$r<($7$F$$e(B
e$B$?$@$$$?J}$,$o$+$j$d$9$$$H;W$$$^$9!#e(B


#6

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:30103] Re: send/send and private method”
on Sun, 7 Jan 2007 17:52:05 +0900, SASADA Koichi removed_email_address@domain.invalid
writes:

|Yukihiro M. wrote:
|> e$B$3$NJU$O$b$&0lEY$$$8$k$D$b$j$,$"$k$N$GJ|CV$7$F$*$$$F$/$@$5$$e(B
|> e$B$^$;$s$G$7$g$&$+!#e(B
|
|e$B!!N;2r$7$^$7$?!#$A$J$_$K!"!V$3$s$J$N$r9M$($F$k!W$H$$$&0F$,$"$C$?$i65$($Fe(B
|e$B$$$?$@$1$l$P$H;W$$$^$9!#e(B

e$B$O$$!#$3$s$J46$8$G!#e(B

(1) sende$B$Oe(Bpublice$B$7$+%"%/%;%9$7$J$$e(B
(2)
sende$B$b%l%7!<%PIU$-%a%=%C%I8F$S=P$7$be(Bprivatee$B$r!V%9%-%C%W!W!#e(B
e$B8=:$O!V%(%i!<!W!#e(B
(3) e$B4X?t7?%a%=%C%I8F$S=P$7$O0J2<$N=g=x$G%a%=%C%IC5:we(B
* privatee$B%a%=%C%Ie(B(BasicObjecte$B$^$Ge(B)
*
publice$B%a%=%C%Ie(B(CLASS_OF(self)e$B$+$ie(BBasicObjecte$B$^$Ge(B)
e$B$3$N7k2L!"e(Bmatzrubye$B$N$h$&$K%0%m!<%P%k%a%=%C%I%-%c%C%7%e%F!<e(B
e$B%V%k$r;H$&$J$i%F!<%V%k$,$U$?$DI,MW$K$J$k!#%$%s%i%$%s%a%=%Ce(B
e$B%I%-%c%C%7%e$OJQ99$NI,MW$J$7e(B(e$B$@$H;W$&e(B)e$B!#e(B
(4) <e$BL$3NDje(B> privatee$B%a%=%C%I$N8F$S=P$7$NC5:w$O!"8=:
%a%=%C%Ie(B
e$B$rDj5A$7$F$$$k%/%i%9e(B(frame->the_class)e$B$+$i;O$^$k!#e(B
e$B$?$@$7!"e(Binstance_evale$B$J$I$Ge(Bselfe$B$,$9$j$+$o$C$F$$$k;~$K$Oe(B
CLASS_OF(self)e$B$+$i!#e(B

e$B$3$l$K$h$je(Bprivatee$B%a%=%C%I$O%5%V%/%i%9$G$N%*!<%P!<%i%$%Ie(B
e$B$,$G$-$J$/$J$k!#L>>N=EJ#$N4m81@-$,8:$j!"0B?4$7$F4X?tE*%ae(B
e$B%=%C%I$r;H$($k$h$&$K$J$k$,!"%a%=%C%I$N0UL#$,$+$J$jJ#;($Ke(B
e$B$J$k$&$($K!V$9$j$+$o$j!W$N%A%'%C%/$,IiC4$K$J$k!)e(B

(5) send!, __send!e$B$N3F%a%=%C%I$OGQ;_!#e(Bprivatee$B%a%=%C%I$r8F$Ve(B
e$B$?$a$Ne(Bprivatee$B%a%=%C%Ie(Bfuncalle$B$,DI2C!#;H$$J}$Oe(B

  funcall name, args...

privatee$B$J$N$Ge(Bobj.funcalle$B$H$$$&Iw$K$O;H$($J$$!#B>$N%*%V%8%'e(B
e$B%/%H$Ne(Bprivatee$B%a%=%C%I$,8F$S$?$$;~$K$Oe(Binstance_evale$B$J$I$re(B
e$B;H$&!#e(B

e$BB>$N%/%i%9$Ne(Bprivatee$B%a%=%C%I$rD>@\8F$S$?$$$H$$$&OC$,$"$Ce(B
e$B$?$h$&$Je(B...e$B!#e(B

e$B$^$@<BAu$O$7$F$$$^$;$s$,!"$I$&<BAu$9$k$+$Oe(B(matzrubye$B$G$J$ie(B)e$B9Me(B
e$B$($F$"$j$^$9!#e(B

                            e$B$^$D$b$He(B e$B$f$-$R$me(B /:|)

#7

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:30109] Re: send/send and private method”
on Mon, 8 Jan 2007 17:17:08 +0900, Urabe S.
removed_email_address@domain.invalid writes:

|Yukihiro M. wrote:
|> (5) send!, __send!e$B$N3F%a%=%C%I$OGQ;_!#e(Bprivatee$B%a%=%C%I$r8F$Ve(B
|> e$B$?$a$Ne(Bprivatee$B%a%=%C%Ie(Bfuncalle$B$,DI2C!#;H$$J}$Oe(B
|>
|> funcall name, args…
|>
|> privatee$B$J$N$Ge(Bobj.funcalle$B$H$$$&Iw$K$O;H$($J$$!#B>$N%%V%8%'e(B
|> e$B%/%H$Ne(Bprivatee$B%a%=%C%I$,8F$S$?$$;~$K$Oe(Binstance_evale$B$J$I$re(B
|> e$B;H$&!#e(B
|
|selfe$B$Ne(Bprivatee$B%a%=%C%I$,8F$S$?$1$l$PIaDL$K$3$l$^$G$I$
$j$NJ}K!$G8F$Y$P$$e(B
|e$B$$$s$8$c$J$$$G$9$+e(B?e$B$o$6$o$6e(Bfuncalle$B$r7PM3$9$kM}M3$Oe(B?
|e$B$3$Ne(B(5)e$B$,$I$N$h$&$JMQK!$r0U?^$7$F$$$k$N$+$,8+$($^$;$s!#6qBNNc$r<($7$F$$e(B
|e$B$?$@$$$?J}$,$o$+$j$d$9$$$H;W$$$^$9!#e(B

e$B$J$K$+8m2r$,$"$k$N$+$J!)e(B
funcalle$B$Oe(Bsende$BF1MM$KF0E*$K%a%=%C%IL>e(B
e$B$r7hDj$7$?$$;~$K;H$&%a%=%C%I$G$9!#%a%=%C%IL>$,8GDj$N$H$-$Oe(B
e$B!VIaDL$K$3$l$^$GDL$j$NJ}K!$G8F$Y$P$h$$!W$G$9!#e(B

methods = {:exposure => :repaint,
:mousemove => :move,
:mouseover => :push}
funcall methods[events], *args

e$B$N$h$&$J46$8$@$H;W$C$F$$$?$@$1$l$P!#e(B


#8

e$BKNIt$G$9!#e(B

Yukihiro M. wrote:

e$B$J$K$+8m2r$,$"$k$N$+$J!)e(B

e$BB?J,!#e(B

e$B$=$l$Oe(Binstance_eval "#{methods[events]},
*args"e$B$H$O$I$&$A$,$&$N$G$7$g$&$+!#e(B
selfe$B0J30$H:.$<$F;H$&$H$-$Ke(Binstance_evale$B$N;HMQ$,?d>)$5$l$F$$$k$J$i!“e(Bself
e$B$N;~$be(Binstance_evale$B$G$$$$$8$c$s$H;W$&$N$G$9$,!#$J$K$+e(Bselfe$B$K$@$1FCJL$JJ}e(B
e$BK!$rDs6!$9$kM}M3$,$”$k$N$G$7$g$&$+e(B?


#9

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:30112] Re: send/send and private method”
on Mon, 8 Jan 2007 20:01:12 +0900, Urabe S.
removed_email_address@domain.invalid writes:

|e$B$=$l$Oe(Binstance_eval "#{methods[events]}, *args"e$B$H$O$I$&$A$,$&$N$G$7$g$&$+!#e(B

e$BJ8;zNs$+$i%3%s%Q%$%k$r9T$&<j=g$,>JN,$5$l$^$9!#$N$G!"$?$V$sB.e(B
e$BEY$,$:$$$V$s0c$&$O$:$G$9!#e(B

|selfe$B0J30$H:.$<$F;H$&$H$-$Ke(Binstance_evale$B$N;HMQ$,?d>)$5$l$F$$$k$J$i!“e(Bself
|e$B$N;~$be(Binstance_evale$B$G$$$$$8$c$s$H;W$&$N$G$9$,!#$J$K$+e(Bselfe$B$K$@$1FCJL$JJ}e(B
|e$BK!$rDs6!$9$kM}M3$,$”$k$N$G$7$g$&$+e(B?

e$B$"!“A0$N%a!<%k$Ge(Binstance_evale$B$H=q$$$?$N$OJ8;zNs5-K!$G$O$J$/e(B
e$B$F!”%V%m%C%/5-K!$NJ}$G$9!#$3$s$J46$8!#e(B

obj.instance_eval{foobar *args}

instance_exece$B$H=q$$$?J}$,8m2r$,>/$J$+$C$?$+$J!#e(B


#10

e$B!!$5$5$@$G$9!#e(B

Yukihiro M. wrote:

* publice$B%a%=%C%Ie(B(CLASS_OF(self)e$B$+$ie(BBasicObjecte$B$^$Ge(B)
e$B$3$N7k2L!"e(Bmatzrubye$B$N$h$&$K%0%m!<%P%k%a%=%C%I%-%c%C%7%e%F!<e(B
e$B%V%k$r;H$&$J$i%F!<%V%k$,$U$?$DI,MW$K$J$k!#%$%s%i%$%s%a%=%Ce(B
e$B%I%-%c%C%7%e$OJQ99$NI,MW$J$7e(B(e$B$@$H;W$&e(B)e$B!#e(B

e$B!!$3$N%k!<%k$@$H!"e(B

class C1
def m
“C1#m”
end
private :m
end

class C2 < C1
def m
“C2#m”
end

def foo
m
end
end

C2.new.foo e$B$,e(B C1#m
e$B$r8F$S=P$7$^$9$,!"$=$&$$$&$b$s$G$7$g$&$+!#e(B


#11

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:30154] Re: send/send and private method”
on Tue, 23 Jan 2007 12:16:32 +0900, SASADA Koichi removed_email_address@domain.invalid
writes:

|e$B!!$3$N%k!<%k$@$H!“e(B
|
|class C1
| def m
| “C1#m”
| end
| private :m
|end
|
|class C2 < C1
| def m
| “C2#m”
| end
|
| def foo
| m
| end
|end
|
|C2.new.foo e$B$,e(B C1#m e$B$r8F$S=P$7$^$9$,!”$=$&$$$&$b$s$G$7$g$&$+!#e(B

e$B$=$&$$$&$b$N$@$H9M$($F$^$9!#e(B


#12

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:30162] Re: send/send and private method”
on Tue, 23 Jan 2007 12:36:43 +0900, SASADA Koichi removed_email_address@domain.invalid
writes:

|e$B!!$&!<$s!#$Q$C$H;W$$$D$$$?Nc$J$s$G$9$,!"e(B
|
|class SomeConfig
| def load filename
| # e$B@_Dj$NFI$_9~$_e(B
| end
|
| def initialize file
| load file
| end
|end
|
|e$B$G!"e(BKernel#load e$B$r8F$s$8$c$&$N$OLdBj$J5$$,$7$^$9!#$3$l$+$i$O5$$r$D$1$m$Ce(B
|e$B$F!)!!E,Ev$JHf3S$+$I$&$+$O$o$+$j$^$;$s$,!"e(BJava e$B$@$He(B SomeConfig#load e$B$r8Fe(B
|e$B$S$^$9$h$M!#e(B

e$B$=$&$$$&>l9g$K$Oe(BSomeConfig#loade$B$re(Bprivatee$B$K$7$F$/$l$C$F$3$H$G!#e(B
e$B7Y9pe(B(e$B$+%(%i!<e(B)e$B$G$I$&$G$7$g$&!#e(B

                            e$B$^$D$b$He(B e$B$f$-$R$me(B /:|)

#13

e$B!!$5$5$@$G$9!#e(B

Yukihiro M. wrote:

|C2.new.foo e$B$,e(B C1#m e$B$r8F$S=P$7$^$9$,!"$=$&$$$&$b$s$G$7$g$&$+!#e(B

e$B$=$&$$$&$b$N$@$H9M$($F$^$9!#e(B

e$B!!$&!<$s!#$Q$C$H;W$$$D$$$?Nc$J$s$G$9$,!"e(B

class SomeConfig
def load filename
# e$B@_Dj$NFI$_9~$_e(B
end

def initialize file
load file
end
end

e$B$G!"e(BKernel#load
e$B$r8F$s$8$c$&$N$OLdBj$J5$$,$7$^$9!#$3$l$+$i$O5$$r$D$1$m$Ce(B
e$B$F!)!!E,Ev$JHf3S$+$I$&$+$O$o$+$j$^$;$s$,!"e(BJava e$B$@$He(B
SomeConfig#load e$B$r8Fe(B
e$B$S$^$9$h$M!#e(B