1.9.1-rc2のNEWSの内容


#1

1.9.1-rc2e$B$Ne(BNEWSe$B$NFbMF$K$D$$$F$N%3%a%s%H$H>/$7<ALd$G$9!#e(B

=== Compatibility issues

  • language core
    • New syntax and semantics

      o Method used for splat arguments: #to_splat instead of
        #to_ary
      

to_splate$B%a%=%C%I$O$J$5$=$&$G$9e(B(r14063e$B$G:o=|e(B?)

      o New semantics for constant definition in instance_eval
        or in module_eval.

(e$B$h$/$o$+$j$^$;$s$G$7$?!#$3$l$K$D$$$F2?$+>pJs$O$"$j$^$;$s$G$7$g$&$+!#e(B)

  • builtin classes and objects
    • Kernel and Object
      o Kernel#methods and #singleton_methods used to return an
      array of strings but now they return an array of symbols.

{global,local,instance,class}_valiablese$B$He(Bconstantse$B$b%7%s%%k$rJV$7$^$9!#e(B

* Class and Module
      o Module#attr is an alias of attr_reader

-we$B$G!Ve(Bwarning: optional boolean argument is obsoletede$B!W$He(B
e$B=P$k$N$G$9$,F0:n<+BN$O=>MhDL$j$N$h$&$G$9!#!Ve(B[Ruby2]e$B!W$G$9$+$Me(B?

* Enumerable and Enumerator
      o Enumerable::Enumerator, compatibility alias of Enumerator,
        is removed.

aliase$B$H$"$C$F!e(BEnumerable::Enumerator =
Enumeratore$B$@$C$?$+$h$&$Je(B
e$B0u>]$r<u$1$k$N$G$9$,!<B:]$K$O$=$&$G$O$J$$$G$9!#e(B

  • builtin classes and objects
* IO operations
      o IO#initialize now accepts an IO argument

ri IOe$B$K$be(BIO.new($stdout)e$B$H$$$&Nc$,$"$k$N$G$9$,!"e(B
e$B<B9T$9$k$H!Ve(Bcant convert IO into Integer
(TypeError)e$B!W$H$$$&e(B
e$BNc30$,5/$-$^$9!#e(B

* String and Regexp
      o No longer an Enumerable

e$B$3$l$Oe(BStringe$B$@$1$G$9$h$M!#e(B

* Symbols: restriction on literal symbols

http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l163e$B$K$h$k$He(B
e$B!Ve(B:$-)e$B!W$N$h$&$JIT@5$J%j%F%i%kI=8=$,$G$-$F$7$^$C$F$$$?e(B
e$B$H$$$&OC$N$h$&$J$N$G$9$,!"3NG$7$F$_$k$H$=$NF0:n$Oe(B1.8.3e$B$^$G$G!"e(B
1.8.4e$B$G$O!Ve(Bparse error, unexpected ), expecting
$e$B!W$K$J$j$^$9!#e(B

* Numeric
      o Numeric#div always rounds as Integer#div has done.
      o Numeric#fdiv: ditto.

http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l103e$B$K$h$k$He(B
e$B!Ve(B-10.0.div(3)e$B!W!Ve(B-10.div(3)e$B!W$J$I$NCM$,$I$&$J$k$+$H$$$&OC$N$h$&$G$9!#e(B
e$B$3$l$Oe(B1.8.4e$B"*e(B1.8.5e$B$G$9$G$KJQ99$5$l$F$$$^$9!#e(B

* $SAFE and bound methods

e$B4*0c$$$+$b$7$l$J$$$N$G$9$,e(B
http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l164e$B$K$h$k$He(B
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-dev/23697e$B$+$i$N%9%l%C%Ie(B
e$B$N$3$H$+$J$H;W$($^$9!#e(B

e$B$3$l$K$D$$$F$O$=$N8e$N$d$j<h$j$Ge(B1.8.3e$B$"$?$j$KF~$C$?$h$&$G$9!#e(B

      o New trusted/untrusted model in addition to
        tainted/untainted model.

e$B$G!"$3$A$i$Oe(B
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-dev/35306e$B$G$9$M!#e(B

e$B$"$^$jM}2r$G$-$J$$$J$$$+$b$7$l$J$$$N$G$9$1$I!"e(B
(a)$SAFE<=2e$B$G30It$+$iF@$i$l$?%%V%8%%/%H$He(B
(b)$SAFE>=3e$B$G30It$+$iF@$i$l$?%
%V%8%%/%H$r6hJL$7!e(B
$SAFE>=4e$B$G$Oe(B(b)e$B$@$1$rJQ99$G$-$k!$H$$$&$h$&$J$3$H$G$7$g$&$+!#e(B

e$BF0:n>e$Oe(B$SAFE>=4e$B$G$Oe(B
obj.tainted? == truee$B$G$+$De(B
obj.untrusted? == truee$B$G$"$ke(B
e$B%*%V%8%%/%H$N$_JQ99$G$-$k$H$$$&46$8$G$7$g$&$+!#e(B

* Deprecation

e$BB>$K!Ve(B$=e$B!W$,;H$($J$/$J$C$?$H$$$&$N$b$"$j$=$&$G$9!#e(B

  • bundled libraries
    === Language core changes
    • New syntax and semantics
      o #[] can take splatted arguments, hash style arguments
      and a block.

e$B$3$l$Oe(Bhttp://eigenclass.org/hiki/Changes+in+Ruby+1.9#l17e$B$G$7$g$&$+!#e(B
e$B!Ve(BFoo.new[*a, :op => :+]{|x| x
}e$B!W$N$h$&$J=q$-J}$,$G$-$k$H$$$&OC$G$9!#e(B

1.9.1rc2e$B$G$O!Ve(Bfoo[*a,
:b=>1]e$B!W$H$O=q$1$k$h$&$K$J$C$F$$$^$9$,!"e(B
e$B!Ve(Bfoo[1] {|x| }e$B!W$H$O=q$1$J$$$h$&$G$9!#e(B

e$BB>$K0J2<$,$"$j$=$&$G$9!#e(B

  • e$B9TF,!Ve(B.e$B!W$K$h$k9T7QB3e(B
  • ENCODING
  • def !=e$B!"e(Bdef !~e$B!"e(Bdef !
  • ife$B$J$I$G$Ne(Bthene$B$NBe$o$j$Ne(B:
  • begine$B!Ae(Bende$B0J30$G$Ne(Bretrye$B$OGQ;_e(B
  • evale$B$NBhFs0z?t$H$7$Fe(BProce$B%*%V%8%%/%H$rEO$;$J$/$J$C$?e(B

=== Library updates

  • builtin classes and objects
    • Blocks and Procs
      o Proc#yield

http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l44e$B$G$7$g$&$+!#e(B
e$B$h$/$o$+$i$J$+$C$?$N$G$9$,e(BProc#calle$B$NJLL>$N$h$&$K8+$($^$9!#e(B

      o Passing blocks to #[]

http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l46e$B$@$H;W$$$^$9$,!e(B
e$B>e$K$b=q$$$?DL$j!!Ve(Bfoo[] {||}e$B!W$O%(%i!<$K$J$j$^$9!#e(B

* Hash
     o Hash#_compare_by_identity and Hash#compare_by_identity?

e$B!Ve(BHash#_compare_by_identitye$B!W$Oe(B
e$B!Ve(BHash#compare_by_identitye$B!W$G$7$g$&$+!#e(B

* Symbol
      o Symbol#=== matches strings

e$B$A$g$C$H$o$+$i$J$+$C$?$N$G$9$,e(B
e$B!Ve(B:s === "s"e$B!W$H$OJL$N$3$H$G$7$g$&$+!#e(B
e$B!Ve(B:s === "s"e$B!W$Oe(Bfalsee$B$G$9!#e(B

* Numeric
      o Numeric#upto, #downto, #times, #step

uptoe$B!"e(Bdowntoe$B!"e(Btimese$B$Oe(B1.8/1.9e$B$H$b$K$J$/!e(Bstepe$B$O$I$A$i$K$b$$j$^$9!#e(B
e$BF0:nJQ$o$C$?$J$I$G$7$g$&$+!#e(B

e$BA4BNE*$K8+$F!"%a%=%C%IL>$@$1=q$+$l$F$$$k$N$Oe(B
e$BDI2C$5$l$?$+JQ99e(B(e$BHs8_49$G$O$J$/5!G=DI2Ce(B?)e$B$,$"$C$?$+e(B
e$B$N$I$A$i$+$N$h$&$G$7$?!#e(B
e$B2DG=$J$i$=$N$I$A$i$+$@$1$G$b$o$+$k$h$&$K$J$C$F$$$k$He(B
e$B$h$$$J$H;W$$$^$7$?!#e(B

e$B0J>e$G$9!#e(B


#2

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

e$B<+J,$bD4$Y$F$$$k:GCf$G$9!#e(B
e$B$o$+$kItJ,$@$1%3%a%s%H$7$^$9!#e(B

e$B$[$H$s$I$o$+$i$J$$!#!#!#e(B

2009/01/29 16:36 akira yamada / e$B$d$^$@$"$-$ie(B removed_email_address@domain.invalid:

1.9.1-rc2e$B$Ne(BNEWSe$B$NFbMF$K$D$$$F$N%3%a%s%H$H>/$7<ALd$G$9!#e(B

(snip)

to_splate$B%a%=%C%I$O$J$5$=$&$G$9e(B(r14063e$B$G:o=|e(B?)

      o New semantics for constant definition in instance_eval
        or in module_eval.

(e$B$h$/$o$+$j$^$;$s$G$7$?!#$3$l$K$D$$$F2?$+>pJs$O$"$j$^$;$s$G$7$g$&$+!#e(B)

e$B0J2<$N$h$&$K!"0JA0$H$O0c$C$FDj?t$rDj5A$9$k%9%3!<%W$,JQ$o$C$?$h$&$G$9!#e(B

class A
end

a = A.new
a.instance_eval{ B = constant B }
A.module_eval{ C = constant C }

B # => constant B # 1.8.7

=> uninitialized constant B (NameError) # 1.9.1

C # => constant C # 1.8.7

=> uninitialized constant C (NameError) # 1.9.1

(class << a ; self end)::B # => constant B # 1.9.1
A::C # => constant C # 1.9.1

a.instance_eval{ ::smiley: = constant D }
A.module_eval{ ::E = constant E }

D # => constant D # e$B6&DLe(B
E # => constant E # e$B6&DLe(B

e$BA4BNE*$K8+$F!"%a%=%C%IL>$@$1=q$+$l$F$$$k$N$Oe(B
e$BDI2C$5$l$?$+JQ99e(B(e$BHs8_49$G$O$J$/5!G=DI2Ce(B?)e$B$,$"$C$?$+e(B
e$B$N$I$A$i$+$N$h$&$G$7$?!#e(B
e$B2DG=$J$i$=$N$I$A$i$+$@$1$G$b$o$+$k$h$&$K$J$C$F$$$k$He(B
e$B$h$$$J$H;W$$$^$7$?!#e(B

e$BF10U$7$^$9!#e(B


#3

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

e$B>/$7$:$DD4$Y$F$^$9$,!"$o$+$C$?e(B(e$B$H;W$&e(B)e$B$b$N$@$1%3%a%s%H$7$^$9!#e(B

2009/01/29 16:36 akira yamada / e$B$d$^$@$"$-$ie(B removed_email_address@domain.invalid:

1.9.1-rc2e$B$Ne(BNEWSe$B$NFbMF$K$D$$$F$N%3%a%s%H$H>/$7<ALd$G$9!#e(B
(snip)

=== Library updates

  • builtin classes and objects
    • Blocks and Procs
      o Proc#yield

http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l44e$B$G$7$g$&$+!#e(B
e$B$h$/$o$+$i$J$+$C$?$N$G$9$,e(BProc#calle$B$NJLL>$N$h$&$K8+$($^$9!#e(B

e$B%=!<%9$r$_$?$i!"0J2<$N$h$&$KDj5A$5$l$F$$$^$7$?!#e(B

proc.c e$B$+$i!#e(B

rb_define_method(rb_cProc, "call", proc_call, -1);
rb_define_method(rb_cProc, "[]", proc_call, -1);
rb_define_method(rb_cProc, "===", proc_call, -1);
rb_define_method(rb_cProc, "yield", proc_call, -1);
* Symbol
      o Symbol#=== matches strings

e$B$A$g$C$H$o$+$i$J$+$C$?$N$G$9$,e(B
e$B!Ve(B:s === "s"e$B!W$H$OJL$N$3$H$G$7$g$&$+!#e(B
e$B!Ve(B:s === "s"e$B!W$Oe(Bfalsee$B$G$9!#e(B

$ ./ruby -ve p :s ===s
ruby 1.9.0 (2008-10-04 revision 19669) [i686-linux]
true
$ ruby-1.9.1 -ve p :s === s
ruby 1.9.1p0 (2009-01-28 revision 21860) [i686-linux]
false

e$B$3$&$J$j$^$7$?!#e(B


#4

At Thu, 29 Jan 2009 16:36:19 +0900,
akira yamada / wrote:

* String and Regexp
      o No longer an Enumerable

String

* Deprecation

$=

* Enumerable and Enumerator
      o Enumerable::Enumerator, compatibility alias of Enumerator,
        is removed.

aliasEnumerable::Enumerator = Enumerator

is removed


#5

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

In message Re: [ruby-dev:37862] Re: 1.9.1-rc2e$B$Ne(BNEWSe$B$NFbMFe(B
on Fri, 30 Jan 2009 16:37:17 +0900, Akinori MUSHA
removed_email_address@domain.invalid writes:

|> * ife$B$J$I$G$Ne(Bthene$B$NBe$o$j$Ne(B:
|
|e$B$3$l$O$^$@$"$k$s$G$7$g$&$+!#e(B

1.9e$B$G$O$b$&$"$j$^$;$s!#e(B

|> * begine$B!Ae(Bende$B0J30$G$Ne(Bretrye$B$OGQ;_e(B
|> * evale$B$NBhFs0z?t$H$7$Fe(BProce$B%%V%8%%/%H$rEO$;$J$/$J$C$?e(B
|
|e$B$3$NJU$O0U?^$5$l$?;EMM!":G=
;EMM$J$s$G$7$g$&$+$M!#e(B

e$B$O$$!#e(B


#6

At Thu, 29 Jan 2009 16:36:19 +0900,
akira yamada / wrote:

  • .
  • ENCODING
  • def !=def !~def !

  • ifthen:

  • beginendretry
  • evalProc