ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:91881] [Ruby trunk Bug#15708] Implicit numbered argument decomposes an array
       [not found] <redmine.issue-15708.20190319110839@ruby-lang.org>
@ 2019-03-19 23:14 ` hsbt
  2019-04-08 18:13 ` [ruby-core:92209] " eregontp
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 14+ messages in thread
From: hsbt @ 2019-03-19 23:14 UTC (permalink / raw
  To: ruby-core

Issue #15708 has been updated by hsbt (Hiroshi SHIBATA).


Sorry, your inconvenience experience. We have an issue of bugs.ruby-lang.org. I fixed it on this morning(JST).
I removed duplicated issues and copy from them.

@nobu said:

Intended.

It equals
```ruby
a.map{|x,| x} # => [1, 2, 3]
```

----------------------------------------
Bug #15708: Implicit numbered argument decomposes an array
https://bugs.ruby-lang.org/issues/15708#change-77202

* 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?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:92209] [Ruby trunk Bug#15708] Implicit numbered argument decomposes an array
       [not found] <redmine.issue-15708.20190319110839@ruby-lang.org>
  2019-03-19 23:14 ` [ruby-core:91881] [Ruby trunk Bug#15708] Implicit numbered argument decomposes an array hsbt
@ 2019-04-08 18:13 ` eregontp
  2019-04-08 18:35 ` [ruby-core:92211] " eregontp
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 14+ messages in thread
From: eregontp @ 2019-04-08 18:13 UTC (permalink / raw
  To: ruby-core

Issue #15708 has been updated by Eregon (Benoit Daloze).


As I said in #15723,

I believe the `|x,|` behavior for `@1` can only be considered a bug.

It prevents `array_of_arrays.each { p @1 }` to work correctly.
Why would we want to prevent that and make this pattern not general, dangerous, inconsistent and unusable for nested arrays?
This doesn't make any sense to me.

How can this be intended?
It ignores elements and make one of the simplest use of `@1` wrong.

```ruby
array_of_arrays = [[1,2], [3,4]]
array_of_arrays.each { p @1 }
# => 1
# => 3
```

The same happens for every block with `@` which passed value happens to be an Array.

This kind of behavior is what I learned in programming languages classes as a design flaw,
because it cannot handle properly elements independent of their representation.

----------------------------------------
Bug #15708: Implicit numbered argument decomposes an array
https://bugs.ruby-lang.org/issues/15708#change-77544

* 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?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:92211] [Ruby trunk Bug#15708] Implicit numbered argument decomposes an array
       [not found] <redmine.issue-15708.20190319110839@ruby-lang.org>
  2019-03-19 23:14 ` [ruby-core:91881] [Ruby trunk Bug#15708] Implicit numbered argument decomposes an array hsbt
  2019-04-08 18:13 ` [ruby-core:92209] " eregontp
@ 2019-04-08 18:35 ` eregontp
  2019-04-08 19:31 ` [ruby-core:92213] " sholde4
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 14+ messages in thread
From: eregontp @ 2019-04-08 18:35 UTC (permalink / raw
  To: ruby-core

Issue #15708 has been updated by Eregon (Benoit Daloze).


FWIW, I would bet >99% of Rubyists would agree this is a bug: https://twitter.com/eregontp/status/1115318993299083265

----------------------------------------
Bug #15708: Implicit numbered argument decomposes an array
https://bugs.ruby-lang.org/issues/15708#change-77546

* 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?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:92213] [Ruby trunk Bug#15708] Implicit numbered argument decomposes an array
       [not found] <redmine.issue-15708.20190319110839@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2019-04-08 18:35 ` [ruby-core:92211] " eregontp
@ 2019-04-08 19:31 ` sholde4
  2019-04-09 15:18 ` [ruby-core:92221] " dgutov
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 14+ messages in thread
From: sholde4 @ 2019-04-08 19:31 UTC (permalink / raw
  To: ruby-core

Issue #15708 has been updated by sholden (Scott Holden).


Eregon (Benoit Daloze) wrote:
> FWIW, I would bet >99% of Rubyists would agree this is a bug: https://twitter.com/eregontp/status/1115318993299083265


This is definitely not the behavior I would expect. In everything that I've seen, developers are describing the feature such that 

``` ruby
a.map{|x| x} == a.map{ @1 }
```

This would be a very surprising behavior for people to stumble upon.

----------------------------------------
Bug #15708: Implicit numbered argument decomposes an array
https://bugs.ruby-lang.org/issues/15708#change-77548

* 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?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:92221] [Ruby trunk Bug#15708] Implicit numbered argument decomposes an array
       [not found] <redmine.issue-15708.20190319110839@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2019-04-08 19:31 ` [ruby-core:92213] " sholde4
@ 2019-04-09 15:18 ` dgutov
  2019-04-09 19:41 ` [ruby-core:92222] " eregontp
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 14+ messages in thread
From: dgutov @ 2019-04-09 15:18 UTC (permalink / raw
  To: ruby-core

Issue #15708 has been updated by dgutov (Dmitry Gutov).


This is what happens when one syntactic sugar(*) collides with another.

(*) `a.map { |x,| x }` being a shorthand for `a.map { |(x)| x }` , and sometimes not, depending on the runtime values.

Neither of these are good, IMO (one for consistency and strong typing, and a lot of people have already expressed their feelings about the other).

It's too late to get rid of the first one, I think. But we can still reverse the decision on the new one.

----------------------------------------
Bug #15708: Implicit numbered argument decomposes an array
https://bugs.ruby-lang.org/issues/15708#change-77558

* 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?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:92222] [Ruby trunk Bug#15708] Implicit numbered argument decomposes an array
       [not found] <redmine.issue-15708.20190319110839@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2019-04-09 15:18 ` [ruby-core:92221] " dgutov
@ 2019-04-09 19:41 ` eregontp
  2019-04-09 19:45 ` [ruby-core:92223] " eregontp
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 14+ messages in thread
From: eregontp @ 2019-04-09 19:41 UTC (permalink / raw
  To: ruby-core

Issue #15708 has been updated by Eregon (Benoit Daloze).


For some reason, a reply on the tracker seems to have been lost, or removed.
I think it is highly relevant, so I'll quote it here:

sholden (Scott Holden) wrote:
> This is definitely not the behavior I would expect. In everything that I've seen, developers are describing the feature such that 
> 
> ``` ruby
> a.map{|x| x} == a.map{ @1 }
> ```
> 
> This would be a very surprising behavior for people to stumble upon.


----------------------------------------
Bug #15708: Implicit numbered argument decomposes an array
https://bugs.ruby-lang.org/issues/15708#change-77559

* 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?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:92223] [Ruby trunk Bug#15708] Implicit numbered argument decomposes an array
       [not found] <redmine.issue-15708.20190319110839@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2019-04-09 19:41 ` [ruby-core:92222] " eregontp
@ 2019-04-09 19:45 ` eregontp
  2019-04-11 21:42 ` [ruby-core:92250] " merch-redmine
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 14+ messages in thread
From: eregontp @ 2019-04-09 19:45 UTC (permalink / raw
  To: ruby-core

Issue #15708 has been updated by Eregon (Benoit Daloze).


FWIW, the replies on my tweet above is some good sign that very few Rubyists expect this behavior and it breaks the basics assumptions of how the feature can be used.

----------------------------------------
Bug #15708: Implicit numbered argument decomposes an array
https://bugs.ruby-lang.org/issues/15708#change-77560

* 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?



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:92250] [Ruby trunk Bug#15708] Implicit numbered argument decomposes an array
       [not found] <redmine.issue-15708.20190319110839@ruby-lang.org>
                   ` (6 preceding siblings ...)
  2019-04-09 19:45 ` [ruby-core:92223] " eregontp
@ 2019-04-11 21:42 ` merch-redmine
  2019-04-12  9:59 ` [ruby-core:92256] " nobu
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 14+ messages in thread
From: merch-redmine @ 2019-04-11 21:42 UTC (permalink / raw
  To: ruby-core

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/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:92256] [Ruby trunk Bug#15708] Implicit numbered argument decomposes an array
       [not found] <redmine.issue-15708.20190319110839@ruby-lang.org>
                   ` (7 preceding siblings ...)
  2019-04-11 21:42 ` [ruby-core:92250] " merch-redmine
@ 2019-04-12  9:59 ` nobu
  2019-06-24 10:26 ` [ruby-core:93331] " sawadatsuyoshi
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 14+ messages in thread
From: nobu @ 2019-04-12  9:59 UTC (permalink / raw
  To: ruby-core

Issue #15708 has been updated by nobu (Nobuyoshi Nakada).


jeremyevans0 (Jeremy Evans) wrote:
> Attached is a patch that will turn off destructuring if the only implicit block variable is `@1`:

```diff
-	args->nd_ainfo->rest_arg = excessed_comma;
+	if (max_numparam > 1) {
+	    args->nd_ainfo->rest_arg = excessed_comma;
+	}
```

It can be done by just removing the line, regardless `max_numparam`.



----------------------------------------
Bug #15708: Implicit numbered argument decomposes an array
https://bugs.ruby-lang.org/issues/15708#change-77589

* 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/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:93331] [Ruby trunk Bug#15708] Implicit numbered argument decomposes an array
       [not found] <redmine.issue-15708.20190319110839@ruby-lang.org>
                   ` (8 preceding siblings ...)
  2019-04-12  9:59 ` [ruby-core:92256] " nobu
@ 2019-06-24 10:26 ` sawadatsuyoshi
  2019-06-28 10:53 ` [ruby-core:93407] " eregontp
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 14+ messages in thread
From: sawadatsuyoshi @ 2019-06-24 10:26 UTC (permalink / raw
  To: ruby-core

Issue #15708 has been updated by sawa (Tsuyoshi Sawada).


説明をありがとうこざいます。バクでないことは分かったので、閉じて下さい。

----------------------------------------
Bug #15708: Implicit numbered argument decomposes an array
https://bugs.ruby-lang.org/issues/15708#change-78810

* 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/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:93407] [Ruby trunk Bug#15708] Implicit numbered argument decomposes an array
       [not found] <redmine.issue-15708.20190319110839@ruby-lang.org>
                   ` (9 preceding siblings ...)
  2019-06-24 10:26 ` [ruby-core:93331] " sawadatsuyoshi
@ 2019-06-28 10:53 ` eregontp
  2019-06-28 11:32 ` [ruby-core:93408] " sawadatsuyoshi
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 14+ messages in thread
From: eregontp @ 2019-06-28 10:53 UTC (permalink / raw
  To: ruby-core

Issue #15708 has been updated by Eregon (Benoit Daloze).

Assignee set to matz (Yukihiro Matsumoto)
Status changed from Rejected to Assigned

IMHO, this is very much a bug, and the single reason I heard for it seems largely outweigh by being non-intuitive and breaking code.
@nobu BTW, that reason has not been written here yet and should be, please write it down.
IMHO using @N will always be surprising for debugging since it changes arity.

So I reopen this and assign to matz.

I believe we all agree that if we accept only a single unnamed parameter, that it should be the same as `{ |x| }`.
I don't think that rule should change with multiple unnamed parameters.

TBH, I don't think this behavior is rational language design (taking the semantics of a almost-never-used syntax (because it's dangerous) for a new syntactic sugar), but it's just my opinion.

----------------------------------------
Bug #15708: Implicit numbered argument decomposes an array
https://bugs.ruby-lang.org/issues/15708#change-78948

* Author: sawa (Tsuyoshi Sawada)
* Status: Assigned
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* 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/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:93408] [Ruby trunk Bug#15708] Implicit numbered argument decomposes an array
       [not found] <redmine.issue-15708.20190319110839@ruby-lang.org>
                   ` (10 preceding siblings ...)
  2019-06-28 10:53 ` [ruby-core:93407] " eregontp
@ 2019-06-28 11:32 ` sawadatsuyoshi
  2019-06-28 13:54 ` [ruby-core:93410] " mame
  2019-06-28 17:26 ` [ruby-core:93414] " eregontp
  13 siblings, 0 replies; 14+ messages in thread
From: sawadatsuyoshi @ 2019-06-28 11:32 UTC (permalink / raw
  To: ruby-core

Issue #15708 has been updated by sawa (Tsuyoshi Sawada).


これは意図されたものなので、明確なバグです。勘違いによりアサインされてしまったようなので、閉じてください。

この挙動に対する不満を述べているコメントがあるようですが、それなら明らかにそれは仕様として別のイシューとして書かれるべきであり、バグに対してまつもとさんにアサインされているのがそもそも自己矛盾だと思います。

----------------------------------------
Bug #15708: Implicit numbered argument decomposes an array
https://bugs.ruby-lang.org/issues/15708#change-78949

* Author: sawa (Tsuyoshi Sawada)
* Status: Assigned
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* 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/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:93410] [Ruby trunk Bug#15708] Implicit numbered argument decomposes an array
       [not found] <redmine.issue-15708.20190319110839@ruby-lang.org>
                   ` (11 preceding siblings ...)
  2019-06-28 11:32 ` [ruby-core:93408] " sawadatsuyoshi
@ 2019-06-28 13:54 ` mame
  2019-06-28 17:26 ` [ruby-core:93414] " eregontp
  13 siblings, 0 replies; 14+ messages in thread
From: mame @ 2019-06-28 13:54 UTC (permalink / raw
  To: ruby-core

Issue #15708 has been updated by mame (Yusuke Endoh).


@eregon I think sawa says "This behavior was intentional so not a bug.  Please file a new ticket if you request a feature change."

@sawa I know you can write English better than I.  Please do not use Japanese in an English ticket.

----------------------------------------
Bug #15708: Implicit numbered argument decomposes an array
https://bugs.ruby-lang.org/issues/15708#change-78952

* Author: sawa (Tsuyoshi Sawada)
* Status: Rejected
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* 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/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:93414] [Ruby trunk Bug#15708] Implicit numbered argument decomposes an array
       [not found] <redmine.issue-15708.20190319110839@ruby-lang.org>
                   ` (12 preceding siblings ...)
  2019-06-28 13:54 ` [ruby-core:93410] " mame
@ 2019-06-28 17:26 ` eregontp
  13 siblings, 0 replies; 14+ messages in thread
From: eregontp @ 2019-06-28 17:26 UTC (permalink / raw
  To: ruby-core

Issue #15708 has been updated by Eregon (Benoit Daloze).


I think we don't need a new ticket.
This ticket description explains the problem and I argue it is bug, even if the current behavior was intended by nobu.
Let's let matz judge.

Also, if the behavior is kept we should have a clear reason written on this ticket.
I see no reason on the ticket besides "intended" which doesn't explain the rationale, so I think the discussion shouldn't be closed.
OTOH I see usages which are broken by this behavior (e.g., array_of_arrays and map), and yet no answer to that.

----------------------------------------
Bug #15708: Implicit numbered argument decomposes an array
https://bugs.ruby-lang.org/issues/15708#change-78956

* Author: sawa (Tsuyoshi Sawada)
* Status: Rejected
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* 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/

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-06-28 17:26 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-15708.20190319110839@ruby-lang.org>
2019-03-19 23:14 ` [ruby-core:91881] [Ruby trunk Bug#15708] Implicit numbered argument decomposes an array hsbt
2019-04-08 18:13 ` [ruby-core:92209] " eregontp
2019-04-08 18:35 ` [ruby-core:92211] " eregontp
2019-04-08 19:31 ` [ruby-core:92213] " sholde4
2019-04-09 15:18 ` [ruby-core:92221] " dgutov
2019-04-09 19:41 ` [ruby-core:92222] " eregontp
2019-04-09 19:45 ` [ruby-core:92223] " eregontp
2019-04-11 21:42 ` [ruby-core:92250] " merch-redmine
2019-04-12  9:59 ` [ruby-core:92256] " nobu
2019-06-24 10:26 ` [ruby-core:93331] " sawadatsuyoshi
2019-06-28 10:53 ` [ruby-core:93407] " eregontp
2019-06-28 11:32 ` [ruby-core:93408] " sawadatsuyoshi
2019-06-28 13:54 ` [ruby-core:93410] " mame
2019-06-28 17:26 ` [ruby-core:93414] " eregontp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).