1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

NEWS: revise grammar, language, markup, etc.

This commit is contained in:
Marcus Stollsteimer 2019-12-23 14:45:24 +01:00
parent bbde77cd26
commit de1a462454

141
NEWS
View file

@ -8,7 +8,7 @@ releases except for bug fixes.
Note that each entry is kept so brief that no reason behind or reference 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 information is supplied with. For a full list of changes with all
sufficient information, see the ChangeLog file or Redmine sufficient information, see the ChangeLog file or Redmine
(e.g. <tt>https://bugs.ruby-lang.org/issues/$FEATURE_OR_BUG_NUMBER</tt>) (e.g. <tt>https://bugs.ruby-lang.org/issues/$FEATURE_OR_BUG_NUMBER</tt>).
== Changes since the 2.6.0 release == Changes since the 2.6.0 release
@ -53,9 +53,9 @@ sufficient information, see the ChangeLog file or Redmine
JSON.parse(json, symbolize_names: true) in {name: "Alice", children: [{name: "Charlie", age: age}]} JSON.parse(json, symbolize_names: true) in {name: "Alice", children: [{name: "Charlie", age: age}]}
#=> NoMatchingPatternError #=> NoMatchingPatternError
* See the following slides in detail * See the following slides for more details:
* https://speakerdeck.com/k_tsj/pattern-matching-new-feature-in-ruby-2-dot-7 * https://speakerdeck.com/k_tsj/pattern-matching-new-feature-in-ruby-2-dot-7
* Note that the slides are slightly obsolete * Note that the slides are slightly obsolete.
==== The spec of keyword arguments is changed towards 3.0 ==== The spec of keyword arguments is changed towards 3.0
@ -128,14 +128,16 @@ sufficient information, see the ChangeLog file or Redmine
h = {}; def foo(*a) a end; foo(h) # [{}] h = {}; def foo(*a) a end; foo(h) # [{}]
h = {}; def foo(a) a end; foo(h) # {} h = {}; def foo(a) a end; foo(h) # {}
==== Numbered parameter ==== Numbered parameters
* Numbered parameter as the default block parameter is introduced as an * Numbered parameters as default block parameters are introduced
experimental feature. [Feature #4475] as an experimental feature. [Feature #4475]
[1, 2, 10].map { _1.to_s(16) } #=> ["1", "2", "a"] [1, 2, 10].map { _1.to_s(16) } #=> ["1", "2", "a"]
[[1, 2], [3, 4]].map { _1 + _2 } #=> [3, 7]
You can still define a local variable named _1 and so on, and that is honored when present, but renders warning. You can still define a local variable named +_1+ and so on,
and that is honored when present, but renders a warning.
_1 = 0 #=> warning: `_1' is reserved for numbered parameter; consider another name _1 = 0 #=> warning: `_1' is reserved for numbered parameter; consider another name
[1].each { p _1 } # prints 0 instead of 1 [1].each { p _1 } # prints 0 instead of 1
@ -165,13 +167,13 @@ sufficient information, see the ChangeLog file or Redmine
ary[..3] # identical to ary[0..3] ary[..3] # identical to ary[0..3]
where(sales: ..100) where(sales: ..100)
* Setting <code>$;</code> to non-nil value is warned now. Use of it in * Setting <code>$;</code> to a non-nil value is warned now.
String#split is warned too. Use of it in String#split is warned too.
* Setting <code>$,</code> to non-nil value is warned now. Use of it in * Setting <code>$,</code> to a non-nil value is warned now.
Array#join is warned too. Use of it in Array#join is warned too.
* Quoted here-document identifier must end within the same line. * Quoted here-document identifiers must end within the same line.
<<"EOS <<"EOS
" # This had been warned since 2.4; Now it raises a SyntaxError " # This had been warned since 2.4; Now it raises a SyntaxError
@ -185,7 +187,7 @@ sufficient information, see the ChangeLog file or Redmine
# .bar # .bar
.baz # => foo.baz .baz # => foo.baz
* Calling a private method with a literal <code>self</code> as the receiver * Calling a private method with a literal +self+ as the receiver
is now allowed. [Feature #11297] [Feature #16123] is now allowed. [Feature #11297] [Feature #16123]
* Modifier rescue now operates the same for multiple assignment as single * Modifier rescue now operates the same for multiple assignment as single
@ -195,7 +197,7 @@ sufficient information, see the ChangeLog file or Redmine
# Previously parsed as: (a, b = raise) rescue [1, 2] # Previously parsed as: (a, b = raise) rescue [1, 2]
# Now parsed as: a, b = (raise rescue [1, 2]) # Now parsed as: a, b = (raise rescue [1, 2])
* +yield+ in singleton class syntax is warned and will be deprecated later [Feature #15575]. * +yield+ in singleton class syntax is warned and will be deprecated later. [Feature #15575].
def foo def foo
class << Object.new class << Object.new
@ -212,7 +214,8 @@ sufficient information, see the ChangeLog file or Redmine
All arguments to +foo+ are forwarded to +bar+, including keyword and All arguments to +foo+ are forwarded to +bar+, including keyword and
block arguments. block arguments.
Note that the parentheses are mandatory. `bar ...` is parsed as an endless range. Note that the parentheses are mandatory. <code>bar ...</code> is parsed
as an endless range.
* Access and setting of <code>$SAFE</code> is now always warned. <code>$SAFE</code> * Access and setting of <code>$SAFE</code> is now always warned. <code>$SAFE</code>
will become a normal global variable in Ruby 3.0. [Feature #16131] will become a normal global variable in Ruby 3.0. [Feature #16131]
@ -230,8 +233,7 @@ Array::
* Added Array#intersection. [Feature #16155] * Added Array#intersection. [Feature #16155]
* Added Array#minmax, with a faster implementation than Enumerable#minmax. * Added Array#minmax, with a faster implementation than Enumerable#minmax. [Bug #15929]
[Bug #15929]
Comparable:: Comparable::
@ -247,7 +249,8 @@ Complex::
New method:: New method::
* Added Complex#<=>. So 0 <=> 0i will not raise NoMethodError. [Bug #15857] * Added Complex#<=>.
So <code>0 <=> 0i</code> will not raise NoMethodError. [Bug #15857]
Dir:: Dir::
@ -260,7 +263,7 @@ Encoding::
New encoding:: New encoding::
* Added new encoding CESU-8 [Feature #15931] * Added new encoding CESU-8. [Feature #15931]
Enumerable:: Enumerable::
@ -278,12 +281,12 @@ Enumerator::
New methods:: New methods::
* Added Enumerator.produce to generate Enumerator from any custom * Added Enumerator.produce to generate an Enumerator from any custom
data-transformation. [Feature #14781] data transformation. [Feature #14781]
require 'date' require "date"
dates = Enumerator.produce(Date.today, &:succ) #=> infinite sequence of dates dates = Enumerator.produce(Date.today, &:succ) #=> infinite sequence of dates
dates.detect(&:tuesday?) #=> next tuesday dates.detect(&:tuesday?) #=> next Tuesday
* Added Enumerator::Lazy#eager that generates a non-lazy enumerator * Added Enumerator::Lazy#eager that generates a non-lazy enumerator
from a lazy enumerator. [Feature #15901] from a lazy enumerator. [Feature #15901]
@ -308,7 +311,7 @@ File::
Modified method:: Modified method::
* File.extname now returns a dot string at a name ending with a dot on * File.extname now returns a dot string for names ending with a dot on
non-Windows platforms. [Bug #15267] non-Windows platforms. [Bug #15267]
File.extname("foo.") #=> "." File.extname("foo.") #=> "."
@ -317,8 +320,8 @@ FrozenError::
New method:: New method::
* Added FrozenError#receiver to return the frozen object that * Added FrozenError#receiver to return the frozen object on which
modification was attempted on. To set this object when raising modification was attempted. To set this object when raising
FrozenError in Ruby code, FrozenError.new accepts a +:receiver+ FrozenError in Ruby code, FrozenError.new accepts a +:receiver+
option. [Feature #15751] option. [Feature #15751]
@ -344,18 +347,18 @@ Integer::
Modified method:: Modified method::
* Integer#[] now supports range operation. [Feature #8842] * Integer#[] now supports range operations. [Feature #8842]
0b01001101[2, 4] #=> 0b0011 0b01001101[2, 4] #=> 0b0011
0b01001100[2..5] #=> 0b0011 0b01001100[2..5] #=> 0b0011
0b01001100[2...6] #=> 0b0011 0b01001100[2...6] #=> 0b0011
^^^^ # ^^^^
Method:: Method::
Modified method:: Modified method::
* Method#inspect shows much information. [Feature #14145] * Method#inspect shows more information. [Feature #14145]
Module:: Module::
@ -371,7 +374,7 @@ Module::
Modified methods:: Modified methods::
* Module#autoload? now takes an +inherit+ optional argument, like as * Module#autoload? now takes an +inherit+ optional argument, like
Module#const_defined?. [Feature #15777] Module#const_defined?. [Feature #15777]
* Module#name now always returns a frozen String. The returned String is * Module#name now always returns a frozen String. The returned String is
@ -426,13 +429,13 @@ String::
* Update Unicode version to 12.1.0, adding support for * Update Unicode version to 12.1.0, adding support for
U+32FF SQUARE ERA NAME REIWA. [Feature #15195] U+32FF SQUARE ERA NAME REIWA. [Feature #15195]
* Update Unicode Emoji version to 12.1 [Feature #16272] * Update Unicode Emoji version to 12.1. [Feature #16272]
Symbol:: Symbol::
New methods:: New methods::
* Added Symbol#start_with? and Symbol#end_with? method. [Feature #16348] * Added Symbol#start_with? and Symbol#end_with? methods. [Feature #16348]
Time:: Time::
@ -444,8 +447,8 @@ Time::
Modified method:: Modified method::
* Time#inspect is separated from Time#to_s and it shows its sub * Time#inspect is separated from Time#to_s and it shows
second. [Feature #15958] the time's sub second. [Feature #15958]
UnboundMethod:: UnboundMethod::
@ -456,7 +459,7 @@ UnboundMethod::
<code>umethod.bind_call(obj, ...)</code> is semantically equivalent <code>umethod.bind_call(obj, ...)</code> is semantically equivalent
to <code>umethod.bind(obj).call(...)</code>. This idiom is used in to <code>umethod.bind(obj).call(...)</code>. This idiom is used in
some libraries to call a method that is overridden. The added some libraries to call a method that is overridden. The added
method does the same without allocation of intermediate Method method does the same without allocation of an intermediate Method
object. object.
class Foo class Foo
@ -477,10 +480,10 @@ UnboundMethod::
Warning:: Warning::
New method:: New methods::
* Added Warning.[] and Warning.[]= to manage emit/suppress some categories of * Added Warning.[] and Warning.[]= to manage emit/suppress of
warnings. [Feature #16345] some categories of warnings. [Feature #16345]
$LOAD_PATH:: $LOAD_PATH::
@ -492,13 +495,13 @@ $LOAD_PATH::
Bundler:: Bundler::
* Upgrade to Bundler 2.1.0 * Upgrade to Bundler 2.1.0.
See https://github.com/bundler/bundler/releases/tag/v2.1.0 See https://github.com/bundler/bundler/releases/tag/v2.1.0
CGI:: CGI::
* CGI.escapeHTML becomes 2~5x faster when there's at least one escaped character. * CGI.escapeHTML becomes 2~5x faster when there is at least one escaped character.
https://github.com/ruby/ruby/pull/2226 See https://github.com/ruby/ruby/pull/2226
CSV:: CSV::
@ -521,12 +524,12 @@ ERB::
IRB:: IRB::
* Introduce syntax highlight inspired by pry.gem to Binding#irb source lines, * Introduce syntax highlighting inspired by the Pry gem to Binding#irb
REPL input, and inspect output of some core-class objects. source lines, REPL input, and inspect output of some core-class objects.
* Introduce multiline mode by Reline. * Introduce multiline editing mode provided by Reline.
* Show documents when completion. * Show documentation when completion.
* Enable auto indent and save/load history by default. * Enable auto indent and save/load history by default.
@ -537,8 +540,8 @@ Net::FTP::
Net::HTTP:: Net::HTTP::
* Add ipaddr optional parameter to Net::HTTP#start to replace the address for * Add +ipaddr+ optional parameter to Net::HTTP#start to replace the address for
TCP/IP connection [Feature #5180] the TCP/IP connection. [Feature #5180]
Net::IMAP:: Net::IMAP::
@ -549,16 +552,16 @@ open-uri::
* Warn open-uri's "open" method at Kernel. * Warn open-uri's "open" method at Kernel.
Use URI.open instead. [Misc #15893] Use URI.open instead. [Misc #15893]
* The default charset of text/* media type is UTF-8 instead of * The default charset of "text/*" media type is UTF-8 instead of
ISO-8859-1. [Bug #15933] ISO-8859-1. [Bug #15933]
OptionParser:: OptionParser::
* Now show "Did you mean?" for unknown option. [Feature #16256] * Now show "Did you mean?" for unknown options. [Feature #16256]
test.rb: test.rb:
require 'optparse' require "optparse"
OptionParser.new do |opts| OptionParser.new do |opts|
opts.on("-f", "--foo", "foo") {|v| } opts.on("-f", "--foo", "foo") {|v| }
opts.on("-b", "--bar", "bar") {|v| } opts.on("-b", "--bar", "bar") {|v| }
@ -576,7 +579,7 @@ OptionParser::
Pathname:: Pathname::
* Delegates 3 arguments from Pathname.glob to Dir.glob to * Delegates 3 arguments from Pathname.glob to Dir.glob to
accept base: keyword. accept +base+ keyword.
Racc:: Racc::
@ -584,8 +587,8 @@ Racc::
Reline:: Reline::
* New stdlib that is compatible with readline stdlib by pure Ruby and also * New stdlib that is compatible with the readline stdlib but is
has a multiline mode. implemented in pure Ruby. It also provides a multiline editing mode.
REXML:: REXML::
@ -619,13 +622,12 @@ StringScanner::
* E2MM (e2mmap gem) * E2MM (e2mmap gem)
Proc:: Proc::
* Proc#to_s format was changed. [Feature #16101] * The Proc#to_s format was changed. [Feature #16101]
Range:: Range::
* Range#minmax used to iterate on the range to determine the maximum. * Range#minmax used to iterate on the range to determine the maximum.
It now uses the same algorithm as Range#max. In rare cases (e.g. It now uses the same algorithm as Range#max. In rare cases (e.g.
ranges of Float or Strings), this may yield different results. ranges of Floats or Strings), this may yield different results. [Bug #15807]
[Bug #15807]
=== Stdlib compatibility issues (excluding feature bug fixes) === Stdlib compatibility issues (excluding feature bug fixes)
@ -658,7 +660,7 @@ pathname::
profile.rb, Profiler__:: profile.rb, Profiler__::
* Removed from standard library. No one maintains it from Ruby 2.0.0. * Removed from standard library. It was unmaintained since Ruby 2.0.0.
=== C API updates === C API updates
@ -671,18 +673,18 @@ profile.rb, Profiler__::
treated as keyword arguments. Passing a positional hash instead of treated as keyword arguments. Passing a positional hash instead of
keyword arguments will emit a deprecation warning. keyword arguments will emit a deprecation warning.
* C API declarations with +ANYARGS+ are changed not to use +ANYARGS+ * C API declarations with +ANYARGS+ are changed not to use +ANYARGS+.
https://github.com/ruby/ruby/pull/2404 See https://github.com/ruby/ruby/pull/2404
=== Implementation improvements === Implementation improvements
Fiber:: Fiber::
* Allow selecting different coroutine implementation by using * Allow selecting different coroutine implementations by using
`--with-coroutine=`, e.g. +--with-coroutine=+, e.g.
./configure --with-coroutine=ucontext $ ./configure --with-coroutine=ucontext
./configure --with-coroutine=copy $ ./configure --with-coroutine=copy
* Replace previous stack cache with fiber pool cache. The fiber pool * Replace previous stack cache with fiber pool cache. The fiber pool
allocates many stacks in a single memory region. Stack allocation allocates many stacks in a single memory region. Stack allocation
@ -703,7 +705,7 @@ Thread::
* VM stack memory allocation is now combined with native thread stack, * VM stack memory allocation is now combined with native thread stack,
improving thread allocation performance and reducing allocation related improving thread allocation performance and reducing allocation related
failures. ~10x performance improvement was measured in micro-benchmarks. failures. Around 10x performance improvement was measured in micro-benchmarks.
JIT:: JIT::
@ -718,7 +720,7 @@ JIT::
RubyVM::InstructionSequence:: RubyVM::InstructionSequence::
* RubyVM::InstructionSequence#to_binary method generate compiled binary. * RubyVM::InstructionSequence#to_binary method generates compiled binary.
The binary size is reduced. [Feature #16163] The binary size is reduced. [Feature #16163]
=== Miscellaneous changes === Miscellaneous changes
@ -727,7 +729,7 @@ RubyVM::InstructionSequence::
difficult to find, native fiber code is difficult to implement, and it added difficult to find, native fiber code is difficult to implement, and it added
non-trivial complexity to the interpreter. [Feature #15894] non-trivial complexity to the interpreter. [Feature #15894]
* Require compilers to support C99 [Misc #15347] * Require compilers to support C99. [Misc #15347]
* Details of our dialect: https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/C99 * Details of our dialect: https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/C99
@ -739,10 +741,11 @@ RubyVM::InstructionSequence::
* RUBY_DESCRIPTION includes Git revision instead of Subversion's one. * RUBY_DESCRIPTION includes Git revision instead of Subversion's one.
* Support built-in methods in Ruby with `__builtin_` syntax. [Feature #16254] * Support built-in methods in Ruby with the <code>_\_builtin_</code> syntax. [Feature #16254]
Some methods are defined in *.rb (such as trace_point.rb). Some methods are defined in *.rb (such as trace_point.rb).
For example, it is easy to define a method which accepts keyword arguments. For example, it is easy to define a method which accepts keyword arguments.
* Per-call-site method cache, which has been there since around 1.9, was * Per-call-site method cache, which has been there since around 1.9, was
improved: cache hit rate raised from 89% to 94%. improved: cache hit rate raised from 89% to 94%.
https://github.com/ruby/ruby/pull/2583 See https://github.com/ruby/ruby/pull/2583