summaryrefslogtreecommitdiff
path: root/NEWS
blob: 7824dfc5d7f715110874e225e559efcbd003bb5b (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
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
# -*- markdown -*- markup: Markdown

# NEWS for Ruby 2.6.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. `https://bugs.ruby-lang.org/issues/$FEATURE_OR_BUG_NUMBER`)

## Changes since the 2.5.0 release

### Language changes

* `$SAFE` is a process global state and we can set 0 again.
  [Feature #14250]

* refinements take place at block passing.  [Feature #14223]

* `else` without `rescue` now causes a syntax error.  [EXPERIMENTAL]

* constant names may start with a non-ASCII capital letter.
  [Feature #13770]

* An endless range is introduced.  You can write a range that has no end,
  like `(0..)`.  The following shows typical use cases.  [Feature #12912]

    ```ruby
    ary[1..]                            # identical to ary[1..-1]
    (1..).each {|index| ... }           # infinite loop from index 1
    ary.zip(1..) {|elem, index| ... }   # ary.each.with_index(1) { }
    ```

* Non-`Symbol` key in keyword arguments hash causes an exception.

### Core classes updates (outstanding ones only)

* `Array`

    * New methods:

        * Added `Array#union` instance method.
          [Feature #14097]

    * Modified methods:

        * `Array#to_h` now maps elements to new keys and values by the
          block if given.  [Feature #15143]

    * Aliased methods:

        * `Array#filter` is a new alias for `Array#select`.
          [Feature #13784]
        * `Array#filter!` is a new alias for `Array#select!`.
          [Feature #13784]

* `Binding`

    * New methods:

        * added `Binding#source_location`.  [Feature #14230]

            This method returns the source location of binding, a 2-element
            array of `__FILE__` and `__LINE__`.  Traditionally, the same
            information could be retrieved by `eval("[__FILE__, __LINE__]",
            binding)`, but we are planning to change this behavior so that
            `Kernel#eval` ignores binding's source location [Bug #4352].
            So, users should use this newly-introduced method instead of
            `Kernel#eval`.

* `Dir`

    * New methods:

        * added `Dir#each_child` and `Dir#children` instance methods.
          [Feature #13969]

* `Enumerable`

    * Modified methods:

        * `Enumerable#to_h` now maps elements to new keys and values
          by the block if given.  [Feature #15143]

    * Aliased methods:

        * `Enumerable#filter` is a new alias for `Enumerable#select`.
          [Feature #13784]

* `Enumerator::ArithmeticSequence`

    * This is a new class to represent a generator of an arithmetic sequence,
      that is a number sequence defined by a common difference. It can be used
      for representing what is similar to Python's slice. You can get an
      instance of this class from `Numeric#step` and `Range#step`.

* `Enumerator::Lazy`

    * Aliased methods:

        * `Enumerator::Lazy#filter` is a new alias for
          `Enumerator::Lazy#select`.  [Feature #13784]

* `ENV`

    * Modified methods:

        * `ENV.to_h` now maps names and values to new keys and values
          by the block if given.  [Feature #15143]

* `Exception`

    * New options:

        * `Exception#full_message` takes `:highlight` and `:order` options.
          [Bug #14324]

* `Hash`

    * Modified methods:

        * `Hash#merge`, `update`, `merge!` and `update!` now accept multiple
           arguments.  [Feature #15111]

        * `Hash#to_h` now maps keys and values to new keys and values
          by the block if given.  [Feature #15143]

    * Aliased methods:

        * `Hash#filter` is a new alias for `Hash#select`.  [Feature #13784]

        * `Hash#filter!` is a new alias for `Hash#select!`.
          [Feature #13784]

* `IO`

    * New options:

        * new mode character `'x'` to open files for exclusive access.
          [Feature #11258]

* `Kernel`

    * Aliased methods:

        * `Kernel#then` is a new alias for `Kernel#yield_self`.
          [Feature #14594]

    * New options:

        * `Kernel.#Complex`, `Kernel.#Float`, `Kernel.#Integer` and
          `Kernel.#Rational` take `:exception` option to specify the way of
          error handling.  [Feature #12732]

        * `Kernel.#system` takes `:exception` option to raise an exception
          on failure.  [Feature #14386]

    * Incompatible changes:

        * `system()` and `exec()` do not close non-standard file descriptors
          (The default of `:close_others` option is changed to `false` by
          default.  but we still set the `FD_CLOEXEC` flag on descriptors we
          create).  [Misc #14907]

* `KeyError`

    * New options:

        * `KeyError#initialize` accepts `:receiver` and `:key` options to
          set receiver and key in Ruby code.  [Feature #14313]

* `Module`

    * New methods:

        * `Module#method_defined?`, `Module#private_method_defined?` and
          `Module#protected_method_defined?` now accepts the second
          parameter as optional. If it's `true` (=default), checks ancestor
          modules/classes, or checks only the class itself.
          [Feature #14944]

* `NameError`

    * New options:

        * `NameError#initialize` accepts `:receiver` option to set receiver
          in Ruby code.  [Feature #14313]

* `NoMethodError`

    * New options:

        * `NoMethodError#initialize` accepts `:receiver` option to set
          receiver in Ruby code.  [Feature #14313]

* `Numeric`

    * Incompatible changes:

        * `Numeric#step` now returns an instance of
          `Enumerator::ArithmeticSequence` class rather than one of
          `Enumerator` class.

* `Proc`

    * Incompatible changes:

        * `Proc#call` doesn't change `$SAFE` any more.  [Feature #14250]

* `Random`

    * New methods:

        * added `Random.bytes`.  [Feature #4938]

* `Range`

    * New methods:

        * Added `Range#%` instance method.  [Feature #14697]

    * Incompatible changes:

        * `Range#===` now uses `#cover?` instead of `#include?` method.
          [Feature #14575]
        * `Range#cover?` now accepts Range object. [Feature #14473]
        * `Range#step` now returns an instance of
          `Enumerator::ArithmeticSequence` class rather than one of
          `Enumerator` class.

* `RubyVM::AST`

    * New methods:

        * `RubyVM::AST.parse` parses a given string and returns AST nodes.
          [experimental]

        * `RubyVM::AST.parse_file` parses a given file and returns AST
          nodes.  [experimental]

* `String`

    * New features:

        * `String#split` yields each substring to the block if given.
          [Feature #4780]

* `Struct`

    * Modified methods:

        * `Struct#to_h` now maps keys and values to new keys and values
          by the block if given.  [Feature #15143]

    * Aliased method:

        * `Struct#filter` is a new alias for `Struct#select` [Feature #13784]

* `TracePoint`

    * New methods:

        * `TracePoint#parameters` [Feature #14694]

### Stdlib updates (outstanding ones only)

* `ERB`

    * New options:

        * Add `:trim_mode` and `:eoutvar` keyword arguments to `ERB.new`.
          Now non-keyword arguments other than first one are softly
          deprecated and will be removed when Ruby 2.5 becomes EOL.
          [Feature #14256]

        * erb command's `-S` option is deprecated, which will be removed in
          the next version.

* `FileUtils`

    * New method:

        * `FileUtils#cp_lr`.  [Feature #4189]

* `Matrix`

    * New methods:

        * `Matrix#antisymmetric?`

        * `Matrix#reflexive?`

* `Net`

    * New options:

        * Add `:write_timeout` keyword argument to `Net::BufferedIO.new`.
          [Feature #13396]

    * New methods:

        * Add `Net::BufferedIO#write_timeout`,
          `Net::BufferedIO#write_timeout=`, `Net::HTTP#write_timeout`, and
          `Net::HTTP#write_timeout=`.  [Feature #13396]

    * New constant:

        * Add `Net::HTTPClientException` to deprecate
          `Net::HTTPServerException`, whose name is misleading.  [Bug #14688]

* `REXML`

    * Improved some XPath implementations:

        * `concat()` function: Stringify all arguments before concatenating

        * `string()` function: Support context node

        * `string()` function: Support processing instruction node

        * Support `"*:#{ELEMENT_NAME}"` syntax in XPath 2.0

    * Fixed some XPath implementations:

        * `"//#{ELEMENT_NAME}[#{POSITION}]"` case

        * `string()` function: Fix `function(document)` returns nodes that
          are out of root elements.

        * `"/ #{ELEMENT_NAME} "` case

        * `"/ #{ELEMENT_NAME} [ #{PREDICATE} ]"` case

        * `"/ #{AXIS}:: #{ELEMENT_NAME} "` case

        * `"#{N}-#{M}"` case: One or more white spaces were required before
          `"-"`

        * `"/child::node()"` case

        * `"#{FUNCTION}()/#{PATH}"` case

        * `"@#{ATTRIBUTE}/parent::"` case

        * `"name(#{NODE_SET})"` case

* `RSS`

    * New options:

        * `RSS::Parser.parse`: Accept options as `Hash`. `:validate`,
          `:ignore_unknown_element`, `:parser_class` options are available.

* `Set`

    * Aliased methods:

        * `Set#filter!` is a new alias for `Set#select!`.  [Feature #13784]

* `URI`

    * New constant:

        * Add `URI::File` to handle file URI scheme.  [Feature #14035]

### Compatibility issues (excluding feature bug fixes)

* `File`

    * `File.read`, `File.binread`, `File.write`, `File.binwrite`,
      `File.foreach`, and `File.readlines` do not invoke external commands
      even if the path starts with the pipe character `'|'`.
      [Feature #14245]

* `Dir`

    * `Dir.glob` with `'\0'`-separated pattern list will be deprecated, and
      is now warned.  [Feature #14643]

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

### C API updates

### Supported platform changes

### Implementation improvements

* Speedup `Proc#call` because we don't need to care about `$SAFE` any more.
  [Feature #14318]

    With `lc_fizzbuzz` benchmark which uses so many `Proc#call` we can
    measure x1.4 improvements.  [Bug #10212]

* Speedup `block.call` where `block` is passed block parameter.
  [Feature #14330]

    Ruby 2.5 improves block passing performance. [Feature #14045]

    Additionally, Ruby 2.6 improves the performance of passed block calling.

* Introduce an initial implementation of JIT (Just-in-time) compiler.
  [Feature #14235] [experimental]
    * `--enable=jit` option is added to enable JIT. `--jit-verbose=1` is good for
      inspection.  See `ruby --help` for others.
    * This JIT relies on C compiler used to build Ruby, on runtime.  Only
      gcc and clang are supported for the JIT for now, and MinGW support has
      some issues.
    * As of 2.6.0-preview1, we're just preparing infrastructure for JIT and
      very few optimizations are implemented.  So it's not ready for
      benchmarking Ruby's JIT performance yet. It's known that current JIT
      enablement makes Rails application slower for now.
    * rb_waitpid reimplemented on Unix-like platforms to maintain
      compatibility [Bug #14867]

* VM generator script renewal; makes the generated VM more optimized.
  [GH-1779]

* Thread cache enabled for pthreads platforms (for `Thread.new` and
  `Thread.start`).  [Feature #14757]

* timer thread is eliminated for platforms with POSIX timers [Misc #14937]

### Miscellaneous changes

* On macOS, shared libraries no longer include a full version number of ruby
  in their names.  This eliminates the burden of each teeny upgrade on the
  platform that users need to rebuild every extension library.

  * Before:
    * libruby.2.6.0.dylib
    * libruby.2.6.dylib -> libruby.2.6.0.dylib
    * libruby.dylib -> libruby.2.6.0.dylib

  * After:
    * libruby.2.6.dylib
    * libruby.dylib -> libruby.2.6.dylib