ruby/doc/NEWS-2.3.0

385 строки
13 KiB
Plaintext
Исходник Обычный вид История

# -*- rdoc -*-
= NEWS for Ruby 2.3.0
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 or Redmine
(e.g. <tt>https://bugs.ruby-lang.org/issues/$FEATURE_OR_BUG_NUMBER</tt>)
== Changes since the 2.2.0 release
=== Language changes
* frozen-string-literal pragma:
2020-05-18 14:42:20 +03:00
* new pragma, frozen-string-literal has been experimentally introduced. [Feature #8976]
* besides, --enable/--disable=frozen-string-literal options also have
been introduced. [Feature #8976]
* command line options --debug or --debug=frozen-string-literal enable
additional debugging mode which shows created location with at frozen
2020-05-18 14:42:20 +03:00
object error (RuntimeError). [Feature #11725]
* safe navigation operator:
* new method call syntax, `object&.foo', method #foo is called on
2020-05-18 14:42:20 +03:00
`object' if it is not nil. [Feature #11537]
This is similar to `try!' in Active Support, except:
* method name is syntactically required
obj.try! {} # valid
obj&. {} # syntax error
* arguments are evaluated only if a call is made:
obj.try!(:foo, bar()) # bar() is always evaluated
obj&.foo(bar()) # bar() is conditionally evaluated
* attribute assignment is valid
obj&.attr += 1
* the did_you_mean gem:
* When a NameError or NoMethodError occurs because of a typo in the name,
the did_you_mean gem automatically suggests other names similar to the
method name.
"Yuki".starts_with?("Y")
# => NoMethodError: undefined method `starts_with?' for "Yuki":String
# Did you mean? start_with?
* indented here document:
* new string literal, here document starts with `<<~`.
2020-05-18 14:42:20 +03:00
refer doc/syntax/literals.rdoc for more details. [Feature #9098]
=== Core classes updates (outstanding ones only)
* ARGF
2020-05-18 14:42:20 +03:00
* ARGF.read_nonblock supports `exception: false' like IO#read_nonblock. [Feature #11358]
* Array
* Array#bsearch_index [Feature #10730]
* Array#dig [Feature #11643]
* Comparable
* Comparable#== no longer rescues exceptions [Feature #7688]
* Encoding
* new Encoding::IBM037 (alias ebcdic-cp-us; dummy)
* Enumerable
2020-05-18 14:42:20 +03:00
* Enumerable#grep_v is added as inverse version of Enumerable#grep. [Feature #11049]
* Enumerable#chunk_while [Feature #10769]
* Enumerator::Lazy
* Enumerator::Lazy#grep_v [Feature #11773]
* File
* File.mkfifo [Feature #11536]
* Add File::TMPFILE corresponding to O_TMPFILE
* Hash
* Hash#fetch_values [Feature #10017]
* Hash#dig [Feature #11643]
* Hash#<=, Hash#<, Hash#>=, Hash#> [Feature #10984]
* Hash#to_proc [Feature #11653]
* IO
* new mode flag File::SHARE_DELETE is available.
this flag means to permit deleting opened file on Windows, but currently
this affect only files opened as binary. [Feature #11218]
* new option parameter `flags' is added.
2020-05-18 14:42:20 +03:00
this parameter is bitwise-ORed to oflags generated by normal mode argument. [Feature #11253]
* IO#advise no longer raises Errno::ENOSYS in cases where it was
detected at build time but not available at runtime. [Feature #11806]
* Kernel
* Kernel#loop, when stopped by a StopIteration exception, returns
what the enumerator has returned instead of nil. [Feature #11498]
* Module
* Module#deprecate_constant [Feature #11398]
* NameError
* NameError#receiver is added to take the receiver object. [Feature #10881]
* Numeric
* Numeric#positive? and Numeric#negative? are added, which return
2020-05-18 14:42:20 +03:00
true when the receiver is positive and negative respectively. [Feature #11151]
* Proc
* Proc#call (and also #[], #===, #yield) are optimized.
Backtrace doesn't show each method (show block lines directly).
TracePoint also ignores these calls. [Feature #11569]
* Queue (Thread::Queue)
* Queue#close is added to notice a termination. [Feature #10600]
* Regexp/String: Updated Unicode version from 7.0.0 to 8.0.0
* introduce new ISeq binary format serializer/de-serializer and a pre-compilation/runtime loader sample. [Feature #11788] * iseq.c: add new methods: * RubyVM::InstructionSequence#to_binary_format(extra_data = nil) * RubyVM::InstructionSequence.from_binary_format(binary) * RubyVM::InstructionSequence.from_binary_format_extra_data(binary) * compile.c: implement body of this new feature. * load.c (rb_load_internal0), iseq.c (rb_iseq_load_iseq): call RubyVM::InstructionSequence.load_iseq(fname) with loading script name if this method is defined. We can return any ISeq object as a result value. Otherwise loading will be continue as usual. This interface is not matured and is not extensible. So that we don't guarantee the future compatibility of this method. Basically, you should'nt use this method. * iseq.h: move ISEQ_MAJOR/MINOR_VERSION (and some definitions) from iseq.c. * encoding.c (rb_data_is_encoding), internal.h: added. * vm_core.h: add several supports for lazy load. * add USE_LAZY_LOAD macro to specify enable or disable of this feature. * add several fields to rb_iseq_t. * introduce new macro rb_iseq_check(). * insns.def: some check for lazy loading feature. * vm_insnhelper.c: ditto. * proc.c: ditto. * vm.c: ditto. * test/lib/iseq_loader_checker.rb: enabled iff suitable environment variables are provided. * test/runner.rb: enable lib/iseq_loader_checker.rb. * sample/iseq_loader.rb: add sample compiler and loader. $ ruby sample/iseq_loader.rb [dir] will compile all ruby scripts in [dir]. With default setting, this compile creates *.rb.yarb files in same directory of target .rb scripts. $ ruby -r sample/iseq_loader.rb [app] will run with enable to load compiled binary data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08 16:58:50 +03:00
* RubyVM::InstructionSequence
* add the following methods as a primitive tool of iseq loader.
See sample/iseq_loader.rb for usage.
Note that loader does not have verifier so it is easy to cause
critical problem by loading modified/broken binary data.
See [Feature #11788] for more details. (experimental feature)
* RubyVM::InstructionSequence#to_binary(extra_data = nil)
* RubyVM::InstructionSequence.load_from_binary(binary)
* RubyVM::InstructionSequence.load_from_binary_extra_data(binary)
* introduce new ISeq binary format serializer/de-serializer and a pre-compilation/runtime loader sample. [Feature #11788] * iseq.c: add new methods: * RubyVM::InstructionSequence#to_binary_format(extra_data = nil) * RubyVM::InstructionSequence.from_binary_format(binary) * RubyVM::InstructionSequence.from_binary_format_extra_data(binary) * compile.c: implement body of this new feature. * load.c (rb_load_internal0), iseq.c (rb_iseq_load_iseq): call RubyVM::InstructionSequence.load_iseq(fname) with loading script name if this method is defined. We can return any ISeq object as a result value. Otherwise loading will be continue as usual. This interface is not matured and is not extensible. So that we don't guarantee the future compatibility of this method. Basically, you should'nt use this method. * iseq.h: move ISEQ_MAJOR/MINOR_VERSION (and some definitions) from iseq.c. * encoding.c (rb_data_is_encoding), internal.h: added. * vm_core.h: add several supports for lazy load. * add USE_LAZY_LOAD macro to specify enable or disable of this feature. * add several fields to rb_iseq_t. * introduce new macro rb_iseq_check(). * insns.def: some check for lazy loading feature. * vm_insnhelper.c: ditto. * proc.c: ditto. * vm.c: ditto. * test/lib/iseq_loader_checker.rb: enabled iff suitable environment variables are provided. * test/runner.rb: enable lib/iseq_loader_checker.rb. * sample/iseq_loader.rb: add sample compiler and loader. $ ruby sample/iseq_loader.rb [dir] will compile all ruby scripts in [dir]. With default setting, this compile creates *.rb.yarb files in same directory of target .rb scripts. $ ruby -r sample/iseq_loader.rb [app] will run with enable to load compiled binary data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08 16:58:50 +03:00
* String
2020-05-18 14:42:20 +03:00
* String#+@ and String#-@ are added to get mutable/frozen strings. [Feature #11782]
2020-05-18 14:42:20 +03:00
* String.new now accepts new option parameter `encoding'. [Feature #11785]
* Struct
* Struct#dig [Feature #11688]
* Thread
* Thread#name, Thread#name= are added to handle thread names [Feature #11251]
=== Core classes compatibility issues (excluding feature bug fixes)
* Array
* Array#select!, Array#keep_if, Array#reject!, and Array#delete_if
no longer changes the receiver array instantly every time the
block is called. [Feature #10714]
* Array#flatten and Array#flatten! no longer try to call #to_ary
method on elements beyond the given level. [Bug #10748]
* Array#inspect doesn't raise error even if its content returns
a string which is not compatible with Encoding.default_external
as inspected result. [Feature #11801]
* Enumerable
* Enumerable#chunk and Enumerable#slice_before no longer takes the
initial_state argument. [Feature #10958]
Use a local variable instead to maintain a state.
* File::Stat
* On Windows File::Stat#ino always returned 0, but now returns
BY_HANDLE_FILE_INFORMATION.nFileIndexHigh/Low. [Feature #11216]
* Hash
* Hash#inspect doesn't raise error even if its content returns
a string which is not compatible with Encoding.default_external
as inspected result. [Feature #11801]
* IO
* IO#close doesn't raise when the IO object is closed. [Feature #10718]
* IO#each_codepoint raises an exception at incomplete character
before EOF when conversion takes place. [Bug #11444]
* Module
* Module#define_method and Object.define_singleton_method now
require method body, Proc, Method, or a block, and raise
ArgumentError if no block is given directly. [Bug #11283]
* pack/unpack (Array/String)
* j and J directives for pointer width integer type. [Feature #11215]
=== Stdlib updates (outstanding ones only)
* Logger
* Logger#level= now supports symbol and string levels such as :debug, :info,
:warn, :error, :fatal (case insensitive) [Feature #11695]
* Logger#reopen is added to reopen a log device. [Feature #11696]
* io/wait
* IO#wait_readable no longer checks FIONREAD, it may be used for
non-bytestream IO such as listen sockets.
* Net::FTP
* Net::FTP#mlst is added.
* Net::FTP#mlsd is added.
* nkf
* Merge nkf 2.1.4.
* ObjectSpace (objspace)
* ObjectSpace.count_symbols is added.
* ObjectSpace.count_imemo_objects is added.
* ObjectSpace.internal_class_of is added.
* ObjectSpace.internal_super_of is added.
accept_nonblock supports "exception: false" This is analogous to functionality found in IO#read_nonblock and IO#wait_nonblock. Raising exceptions for common failures on non-blocking servers is expensive and makes $DEBUG too noisy. Benchmark results: user system total real default 2.790000 0.870000 3.660000 ( 3.671597) exception: false 1.120000 0.800000 1.920000 ( 1.922032) exception: false (cached arg) 0.820000 0.770000 1.590000 ( 1.589267) --------------------- benchmark script ------------------------ require 'socket' require 'benchmark' require 'tmpdir' nr = 1000000 Dir.mktmpdir('nb_bench') do |path| sock_path = "#{path}/test.sock" s = UNIXServer.new(sock_path) Benchmark.bmbm do |x| x.report("default") do nr.times do begin s.accept_nonblock rescue IO::WaitReadable end end end x.report("exception: false") do nr.times do begin s.accept_nonblock(exception: false) rescue IO::WaitReadable abort "should not raise" end end end x.report("exception: false (cached arg)") do arg = { exception: false } nr.times do begin s.accept_nonblock(arg) rescue IO::WaitReadable abort "should not raise" end end end end end * ext/socket/init.c (rsock_s_accept_nonblock): support exception: false [ruby-core:66385] [Feature #10532] * ext/socket/init.c (rsock_init_socket_init): define new symbols * ext/socket/rubysocket.h: adjust prototype * ext/socket/socket.c (sock_accept_nonblock): support exception: false * ext/openssl/ossl_ssl.c (ossl_ssl_accept_nonblock): ditto * ext/socket/socket.c (Init_socket): adjust accept_nonblock definition * ext/openssl/ossl_ssl.c (Init_ossl_ssl): ditto * ext/socket/tcpserver.c (rsock_init_tcpserver): ditto * ext/socket/unixserver.c (rsock_init_unixserver): ditto * ext/socket/tcpserver.c (tcp_accept_nonblock): adjust rsock_s_accept_nonblock call * ext/socket/unixserver.c (unix_accept_nonblock): ditto * ext/openssl/ossl_ssl.c (ossl_start_ssl): support no_exception * ext/openssl/ossl_ssl.c (ossl_ssl_connect): adjust ossl_start_ssl call * ext/openssl/ossl_ssl.c (ossl_ssl_connect_nonblock): ditto * ext/openssl/ossl_ssl.c (ossl_ssl_accept): ditto * test/socket/test_nonblock.rb (test_accept_nonblock): test for "exception :false" * test/socket/test_tcp.rb (test_accept_nonblock): new test * test/socket/test_unix.rb (test_accept_nonblock): ditto * test/openssl/test_pair.rb (test_accept_nonblock_no_exception): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49948 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-12 06:03:04 +03:00
* OpenSSL
connect_nonblock supports "exception: false" This is for consistency with accept_nonblock arguments and gives a minor speedup from avoiding exceptions. [ruby-core:68838] [Feature #11024] * ext/openssl/ossl_ssl.c (ossl_ssl_connect_nonblock): support `exception: false' * (get_no_exception): move function location * ext/socket/socket.c (sock_connect_nonblock): support `exception: false' * test/openssl/test_pair.rb (test_connect_accept_nonblock_no_exception): test `exception: false' on connect, rename from `test_accept_nonblock_no_exception' * test/socket/test_nonblock.rb (test_connect_nonblock_no_exception): new test Benchmark results: default 0.050000 0.100000 0.150000 ( 0.151307) exception: false 0.030000 0.080000 0.110000 ( 0.108840) ----------------------------8<----------------------- require 'socket' require 'benchmark' require 'io/wait' require 'tmpdir' host = '127.0.0.1' serv = TCPServer.new(host, 0) # UNIX sockets may not hit EINPROGRESS nr = 5000 # few iterations to avoid running out of ports addr = serv.getsockname pid = fork do begin serv.accept.close rescue => e warn "#$$: #{e.message} (#{e.class})" end while true end at_exit { Process.kill(:TERM, pid) } serv.close Benchmark.bmbm do |x| x.report("default") do nr.times do s = Socket.new(:INET, :STREAM) s.setsockopt(:SOL_SOCKET, :SO_REUSEADDR, 1) begin s.connect_nonblock(addr) rescue IO::WaitWritable s.wait_writable end s.close end end x.report("exception: false") do nr.times do s = Socket.new(:INET, :STREAM) s.setsockopt(:SOL_SOCKET, :SO_REUSEADDR, 1) case s.connect_nonblock(addr, exception: false) when :wait_writable s.wait_writable end s.close end end end git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50254 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-12 04:41:51 +03:00
* OpenSSL::SSL::SSLSocket#accept_nonblock and
2020-05-18 14:42:20 +03:00
OpenSSL::SSL::SSLSocket#connect_nonblock supports `exception: false`. [Feature #10532]
accept_nonblock supports "exception: false" This is analogous to functionality found in IO#read_nonblock and IO#wait_nonblock. Raising exceptions for common failures on non-blocking servers is expensive and makes $DEBUG too noisy. Benchmark results: user system total real default 2.790000 0.870000 3.660000 ( 3.671597) exception: false 1.120000 0.800000 1.920000 ( 1.922032) exception: false (cached arg) 0.820000 0.770000 1.590000 ( 1.589267) --------------------- benchmark script ------------------------ require 'socket' require 'benchmark' require 'tmpdir' nr = 1000000 Dir.mktmpdir('nb_bench') do |path| sock_path = "#{path}/test.sock" s = UNIXServer.new(sock_path) Benchmark.bmbm do |x| x.report("default") do nr.times do begin s.accept_nonblock rescue IO::WaitReadable end end end x.report("exception: false") do nr.times do begin s.accept_nonblock(exception: false) rescue IO::WaitReadable abort "should not raise" end end end x.report("exception: false (cached arg)") do arg = { exception: false } nr.times do begin s.accept_nonblock(arg) rescue IO::WaitReadable abort "should not raise" end end end end end * ext/socket/init.c (rsock_s_accept_nonblock): support exception: false [ruby-core:66385] [Feature #10532] * ext/socket/init.c (rsock_init_socket_init): define new symbols * ext/socket/rubysocket.h: adjust prototype * ext/socket/socket.c (sock_accept_nonblock): support exception: false * ext/openssl/ossl_ssl.c (ossl_ssl_accept_nonblock): ditto * ext/socket/socket.c (Init_socket): adjust accept_nonblock definition * ext/openssl/ossl_ssl.c (Init_ossl_ssl): ditto * ext/socket/tcpserver.c (rsock_init_tcpserver): ditto * ext/socket/unixserver.c (rsock_init_unixserver): ditto * ext/socket/tcpserver.c (tcp_accept_nonblock): adjust rsock_s_accept_nonblock call * ext/socket/unixserver.c (unix_accept_nonblock): ditto * ext/openssl/ossl_ssl.c (ossl_start_ssl): support no_exception * ext/openssl/ossl_ssl.c (ossl_ssl_connect): adjust ossl_start_ssl call * ext/openssl/ossl_ssl.c (ossl_ssl_connect_nonblock): ditto * ext/openssl/ossl_ssl.c (ossl_ssl_accept): ditto * test/socket/test_nonblock.rb (test_accept_nonblock): test for "exception :false" * test/socket/test_tcp.rb (test_accept_nonblock): new test * test/socket/test_unix.rb (test_accept_nonblock): ditto * test/openssl/test_pair.rb (test_accept_nonblock_no_exception): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49948 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-12 06:03:04 +03:00
* Pathname
2020-05-18 14:42:20 +03:00
* Pathname#descend and Pathname#ascend supported blockless form. [Feature #11052]
* Socket
* Socket#connect_nonblock, Socket#accept_nonblock,
TCPServer#accept_nonblock, UNIXServer#accept_nonblock,
BasicSocket#recv_nonblock, BasicSocket#recvmsg_nonblock,
BasicSocket#sendmsg_nonblock all support `exception: false` to return
:wait_readable or :wait_writable symbols instead of raising
2020-05-18 14:42:20 +03:00
IO::WaitReadable or IO::WaitWritable exceptions [Feature #10532] [Feature #11229]
* BasicSocket#recv and BasicSocket#recv_nonblock allow an output
String buffer argument like IO#read and IO#read_nonblock to reduce
GC overhead [Feature #11242]
* StringIO
* In read-only mode, StringIO#set_encoding no longer sets the encoding
of its buffer string. Setting the encoding of the string directly
2020-05-18 14:42:20 +03:00
without StringIO#set_encoding may cause unpredictable behavior now. [Bug #11827]
* timeout
* Object#timeout is now warned as deprecated when called.
=== Stdlib compatibility issues (excluding feature bug fixes)
* ext/coverage/coverage.c
* Coverage.peek_result: new method to allow coverage to be captured without
stopping the coverage tool. [Feature #10816]
* Fiddle
* Fiddle::Function#call releases the GVL. [Feature #11607]
* io-console
* Update to io-console 0.4.5, and change the license to BSD 2-clause
"Simplified" License.
* lib/base64.rb
* Base64.urlsafe_encode64: added a "padding" option to suppress
the padding character ("="). [Feature #10740]
* Base64.urlsafe_decode64: now it accepts not only correctly-padded
input but also unpadded input. [Feature #10740]
* lib/drb/drb.rb
* removed unused argument. https://github.com/ruby/ruby/pull/515
* lib/matrix.rb
* Add Vector#round. https://github.com/ruby/ruby/pull/802
* lib/webrick/utils.rb
* removed unused argument. https://github.com/ruby/ruby/pull/356
* Net::FTP
* Connections are in passive mode per default now. The default mode can
be changed by Net::FTP.default_passive=. [Feature #11612]
* Net::HTTP
* default value of Net::HTTP#open_timeout is now 60 (was nil).
* Net::Telnet
2020-05-18 14:42:20 +03:00
* Net::Telnet is extracted to net-telnet gem. It's unmaintain code. [Feature #11083]
* Psych
* Updated to Psych 2.0.17
* Rake
* Rake is removed from stdlib. [Feature #11025]
* RDoc
* Updated to RDoc 4.2.1. For full release notes see:
https://github.com/rdoc/rdoc/blob/master/History.rdoc#421--2015-12-22
* RubyGems
* Updated to RubyGems 2.5.1. For full release notes see:
http://docs.seattlerb.org/rubygems/History_txt.html#label-2.5.0+-2F+2015-11-03
and
http://docs.seattlerb.org/rubygems/History_txt.html#label-2.5.1+-2F+2015-12-10
=== Built-in global variables compatibility issues
* $SAFE
* $SAFE=2 and $SAFE=3 are obsolete. If $SAFE is set to 2 or larger,
an ArgumentError is raised. [Feature #5455]
=== C API updates
* rb_define_class_id_under() now raises a TypeError exception when the
class is already defined but its superclass does not match the given
superclass, as well as definitions in ruby level.
2020-05-18 14:42:20 +03:00
* rb_timespec_now() is added to fetch current datetime as struct timespec. [Feature #11558]
* rb_time_timespec_new() is added to create a time object with epoch,
nanosecond, and UTC/localtime/time offset arguments. [Feature #11558]
* rb_autoload() deprecated, use rb_funcall() instead. [Feature #11664]
* rb_compile_error_with_enc(), rb_compile_error(), and rb_compile_bug()
deprecated. these functions are exposed but only for internal use.
external libraries should not use them.
=== Supported platform changes
* OS/2 is no longer supported
* BeOS is no longer supported
* Borland-C is no longer supported
* Haiku now stable and best effort
=== Implementation improvements
2020-05-18 14:42:20 +03:00
* Optimize Proc#call to eliminate method frame construction. [Feature #11569]
2020-05-18 14:42:20 +03:00
* Reconsidering method entry data structure. [Bug #11278]
* Introducing new table data structure for ID keys tables used by
method table and so on. New table structure is simple and fast
than st_table. [Feature #11420]
* Machine code level tuning for object allocation and method calling
code. r52099, r52254
2020-05-18 14:42:20 +03:00
* RubyVM::InstructionSequence is extended for future improvement. [Feature #11788]
* Case dispatch is now optimized for all special constant literals
including nil, true, and false. Previously, only literal strings,
2020-05-18 14:42:20 +03:00
symbols, integers and floats compiled to optimized case dispatch. [Feature #11769]
* Instance variables on non-pure Ruby classes (T_DATA, T_FILE,
etc..) is less expensive to store than before. [Feature #11170]
* All accesses to members of big Struct objects are performed in
constant-time. Previously, Struct elements beyond the first 10
elements used a linear scan. [Feature #10585]
2020-05-18 14:42:20 +03:00
* The Set class got several speed up. [Misc #10754], [r52591]
* Socket and I/O-related improvements
* Calling overhead of most of new keyword-using I/O methods in
[Feature #11229] is reduced by avoiding the inefficient C API
to parse keywords. [Feature #11339]
* The standard library is updated to use the improved
exception-free non-blocking I/O from [Feature #11229].
This has the additional benefit of quieter $DEBUG output in
addition to reducing expensive exceptions. [Feature #11044]
* (Linux-only) waiting on a single FD anywhere in the stdlib no longer
2020-05-18 14:42:20 +03:00
uses select(2), making it immune to slowdowns with high-numbered
FDs. [Feature #11081] [Feature #11377]
* CGI.escapeHTML is optimized with C extension.
https://github.com/ruby/ruby/pull/1164