ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:122356] [Ruby Feature#21390] Deprecate passing arguments to Set#to_set and Enumerable#to_set
@ 2025-06-01  3:38 jeremyevans0 (Jeremy Evans) via ruby-core
  2025-06-05  5:54 ` [ruby-core:122427] " nobu (Nobuyoshi Nakada) via ruby-core
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: jeremyevans0 (Jeremy Evans) via ruby-core @ 2025-06-01  3:38 UTC (permalink / raw)
  To: ruby-core; +Cc: jeremyevans0 (Jeremy Evans)

Issue #21390 has been reported by jeremyevans0 (Jeremy Evans).

----------------------------------------
Feature #21390: Deprecate passing arguments to Set#to_set and Enumerable#to_set
https://bugs.ruby-lang.org/issues/21390

* Author: jeremyevans0 (Jeremy Evans)
* Status: Open
----------------------------------------
Array#to_a, Hash#to_h, Enumerable#to_a, and Enumerable#to_h do not allow you to specify subclasses.  This has undesired behavior when passing non-Set subclasses.  All of these are currently allowed, and none make sense:

```ruby
enum = [1,2,3].to_enum

enum.to_set(Hash)
enum.to_set(Struct.new("A", :a))
enum.to_set(ArgumentError)
enum.to_set(Thread){}
```

Users who want to create instances of a subclass of Set from an enumerable should pass the enumerable to SetSubclass.new instead of using to_set, similar to how they would have to handle subclasses of Array or Hash.

I've submitted a pull request that implements this: https://github.com/ruby/ruby/pull/13489

With the pull request, block arguments are still allowed (no warning). Positional and keyword argument use results in a deprecation warning.

I would like to deprecate this in Ruby 3.5 (next feature release), and remove it in Ruby 3.6 (following feature release).



-- 
https://bugs.ruby-lang.org/
______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

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

* [ruby-core:122427] [Ruby Feature#21390] Deprecate passing arguments to Set#to_set and Enumerable#to_set
  2025-06-01  3:38 [ruby-core:122356] [Ruby Feature#21390] Deprecate passing arguments to Set#to_set and Enumerable#to_set jeremyevans0 (Jeremy Evans) via ruby-core
@ 2025-06-05  5:54 ` nobu (Nobuyoshi Nakada) via ruby-core
  2025-06-05 12:30 ` [ruby-core:122454] " knu (Akinori MUSHA) via ruby-core
  2025-06-05 16:25 ` [ruby-core:122461] " jeremyevans0 (Jeremy Evans) via ruby-core
  2 siblings, 0 replies; 4+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2025-06-05  5:54 UTC (permalink / raw)
  To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)

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

Status changed from Open to Assigned
Assignee set to knu (Akinori MUSHA)

----------------------------------------
Feature #21390: Deprecate passing arguments to Set#to_set and Enumerable#to_set
https://bugs.ruby-lang.org/issues/21390#change-113607

* Author: jeremyevans0 (Jeremy Evans)
* Status: Assigned
* Assignee: knu (Akinori MUSHA)
----------------------------------------
Array#to_a, Hash#to_h, Enumerable#to_a, and Enumerable#to_h do not allow you to specify subclasses.  This has undesired behavior when passing non-Set subclasses.  All of these are currently allowed, and none make sense:

```ruby
enum = [1,2,3].to_enum

enum.to_set(Hash)
enum.to_set(Struct.new("A", :a))
enum.to_set(ArgumentError)
enum.to_set(Thread){}
```

Users who want to create instances of a subclass of Set from an enumerable should pass the enumerable to SetSubclass.new instead of using to_set, similar to how they would have to handle subclasses of Array or Hash.

I've submitted a pull request that implements this: https://github.com/ruby/ruby/pull/13489

With the pull request, block arguments are still allowed (no warning). Positional and keyword argument use results in a deprecation warning.

I would like to deprecate this in Ruby 3.5 (next feature release), and remove it in Ruby 3.6 (following feature release).



-- 
https://bugs.ruby-lang.org/
______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

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

* [ruby-core:122454] [Ruby Feature#21390] Deprecate passing arguments to Set#to_set and Enumerable#to_set
  2025-06-01  3:38 [ruby-core:122356] [Ruby Feature#21390] Deprecate passing arguments to Set#to_set and Enumerable#to_set jeremyevans0 (Jeremy Evans) via ruby-core
  2025-06-05  5:54 ` [ruby-core:122427] " nobu (Nobuyoshi Nakada) via ruby-core
@ 2025-06-05 12:30 ` knu (Akinori MUSHA) via ruby-core
  2025-06-05 16:25 ` [ruby-core:122461] " jeremyevans0 (Jeremy Evans) via ruby-core
  2 siblings, 0 replies; 4+ messages in thread
From: knu (Akinori MUSHA) via ruby-core @ 2025-06-05 12:30 UTC (permalink / raw)
  To: ruby-core; +Cc: knu (Akinori MUSHA)

Issue #21390 has been updated by knu (Akinori MUSHA).


I can agree with this.  As it turned out, subclassing Set classes did not become very common, so I think it's fine to deprecate this feature now.

----------------------------------------
Feature #21390: Deprecate passing arguments to Set#to_set and Enumerable#to_set
https://bugs.ruby-lang.org/issues/21390#change-113639

* Author: jeremyevans0 (Jeremy Evans)
* Status: Assigned
* Assignee: knu (Akinori MUSHA)
----------------------------------------
Array#to_a, Hash#to_h, Enumerable#to_a, and Enumerable#to_h do not allow you to specify subclasses.  This has undesired behavior when passing non-Set subclasses.  All of these are currently allowed, and none make sense:

```ruby
enum = [1,2,3].to_enum

enum.to_set(Hash)
enum.to_set(Struct.new("A", :a))
enum.to_set(ArgumentError)
enum.to_set(Thread){}
```

Users who want to create instances of a subclass of Set from an enumerable should pass the enumerable to SetSubclass.new instead of using to_set, similar to how they would have to handle subclasses of Array or Hash.

I've submitted a pull request that implements this: https://github.com/ruby/ruby/pull/13489

With the pull request, block arguments are still allowed (no warning). Positional and keyword argument use results in a deprecation warning.

I would like to deprecate this in Ruby 3.5 (next feature release), and remove it in Ruby 3.6 (following feature release).



-- 
https://bugs.ruby-lang.org/
______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

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

* [ruby-core:122461] [Ruby Feature#21390] Deprecate passing arguments to Set#to_set and Enumerable#to_set
  2025-06-01  3:38 [ruby-core:122356] [Ruby Feature#21390] Deprecate passing arguments to Set#to_set and Enumerable#to_set jeremyevans0 (Jeremy Evans) via ruby-core
  2025-06-05  5:54 ` [ruby-core:122427] " nobu (Nobuyoshi Nakada) via ruby-core
  2025-06-05 12:30 ` [ruby-core:122454] " knu (Akinori MUSHA) via ruby-core
@ 2025-06-05 16:25 ` jeremyevans0 (Jeremy Evans) via ruby-core
  2 siblings, 0 replies; 4+ messages in thread
From: jeremyevans0 (Jeremy Evans) via ruby-core @ 2025-06-05 16:25 UTC (permalink / raw)
  To: ruby-core; +Cc: jeremyevans0 (Jeremy Evans)

Issue #21390 has been updated by jeremyevans0 (Jeremy Evans).

Status changed from Assigned to Closed

Implemented in commit:0b07d2a1e32a456fc302c8d970fa85782bdb98ce 

----------------------------------------
Feature #21390: Deprecate passing arguments to Set#to_set and Enumerable#to_set
https://bugs.ruby-lang.org/issues/21390#change-113649

* Author: jeremyevans0 (Jeremy Evans)
* Status: Closed
* Assignee: knu (Akinori MUSHA)
----------------------------------------
Array#to_a, Hash#to_h, Enumerable#to_a, and Enumerable#to_h do not allow you to specify subclasses.  This has undesired behavior when passing non-Set subclasses.  All of these are currently allowed, and none make sense:

```ruby
enum = [1,2,3].to_enum

enum.to_set(Hash)
enum.to_set(Struct.new("A", :a))
enum.to_set(ArgumentError)
enum.to_set(Thread){}
```

Users who want to create instances of a subclass of Set from an enumerable should pass the enumerable to SetSubclass.new instead of using to_set, similar to how they would have to handle subclasses of Array or Hash.

I've submitted a pull request that implements this: https://github.com/ruby/ruby/pull/13489

With the pull request, block arguments are still allowed (no warning). Positional and keyword argument use results in a deprecation warning.

I would like to deprecate this in Ruby 3.5 (next feature release), and remove it in Ruby 3.6 (following feature release).



-- 
https://bugs.ruby-lang.org/
______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

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

end of thread, other threads:[~2025-06-05 16:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-01  3:38 [ruby-core:122356] [Ruby Feature#21390] Deprecate passing arguments to Set#to_set and Enumerable#to_set jeremyevans0 (Jeremy Evans) via ruby-core
2025-06-05  5:54 ` [ruby-core:122427] " nobu (Nobuyoshi Nakada) via ruby-core
2025-06-05 12:30 ` [ruby-core:122454] " knu (Akinori MUSHA) via ruby-core
2025-06-05 16:25 ` [ruby-core:122461] " jeremyevans0 (Jeremy Evans) via ruby-core

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 NNTP newsgroup(s).