[Feature #841] Object#self


#1

Feature #841: Object#self
http://redmine.ruby-lang.org/issues/show/841

e$B5/I<<Te(B: rubikitch .
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal

e$B<+J,<+?H$rJV$9%a%=%C%I$,$"$C$F$b$$$$$s$8$c$J$$$G$7$g$&$+!)e(B
e$BL>A0$Oe(BRubye$BE*$K$Oe(Bselfe$B!"e(BLispe$B$KJo$&$J$i$Pe(Bidentitye$B$H$+!#e(B

class Object
def self; self end
end

1.self # => 1
“a”.self # => “a”


#2

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

In message “Re: [ruby-dev:37337] [Feature #841] Object#self”
on Wed, 10 Dec 2008 08:36:44 +0900, “rubikitch .”
removed_email_address@domain.invalid writes:

|e$B<+J,<+?H$rJV$9%a%=%C%I$,$"$C$F$b$$$$$s$8$c$J$$$G$7$g$&$+!)e(B
|e$BL>A0$Oe(BRubye$BE*$K$Oe(Bselfe$B!"e(BLispe$B$KJo$&$J$i$Pe(Bidentitye$B$H$+!#e(B

e$B$I$&$$$&Iw$K;H$&$s$G$9$+!)e(B


#3

e$B$3$s$K$A$O!"$J$+$`$ie(B(e$B$&e(B)e$B$G$9!#e(B

In message “[ruby-dev:37342] Re: [Feature #841] Object#self”
on Dec.10,2008 15:18:29, removed_email_address@domain.invalid wrote:

|e$B<+J,<+?H$rJV$9%a%=%C%I$,$"$C$F$b$$$$$s$8$c$J$$$G$7$g$&$+!)e(B
|e$BL>A0$Oe(BRubye$BE*$K$Oe(Bselfe$B!"e(BLispe$B$KJo$&$J$i$Pe(Bidentitye$B$H$+!#e(B

e$B$I$&$$$&Iw$K;H$&$s$G$9$+!)e(B

e$BB@8E$N@N$Ke(B +@ e$B$r$=$N$h$&$K$7$h$&$H$$$&Ds0F$,$"$C$?$h$&$G$9!#e(B
e$B"(e(B[ruby-dev:6416]
e$B$G!“e(B[ruby-dev:6450]e$B$Ge(B(e$B6qBNE*$J;H$$J}$G$O$J$$$G$9$,e(B)e$B@bL@$,$”$je(B
e$B$^$9$M!#e(B

[ruby-dev:6441]e$B$G$^$D$b$H$5$s$,!V$+$J$jA08~$-!W$HH/8@$7$?$1$Ie(B
e$B$=$l$C$-$j$K$J$C$?$h$&$K8+$($k$N$G$9$,!"8=:_$@$H$I$&;W$o$l$^e(B
e$B$9$+e(B?

e$B$=$l$G$O!#e(B


#4

From: Yukihiro M. removed_email_address@domain.invalid
Subject: [ruby-dev:37342] Re: [Feature #841] Object#self
Date: Wed, 10 Dec 2008 15:18:29 +0900

|e$B<+J,<+?H$rJV$9%a%=%C%I$,$"$C$F$b$$$$$s$8$c$J$$$G$7$g$&$+!)e(B
|e$BL>A0$Oe(BRubye$BE*$K$Oe(Bselfe$B!"e(BLispe$B$KJo$&$J$i$Pe(Bidentitye$B$H$+!#e(B

e$B$I$&$$$&Iw$K;H$&$s$G$9$+!)e(B

class Object
def self() self; end
end

e$B<+J,<+?H$rJV$9%a%=%C%I$re(Baliase$B$G:n@.$9$ke(B

class Test
alias foo self
end
Test.new.foo # => #Test:0x91aa1b8

e$B%V%m%C%/e(B {|x| x } e$B$re(B &:self e$B$H5-=R$9$ke(B

require ‘scanf’
“abcd”.scanf(’%c%c’) # => [“a”, “b”]
“abcd”.scanf(’%c%c’){|a| a} # => [[“a”, “b”], [“c”, “d”]]
“abcd”.scanf(’%c%c’, &:self) # => [[“a”, “b”], [“c”, “d”]]


#5

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

In message “Re: [ruby-dev:37346] Re: [Feature #841] Object#self”
on Wed, 10 Dec 2008 21:03:01 +0900, “U.Nakamura”
removed_email_address@domain.invalid writes:

|> e$B$I$&$$$&Iw$K;H$&$s$G$9$+!)e(B
|
|e$BB@8E$N@N$Ke(B +@ e$B$r$=$N$h$&$K$7$h$&$H$$$&Ds0F$,$"$C$?$h$&$G$9!#e(B
|e$B"(e(B[ruby-dev:6416]
|e$B$G!“e(B[ruby-dev:6450]e$B$Ge(B(e$B6qBNE*$J;H$$J}$G$O$J$$$G$9$,e(B)e$B@bL@$,$”$je(B
|e$B$^$9$M!#e(B
|
|[ruby-dev:6441]e$B$G$^$D$b$H$5$s$,!V$+$J$jA08~$-!W$HH/8@$7$?$1$Ie(B
|e$B$=$l$C$-$j$K$J$C$?$h$&$K8+$($k$N$G$9$,!"8=:_$@$H$I$&;W$o$l$^e(B
|e$B$9$+e(B?

e$B$"$N;~$[$II,MW@-$r46$8$J$/$J$C$F$^$9!#$"$l$+$i$:$$$V$s7P$D$Ne(B
e$B$K7k6II,MW$J%1!<%9$r8+$+$1$F$$$J$$$+$i$G$9!#$5$i$K$$$($P!Ve(B+@e$B!We(B
e$B$h$j$b!Ve(Bselfe$B!W$NJ}$,$5$i$KI,MW$5$r46$8$F$^$;$s!#e(B

identitye$B$N%f!<%9%1!<%9$Ge(Bselfe$B$H$$$&L>A0$,$U$5$o$7$$$b$N$O$J$$e(B
e$B$h$&$J5$$,$7$^$9!#e(B


#6

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

In message “Re: [ruby-dev:37347] Re: [Feature #841] Object#self”
on Wed, 10 Dec 2008 21:06:23 +0900, removed_email_address@domain.invalid writes:

|> e$B$I$&$$$&Iw$K;H$&$s$G$9$+!)e(B

|# e$B<+J,<+?H$rJV$9%a%=%C%I$re(Baliase$B$G:n@.$9$ke(B
|class Test
| alias foo self
|end
|Test.new.foo # => #Test:0x91aa1b8
|
|# e$B%V%m%C%/e(B {|x| x } e$B$re(B &:self e$B$H5-=R$9$ke(B
|require ‘scanf’
|“abcd”.scanf(’%c%c’) # => [“a”, “b”]
|“abcd”.scanf(’%c%c’){|a| a} # => [[“a”, “b”], [“c”, “d”]]
|“abcd”.scanf(’%c%c’, &:self) # => [[“a”, “b”], [“c”, “d”]]

e$BA0<T$O$^$C$?$/I,MW@-$,M}2r$G$-$^$;$s!#8e<T$Oe(Bselfe$B$H$$$&L>A0$Oe(B
e$B$U$5$o$7$/$J$$$H;W$$$^$9!#$5$i$K8@$($P$o$+$j$d$9$5$,A}$7$F$Je(B
e$B$$e(B(e$B$C$F$$$&$+$`$7$m0U?^$,$o$+$j$K$/$$e(B)e$B3d$K%P%$%H?t$9$i8:$C$Fe(B
e$B$J$$$7!#e(B


#7

e$B:#9946$,$"$j$^$9$,!"$"$C$F$b$$$$$J$H;W$C$F$$$^$7$?!#2?$b$7$J$$%a%=%C%Ie(B
e$B$,$"$k$HET9g$,$$$$$3$H$b$"$k$H;W$$$^$9!#e(B

class Object
def identity() self end
end

class Time
def to_s2(t=:identity) dup.send(t).to_s end
end

a = Time.now

p a.to_s2(:localtime)
p a.to_s2(:utc)
p a.to_s2


#8

e$B%A%1%C%He(B #841 e$B$,99?7$5$l$^$7$?!#e(B (by Yukihiro M.)

e$B%9%F!<%?%9e(B Opene$B$+$ie(BRejectede$B$KJQ99e(B

e$B:#2s$Oe(Brejecte$B!#e(B
e$BJL$NL>A0$H!"$=$NL>A0$K$U$5$o$7$$%f!<%9%1!<%9$,$"$l$P:#8e:NMQ$9$k$+$b!#e(B


http://redmine.ruby-lang.org/issues/show/841


#9

e$B%A%1%C%He(B #841 e$B$,99?7$5$l$^$7$?!#e(B (by Nobuhiro IMAI)

e$B%U%!%$%ke(B tap-without-block.patch e$BDI2Ce(B

e$B$9$G$K$"$k$b$N$rMxMQ$C$F$3$H$G!"e(BObject#tap
e$B$,%V%m%C%/$J$7$G$b8F$Y$k!"e(B
e$B$H$$$&$N$O$I$&$G$7$g$&$+!)e(B

array.send(hoge ? :sort : :tap).each{…}

e$B$N$h$&$K!"%=!<%H$,I,MW$+$I$&$+$,<B9T;~$K7h$^$k!"$_$?$$$J%1!<%9$O$?$^$K$"$j$^$9!#e(B

array = array.sort if hoge
array.each{…}

e$B$H=q$1$P$$$$$N$G$9$,!#e(B


http://redmine.ruby-lang.org/issues/show/841


#10

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

In message “Re: [ruby-dev:37354] Re: [Feature #841] Object#self”
on Thu, 11 Dec 2008 00:43:42 +0900, Tadayoshi F.
removed_email_address@domain.invalid writes:

|e$B:#9946$,$"$j$^$9$,!"$"$C$F$b$$$$$J$H;W$C$F$$$^$7$?!#2?$b$7$J$$%a%=%C%Ie(B
|e$B$,$"$k$HET9g$,$$$$$3$H$b$"$k$H;W$$$^$9!#e(B

e$B!VET9g$,$$$$$3$H$b$"$k!W$C$F$N$OJ,$+$i$J$$$G$b$J$$$s$G$9$,!"e(B
e$BL>A0$,5$$KF~$i$J$$$s$G!#e(Bselfe$B$be(Bidentitye$B$b$M$’!#e(B


#11

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

In message “Re: [ruby-dev:37361] [Feature #841] Object#self”
on Thu, 11 Dec 2008 07:58:23 +0900, Nobuhiro IMAI
removed_email_address@domain.invalid writes:

|e$B$9$G$K$"$k$b$N$rMxMQ$C$F$3$H$G!"e(BObject#tap e$B$,%V%m%C%/$J$7$G$b8F$Y$k!"e(B
|e$B$H$$$&$N$O$I$&$G$7$g$&$+!)e(B

tape$B$C$FL>A0$OJQ$8$c$J$$$G$9$+!#e(B


#12

e$B%A%1%C%He(B #841 e$B$,99?7$5$l$^$7$?!#e(B (by Nobuhiro IMAI)

e$B85$N0UL#$Oe(B tap into
e$B$H=q$$$F$"$k$h$&$K!VF~$j9~$`!W$J$N$+$J$H;W$$$^$9$,!“e(B
tap
e$B<+BN$K!V7Z$/C!$/!W$H$$$&0UL#$b$”$k$N$G!"%*%V%8%’%/%H$r7Z$/C!$$$?$i$=$N?Me(B
e$B$,JV;v$9$k$N$O<+A3$+$b!)$H$$$&$N$OL5M}$,$"$k$G$7$g$&$+e(B :-)e$B!#e(B


http://redmine.ruby-lang.org/issues/show/841


#13

e$B$3$s$K$A$O!"$J$+$`$ie(B(e$B$&e(B)e$B$G$9!#e(B

In message “[ruby-dev:37351] Re: [Feature #841] Object#self”
on Dec.11,2008 00:04:33, removed_email_address@domain.invalid wrote:

e$BA0<T$O$^$C$?$/I,MW@-$,M}2r$G$-$^$;$s!#8e<T$Oe(Bselfe$B$H$$$&L>A0$Oe(B
e$B$U$5$o$7$/$J$$$H;W$$$^$9!#$5$i$K8@$($P$o$+$j$d$9$5$,A}$7$F$Je(B
e$B$$e(B(e$B$C$F$$$&$+$`$7$m0U?^$,$o$+$j$K$/$$e(B)e$B3d$K%P%$%H?t$9$i8:$C$Fe(B
e$B$J$$$7!#e(B

e$B0U?^$N$o$+$j$d$9$5$O$H$b$+$/!"e(B+@e$B$K$3$N5!G=$r;}$?$;$k$H!"3g8Le(B
e$B$,>JN,$G$-$k$H$-$Ke(B &:+@ e$B$Oe(B {|a|a}
e$B$h$je(B1e$B%P%$%HC;$/$J$j$^$9!#e(B

… gorubye$B$KF~$l$H$/$+!#e(B

e$B$=$l$G$O!#e(B