* [ruby-core:75477] [Ruby trunk Feature#12374] SingletonClass
[not found] <redmine.issue-12374.20160512182821@ruby-lang.org>
@ 2016-05-12 18:28 ` sawadatsuyoshi
2016-05-12 18:30 ` [ruby-core:75478] " sawadatsuyoshi
` (8 subsequent siblings)
9 siblings, 0 replies; 10+ messages in thread
From: sawadatsuyoshi @ 2016-05-12 18:28 UTC (permalink / raw
To: ruby-core
Issue #12374 has been reported by Tsuyoshi Sawada.
----------------------------------------
Feature #12374: SingletonClass
https://bugs.ruby-lang.org/issues/12374
* Author: Tsuyoshi Sawada
* Status: Open
* Priority: Normal
* Assignee:
----------------------------------------
I propose to have a class `SingletonClass`, a subclass of the class `Class`, to which all singleton classes belong. It should be the owner of all the properties that are specific to singleton classes. Also, the methods defined on `Singleton` module should be moved to this class.
Reasons are as follows:
1. I was thinking that the reason #12084 hasn't been seen positively may be because the developers do not want to define a method only on limited instances of a class. If we have `SingletonClass`, the method `#instance` proposed in #12084 could be defined as an instance method of `SingletonClass`.
2. The way to introduce the singleton pattern using the `Singleton` module (http://ruby-doc.org/stdlib-2.3.0/libdoc/singleton/rdoc/Singleton.html):
~~~ruby
class A
include Singleton
# ...
end
~~~
is a bit unnatural and verbose. If we have `SingletonClass`, then we can define a singleton class more naturally:
~~~ruby
A.SingletonClass.new
~~~
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 10+ messages in thread
* [ruby-core:75478] [Ruby trunk Feature#12374] SingletonClass
[not found] <redmine.issue-12374.20160512182821@ruby-lang.org>
2016-05-12 18:28 ` [ruby-core:75477] [Ruby trunk Feature#12374] SingletonClass sawadatsuyoshi
@ 2016-05-12 18:30 ` sawadatsuyoshi
2016-05-20 15:45 ` [ruby-core:75641] " danieldasilvaferreira
` (7 subsequent siblings)
9 siblings, 0 replies; 10+ messages in thread
From: sawadatsuyoshi @ 2016-05-12 18:30 UTC (permalink / raw
To: ruby-core
Issue #12374 has been updated by Tsuyoshi Sawada.
Sorry, for the last example, I meant:
~~~ruby
A = SingletonClass.new
~~~
----------------------------------------
Feature #12374: SingletonClass
https://bugs.ruby-lang.org/issues/12374#change-58598
* Author: Tsuyoshi Sawada
* Status: Open
* Priority: Normal
* Assignee:
----------------------------------------
I propose to have a class `SingletonClass`, a subclass of the class `Class`, to which all singleton classes belong. It should be the owner of all the properties that are specific to singleton classes. Also, the methods defined on `Singleton` module should be moved to this class.
Reasons are as follows:
1. I was thinking that the reason #12084 hasn't been seen positively may be because the developers do not want to define a method only on limited instances of a class. If we have `SingletonClass`, the method `#instance` proposed in #12084 could be defined as an instance method of `SingletonClass`.
2. The way to introduce the singleton pattern using the `Singleton` module (http://ruby-doc.org/stdlib-2.3.0/libdoc/singleton/rdoc/Singleton.html):
~~~ruby
class A
include Singleton
# ...
end
~~~
is a bit unnatural and verbose. If we have `SingletonClass`, then we can define a singleton class more naturally:
~~~ruby
A.SingletonClass.new
~~~
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 10+ messages in thread
* [ruby-core:75641] [Ruby trunk Feature#12374] SingletonClass
[not found] <redmine.issue-12374.20160512182821@ruby-lang.org>
2016-05-12 18:28 ` [ruby-core:75477] [Ruby trunk Feature#12374] SingletonClass sawadatsuyoshi
2016-05-12 18:30 ` [ruby-core:75478] " sawadatsuyoshi
@ 2016-05-20 15:45 ` danieldasilvaferreira
2016-05-20 15:56 ` [ruby-core:75642] " danieldasilvaferreira
` (6 subsequent siblings)
9 siblings, 0 replies; 10+ messages in thread
From: danieldasilvaferreira @ 2016-05-20 15:45 UTC (permalink / raw
To: ruby-core
Issue #12374 has been updated by Daniel Ferreira.
Why don't you edit the description to correct the error?
----------------------------------------
Feature #12374: SingletonClass
https://bugs.ruby-lang.org/issues/12374#change-58775
* Author: Tsuyoshi Sawada
* Status: Open
* Priority: Normal
* Assignee:
----------------------------------------
I propose to have a class `SingletonClass`, a subclass of the class `Class`, to which all singleton classes belong. It should be the owner of all the properties that are specific to singleton classes. Also, the methods defined on `Singleton` module should be moved to this class.
Reasons are as follows:
1. I was thinking that the reason #12084 hasn't been seen positively may be because the developers do not want to define a method only on limited instances of a class. If we have `SingletonClass`, the method `#instance` proposed in #12084 could be defined as an instance method of `SingletonClass`.
2. The way to introduce the singleton pattern using the `Singleton` module (http://ruby-doc.org/stdlib-2.3.0/libdoc/singleton/rdoc/Singleton.html):
~~~ruby
class A
include Singleton
# ...
end
~~~
is a bit unnatural and verbose. If we have `SingletonClass`, then we can define a singleton class more naturally:
~~~ruby
A.SingletonClass.new
~~~
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 10+ messages in thread
* [ruby-core:75642] [Ruby trunk Feature#12374] SingletonClass
[not found] <redmine.issue-12374.20160512182821@ruby-lang.org>
` (2 preceding siblings ...)
2016-05-20 15:45 ` [ruby-core:75641] " danieldasilvaferreira
@ 2016-05-20 15:56 ` danieldasilvaferreira
2016-05-20 16:00 ` [ruby-core:75643] [Ruby trunk Feature#12374][Feedback] SingletonClass nobu
` (5 subsequent siblings)
9 siblings, 0 replies; 10+ messages in thread
From: danieldasilvaferreira @ 2016-05-20 15:56 UTC (permalink / raw
To: ruby-core
Issue #12374 has been updated by Daniel Ferreira.
Description updated
----------------------------------------
Feature #12374: SingletonClass
https://bugs.ruby-lang.org/issues/12374#change-58776
* Author: Tsuyoshi Sawada
* Status: Open
* Priority: Normal
* Assignee:
----------------------------------------
I propose to have a class `SingletonClass`, a subclass of the class `Class`, to which all singleton classes belong. It should be the owner of all the properties that are specific to singleton classes. Also, the methods defined on `Singleton` module should be moved to this class.
Reasons are as follows:
1. I was thinking that the reason #12084 hasn't been seen positively may be because the developers do not want to define a method only on limited instances of a class. If we have `SingletonClass`, the method `#instance` proposed in #12084 could be defined as an instance method of `SingletonClass`.
2. The way to introduce the singleton pattern using the `Singleton` module (http://ruby-doc.org/stdlib-2.3.0/libdoc/singleton/rdoc/Singleton.html):
~~~ruby
class A
include Singleton
# ...
end
~~~
is a bit unnatural and verbose. If we have `SingletonClass`, then we can define a singleton class more naturally:
~~~ruby
A = SingletonClass.new
~~~
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 10+ messages in thread
* [ruby-core:75643] [Ruby trunk Feature#12374][Feedback] SingletonClass
[not found] <redmine.issue-12374.20160512182821@ruby-lang.org>
` (3 preceding siblings ...)
2016-05-20 15:56 ` [ruby-core:75642] " danieldasilvaferreira
@ 2016-05-20 16:00 ` nobu
2016-05-21 2:40 ` [ruby-core:75649] [Ruby trunk Feature#12374] SingletonClass sawadatsuyoshi
` (4 subsequent siblings)
9 siblings, 0 replies; 10+ messages in thread
From: nobu @ 2016-05-20 16:00 UTC (permalink / raw
To: ruby-core
Issue #12374 has been updated by Nobuyoshi Nakada.
Status changed from Open to Feedback
What is `SingletonClass`?
A wrapper object?
```ruby
def (SingletonClass = Object.new).new(*args)
Class.new(*args) {include Singleton}
end
```
----------------------------------------
Feature #12374: SingletonClass
https://bugs.ruby-lang.org/issues/12374#change-58777
* Author: Tsuyoshi Sawada
* Status: Feedback
* Priority: Normal
* Assignee:
----------------------------------------
I propose to have a class `SingletonClass`, a subclass of the class `Class`, to which all singleton classes belong. It should be the owner of all the properties that are specific to singleton classes. Also, the methods defined on `Singleton` module should be moved to this class.
Reasons are as follows:
1. I was thinking that the reason #12084 hasn't been seen positively may be because the developers do not want to define a method only on limited instances of a class. If we have `SingletonClass`, the method `#instance` proposed in #12084 could be defined as an instance method of `SingletonClass`.
2. The way to introduce the singleton pattern using the `Singleton` module (http://ruby-doc.org/stdlib-2.3.0/libdoc/singleton/rdoc/Singleton.html):
~~~ruby
class A
include Singleton
# ...
end
~~~
is a bit unnatural and verbose. If we have `SingletonClass`, then we can define a singleton class more naturally:
~~~ruby
A = SingletonClass.new
~~~
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 10+ messages in thread
* [ruby-core:75649] [Ruby trunk Feature#12374] SingletonClass
[not found] <redmine.issue-12374.20160512182821@ruby-lang.org>
` (4 preceding siblings ...)
2016-05-20 16:00 ` [ruby-core:75643] [Ruby trunk Feature#12374][Feedback] SingletonClass nobu
@ 2016-05-21 2:40 ` sawadatsuyoshi
2016-05-21 3:03 ` [ruby-core:75651] " nobu
` (3 subsequent siblings)
9 siblings, 0 replies; 10+ messages in thread
From: sawadatsuyoshi @ 2016-05-21 2:40 UTC (permalink / raw
To: ruby-core
Issue #12374 has been updated by Tsuyoshi Sawada.
Nobuyoshi Nakada wrote:
> What is `SingletonClass`?
> A wrapper object?
No, it should be a subclass of `Class`. It would perhaps need C-level modification. For any singleton class, I want `SingletonClass` to be in the ancestors.
Present:
~~~ruby
"".singleton_class.ancestors # => [#<Class:#<String:0x007f3f651d16d0>>, String, ...]
~~~
I want it to be:
~~~ruby
"".singleton_class.ancestors # => [#<Class:#<String:0x007f3f651d16d0>>, SingletonClass, String, ...]
~~~
----------------------------------------
Feature #12374: SingletonClass
https://bugs.ruby-lang.org/issues/12374#change-58782
* Author: Tsuyoshi Sawada
* Status: Feedback
* Priority: Normal
* Assignee:
----------------------------------------
I propose to have a class `SingletonClass`, a subclass of the class `Class`, to which all singleton classes belong. It should be the owner of all the properties that are specific to singleton classes. Also, the methods defined on `Singleton` module should be moved to this class.
Reasons are as follows:
1. I was thinking that the reason #12084 hasn't been seen positively may be because the developers do not want to define a method only on limited instances of a class. If we have `SingletonClass`, the method `#instance` proposed in #12084 could be defined as an instance method of `SingletonClass`.
2. The way to introduce the singleton pattern using the `Singleton` module (http://ruby-doc.org/stdlib-2.3.0/libdoc/singleton/rdoc/Singleton.html):
~~~ruby
class A
include Singleton
# ...
end
~~~
is a bit unnatural and verbose. If we have `SingletonClass`, then we can define a singleton class more naturally:
~~~ruby
A = SingletonClass.new
~~~
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 10+ messages in thread
* [ruby-core:75651] [Ruby trunk Feature#12374] SingletonClass
[not found] <redmine.issue-12374.20160512182821@ruby-lang.org>
` (5 preceding siblings ...)
2016-05-21 2:40 ` [ruby-core:75649] [Ruby trunk Feature#12374] SingletonClass sawadatsuyoshi
@ 2016-05-21 3:03 ` nobu
2016-05-21 3:05 ` [ruby-core:75652] " sawadatsuyoshi
` (2 subsequent siblings)
9 siblings, 0 replies; 10+ messages in thread
From: nobu @ 2016-05-21 3:03 UTC (permalink / raw
To: ruby-core
Issue #12374 has been updated by Nobuyoshi Nakada.
If a singleton class is a subclass of `SingletonClass`, no singleton classed inheriting other classes cannot be made.
I think it's a bad idea.
----------------------------------------
Feature #12374: SingletonClass
https://bugs.ruby-lang.org/issues/12374#change-58784
* Author: Tsuyoshi Sawada
* Status: Feedback
* Priority: Normal
* Assignee:
----------------------------------------
I propose to have a class `SingletonClass`, a subclass of the class `Class`, to which all singleton classes belong. It should be the owner of all the properties that are specific to singleton classes. Also, the methods defined on `Singleton` module should be moved to this class.
Reasons are as follows:
1. I was thinking that the reason #12084 hasn't been seen positively may be because the developers do not want to define a method only on limited instances of a class. If we have `SingletonClass`, the method `#instance` proposed in #12084 could be defined as an instance method of `SingletonClass`.
2. The way to introduce the singleton pattern using the `Singleton` module (http://ruby-doc.org/stdlib-2.3.0/libdoc/singleton/rdoc/Singleton.html):
~~~ruby
class A
include Singleton
# ...
end
~~~
is a bit unnatural and verbose. If we have `SingletonClass`, then we can define a singleton class more naturally:
~~~ruby
A = SingletonClass.new
~~~
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 10+ messages in thread
* [ruby-core:75652] [Ruby trunk Feature#12374] SingletonClass
[not found] <redmine.issue-12374.20160512182821@ruby-lang.org>
` (6 preceding siblings ...)
2016-05-21 3:03 ` [ruby-core:75651] " nobu
@ 2016-05-21 3:05 ` sawadatsuyoshi
2016-08-03 4:07 ` [ruby-core:76672] " transfire
2016-08-09 6:13 ` [ruby-core:76774] [Ruby trunk Feature#12374][Closed] SingletonClass matz
9 siblings, 0 replies; 10+ messages in thread
From: sawadatsuyoshi @ 2016-05-21 3:05 UTC (permalink / raw
To: ruby-core
Issue #12374 has been updated by Tsuyoshi Sawada.
Nobuyoshi Nakada wrote:
> If a singleton class is a subclass of `SingletonClass`, no singleton classed inheriting other classes cannot be made.
> I think it's a bad idea.
No, I want a singleton class to be an **instance** of `SingletonClass`.
----------------------------------------
Feature #12374: SingletonClass
https://bugs.ruby-lang.org/issues/12374#change-58785
* Author: Tsuyoshi Sawada
* Status: Feedback
* Priority: Normal
* Assignee:
----------------------------------------
I propose to have a class `SingletonClass`, a subclass of the class `Class`, to which all singleton classes belong. It should be the owner of all the properties that are specific to singleton classes. Also, the methods defined on `Singleton` module should be moved to this class.
Reasons are as follows:
1. I was thinking that the reason #12084 hasn't been seen positively may be because the developers do not want to define a method only on limited instances of a class. If we have `SingletonClass`, the method `#instance` proposed in #12084 could be defined as an instance method of `SingletonClass`.
2. The way to introduce the singleton pattern using the `Singleton` module (http://ruby-doc.org/stdlib-2.3.0/libdoc/singleton/rdoc/Singleton.html):
~~~ruby
class A
include Singleton
# ...
end
~~~
is a bit unnatural and verbose. If we have `SingletonClass`, then we can define a singleton class more naturally:
~~~ruby
A = SingletonClass.new
~~~
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 10+ messages in thread
* [ruby-core:76672] [Ruby trunk Feature#12374] SingletonClass
[not found] <redmine.issue-12374.20160512182821@ruby-lang.org>
` (7 preceding siblings ...)
2016-05-21 3:05 ` [ruby-core:75652] " sawadatsuyoshi
@ 2016-08-03 4:07 ` transfire
2016-08-09 6:13 ` [ruby-core:76774] [Ruby trunk Feature#12374][Closed] SingletonClass matz
9 siblings, 0 replies; 10+ messages in thread
From: transfire @ 2016-08-03 4:07 UTC (permalink / raw
To: ruby-core
Issue #12374 has been updated by Thomas Sawyer.
So...
~~~
Object..singleton_class.instance_of?(SingletonClass) #=> true
~~~
----------------------------------------
Feature #12374: SingletonClass
https://bugs.ruby-lang.org/issues/12374#change-59890
* Author: Tsuyoshi Sawada
* Status: Feedback
* Priority: Normal
* Assignee:
----------------------------------------
I propose to have a class `SingletonClass`, a subclass of the class `Class`, to which all singleton classes belong. It should be the owner of all the properties that are specific to singleton classes. Also, the methods defined on `Singleton` module should be moved to this class.
Reasons are as follows:
1. I was thinking that the reason #12084 hasn't been seen positively may be because the developers do not want to define a method only on limited instances of a class. If we have `SingletonClass`, the method `#instance` proposed in #12084 could be defined as an instance method of `SingletonClass`.
2. The way to introduce the singleton pattern using the `Singleton` module (http://ruby-doc.org/stdlib-2.3.0/libdoc/singleton/rdoc/Singleton.html):
~~~ruby
class A
include Singleton
# ...
end
~~~
is a bit unnatural and verbose. If we have `SingletonClass`, then we can define a singleton class more naturally:
~~~ruby
A = SingletonClass.new
~~~
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 10+ messages in thread
* [ruby-core:76774] [Ruby trunk Feature#12374][Closed] SingletonClass
[not found] <redmine.issue-12374.20160512182821@ruby-lang.org>
` (8 preceding siblings ...)
2016-08-03 4:07 ` [ruby-core:76672] " transfire
@ 2016-08-09 6:13 ` matz
9 siblings, 0 replies; 10+ messages in thread
From: matz @ 2016-08-09 6:13 UTC (permalink / raw
To: ruby-core
Issue #12374 has been updated by Yukihiro Matsumoto.
Status changed from Feedback to Closed
I don't think the idea itself is meaningless.
But its use-case is not clear to us yet.
(For the record, Singleton module is totally different story.)
If you have any real-world use-case, please reopen the issue.
Matz.
----------------------------------------
Feature #12374: SingletonClass
https://bugs.ruby-lang.org/issues/12374#change-59997
* Author: Tsuyoshi Sawada
* Status: Closed
* Priority: Normal
* Assignee:
----------------------------------------
I propose to have a class `SingletonClass`, a subclass of the class `Class`, to which all singleton classes belong. It should be the owner of all the properties that are specific to singleton classes. Also, the methods defined on `Singleton` module should be moved to this class.
Reasons are as follows:
1. I was thinking that the reason #12084 hasn't been seen positively may be because the developers do not want to define a method only on limited instances of a class. If we have `SingletonClass`, the method `#instance` proposed in #12084 could be defined as an instance method of `SingletonClass`.
2. The way to introduce the singleton pattern using the `Singleton` module (http://ruby-doc.org/stdlib-2.3.0/libdoc/singleton/rdoc/Singleton.html):
~~~ruby
class A
include Singleton
# ...
end
~~~
is a bit unnatural and verbose. If we have `SingletonClass`, then we can define a singleton class more naturally:
~~~ruby
A = SingletonClass.new
~~~
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2016-08-09 5:40 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <redmine.issue-12374.20160512182821@ruby-lang.org>
2016-05-12 18:28 ` [ruby-core:75477] [Ruby trunk Feature#12374] SingletonClass sawadatsuyoshi
2016-05-12 18:30 ` [ruby-core:75478] " sawadatsuyoshi
2016-05-20 15:45 ` [ruby-core:75641] " danieldasilvaferreira
2016-05-20 15:56 ` [ruby-core:75642] " danieldasilvaferreira
2016-05-20 16:00 ` [ruby-core:75643] [Ruby trunk Feature#12374][Feedback] SingletonClass nobu
2016-05-21 2:40 ` [ruby-core:75649] [Ruby trunk Feature#12374] SingletonClass sawadatsuyoshi
2016-05-21 3:03 ` [ruby-core:75651] " nobu
2016-05-21 3:05 ` [ruby-core:75652] " sawadatsuyoshi
2016-08-03 4:07 ` [ruby-core:76672] " transfire
2016-08-09 6:13 ` [ruby-core:76774] [Ruby trunk Feature#12374][Closed] SingletonClass matz
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).