1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/NEWS
nobu 15533bb40a NEWS: codify keywords and callback methods [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-28 01:58:27 +00:00

474 lines
13 KiB
Text

# -*- rdoc -*-
= NEWS for Ruby 2.6.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.5.0 release
=== Language changes
* <code>$SAFE</code> is a process global state and we can set 0 again. [Feature #14250]
* refinements take place at block passing. [Feature #14223]
* +else+ without +rescue+ now causes a syntax error. [EXPERIMENTAL]
* constant names may start with a non-ASCII capital letter. [Feature #13770]
* An endless range is introduced. You can write a range that has no end,
like <code>(0..)</code>. The following shows typical use cases. [Feature #12912]
ary[1..] # identical to ary[1..-1]
(1..).each {|index| ... } # infinite loop from index 1
ary.zip(1..) {|elem, index| ... } # ary.each.with_index(1) { }
* Non-Symbol key in keyword arguments hash causes an exception.
* "shadowing outer local variable" warning was removed. [Feature #12490]
You can now write the following without warning.
user = users.find {|user| cond(user) }
* Print exception backtrace and error message in reverse order when the
exception is not caught and STDOUT is unchanged and a tty. [Feature #8661]
* Print `cause` of the exception if the exception is not caught and printed
its backtraces and error message [Feature #8257]
=== Core classes updates (outstanding ones only)
[Array]
[New methods]
* Added Array#union and Array#difference instance methods. [Feature #14097]
[Modified methods]
* Array#to_h now maps elements to new keys and values by the
block if given. [Feature #15143]
[Aliased methods]
* Array#filter is a new alias for Array#select. [Feature #13784]
* Array#filter! is a new alias for Array#select!. [Feature #13784]
[Binding]
[New methods]
* added Binding#source_location. [Feature #14230]
This method returns the source location of the binding, a 2-element
array of <code>__FILE__</code> and <code>__LINE__</code>.
Traditionally, the same information could be retrieved by
<code>eval("[__FILE__, __LINE__]", binding)</code>, but we are
planning to change this behavior so that Kernel#eval ignores
binding's source location [Bug #4352]. So, users should use this
newly-introduced method instead of Kernel#eval.
[Dir]
[New methods]
* added Dir#each_child and Dir#children instance methods. [Feature #13969]
[Enumerable]
[Modified methods]
* Enumerable#to_h now maps elements to new keys and values by the block if
given. [Feature #15143]
[Aliased methods]
* Enumerable#filter is a new alias for Enumerable#select. [Feature #13784]
[Enumerator::ArithmeticSequence]
* This is a new class to represent a generator of an arithmetic sequence,
that is a number sequence defined by a common difference. It can be used
for representing what is similar to Python's slice. You can get an
instance of this class from Numeric#step and Range#step.
[Enumerator::Lazy]
[Aliased methods]
* Enumerator::Lazy#filter is a new alias for
Enumerator::Lazy#select. [Feature #13784]
[ENV]
[Modified methods]
* ENV.to_h now maps names and values to new keys and values
by the block if given. [Feature #15143]
[Exception]
[New options]
* Exception#full_message takes +:highlight+ and +:order+
options. [Bug #14324]
[Hash]
[Modified methods]
* Hash#merge, merge!, and update now accept multiple
arguments. [Feature #15111]
* Hash#to_h now maps keys and values to new keys and values
by the block if given. [Feature #15143]
[Aliased methods]
* Hash#filter is a new alias for Hash#select. [Feature #13784]
* Hash#filter! is a new alias for Hash#select!. [Feature #13784]
[IO]
[New options]
* new mode character <code>'x'</code> to open files for exclusive
access. [Feature #11258]
[Kernel]
[Aliased methods]
* Kernel#then is a new alias for Kernel#yield_self. [Feature #14594]
[New options]
* Kernel#Complex, Kernel#Float, Kernel#Integer, and
Kernel#Rational take +:exception+ option to specify the way of
error handling. [Feature #12732]
* Kernel#system takes +:exception+ option to raise an exception
on failure. [Feature #14386]
[Incompatible changes]
* Kernel#system and Kernel#exec do not close non-standard file descriptors
(The default of the +:close_others+ option is changed to +false+,
but we still set the +FD_CLOEXEC+ flag on descriptors we
create). [Misc #14907]
[KeyError]
[New options]
* KeyError#initialize accepts +:receiver+ and +:key+ options to
set receiver and key in Ruby code. [Feature #14313]
[Module]
[New methods]
* Module#method_defined?, Module#private_method_defined?, and
Module#protected_method_defined? now accept the second
parameter as optional. If it's +true+ (=default), checks ancestor
modules/classes, or checks only the class itself. [Feature #14944]
[NameError]
[New options]
* NameError#initialize accepts +:receiver+ option to set receiver
in Ruby code. [Feature #14313]
[NoMethodError]
[New options]
* NoMethodError#initialize accepts +:receiver+ option to set receiver
in Ruby code. [Feature #14313]
[Numeric]
[Incompatible changes]
* Numeric#step now returns an instance of Enumerator::ArithmeticSequence
class rather than one of Enumerator class.
[Proc]
[Incompatible changes]
* Proc#call doesn't change <code>$SAFE</code> any more. [Feature #14250]
[Random]
[New methods]
* added Random.bytes. [Feature #4938]
[Range]
[New methods]
* Added Range#% instance method. [Feature #14697]
[Incompatible changes]
* Range#=== now uses +#cover?+ instead of +#include?+ method. [Feature #14575]
* Range#cover? now accepts Range object. [Feature #14473]
* Range#step now returns an instance of Enumerator::ArithmeticSequence
class rather than one of Enumerator class.
[RubyVM::AST]
[New methods]
* RubyVM::AST.parse parses a given string and returns AST
nodes. [experimental]
* RubyVM::AST.parse_file parses a given file and returns AST
nodes. [experimental]
[String]
[New features]
* String#split yields each substring to the block if given. [Feature #4780]
[Struct]
[Modified methods]
* Struct#to_h now maps keys and values to new keys and values
by the block if given. [Feature #15143]
[Aliased method]
* Struct#filter is a new alias for Struct#select [Feature #13784]
[Time]
[New features]
* Time.new and Time#getlocal accept a timezone object as well as
UTC offset string. Time#+, Time#- and Time#succ also preserve
the timezone. [Feature #14850]
[TracePoint]
[New methods]
* TracePoint#parameters [Feature #14694]
=== Stdlib updates (outstanding ones only)
[Coverage]
A oneshot_lines mode is added. [Feature #15022]
This mode checks "whether each line was executed at least once or not",
instead of "how many times each line was executed".
A hook for each line is fired at most once, and after it is fired
the hook flag is removed, i.e., it runs with zero overhead.
[New options]
* Add +:oneshot_lines+ keyword argument to Coverage.start.
* Add +:stop+ and +:clear+ keyword arguments to Coverage.result.
If +clear+ is true, it clears the counters to zero.
If +stop+ is true, it disables coverage measurement.
[New methods]
* Coverage.line_stub, which is a simple helper function that
creates the "stub" of line coverage from a given source code.
[ERB]
[New options]
* Add +:trim_mode+ and +:eoutvar+ keyword arguments to ERB.new.
Now non-keyword arguments other than first one are softly deprecated
and will be removed when Ruby 2.5 becomes EOL. [Feature #14256]
* erb command's <tt>-S</tt> option is deprecated, which will be removed
in the next version.
[FileUtils]
[New methods]
* FileUtils#cp_lr. [Feature #4189]
[Matrix]
[New methods]
* Matrix#antisymmetric?
* Matrix#reflexive?
[Net]
[New options]
* Add +:write_timeout+ keyword argument to Net::HTTP.new. [Feature #13396]
[New methods]
* Add Net::HTTP#write_timeout and Net::HTTP#write_timeout=. [Feature #13396]
[New constant]
* Add Net::HTTPClientException to deprecate Net::HTTPServerException,
whose name is misleading. [Bug #14688]
[REXML]
[Improved some XPath implementations]
* <code>concat()</code> function: Stringify all arguments before concatenating
* <code>string()</code> function: Support context node
* <code>string()</code> function: Support processing instruction node
* Support <code>"*:#{ELEMENT_NAME}"</code> syntax in XPath 2.0
[Fixed some XPath implementations]
* <code>"//#{ELEMENT_NAME}[#{POSITION}]"</code> case
* <code>string()</code> function: Fix <code>function(document)</code>
returns nodes that are out of root elements.
* <code>"/ #{ELEMENT_NAME} "</code> case
* <code>"/ #{ELEMENT_NAME} [ #{PREDICATE} ]"</code> case
* <code>"/ #{AXIS}::#{ELEMENT_NAME}"</code> case
* <code>"#{N}-#{M}"</code> case: One or more white spaces were required
before <code>"-"</code>
* <code>"/child::node()"</code> case
* <code>"#{FUNCTION}()/#{PATH}"</code> case
* <code>"@#{ATTRIBUTE}/parent::"</code> case
* <code>"name(#{NODE_SET})"</code> case
[RSS]
[New options]
* RSS::Parser.parse: Accept options as Hash. +:validate+ ,
+:ignore_unknown_element+ , +:parser_class+ options are available.
[Set]
[Aliased methods]
* Set#filter! is a new alias for Set#select!. [Feature #13784]
[URI]
[New constant]
* Add URI::File to handle file URI scheme. [Feature #14035]
=== Compatibility issues (excluding feature bug fixes)
[File]
* File.read, File.binread, File.write, File.binwrite, File.foreach, and
File.readlines do not invoke external commands even if the path starts
with the pipe character <code>'|'</code>. [Feature #14245]
[Dir]
* Dir.glob with <code>'\0'</code>-separated pattern list will be deprecated,
and is now warned. [Feature #14643]
=== Stdlib compatibility issues (excluding feature bug fixes)
* These standard libraries have been promoted to default gems.
* e2mmap
* forwardable
* irb
* logger
* matrix
* mutex_m
* ostruct
* prime
* rexml
* rss
* shell
* sync
* thwait
* tracer
=== C API updates
=== Supported platform changes
=== Implementation improvements
* Speedup Proc#call because we don't need to care about <code>$SAFE</code>
any more. [Feature #14318]
With +lc_fizzbuzz+ benchmark which uses so many Proc#call we can
measure x1.4 improvements. [Bug #10212]
* Speedup block.call where +block+ is passed block parameter. [Feature #14330]
Ruby 2.5 improves block passing performance. [Feature #14045]
Additionally, Ruby 2.6 improves the performance of passed block calling.
* Introduce an initial implementation of JIT (Just-in-time) compiler. [Feature #14235] [experimental]
* <tt>--jit</tt> command line option is added to enable JIT. <tt>--jit-verbose=1</tt>
is good for inspection. See <tt>ruby --help</tt> for others.
* To generate machine code, this JIT compiler uses C compiler used for building
the interpreter. Currently GCC, Clang, and Microsoft Visual C++ are supported for it.
* <tt>--disable-mjit-support</tt> option is added to configure. This is added for JIT debugging,
but if you get an error on building a header file for JIT, you can use this option to skip
building it as a workaround.
* rb_waitpid reimplemented on Unix-like platforms to maintain
compatibility with processes created for JIT [Bug #14867]
* VM generator script renewal; makes the generated VM more optimized. [GH-1779]
* Thread cache enabled for pthreads platforms (for Thread.new and
Thread.start). [Feature #14757]
* timer thread is eliminated for platforms with POSIX timers [Misc #14937]
=== Miscellaneous changes
* On macOS, shared libraries no longer include a full version number of Ruby
in their names. This eliminates the burden of each teeny upgrade on the
platform that users need to rebuild every extension library.
[Before]
* libruby.2.6.0.dylib
* libruby.2.6.dylib -> libruby.2.6.0.dylib
* libruby.dylib -> libruby.2.6.0.dylib
[After]
* libruby.2.6.dylib
* libruby.dylib -> libruby.2.6.dylib
=== Misc
* Extracted misc/*.el files to https://github.com/ruby/elisp