From 6e395064adbf287e23e9d2371bec4c57c2e3e232 Mon Sep 17 00:00:00 2001 From: roypen Date: Apr 07 2020 15:41:33 +0000 Subject: [PATCH 1/2] Release notes for Ruby 2.7. Issue #428 Signed-off-by: roypen --- diff --git a/modules/release-notes/pages/developers/Development_Ruby.adoc b/modules/release-notes/pages/developers/Development_Ruby.adoc index f40ff6e..8cf95c2 100644 --- a/modules/release-notes/pages/developers/Development_Ruby.adoc +++ b/modules/release-notes/pages/developers/Development_Ruby.adoc @@ -2,4 +2,202 @@ include::{partialsdir}/entities.adoc[] [[sect-ruby]] -= Ruby += Ruby 2.7 + +Fedora 32 provides Ruby 2.7 version. With this major update from Ruby 2.6, Fedora becomes the superior Ruby development platform. +[[back]] +== Changes since Ruby 2.6: + +Ruby 2.7 comes with several new features and performance improvements. + +=== New features: + +* <> +* <> +* <> +* <> + +=== Performance improvements: + +* JIT [Experimental] +* Fiber’s cache strategy is changed and fiber creation is speeded up. +* `Module#name`, `true.to_s`, `false.to_s`, and `nil.to_s` now always return a frozen String. The returned String is always the same for a given object. [Experimental] +* The performance of Monitor and MonitorMixin is improved. +* The performance of `CGI.escapeHTML` is improved. +* The performance of Monitor and MonitorMixin is improved. +* Per-call-site method cache, which has been there since around 1.9, was improved: cache hit rate raised from 89% to 94%. +* RubyVM::InstructionSequence#to_binary method generates compiled binary. The binary size is reduced. + +=== Other notable changes: + + +* Some standard libraries are updated. +** Bundler 2.1.2 (Release note) +** RubyGems 3.1.2 +** Racc 1.4.15 +** CSV 3.1.2 (NEWS) +** REXML 3.2.3 (NEWS) +** RSS 0.2.8 (NEWS) +** StringScanner 1.0.3 +** Some other libraries that have no original version are also updated. +* The following libraries are no longer bundled gems. Install corresponding gems to use these features. +** CMath (cmath gem) +** Scanf (scanf gem) +** Shell (shell gem) +** Synchronizer (sync gem) +** ThreadsWait (thwait gem) +** E2MM (e2mmap gem) + +* profile.rb was removed from standard library. +* Promote stdlib to default gems +** The following default gems were published on rubygems.org +*** benchmark +*** cgi +*** delegate +*** getoptlong +*** net-pop +*** net-smtp +*** open3 +*** pstore +*** singleton +** The following default gems were only promoted at ruby-core, but not yet published on rubygems.org. +*** monitor +*** observer +*** timeout +*** tracer +*** uri +*** yaml + +* Proc.new and proc with no block in a method called with a block is warned now. + +* lambda with no block in a method called with a block raises an exception. + +* Update Unicode version and Emoji version from 11.0.0 to 12.0.0. + +* Update Unicode version to 12.1.0, adding support for U+32FF SQUARE ERA NAME REIWA. + +* Date.jisx0301, Date#jisx0301, and Date.parse support the new Japanese era. +* Require compilers to support C99. + + +== Detailed changes: + + +[[Pattern]] +=== Pattern Matching [Experimental] + + + +Pattern matching, a widely used feature in functional programming languages, is introduced as an experimental feature. It can traverse a given object and assign it's value if it matches a pattern. + +---- +require "json" + +json = < 2 +end +---- + + +[[REPL]] +=== REPL improvement + + +`irb`, the bundled interactive environment (REPL; Read-Eval-Print-Loop), now supports multi-line editing. It is powered by `reline`, a `readline` -compatible library implemented in pure Ruby. It also provides rdoc integration. In `irb` you can display the reference for a given class, module, or method. + + +[[GC]] +=== Compaction GC + + +This release introduces Compaction GC which can defragment a fragmented memory space. + +Some multi-threaded Ruby programs may cause memory fragmentation, leading to high memory usage and degraded speed. + +The `GC.compact` method is introduced for compacting the heap. This function compacts live objects in the heap so that fewer pages may be used, and the heap may be more CoW (copy-on-write) friendly. + + + +[[Separation]] +=== Separation of positional and keyword arguments + + +Automatic conversion of keyword arguments and positional arguments is deprecated, and conversion will be removed in Ruby 3. + +==== Changes: + + + +* When a method call passes a Hash at the last argument, and when it passes no keywords, and when the called method accepts keywords, a warning is emitted. To continue treating the hash as keywords, add a double splat operator to avoid the warning and ensure correct behavior in Ruby 3. + +---- + def foo(key: 42); end; foo({key: 42}) # warned + def foo(**kw); end; foo({key: 42}) # warned + def foo(key: 42); end; foo(**{key: 42}) # OK + def foo(**kw); end; foo(**{key: 42}) # OK +---- + +* When a method call passes keywords to a method that accepts keywords, but it does not pass enough required positional arguments, the keywords are treated as a final required positional argument, and a warning is emitted. Pass the argument as a hash instead of keywords to avoid the warning and ensure correct behavior in Ruby 3. + +---- + def foo(h, **kw); end; foo(key: 42) # warned + def foo(h, key: 42); end; foo(key: 42) # warned + def foo(h, **kw); end; foo({key: 42}) # OK + def foo(h, key: 42); end; foo({key: 42}) # OK +---- + +* When a method accepts specific keywords but not a keyword splat, and a hash or keywords splat is passed to the method that includes both Symbol and non-Symbol keys, the hash will continue to be split, and a warning will be emitted. You will need to update the calling code to pass separate hashes to ensure correct behavior in Ruby 3. + +---- + def foo(h={}, key: 42); end; foo("key" => 43, key: 42) # warned + def foo(h={}, key: 42); end; foo({"key" => 43, key: 42}) # warned + def foo(h={}, key: 42); end; foo({"key" => 43}, key: 42) # OK +---- + +* If a method does not accept keywords, and is called with keywords, the keywords are still treated as a positional hash, with no warning. This behavior will continue to work in Ruby 3. + +---- + def foo(opt={}); end; foo( key: 42 ) # OK +---- + +* Non-symbols are allowed as keyword argument keys if the method accepts arbitrary keywords. [Feature #14183] + +---- + def foo(**kw); p kw; end; foo("str" => 1) #=> {"str"=>1} +---- + +* `**nil` is allowed in method definitions to explicitly mark that the method accepts no keywords. Calling such a method with keywords will result in an ArgumentError. + +---- + def foo(h, **nil); end; foo(key: 1) # ArgumentError + def foo(h, **nil); end; foo(**{key: 1}) # ArgumentError + def foo(h, **nil); end; foo("str" => 1) # ArgumentError + def foo(h, **nil); end; foo({key: 1}) # OK + def foo(h, **nil); end; foo({"str" => 1}) # OK +---- + +* Passing an empty keyword splat to a method that does not accept keywords no longer passes an empty hash, unless the empty hash is necessary for a required parameter, in which case a warning will be emitted. Remove the double splat to continue passing a positional hash. [Feature #14183] + +---- + h = {}; def foo(*a) a end; foo(**h) # [] + h = {}; def foo(a) a end; foo(**h) # {} and warning + h = {}; def foo(*a) a end; foo(h) # [{}] + h = {}; def foo(a) a end; foo(h) # {} +---- + +If you want to disable the deprecation warnings, please use a command-line argument -W:no-deprecated or add Warning[:deprecated] = false to your code. + +See the link:https://www.ruby-lang.org/en/news/2019/12/25/ruby-2-7-0-released/[upstream release announcement] for more detailed information about this release. + +<> + + From 88cb20e8abb261ec9fd77ea46e543aabd7c8eed2 Mon Sep 17 00:00:00 2001 From: Lukas Piekarski Date: Apr 07 2020 15:41:33 +0000 Subject: [PATCH 2/2] Update modules/release-notes/pages/developers/Development_Ruby.adoc - removed duplicates - module names, functions, commands are now marked up - removed ((Release note), (NEWS)) - syntax highlighting - added [source,*language*] at the beginning of the code block --- diff --git a/modules/release-notes/pages/developers/Development_Ruby.adoc b/modules/release-notes/pages/developers/Development_Ruby.adoc index 8cf95c2..c496224 100644 --- a/modules/release-notes/pages/developers/Development_Ruby.adoc +++ b/modules/release-notes/pages/developers/Development_Ruby.adoc @@ -1,4 +1,3 @@ - include::{partialsdir}/entities.adoc[] [[sect-ruby]] @@ -22,22 +21,21 @@ Ruby 2.7 comes with several new features and performance improvements. * JIT [Experimental] * Fiber’s cache strategy is changed and fiber creation is speeded up. * `Module#name`, `true.to_s`, `false.to_s`, and `nil.to_s` now always return a frozen String. The returned String is always the same for a given object. [Experimental] -* The performance of Monitor and MonitorMixin is improved. +* The performance of `Monitor` and `MonitorMixin` is improved. * The performance of `CGI.escapeHTML` is improved. -* The performance of Monitor and MonitorMixin is improved. -* Per-call-site method cache, which has been there since around 1.9, was improved: cache hit rate raised from 89% to 94%. -* RubyVM::InstructionSequence#to_binary method generates compiled binary. The binary size is reduced. +* `Per-call-site` method cache, which has been there since around 1.9, was improved: cache hit rate raised from 89% to 94%. +* `RubyVM::InstructionSequence#to_binary` method generates compiled binary. The binary size is reduced. === Other notable changes: * Some standard libraries are updated. -** Bundler 2.1.2 (Release note) +** Bundler 2.1.2 ** RubyGems 3.1.2 ** Racc 1.4.15 -** CSV 3.1.2 (NEWS) -** REXML 3.2.3 (NEWS) -** RSS 0.2.8 (NEWS) +** CSV 3.1.2 +** REXML 3.2.3 +** RSS 0.2.8 ** StringScanner 1.0.3 ** Some other libraries that have no original version are also updated. * The following libraries are no longer bundled gems. Install corresponding gems to use these features. @@ -48,8 +46,8 @@ Ruby 2.7 comes with several new features and performance improvements. ** ThreadsWait (thwait gem) ** E2MM (e2mmap gem) -* profile.rb was removed from standard library. -* Promote stdlib to default gems +* `profile.rb` was removed from standard library. +* Promote `stdlib` to default gems ** The following default gems were published on rubygems.org *** benchmark *** cgi @@ -68,7 +66,7 @@ Ruby 2.7 comes with several new features and performance improvements. *** uri *** yaml -* Proc.new and proc with no block in a method called with a block is warned now. +* `Proc.new` and `proc` with no block in a method called with a block is warned now. * lambda with no block in a method called with a block raises an exception. @@ -76,7 +74,8 @@ Ruby 2.7 comes with several new features and performance improvements. * Update Unicode version to 12.1.0, adding support for U+32FF SQUARE ERA NAME REIWA. -* Date.jisx0301, Date#jisx0301, and Date.parse support the new Japanese era. +* `Date.jisx0301`, `Date#jisx0301`, and `Date.parse` support the new Japanese era. + * Require compilers to support C99. @@ -90,6 +89,7 @@ Ruby 2.7 comes with several new features and performance improvements. Pattern matching, a widely used feature in functional programming languages, is introduced as an experimental feature. It can traverse a given object and assign it's value if it matches a pattern. +[source,json] ---- require "json" @@ -139,6 +139,7 @@ Automatic conversion of keyword arguments and positional arguments is deprecated * When a method call passes a Hash at the last argument, and when it passes no keywords, and when the called method accepts keywords, a warning is emitted. To continue treating the hash as keywords, add a double splat operator to avoid the warning and ensure correct behavior in Ruby 3. +[source,ruby] ---- def foo(key: 42); end; foo({key: 42}) # warned def foo(**kw); end; foo({key: 42}) # warned @@ -148,6 +149,7 @@ Automatic conversion of keyword arguments and positional arguments is deprecated * When a method call passes keywords to a method that accepts keywords, but it does not pass enough required positional arguments, the keywords are treated as a final required positional argument, and a warning is emitted. Pass the argument as a hash instead of keywords to avoid the warning and ensure correct behavior in Ruby 3. +[source,ruby] ---- def foo(h, **kw); end; foo(key: 42) # warned def foo(h, key: 42); end; foo(key: 42) # warned @@ -157,6 +159,7 @@ Automatic conversion of keyword arguments and positional arguments is deprecated * When a method accepts specific keywords but not a keyword splat, and a hash or keywords splat is passed to the method that includes both Symbol and non-Symbol keys, the hash will continue to be split, and a warning will be emitted. You will need to update the calling code to pass separate hashes to ensure correct behavior in Ruby 3. +[source,ruby] ---- def foo(h={}, key: 42); end; foo("key" => 43, key: 42) # warned def foo(h={}, key: 42); end; foo({"key" => 43, key: 42}) # warned @@ -165,18 +168,21 @@ Automatic conversion of keyword arguments and positional arguments is deprecated * If a method does not accept keywords, and is called with keywords, the keywords are still treated as a positional hash, with no warning. This behavior will continue to work in Ruby 3. +[source,ruby] ---- def foo(opt={}); end; foo( key: 42 ) # OK ---- -* Non-symbols are allowed as keyword argument keys if the method accepts arbitrary keywords. [Feature #14183] +* Non-symbols are allowed as keyword argument keys if the method accepts arbitrary keywords. +[source,ruby] ---- def foo(**kw); p kw; end; foo("str" => 1) #=> {"str"=>1} ---- -* `**nil` is allowed in method definitions to explicitly mark that the method accepts no keywords. Calling such a method with keywords will result in an ArgumentError. +* `**nil` is allowed in method definitions to explicitly mark that the method accepts no keywords. Calling such a method with keywords will result in an `ArgumentError`. +[source,ruby] ---- def foo(h, **nil); end; foo(key: 1) # ArgumentError def foo(h, **nil); end; foo(**{key: 1}) # ArgumentError @@ -185,8 +191,9 @@ Automatic conversion of keyword arguments and positional arguments is deprecated def foo(h, **nil); end; foo({"str" => 1}) # OK ---- -* Passing an empty keyword splat to a method that does not accept keywords no longer passes an empty hash, unless the empty hash is necessary for a required parameter, in which case a warning will be emitted. Remove the double splat to continue passing a positional hash. [Feature #14183] +* Passing an empty keyword splat to a method that does not accept keywords no longer passes an empty hash, unless the empty hash is necessary for a required parameter, in which case a warning will be emitted. Remove the double splat to continue passing a positional hash. +[source,ruby] ---- h = {}; def foo(*a) a end; foo(**h) # [] h = {}; def foo(a) a end; foo(**h) # {} and warning