< :前の番号
^ :番号順リスト
> :次の番号
P :前の記事(スレッド移動)
N :次の記事
|<:前のスレッド
>|:次のスレッド
^ :返事先
_:自分への返事
>:同じ返事先を持つ記事(前)
<:同じ返事先を持つ記事(後)
---:分割してスレッド表示、再表示
| :分割して(縦)スレッド表示、再表示
~ :スレッドのフレーム消去
.:インデックス
..:インデックスのインデックス
1.9.1-rc2のNEWSの内容についてのコメントと少し質問です。
> === Compatibility issues
> * language core
> * New syntax and semantics
>
> o Method used for splat arguments: #to_splat instead of
> #to_ary
to_splatメソッドはなさそうです(r14063で削除?)
> o New semantics for constant definition in instance_eval
> or in module_eval.
(よくわかりませんでした。これについて何か情報はありませんでしょうか。)
> * 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}_valiablesとconstantsもシンボルを返します。
> * Class and Module
> o Module#attr is an alias of attr_reader
-wで「warning: optional boolean argument is obsoleted」と
出るのですが動作自体は従来通りのようです。「[Ruby2]」ですかね?
* Enumerable and Enumerator
o Enumerable::Enumerator, compatibility alias of Enumerator,
is removed.
aliasとあって、Enumerable::Enumerator = Enumeratorだったかような
印象を受けるのですが、実際にはそうではないです。
> * builtin classes and objects
> * IO operations
> o IO#initialize now accepts an IO argument
ri IOにもIO.new($stdout)という例があるのですが、
実行すると「can't convert IO into Integer (TypeError)」という
例外が起きます。
> * String and Regexp
> o No longer an Enumerable
これはStringだけですよね。
> * Symbols: restriction on literal symbols
<http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l163>によると
「:$-)」のような不正なリテラル表現ができてしまっていた
という話のようなのですが、確認してみるとその動作は1.8.3までで、
1.8.4では「parse error, unexpected ')', expecting $」になります。
> * Numeric
> o Numeric#div always rounds as Integer#div has done.
> o Numeric#fdiv: ditto.
<http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l103>によると
「-10.0.div(3)」「-10.div(3)」などの値がどうなるかという話のようです。
これは1.8.4→1.8.5ですでに変更されています。
> * $SAFE and bound methods
勘違いかもしれないのですが
<http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l164>によると
<http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-dev/23697>からのスレッド
のことかなと思えます。
これについてはその後のやり取りで1.8.3あたりに入ったようです。
> o New trusted/untrusted model in addition to
> tainted/untainted model.
で、こちらは
<http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-dev/35306>ですね。
あまり理解できないないかもしれないのですけど、
(a)$SAFE<=2で外部から得られたオブジェクトと
(b)$SAFE>=3で外部から得られたオブジェクトを区別し、
$SAFE>=4では(b)だけを変更できる、というようなことでしょうか。
動作上は$SAFE>=4では
obj.tainted? == trueでかつ
obj.untrusted? == trueである
オブジェクトのみ変更できるという感じでしょうか。
> * Deprecation
他に「$=」が使えなくなったというのもありそうです。
> * bundled libraries
> === Language core changes
> * New syntax and semantics
> o #[] can take splatted arguments, hash style arguments
> and a block.
これは<http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l17>でしょうか。
「Foo.new[*a, :op => :+]{|x| x }」のような書き方ができるという話です。
1.9.1rc2では「foo[*a, :b=>1]」とは書けるようになっていますが、
「foo[1] {|x| ...}」とは書けないようです。
他に以下がありそうです。
* 行頭「.」による行継続
* __ENCODING__
* def !=、def !~、def !
* ifなどでのthenの代わりの:
* begin〜end以外でのretryは廃止
* evalの第二引数としてProcオブジェクトを渡せなくなった
> === Library updates
> * builtin classes and objects
> * Blocks and Procs
> o Proc#yield
<http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l44>でしょうか。
よくわからなかったのですがProc#callの別名のように見えます。
> o Passing blocks to #[]
<http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l46>だと思いますが、
上にも書いた通り、「foo[] {||}」はエラーになります。
> * Hash
> o Hash#_compare_by_identity and Hash#compare_by_identity?
「Hash#_compare_by_identity」は
「Hash#compare_by_identity」でしょうか。
> * Symbol
> o Symbol#=== matches strings
ちょっとわからなかったのですが
「:s === "s"」とは別のことでしょうか。
「:s === "s"」はfalseです。
> * Numeric
> o Numeric#upto, #downto, #times, #step
upto、downto、timesは1.8/1.9ともになく、stepはどちらにもあります。
動作変わったなどでしょうか。
全体的に見て、メソッド名だけ書かれているのは
追加されたか変更(非互換ではなく機能追加?)があったか
のどちらかのようでした。
可能ならそのどちらかだけでもわかるようになっていると
よいなと思いました。
以上です。
--
やまだ