#456 #428 F32 System-Wide Change: Ruby 2.7
Merged 4 years ago by pbokoc. Opened 4 years ago by roypen.
fedora-docs/ roypen/release-notes iss428  into  f32

@@ -1,5 +1,210 @@ 

- 

  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:

+ 

+ * <<Pattern,Pattern Matching>>

+ * <<REPL,REPL improvement>>

+ * <<GC,Compaction GC>>

+ * <<Separation,Separation of positional and keyword arguments>>

+ 

+ === 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. 

+ * `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

+ **        RubyGems 3.1.2

+ **        Racc 1.4.15

+ **        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.

+ **        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.

+ 

+ [source,json]

+ ----

+ require "json"

+ 

+ json = <<END

+ {

+   "name": "Alice",

+   "age": 30,

+   "children": [{ "name": "Bob", "age": 2 }]

+ }

+ END

+ 

+ case JSON.parse(json, symbolize_names: true)

+ in {name: "Alice", children: [{name: "Bob", age: age}]}

+   p age #=> 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.

+ 

+ [source,ruby]

+ ----

+     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.

+ 

+ [source,ruby]

+ ----

+     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.

+ 

+ [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

+     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.

+ 

+ [source,ruby]

+ ----

+     def foo(opt={});  end; foo( key: 42 )   # OK

+ ----

+ 

+ * 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`. 

+ 

+ [source,ruby]

+ ----

+     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.

+ 

+ [source,ruby]

+ ----

+     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.

+ 

+ <<back,back to top>>

+ 

+ 

Release notes for Ruby 2.7. Issue #428

Metadata Update from @pbokoc:
- Request assigned

4 years ago

rebased onto 4ed0766c2da2e968bacf4cda572f51c299a846de

4 years ago

The things in parentheses ((Release note), (NEWS)) should probably be links

"RubyVM::InstructionSequence#to_binary" should be marked up with ` ` to highlight it, similar to the items on line 25. There are other spots on this page where you're using module names, functions, commands, etc. without markup as well, so please go through the whole doc and mark them up.

I'm not sure if this is a mistake or not; is this list item supposed to be under "Promote stdlib to default gems"? It seems like it should be on the same level and its children should be one level up (** instead of ***), but I could be wrong.

Pro tip: If you add a line above each example that says [source,*language*], you'll get syntax highlighting in the rendered page. In this example it's [source,json], in the subsequent examples it's [source,ruby].

Looks good other than the couple of notes above.

1 new commit added

  • Update modules/release-notes/pages/developers/Development_Ruby.adoc
4 years ago

rebased onto 6e39506

4 years ago

Pull-Request has been merged by pbokoc

4 years ago