Skip to content

2.7.0preview2 release note: format consistency #2202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 31 additions & 24 deletions en/news/_posts/2019-10-22-ruby-2-7-0-preview2-released.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ This release introduces Compaction GC which can defragment a fragmented memory s

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 friendly. [#15626](https://bugs.ruby-lang.org/issues/15626)
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 friendly. [[Feature #15626]](https://bugs.ruby-lang.org/issues/15626)

## Pattern Matching [Experimental]

Pattern matching, widely used feature in functional programming languages, is introduced as an experimental feature. [#14912](https://bugs.ruby-lang.org/issues/14912)
Pattern matching, widely used feature in functional programming languages, is introduced as an experimental feature. [[Feature #14912]](https://bugs.ruby-lang.org/issues/14912)
It can traverse a given object and assign its value if it matches a pattern.

```ruby
Expand All @@ -42,7 +42,7 @@ For more details, please see [Pattern matching - New feature in Ruby 2.7](https:
## REPL improvement

`irb`, bundled interactive environment (REPL; Read-Eval-Print-Loop), now supports multi-line editing. It's powered by `reline`, `readline`-compatible pure Ruby implementation.
It also provides rdoc integration. In `irb` you can display the reference for a given class, module, or method. [#14683](https://bugs.ruby-lang.org/issues/14683), [#14787](https://bugs.ruby-lang.org/issues/14787), [#14918](https://bugs.ruby-lang.org/issues/14918)
It also provides rdoc integration. In `irb` you can display the reference for a given class, module, or method. [[Feature #14683]](https://bugs.ruby-lang.org/issues/14683), [[Feature #14787]](https://bugs.ruby-lang.org/issues/14787), [[Feature #14918]](https://bugs.ruby-lang.org/issues/14918)
Besides, source lines shown at `binding.irb` and inspect results for core-class objects are now colorized.

<video autoplay="autoplay" controls="controls" muted="muted" width="576" height="259">
Expand Down Expand Up @@ -134,35 +134,43 @@ deprecated, and conversion will be removed in Ruby 3. [[Feature #14183]](https:

## Other Notable New Features

* A method reference operator, <code>.:</code>, is introduced as an experimental feature. [#12125]( https://bugs.ruby-lang.org/issues/12125), [#13581]( https://bugs.ruby-lang.org/issues/13581)
* A method reference operator, <code>.:</code>, is introduced as an experimental feature. [[Feature #12125]](https://bugs.ruby-lang.org/issues/12125), [[Feature #13581]]( https://bugs.ruby-lang.org/issues/13581)

* Numbered parameter as the default block parameter is introduced as an experimental feature. [#4475](https://bugs.ruby-lang.org/issues/4475)
* Numbered parameter as the default block parameter is introduced as an experimental feature. [[Feature #4475]](https://bugs.ruby-lang.org/issues/4475)

* A beginless range is experimentally introduced. It might not be as useful
as an endless range, but would be good for DSL purpose. [#14799](https://bugs.ruby-lang.org/issues/14799)
as an endless range, but would be good for DSL purpose. [[Feature #14799]](https://bugs.ruby-lang.org/issues/14799)

ary[..3] # identical to ary[0..3]
rel.where(sales: ..100)
```ruby
ary[..3] # identical to ary[0..3]
rel.where(sales: ..100)
```

* `Enumerable#tally` is added. It counts the occurrence of each element.

["a", "b", "c", "b"].tally
#=> {"a"=>1, "b"=>2, "c"=>1}
```ruby
["a", "b", "c", "b"].tally
#=> {"a"=>1, "b"=>2, "c"=>1}
```

* Calling a private method on `self` is now allowed. [Feature #11297] [Feature #16123]
* Calling a private method on `self` is now allowed. [[Feature #11297]](https://bugs.ruby-lang.org/issues/11297) [[Feature #16123]](https://bugs.ruby-lang.org/issues/16123)

def foo
end
private :foo
self.foo
```ruby
def foo
end
private :foo
self.foo
```

* `Enumerator::Lazy#eager` is added. It generates a non-lazy enumerator
from a lazy enumerator. [Feature #15901]

a = %w(foo bar baz)
e = a.lazy.map {|x| x.upcase }.map {|x| x + "!" }.eager
p e.class #=> Enumerator
p e.map {|x| x + "?" } #=> ["FOO!?", "BAR!?", "BAZ!?"]
```ruby
a = %w(foo bar baz)
e = a.lazy.map {|x| x.upcase }.map {|x| x + "!" }.eager
p e.class #=> Enumerator
p e.map {|x| x + "?" } #=> ["FOO!?", "BAR!?", "BAZ!?"]
```

## Performance improvements

Expand All @@ -178,18 +186,17 @@ deprecated, and conversion will be removed in Ruby 3. [[Feature #14183]](https:

* `Symbol#to_s`, `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] [[Feature #16150]](https://bugs.ruby-lang.org/issues/16150)

* The performance of CGI.escapeHTML is improved.
* https://github.com/ruby/ruby/pull/2226
* The performance of `CGI.escapeHTML` is improved. [GH-2226](https://github.com/ruby/ruby/pull/2226)

## Other notable changes since 2.6

* Some standard libraries are updated.
* Bundler 2.1.0.pre.1
* RubyGems 3.1.0.pre.1
* CSV 3.1.2 ([NEWS](https://github.com/ruby/csv/blob/master/NEWS.md))
* CSV 3.1.2 ([NEWS](https://github.com/ruby/csv/blob/v3.1.2/NEWS.md))
* Racc 1.4.15
* REXML 3.2.3 ([NEWS](https://github.com/ruby/rexml/blob/master/NEWS.md))
* RSS 0.2.8 ([NEWS](https://github.com/ruby/rss/blob/master/NEWS.md))
* REXML 3.2.3 ([NEWS](https://github.com/ruby/rexml/blob/v3.2.3/NEWS.md))
* RSS 0.2.8 ([NEWS](https://github.com/ruby/rss/blob/v0.2.8/NEWS.md))
* StringScanner 1.0.3
* Some of other libraries that have no original version are also updated.

Expand Down
55 changes: 31 additions & 24 deletions ja/news/_posts/2019-10-22-ruby-2-7-0-preview2-released.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ Ruby 2.7.0-preview2では、多くの新しい機能やパフォーマンスの

一部のマルチスレッドなRubyプログラムを長期間動かし、マーク&スイープ型GCを何度も実行していると、メモリが断片化してメモリ使用量の増大や性能の劣化を招くことが知られています。

Ruby 2.7では`GC.compact` というメソッドを導入し、ヒープをコンパクションすることが出来るようになります。ヒープ内の生存しているオブジェクトを他のページに移動し、不要なページを解放できるようになるとともに、ヒープをCoW (Copy on Write) フレンドリーにすることが出来ます。 [#15626](https://bugs.ruby-lang.org/issues/15626)
Ruby 2.7では`GC.compact` というメソッドを導入し、ヒープをコンパクションすることが出来るようになります。ヒープ内の生存しているオブジェクトを他のページに移動し、不要なページを解放できるようになるとともに、ヒープをCoW (Copy on Write) フレンドリーにすることが出来ます。 [[Feature #15626]](https://bugs.ruby-lang.org/issues/15626)

## Pattern Matching [Experimental]

関数型言語で広く使われているパターンマッチという機能が実験的に導入されました。
渡されたオブジェクトの構造がパターンと一致するかどうかを調べ、一致した場合にその値を変数に代入するといったことができるようになります。 [#14912](https://bugs.ruby-lang.org/issues/14912)
渡されたオブジェクトの構造がパターンと一致するかどうかを調べ、一致した場合にその値を変数に代入するといったことができるようになります。 [[Feature #14912]](https://bugs.ruby-lang.org/issues/14912)

```ruby
case JSON.parse('{...}', symbolize_names: true)
Expand All @@ -38,7 +38,7 @@ end
## REPL improvement

Ruby に添付されている REPL (Read-Eval-Print-Loop) である `irb` で、複数行編集がサポートされました。これは `reline` という `readline` 互換のピュア Ruby 実装によるものです。
また、rdoc 連携も提供されるようになっています。`irb` 内で、クラス、モジュール、メソッドのリファレンスをその場で確認できるようになりました。 [#14683](https://bugs.ruby-lang.org/issues/14683), [#14787](https://bugs.ruby-lang.org/issues/14787), [#14918](https://bugs.ruby-lang.org/issues/14918)
また、rdoc 連携も提供されるようになっています。`irb` 内で、クラス、モジュール、メソッドのリファレンスをその場で確認できるようになりました。 [[Feature #14683]](https://bugs.ruby-lang.org/issues/14683), [[Feature #14787]](https://bugs.ruby-lang.org/issues/14787), [[Feature #14918]](https://bugs.ruby-lang.org/issues/14918)
これに加え、`binding.irb`で表示される周辺のコードや、コアクラスのオブジェクトのinspect結果に色がつくようになっています。

<video autoplay="autoplay" controls="controls" muted="muted" width="576" height="259">
Expand Down Expand Up @@ -109,33 +109,41 @@ Ruby に添付されている REPL (Read-Eval-Print-Loop) である `irb` で、

## 主要な新機能

* メソッド参照演算子 <code>.:</code> が試験的に導入されました。[#12125](https://bugs.ruby-lang.org/issues/12125), [#13581](https://bugs.ruby-lang.org/issues/13581)
* メソッド参照演算子 <code>.:</code> が試験的に導入されました。[[Feature #12125]](https://bugs.ruby-lang.org/issues/12125), [[Feature #13581]]( https://bugs.ruby-lang.org/issues/13581)

* デフォルトのブロックの仮引数として番号指定パラメータが試験的に導入されました。[#4475](https://bugs.ruby-lang.org/issues/4475)
* デフォルトのブロックの仮引数として番号指定パラメータが試験的に導入されました。[[Feature #4475]](https://bugs.ruby-lang.org/issues/4475)

* 開始値省略範囲式が試験的に導入されました。これは終了値省略範囲式ほど有用ではないと思われますが、しかし DSL のような目的には役立つかもしれません。 [#14799](https://bugs.ruby-lang.org/issues/14799)
* 開始値省略範囲式が試験的に導入されました。これは終了値省略範囲式ほど有用ではないと思われますが、しかし DSL のような目的には役立つかもしれません。 [[Feature #14799]](https://bugs.ruby-lang.org/issues/14799)

ary[..3] # identical to ary[0..3]
rel.where(sales: ..100)
```ruby
ary[..3] # identical to ary[0..3]
rel.where(sales: ..100)
```

* `Enumerable#tally` が追加されました。各要素の出現回数を数えます。

["a", "b", "c", "b"].tally
#=> {"a"=>1, "b"=>2, "c"=>1}
```ruby
["a", "b", "c", "b"].tally
#=> {"a"=>1, "b"=>2, "c"=>1}
```

* レシーバを`self`としてprivateメソッドを呼び出すことが許容されるようになりました。[Feature #11297] [Feature #16123]
* レシーバを`self`としてprivateメソッドを呼び出すことが許容されるようになりました。 [[Feature #11297]](https://bugs.ruby-lang.org/issues/11297) [[Feature #16123]](https://bugs.ruby-lang.org/issues/16123)

def foo
end
private :foo
self.foo
```ruby
def foo
end
private :foo
self.foo
```

* `Enumerator::Lazy#eager` が追加されました。lazyなEnumeratorを非lazyなEnumeratorに変換します。

a = %w(foo bar baz)
e = a.lazy.map {|x| x.upcase }.map {|x| x + "!" }.eager
p e.class #=> Enumerator
p e.map {|x| x + "?" } #=> ["FOO!?", "BAR!?", "BAZ!?"]
```ruby
a = %w(foo bar baz)
e = a.lazy.map {|x| x.upcase }.map {|x| x + "!" }.eager
p e.class #=> Enumerator
p e.map {|x| x + "?" } #=> ["FOO!?", "BAR!?", "BAZ!?"]
```

## パフォーマンスの改善

Expand All @@ -151,18 +159,17 @@ Ruby に添付されている REPL (Read-Eval-Print-Loop) である `irb` で、

* `Symbol#to_s`, `Module#name`, `true.to_s`, `false.to_s` `nil.to_s` は常にfrozenな文字列を返すようになりました。返された文字列は常に同じオブジェクトとなります。 [Experimental] [[Feature #16150]](https://bugs.ruby-lang.org/issues/16150)

* CGI.escapeHTMLのパフォーマンスが改善されました。
* https://github.com/ruby/ruby/pull/2226
* `CGI.escapeHTML` のパフォーマンスが改善されました。 [GH-2226](https://github.com/ruby/ruby/pull/2226)

## その他の注目すべき 2.6 からの変更点

* いくつかの標準ライブラリがアップデートされました。
* Bundler 2.1.0.pre.1
* RubyGems 3.1.0.pre.1
* CSV 3.1.2 ([NEWS](https://github.com/ruby/csv/blob/master/NEWS.md))
* CSV 3.1.2 ([NEWS](https://github.com/ruby/csv/blob/v3.1.2/NEWS.md))
* Racc 1.4.15
* REXML 3.2.3 ([NEWS](https://github.com/ruby/rexml/blob/master/NEWS.md))
* RSS 0.2.8 ([NEWS](https://github.com/ruby/rss/blob/master/NEWS.md))
* REXML 3.2.3 ([NEWS](https://github.com/ruby/rexml/blob/v3.2.3/NEWS.md))
* RSS 0.2.8 ([NEWS](https://github.com/ruby/rss/blob/v0.2.8/NEWS.md))
* StringScanner 1.0.3
* 独自のバージョン番号を持たないその他のライブラリの一部も更新されています。

Expand Down