[#92070] [Ruby trunk Feature#15667] Introduce malloc_trim(0) in full gc cycles — sam.saffron@...
Issue #15667 has been updated by sam.saffron (Sam Saffron).
3 messages
2019/04/01
[ruby-core:92250] [Ruby trunk Bug#15708] Implicit numbered argument decomposes an array
From:
merch-redmine@...
Date:
2019-04-11 21:42:13 UTC
List:
ruby-core #92250
Issue #15708 has been updated by jeremyevans0 (Jeremy Evans).
File single-implicit-arg-no-destructure.diff added
Attached is a patch that will turn off destructuring if the only implicit block variable is `@1`:
```ruby
# equivalent to proc{|x| x}
proc{@1}.call([1,2])
# => [1, 2]
# equivalent to proc{|_,x| x}
proc{@2}.call([1,2])
# => 2
# equivalent to proc{|x,y| y; x}
proc{@2; @1}.call([1,2])
# => 1
```
I think this results in semantics that most people would expect, even if they don't like the implicit block argument syntax.
----------------------------------------
Bug #15708: Implicit numbered argument decomposes an array
https://bugs.ruby-lang.org/issues/15708#change-77584
* Author: sawa (Tsuyoshi Sawada)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: 2.7.0dev
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
In the following, `@1` refers to the entire item iterated:
```ruby
a = [1, 2, 3]
a.map{|x| x} # => [1, 2, 3]
a.map{@1} # => [1, 2, 3]
```
whereas in the following, `@1` refers to the first item achieved by decomposing the item iterated, behaving the same as `x` given by `|(x)|` rather than by `|x|`:
```ruby
a = [[1], [2], [3]]
a.map{|x| x} # => [[1], [2], [3]]
a.map{|(x)| x} # => [1, 2, 3]
a.map{@1} # => [1, 2, 3]
```
Is this intended?
---Files--------------------------------
single-implicit-arg-no-destructure.diff (471 Bytes)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>