summaryrefslogtreecommitdiff
path: root/NEWS
blob: 710039417aaf60bff1a7e6830bb6b7b9783959ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
# -*- rdoc -*-

= NEWS for Ruby 2.7.0

This document is a list of user visible feature changes made between
releases 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
sufficient information, see the ChangeLog file or Redmine
(e.g. <tt>https://bugs.ruby-lang.org/issues/$FEATURE_OR_BUG_NUMBER</tt>)

== Changes since the 2.6.0 release

=== Language changes

* Pattern matching is introduced as an experimental feature. [Feature #14912]

* Method reference operator, <code>.:</code> is introduced as an
  experimental feature.  [Feature #12125] [Feature #13581]

* Preparations for the redesign of keyword arguments towards
  Ruby 3.  [Feature #14183]

  * Automatic conversion from a Hash to keyword arguments is deprecated:
    when a method call passes a Hash at the last argument, and when the
    called method accepts keywords, it is warned.
    Please add a double splat operator.

     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(opt={});  end; foo( key: 42 )   # OK

  * Non-symbol keys are allowed as a keyword argument.

     def foo(**kw); p kw; end; foo("str" => 1) #=> {"str"=>1}

* Automatic conversion of keyword arguments and positional ones is
  warned.  [Feature #14183]

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

* Non-Symbol keys in a keyword arguments hash were prohibited in 2.6.0,
  but are now allowed again.  [Bug #15658]

* Numbered parameter as the default block parameter is introduced as an
  experimental feature.  [Feature #4475]

* A beginless range is experimentally introduced.  It might not be as useful
  as an endless range, but would be good for DSL purpose.  [Feature #14799]

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

* Setting <code>$;</code> to non-nil value is warned now.  Use of it in
  String#split is warned too.

* Setting <code>$,</code> to non-nil value is warned now.  Use of it in
  Array#join is warned too.

* Quoted here-document identifier must end within the same line.

     <<"EOS
     " # This has been warned since 2.4
     EOS


* The flip-flop syntax deprecation is reverted. [Feature #5400]

=== Core classes updates (outstanding ones only)

Complex::

  New method::

    * Added Complex#<=>. So 0 <=> 0i will not raise NoMethodError. [Bug #15857]

Dir::

  Modified method::

    * Dir#glob and Dir#[] no longer allow NUL-separated glob pattern.
      Use Array instead.  [Feature #14643]

Encoding::

  * Added new encoding CESU-8 [Feature #15931]

Enumerable::

  New methods::

    * Added Enumerable#filter_map.  [Feature #15323]

    * Added Enumerable#tally.  [Feature #11076]

Enumerator::

  New method::

    * Added Enumerator::Yielder#to_proc so that a Yielder object
      can be directly passed to another method as a block
      argument.  [Feature #15618]

FrozenError::

  New method::

    * Added FrozenError#receiver to return the frozen object that
      modification was attempted on.  To set this object when raising
      FrozenError in Ruby code, pass it as the second argument to
      FrozenError.new.

GC::

  New method::

    * Added GC.compact method 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]

      Details on the algorithm and caveats can be found here:
      https://bugs.ruby-lang.org/issues/15626

IO::

  New method::

    * Added IO#set_encoding_by_bom to check the BOM and set the external
      encoding.  [Bug #15210]

Integer::

  Modified method::

    * Integer#[] now supports range operation.  [Feature #8842]

         0b01001101[2, 4]  #=> 0b0011
         0b01001100[2..5]  #=> 0b0011
         0b01001100[2...6] #=> 0b0011
             ^^^^

Module::

  New method::

    * Added Module#const_source_location to retrieve the location where a
      constant is defined.  [Feature #10771]

  Modified method::

    * Module#autoload? now takes an +inherit+ optional argument, like as
      Module#const_defined?.  [Feature #15777]

ObjectSpace::WeakMap::

  Modified method::

    * ObjectSpace::WeakMap#[]= now accepts special objects as either key or
      values.  [Feature #16035]

Regexp / String::

    * Update Unicode version and Emoji version from 11.0.0 to
      12.0.0.  [Feature #15321]

    * Update Unicode version to 12.1.0, adding support for
      U+32FF SQUARE ERA NAME REIWA.  [Feature #15195]

RubyVM::

  Removed method::

    * RubyVM.resolve_feature_path moved to
      $LOAD_PATH.resolve_feature_path.  [Feature #15903] [Feature #15230]

Time::

  New methods::

    * Added Time#ceil method.  [Feature #15772]

    * Added Time#floor method.  [Feature #15653]

UnboundMethod::

  New methods::

    * Added UnboundMethod#bind_call method.  [Feature #15955]

`umethod.bind_call(obj, ...)` is semantically equivalent to
`umethod.bind(obj).call(...)`.  This idiom is used in some libraries to
call a method that is overridden.  The added method does the same
without allocation of intermediate Method object.

    class Foo
      def add_1(x)
        x + 1
      end
    end
    class Bar < Foo
      def add_1(x) # override
        x + 2
      end
    end

    obj = Bar.new
    p obj.add_1(1) #=> 3
    p Foo.instance_method(:add_1).bind(obj).call(1) #=> 2
    p Foo.instance_method(:add_1).bind_call(obj, 1) #=> 2


$LOAD_PATH::

  New method::

    * Added $LOAD_PATH.resolve_feature_path.  [Feature #15903] [Feature #15230]

=== Stdlib updates (outstanding ones only)

Bundler::

  * Upgrade to Bundler 2.1.0.pre.1
    Bundled from https://github.com/bundler/bundler/commit/a53709556b95a914e874b22ed2116a46b0528852

CGI::

  * CGI.escapeHTML becomes 2~5x faster when there's at least one escaped character.

CSV::

  * Upgrade to 3.0.9.
    See https://github.com/ruby/csv/blob/master/NEWS.md.

Date::

  * Date.jisx0301, Date#jisx0301, and Date.parse support the new Japanese
    era.  [Feature #15742]

Delegator::

  * Object#DelegateClass accepts a block and module_evals it in the context
    of the returned class, similar to Class.new and Struct.new.

ERB::

  * Prohibit marshaling ERB instance.

IRB::

  * Introduce syntax highlight inspired by pry.gem to Binding#irb source lines,
    REPL input, and inspect output of some core-class objects.

  * Introduce multiline mode by Reline.

  * Show documents when completion.

  * Enable auto indent and save/load history by default.

Net::FTP::

  * Add features and options.  [Feature #15964]

Net::IMAP::

  * Add Server Name Indication (SNI) support.  [Feature #15594]

open-uri::

  * Warn open-uri's "open" method at Kernel.
    Use URI.open instead.  [Misc #15893]

  * The default charset of text/* media type is UTF-8 instead of
    ISO-8859-1.  [Bug #15933]

Pathname::

  * Delegates 3 arguments from Pathname.glob to Dir.glob to
    accept base: keyword.

Racc::

  * Merge 1.4.15 from upstream repository and added cli of racc.

Reline::

  * New stdlib that is compatible with readline stdlib by pure Ruby and also
    has a multiline mode.

RSS::

  * Upgrade to RSS 0.2.8.
    See https://github.com/ruby/rss/blob/master/NEWS.md.

RubyGems::

  * Upgrade to RubyGems 3.1.0.pre1
    Bundled from https://github.com/rubygems/rubygems/commit/97b264f0fa248c864b6ee9a23d3ff1cdd217dddb

=== Compatibility issues (excluding feature bug fixes)

=== Stdlib compatibility issues (excluding feature bug fixes)

profile.rb, Profiler__::

  * Removed from standard library. No one maintains it from Ruby 2.0.0.

=== C API updates

  * C API declarations with `ANYARGS` are changed not to use `ANYARGS`
    https://github.com/ruby/ruby/pull/2404

=== Implementation improvements

Fiber::

  * Allow selecting different coroutine implementation by using
    `--with-coroutine=`, e.g.

         ./confgure --with-coroutine=ucontext
         ./confgure --with-coroutine=copy

  * Replace previous stack cache with fiber pool cache. The fiber pool
    allocates many stacks in a single memory region. Stack allocation
    becomes O(log N) and fiber creation is amortized O(1). Around 10x
    performance improvement was measured in micro-benchmarks.

Thread::

  * VM stack memory allocation is now combined with native thread stack,
    improving thread allocation performance and reducing allocation related
    failures. ~10x performance improvement was measured in micro-benchmarks.

JIT::

  * JIT-ed code is recompiled to less-optimized code when an optimization assumption is invalidated.

  * Method inlining is performed when a method is considered as pure.
    This optimization is still experimental and many methods are NOT considered as pure yet.

  * Default value of +--jit-max-cache+ is changed from 1,000 to 100

  * Default value of +--jit-min-calls+ is changed from 5 to 10,000

=== Miscellaneous changes

* Support for IA64 architecture has been removed. Hardware for testing was
  difficult to find, native fiber code is difficult to implement, and it added
  non-trivial complexity to the interpreter. [Feature #15894]

* Require compilers to support C99 [Misc #15347]

  * Details of our dialect: https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/C99

* Ruby's upstream repository is changed from Subversion to Git.

  * https://git.ruby-lang.org/ruby.git

  * RUBY_REVISION class is changed from Integer to String.

  * RUBY_DESCRIPTION includes Git revision instead of Subversion's one.