Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arika/54547 to your computer and use it in GitHub Desktop.
Save arika/54547 to your computer and use it in GitHub Desktop.
書籍「プログラミング言語Ruby」とRuby 1.9.1RC2のNEWSファイルの対応状況
書籍「プログラミング言語Ruby」と
Ruby 1.9.1RC2のNEWSファイルの対応状況。
o - 記述あり
x - 記述なし
- - 対象範囲外
? - 未確認・判断できず
------------------------------------------------------------------------------
= NEWS
This document is a list of user visible feature changes made between
releases except for bug fixes.
Note that each entry is kept so brief that no reason behind or
reference information is supplied with. For a full list of changes
with all sufficient information, see the ChangeLog file.
== Changes since the 1.8.7 release
See doc/NEWS-1.8.7 for changes between 1.8.6 and 1.8.7.
=== Compatibility issues
* language core
* New syntax and semantics
o Block arguments are always local (5.4.4 p150)
o New semantics for block arguments (5.4.4 p150)
o Method used for splat arguments: #to_splat instead of
#to_ary (6.4.2 p193, 6.4.3 p194; ただし対応する実装がないかもしれない)
o defined? and local variables (4.6.12 p117)
o Parser expects that your source code has only valid byte
sequence in some character encoding. Use magic comments
to tell the parser which encoding you use. (2.4.1 p39)
x 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.
(8.4.1 p283)
* Class and Module
o Module#attr is an alias of attr_reader
(7.1.5 p227; ただし、第二引数がtrue/falseのときに出る
警告についてのは記述はない)
o Module#instance_methods, #private_instance_methods and
#public_instance_methods used to return an array of
strings but now they return an array of symbols. (8.4.1 p283)
x Extra subclassing check when binding UnboundMethods
(<http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l41>)
! {public,protected,private}_instance_methodが追加になった
(6.7.1 p212, 8.4.1 p283)
! {global,local,instance,class}_valiablesとconstantsもシンボルを返す
(8.3 p281)
* Exceptions
x Exceptions are equal to each other if they belong to
the same class and have the same message and backtrace.
(<http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l51>)
o SystemStackError used to be a subclass of StandardError
but not it is a direct subclass of Exception. (5.6.1 p161)
o SecurityError: ditto (5.6.1 p161)
o Removed Exception#to_str [Ruby2] (3.8.7.2 p84)
* Enumerable and Enumerator
x Enumerable::Enumerator, compatibility alias of Enumerator,
is removed.
o Enumerable#map,collect_all called without a block returns
an enumerator. (5.3.4 p141)
o Even more builtin and bundled libraries have been made to
return an enumerator when called without a block.
* Array
o Array#nitems was removed (use count {|i| !i.nil?})
o Array#choice was removed (use sample)
o Array#[m,n] = nil places nil in the array.
(3.3 p69, 9.5.2.3 p354)
* Hash
o Hash#to_s is equivalent to Hash#inspect (9.5.3.9 p364)
o Semantics for Hash#each and Hash#each_pair
(5.4.4 p150脚注, 9.5.3.6 p362)
o Hash#select returns a hash (9.5.3.2 p359)
x Hash#key is the new name for #index which has been
deprecated.
o Hash preserves order. It enumerates its elements in the
order in which the keys are inserted.
(9.5.3.6 p361, 9.5.4.4 p367)
- Most of the changes in Hash apply to hash like interfaces
such as ENV and *DBM.
* IO operations
o Many methods used to act byte-wise but now some of those act
character-wise. You can use alternate byte-wise methods.
(9.7.3.3 p381)
o IO#getc (9.7.3.3 p381)
o Non-blocking IO (9.7.3.3 p383, 9.8.4 p389)
x Kernel#open takes "t" for newline conversion
(<ri IO>)
o Kernel#open takes encoding specified (9.7.2 p378)
? IO#initialize now accepts an IO argument
o IO automatically converts byte sequence from a character
encodings into another if specified. (9.7.2 p378-384)
- StringIO#readpartial
o IO.try_convert (3.8.7.2 p85)
x IO.binread
o IO.copy_stream (9.6.4 p374)
x IO#binmode?
x IO#close_on_exec= and IO#close_on_exec?
o Limit input in IO#gets, IO#readline, IO#readlines,
IO#each_line, IO#lines, IO.foreach, IO.readlines,
StringIO#gets, StringIO#readline, StringIO#each,
StringIO#readlines (9.7.3.1 p380)
o IO#ungetc, StringIO#ungetc (9.7.3.3 p382)
o IO#ungetbyte, StringIO#ungetbyte (9.7.3.3 p382)
o IO#internal_encoding, IO#external_encoding,
IO#set_encoding (9.7.2 p378)
- IO.pipe takes encoding option
x Directive %u behaves like %d for negative values in
printf-style formatting.
(<http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l1>)
* File and Dir operations
o #to_path is called as necessary in File.path, File.chmod,
File.lchmod, File.chown, File.lchown, File.utime,
File.unlink, etc.. (7.6.1 p264, 9.6 p369)
o File.world_readable? (9.6.3 p372)
o File.world_writable? (9.6.3 p372)
x Dir.[], Dir.glob
x Dir.exist?
x Dir.exists?
* File::Stat
- File::Stat#world_readable?
- File::Stat#world_writable?
* String and Regexp
o No longer an Enumerable (7.5.2 p261, 9.1 p319; Stringのみ)
o ?c semantics (3.2.2 p57)
o "One-char-wide" semantics for String#[] and String#[]=
(3.2.4 p59)
o Character-wise semantics in many methods in stead of
byte-wise. (3.2.6 p61)
o Encoding-awareness (3.2.6 p61, 3.2.6.1 p62)
o Regexp matches only with strings which is encoded in a
compatible character encoding to the regexp's. (9.2.4.4 p335)
o Regexp#kcode is removed. use Regexp#encoding. (9.2.4.4 p335)
* Symbols: restriction on literal symbols
* Numeric
x Numeric#div always rounds as Integer#div has done.
(<http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l103>)
x Numeric#fdiv: ditto.
(<http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l103>)
* Integer
x Integer(nil) raises TypeError
* Fixnum
x Fixnum#id2name removed
x Fixnum#to_sym removed
* Struct
- Struct#inspect
* Time
- New format in Time#to_s
- Timezone information preserved on Marshal.dump/load
* $SAFE and bound methods
x New trusted/untrusted model in addition to
tainted/untainted model.
* Deprecation
x Kernel#to_a
o Kernel#getc, #gsub, #sub
(10.2.4.2 p423, 10.3.2 p425)
o Kernel#callcc and Continuation now become 'continuation'
bundled library. (5.8.3 p178)
- Object#type
- Removed Array and Hash #indices, #indexes
- Hash#index
- ENV.index
- Process::Status#to_int
- Numeric#rdiv
- Precision is removed. Don't cry, it will be redesigned
and come back in future version.
- Symbol#to_int and Symbol#to_i
o $KCODE is no longer effective. Use Encoding related
features of each class.
(10.2.3.1 p419)
x VERSION and friends
* bundled libraries
(全体的にカバー範囲から外れる)
=== Language core changes
* New syntax and semantics
o Magic comments to declare in which encoding your source
code is written (2.4.1 p39)
o New literal hash syntax and new syntax for hash style
arguments (3.4.1 p71)
o New syntax for lambdas (6.5.1.4 p200-202, 5.4.4 p152)
o .() and calling Procs without #call/#[]
(6.5.2 p202)
o Block in block arguments (5.4.4 p151)
o Block local variables (5.4.3 p149)
o Mandatory arguments after optional arguments allowed
(6.4.2 p193, 6.4.3 p194)
o Multiple splats allowed (4.5.5.5 p103, 5.4.4 p151)
? #[] can take splatted arguments, hash style arguments
and a block.
(<http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l17>;
実際にはできない?)
x New directives in printf-style formatted strings (%).
(<http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l18>)
x Newlines allowed before ternary colon
(<http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l19>)
o Encoding.default_external and default_internal
(2.4.2 p40)
=== Library updates
* builtin classes and objects
* Kernel and Object
o BasicObject (3.8.4 p78, 7.3 p245コラム)
x Object#=~ returns nil instead of false by default.
o Kernel#define_singleton_method (8.4.4 p286)
o Kernel#load can load a library from the highest versions
of gems by default. (7.6.1 p265)
* Class and Module
o Module#const_defined?, #const_get and #method_defined?
take an optional parameter.
(8.3.1 p282, 8.4.1 p284; ただし、
{public_,protected_private_}method_defined?などもそう、
とも書いているが、実際にはそうではないない)
o #class_variable_{set,get} are public.
(8.3.1 p282)
? Class of singleton classes
* Errno::EXXX
- All of those are always defined. Errno::EXXX will be
defined as an alias to Errno::NOERROR if your platform
does not have one.
* Binding#eval (6.6.2 p210)
* Blocks and Procs
o Arity of blocks without arguments (6.5.3 p203)
o proc is now a synonym of Proc.new (6.5.1.3 p200)
x Proc#yield
? Passing blocks to #[]
(<http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l46>;
実際にはできない?)
o Proc#lambda? (6.5.5 p204)
o Proc#curry (6.5.2 p202)
* Fiber: coroutines/micro-threads (5.8.2 p173-178)
* Thread
- Thread.critical and Thread.critical= removed
- Thread#exit!, Thread#kill! and Thread#terminate! removed.
* Enumerable and Enumerator
? Enumerable#each_with_index can take optional arguments
and passes them to #each.
? Enumerable#each_with_object
? Enumerator#with_object
? Enumerator.new { ... }
! Enumerable#cycle (9.5.1.1 p344)
* Array
x Array#delete returns a deleted element rather than a given
object
- Array#to_s is equivalent to Array#inspect
o Array.try_convert (3.8.7.2 p85)
x Array#pack('m0') complies with RFC 4648.
* Hash
o preserving item insertion order (9.5.1 p344)
x Hash#default_proc=
x Hash#_compare_by_identity and Hash#compare_by_identity?
o Hash.try_convert (3.8.7.2 p85)
o Hash#assoc (9.5.3.2 p359)
o Hash#rassoc (9.5.3.2 p359)
o Hash#flatten (9.5.2.9 p358)
* Range
o Range#cover? (3.5.1 p74)
o Range#include? iterates over elements and compares the
given value with each element unless the range is numeric.
Use Range#cover? for the old behavior, i.e. comparison
with boundary values. (3.5.1 p74)
x Range#min, Range#max
* File and Dir operations
? New methods
* Process
- Process.spawn
- Process.daemon
* String
? String#clear
? String#ord
o String#getbyte, String#setbyte (9.7.3.3 p382)
o String#chars and String#each_char act as character-wise.
(3.2.5 p61)
o String#codepoints, String#each_codepoint (3.2.5 p61)
? String#unpack with a block
? String#hash
o String.try_convert (3.8.7.2 p85)
o String#encoding (3.2.6.1 p63)
o String#force_encoding, String#encode and String#encode!
(3.2.6.1 p63)
? String#ascii_only?
o String#valid_encoding? (3.2.6.1 p64)
o String#match (9.1 p317)
* Symbol
- Zero-length symbols allowed
o Symbol#=== matches strings
(3.8.5.4 p83, 5.1.4 p129; ただ、実際には動作しないような)
- Symbol#intern
? Symbol#encoding
o Symbol methods similar to those in String
(3.6 p75, 3.8.5.5 p82)
* Regexp
x Regexp#=== matches symbols
o Regexp.try_convert (3.8.7.2 p85)
o Regexp#match (9.2.4 p331)
o Regexp#fixed_encoding? (9.2.4.4 p335)
o Regexp#encoding (9.2.4.4 p335)
o Regexp#named_captures (9.2.4 p330)
o Regexp#names (9.2.4 p330)
* MatchData
x MatchData#names
x MatchData#regexp
* Encoding
* Encoding::Converter
- supports conversion between many encodings
* Numeric
? Numeric#upto, #downto, #times, #step
x Numeric#real?, Complex#real?
x Numeric#magnitude
* Rational / Complex
o They are in the core library now
(3.1 p44, 9.3.4 p338, 9.3.5 p339)
* Math
? Math#log takes an optional argument.
? Math#log2
? Math#cbrt, Math#lgamma, Math#gamma
* Time
- Time.times removed. Use Process.times.
x Time#sunday?
x Time#monday?
x Time#tuesday?
x Time#wednesday?
x Time#thursday?
x Time#friday?
x Time#saturday?
? Time#tv_nsec and Time#nsec
* Misc. new methods
o RUBY_ENGINE to distinguish between Ruby processor implementation
o public_method (6.7 p310)
o public_send (7.2 p244, 8.4.3 p285)
- GC.count
- ObjectSpace.count_objects
? Method#hash, Proc#hash
x Method#source_location, UnboundMethod#source_location and
Proc#source_location
o __callee__ (8.6 p291)
o Elements in $LOAD_PATH and $LOADED_FEATURES are expanded
(7.6 p264)
* bundled libraries
(全体的にカバー範囲から外れる)
* commandline options
o -E, --encoding (2.4.2 p41, 10.1.3 p413)
x -U
o --enable-gems, --disable-gems (10.1.1 p412)
o --enable-rubyopt, --disable-rubyopt (10.1 p410)
x long options are allowed in RUBYOPT environment variable.
=== Implementation changes
(全体的にカバー範囲から外れる)
------------------------------------------------------------------------------
以下、カバー状況についてのコメント。
おおまかにカウントすると以下の通り。
o 92 (記述あり)
x 45 (記述なし)
- 28 (対象範囲外)
? 21 (未確認・判断できず)
約六割をカバーしている。
実際に読んでみた印象で言えば、
NEWSに含まれている中で影響の大きそうな変更は
おおむねカバーされているように思う。
また、xの中にはバグ修正なども含まれているなど、
書籍としては単に載せるスペースがないというものもある。
さらに、NEWSにはない変更点も複数挙げている。
気付いたものとしては以下のようなものがあった。
* {public,protected,private}_instance_methodが追加になった
(6.7.1 p212)(8.4.1 p283)
* {global,local,instance,class}_valiablesとconstantsもシンボルを返す
(8.3 p281)
* $=はもはや機能しない (3.2.3 p58脚注)
* 行頭「.」による行継続 (2.6.1 p35)
* __ENCODING__ (2.4.1 p40, 4.1 p91)
* def !=(obj) できる (3.8.5.2 p81, 4.6 p106)
* def !~(obj) できる (3.8.5.5 p82, 4.6 p106)
* def ! できる (4.6 p106)
* if、elsif、whenの後の「:」は廃止 (5.1.1 p122脚注, 5.1.4 p128脚注, 5.2.1 p132脚注)
* begin〜end以外でのretryは廃止 (5.5.5 p158)
* evalの第二引数としてProcオブジェクトを渡せなくなった (6.6.2 p 210脚注)
* String#gsubの第二引数にハッシュ (9.1 p318)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment