ruby-changes:64595
From: Kazuhiro <ko1@a...>
Date: Fri, 25 Dec 2020 17:33:01 +0900 (JST)
Subject: [ruby-changes:64595] 7e3d710a22 (master): Copy NEWS.md to doc/NEWS-3.0.0.md and update for 3.1.0
https://git.ruby-lang.org/ruby.git/commit/?id=7e3d710a22 From 7e3d710a22049b8d5c8ced71a136b8807b2e99e7 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA <zn@m...> Date: Fri, 25 Dec 2020 17:31:48 +0900 Subject: Copy NEWS.md to doc/NEWS-3.0.0.md and update for 3.1.0 diff --git a/NEWS.md b/NEWS.md index 2dcfacb..ccbf60c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/NEWS.md#L1 -# NEWS for Ruby 3.0.0 +# NEWS for Ruby 3.1.0 This document is a list of user visible feature changes -since the **2.7.0** release, except for bug fixes. +since the **3.0.0** release, 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 @@ -10,811 +10,32 @@ sufficient information, see the ChangeLog file or Redmine https://github.com/ruby/ruby/blob/trunk/NEWS.md#L10 ## Language changes -* Keyword arguments are now separated from positional arguments. - Code that resulted in deprecation warnings in Ruby 2.7 will now - result in ArgumentError or different behavior. [[Feature #14183]] - -* Procs accepting a single rest argument and keywords are no longer - subject to autosplatting. This now matches the behavior of Procs - accepting a single rest argument and no keywords. - [[Feature #16166]] - - ```ruby - pr = proc{|*a, **kw| [a, kw]} - - pr.call([1]) - # 2.7 => [[1], {}] - # 3.0 => [[[1]], {}] - - pr.call([1, {a: 1}]) - # 2.7 => [[1], {:a=>1}] # and deprecation warning - # 3.0 => [[[1, {:a=>1}]], {}] - ``` - -* Arguments forwarding (`...`) now supports leading arguments. - [[Feature #16378]] - - ```ruby - def method_missing(meth, ...) - send(:"do_#{meth}", ...) - end - ``` - -* Pattern matching (`case/in`) is no longer experimental. [[Feature #17260]] - -* One-line pattern matching is redesigned. [EXPERIMENTAL] - - * `=>` is added. It can be used like a rightward assignment. - [[Feature #17260]] - - ```ruby - 0 => a - p a #=> 0 - - {b: 0, c: 1} => {b:} - p b #=> 0 - ``` - - * `in` is changed to return `true` or `false`. [[Feature #17371]] - - ```ruby - # version 3.0 - 0 in 1 #=> false - - # version 2.7 - 0 in 1 #=> raise NoMatchingPatternError - ``` - -* Find-pattern is added. [EXPERIMENTAL] - [[Feature #16828]] - - ```ruby - case ["a", 1, "b", "c", 2, "d", "e", "f", 3] - in [*pre, String => x, String => y, *post] - p pre #=> ["a", 1] - p x #=> "b" - p y #=> "c" - p post #=> [2, "d", "e", "f", 3] - end - ``` - -* Endless method definition is added. [EXPERIMENTAL] - [[Feature #16746]] - - ```ruby - def square(x) = x * x - ``` - -* Interpolated String literals are no longer frozen when - `# frozen-string-literal: true` is used. [[Feature #17104]] - -* Magic comment `shareable_constant_value` added to freeze constants. - See {Magic Comments}[rdoc-ref:doc/syntax/comments.rdoc@Magic+Comments] for more details. - [[Feature #17273]] - -* A {static analysis}[rdoc-label:label-Static+analysis] foundation is - introduced. - * {RBS}[rdoc-label:label-RBS] is introduced. It is a type definition - language for Ruby programs. - * {TypeProf}[rdoc-label:label-TypeProf] is experimentally bundled. It is a - type analysis tool for Ruby programs. - -* Deprecation warnings are no longer shown by default (since Ruby 2.7.2). - Turn them on with `-W:deprecated` (or with `-w` to show other warnings too). - [[Feature #16345]] - -* $SAFE and $KCODE are now normal global variables with no special behavior. - C-API methods related to $SAFE have been removed. - [[Feature #16131]] [[Feature #17136]] - -* yield in singleton class definitions in methods is now a SyntaxError - instead of a warning. yield in a class definition outside of a method - is now a SyntaxError instead of a LocalJumpError. [[Feature #15575]] - -* When a class variable is overtaken by the same definition in an - ancestor class/module, a RuntimeError is now raised (previously, - it only issued a warning in verbose mode). Additionally, accessing a - class variable from the toplevel scope is now a RuntimeError. - [[Bug #14541]] - -* Assigning to a numbered parameter is now a SyntaxError instead of - a warning. - ## Command line options -### `--help` option - -When the environment variable `RUBY_PAGER` or `PAGER` is present and has -a non-empty value, and the standard input and output are tty, the `--help` -option shows the help message via the pager designated by the value. -[[Feature #16754]] - -### `--backtrace-limit` option - -The `--backtrace-limit` option limits the maximum length of a backtrace. -[[Feature #8661]] - ## Core classes updates Outstanding ones only. -* Array - - * The following methods now return Array instances instead of - subclass instances when called on subclass instances: - [[Bug #6087]] - - * Array#drop - * Array#drop_while - * Array#flatten - * Array#slice! - * Array#slice / Array#[] - * Array#take - * Array#take_while - * Array#uniq - * Array#* - - * Can be sliced with Enumerator::ArithmeticSequence - - ```ruby - dirty_data = ['--', 'data1', '--', 'data2', '--', 'data3'] - dirty_data[(1..).step(2)] # take each second element - # => ["data1", "data2", "data3"] - ``` - -* Binding - - * Binding#eval when called with one argument will use "(eval)" - for `__FILE__` and 1 for `__LINE__` in the evaluated code. - [[Bug #4352]] [[Bug #17419]] - -* ConditionVariable - - * ConditionVariable#wait may now invoke the `block`/`unblock` scheduler - hooks in a non-blocking context. [[Feature #16786]] - -* Dir - - * Dir.glob and Dir.[] now sort the results by default, and - accept the `sort:` keyword option. [[Feature #8709]] - -* ENV - - * ENV.except has been added, which returns a hash excluding the - given keys and their values. [[Feature #15822]] - - * Windows: Read ENV names and values as UTF-8 encoded Strings - [[Feature #12650]] - -* Encoding - - * Added new encoding IBM720. [[Feature #16233]] - - * Changed default for Encoding.default_external to UTF-8 on Windows - [[Feature #16604]] - -* Fiber - - * Fiber.new(blocking: true/false) allows you to create non-blocking - execution contexts. [[Feature #16786]] - - * Fiber#blocking? tells whether the fiber is non-blocking. [[Feature #16786]] - - * Fiber#backtrace and Fiber#backtrace_locations provide per-fiber backtrace. - [[Feature #16815]] - - * The limitation of Fiber#transfer is relaxed. [[Bug #17221]] - -* GC - - * GC.auto_compact= and GC.auto_compact have been added to control - when compaction runs. Setting `auto_compact=` to true will cause - compaction to occur during major collections. At the moment, - compaction adds significant overhead to major collections, so please - test first! [[Feature #17176]] - -* Hash - - * Hash#transform_keys and Hash#transform_keys! now accept a hash that maps - keys to new keys. [[Feature #16274]] - - * Hash#except has been added, which returns a hash excluding the - given keys and their values. [[Feature #15822]] - -* IO - - * IO#nonblock? now defaults to `true`. [[Feature #16786]] - - * IO#wait_readable, IO#wait_writable, IO#read, IO#write and other - related methods (e.g. IO#puts, IO#gets) may invoke the scheduler hook - `#io_wait(io, events, timeout)` in a non-blocking execution context. - [[Feature #16786]] - -* Kernel - - * Kernel#clone when called with the `freeze: false` keyword will call - `#initialize_clone` with the `freeze: false` keyword. - [[Bug #14266]] - - * Kernel#clone when called with the `freeze: true` keyword will call - `#initialize_clone` with the `freeze: true` keyword, and will - return a frozen copy even if the receiver is unfrozen. - [[Feature #16175]] - - * Kernel#eval when called with two arguments will use "(eval)" - for `__FILE__` and 1 for `__LINE__` in the evaluated code. - [[Bug #4352]] - - * Kernel#lambda now warns if called without a literal block. - [[Feature #15973]] - - * Kernel.sleep invokes the scheduler hook `#kernel_sleep(...)` in a - non-blocking execution context. [[Feature #16786]] - -* Module - - * Module#include and Module#prepend now affect classes and modules - that have already included or prepended the receiver, mirroring the - behavior if the arguments were included in the receiver before - the other modules and classes included or prepended the receiver. - [[Feature #9573]] - - ```ruby - class C; end - module M1; end - module M2; end - C.include M1 - M1.include M2 - p C.ancestors #=> [C, M1, M2, Object, Kernel, BasicObject] - ``` - - * Module#public, Module#protected, Module#private, Module#public_class_method, - Module#private_class_method, toplevel "private" and "public" methods - now accept single array argument with a list of method names. [[Feature #17314]] - - * Module#attr_accessor, Module#attr_reader, Module#attr_writer and Module#attr - methods now return an array of defined method names as symbols. - [[Feature #17314]] - - * Module#alias_method now returns the defined alias as a symbol. - [[Feature #17314]] - -* Mutex - - * `Mutex` is now acquired per-`Fiber` instead of per-`Thread`. This change - should be compatible for essentially all usages and avoids blocking when - using a scheduler. [[Feature #16792]] - -* Proc - - * Proc#== and Proc#eql? are now defined and will return true for - separate Proc instances if the procs were created from the same block. - [[Feature #14267]] - -* Queue / SizedQueue - - * Queue#pop, SizedQueue#push (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/