https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112009-02-01T07:00:36ZRuby Issue Tracking SystemRuby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=28352009-02-01T07:00:36Zradarek (Radosław Bułat)
<ul></ul><p>=begin<br>
+1<br>
"Singleton" is most popular name for describe... singleton classes (sometimes named eigenclass, virtual class, metaclass). To be consistent with singleton_methods, define_singleton_method it would be very nice to name it singleton_class.<br>
=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=28362009-02-01T10:02:10Zmurphy (Kornelius Kalnbach)murphy@rubychan.de
<ul></ul><p>=begin<br>
+1<br>
I thought this feature was already added to 1.9? class << self; self; end is not very helpful for beginners.</p>
<p>What about singleton_class_eval? (Or singleton_class.eval, for that matter...)<br>
=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=28392009-02-01T20:31:42Zdblack (David Black)dblack@rubypal.com
<ul></ul><p>=begin<br>
Hi --</p>
<p>On Sun, 1 Feb 2009, Kornelius Kalnbach wrote:</p>
<blockquote>
<p>Issue <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: add Object#singleton_class method (Closed)" href="https://bugs.ruby-lang.org/issues/1082">#1082</a> has been updated by Kornelius Kalnbach.</p>
<p>+1<br>
I thought this feature was already added to 1.9? class << self; self; end is not very helpful for beginners.</p>
<p>What about singleton_class_eval? (Or singleton_class.eval, for that matter...)</p>
</blockquote>
<p>singleton_class.class_eval. The less it's treated like a special case,<br>
the better.</p>
<p>David</p>
<p>--<br>
David A. Black / Ruby Power and Light, LLC<br>
Ruby/Rails consulting & training: <a href="http://www.rubypal.com" class="external">http://www.rubypal.com</a><br>
Coming in 2009: The Well-Grounded Rubyist (<a href="http://manning.com/black2" class="external">http://manning.com/black2</a>)</p>
<p><a href="http://www.wishsight.com" class="external">http://www.wishsight.com</a> => Independent, social wishlist management!</p>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=28582009-02-02T12:01:57Zko1 (Koichi Sasada)
<ul><li><strong>Assignee</strong> set to <i>matz (Yukihiro Matsumoto)</i></li></ul><p>=begin</p>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=75002010-01-03T04:53:33Zsunaku (Suraj Kurapati)sunaku@gmail.com
<ul></ul><p>=begin<br>
Hi Matz,</p>
<p>Any thoughts on this feature request?</p>
<p>hello.singleton_class == (class << hello; self; end)</p>
<p>Thanks for your consideration.<br>
=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=75082010-01-04T15:25:23Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul></ul><p>=begin<br>
Hi,</p>
<p>In message "Re: <a href="https://blade.ruby-lang.org/ruby-core/27372">[ruby-core:27372]</a> [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: add Object#singleton_class method (Closed)" href="https://bugs.ruby-lang.org/issues/1082">#1082</a>] add Object#singleton_class method"<br>
on Sun, 3 Jan 2010 04:53:36 +0900, Suraj Kurapati <a href="mailto:redmine@ruby-lang.org" class="email">redmine@ruby-lang.org</a> writes:</p>
<p>|Any thoughts on this feature request?<br>
|<br>
| hello.singleton_class == (class << hello; self; end)<br>
|<br>
|Thanks for your consideration.</p>
<p>We haven't met any consensus of a name for the method.<br>
singleton_class, singletonclass, eigenclass, or whatever.</p>
<pre><code> matz.
</code></pre>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=75092010-01-04T15:46:45Zmurphy (Kornelius Kalnbach)murphy@rubychan.de
<ul></ul><p>=begin<br>
On 04.01.10 07:25, Yukihiro Matsumoto wrote:</p>
<blockquote>
<p>|Any thoughts on this feature request?<br>
|<br>
| hello.singleton_class == (class << hello; self; end)<br>
|<br>
|Thanks for your consideration.</p>
<p>We haven't met any consensus of a name for the method.<br>
singleton_class, singletonclass, eigenclass, or whatever.<br>
_why suggested "metaclass" back in 2005. But since we already have<br>
#define_singleton_method and #singleton_methods, "singleton_class"<br>
should be the name of it.</p>
</blockquote>
<p>I'd like to see it included in future Ruby versions.</p>
<p>[murphy]</p>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=75122010-01-05T01:14:18Zjudofyr (Magnus Holm)judofyr@gmail.com
<ul></ul><p>=begin<br>
+1 for whatever. (Okay then, maybe singleton_class is better)</p>
<p>//Magnus Holm</p>
<p>On Mon, Jan 4, 2010 at 07:25, Yukihiro Matsumoto <a href="mailto:matz@ruby-lang.org" class="email">matz@ruby-lang.org</a> wrote:</p>
<blockquote>
<p>Hi,</p>
<p>In message "Re: <a href="https://blade.ruby-lang.org/ruby-core/27372">[ruby-core:27372]</a> [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: add Object#singleton_class method (Closed)" href="https://bugs.ruby-lang.org/issues/1082">#1082</a>] add Object#singleton_class method"<br>
on Sun, 3 Jan 2010 04:53:36 +0900, Suraj Kurapati <a href="mailto:redmine@ruby-lang.org" class="email">redmine@ruby-lang.org</a> writes:</p>
<p>|Any thoughts on this feature request?<br>
|<br>
| hello.singleton_class == (class << hello; self; end)<br>
|<br>
|Thanks for your consideration.</p>
<p>We haven't met any consensus of a name for the method.<br>
singleton_class, singletonclass, eigenclass, or whatever.</p>
<p> matz.</p>
</blockquote>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=75132010-01-05T02:06:57Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul></ul><p>=begin<br>
Hi,</p>
<p>2010/1/4 Yukihiro Matsumoto <a href="mailto:matz@ruby-lang.org" class="email">matz@ruby-lang.org</a>:</p>
<blockquote>
<p>We haven't met any consensus of a name for the method.<br>
singleton_class, singletonclass, eigenclass, or whatever.</p>
</blockquote>
<p>The draft of ruby-std uses eigenclass. (13.4 Eigenclass)</p>
<p>--<br>
Yusuke ENDOH <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a></p>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=75172010-01-05T03:52:46Zmurphy (Kornelius Kalnbach)murphy@rubychan.de
<ul></ul><p>=begin<br>
On 04.01.10 17:28, Haase, Konstantin wrote:</p>
<blockquote>
<p>+1 for metaclass, as is it compatible with ActiveSupport, Rubinius<br>
and _why.</p>
</blockquote>
<p>The current methods are all named singleton_*, so anything else than<br>
singleton_class would be inconsistent.</p>
<p>ActiveSupport can (and will) still implement metaclass. And I didn't<br>
know Rubinius was having its own Ruby language. Compatibility with<br>
_why's metaid can be installed as a gem.</p>
<blockquote>
<p>Also, it confuses people with a Python background.<br>
Is that a plus? A metaclass are just the class of a class. I think _why<br>
didn't pick the best name.</p>
</blockquote>
<p>"Eigenclass" still sounds like a mathematician's joke to me ;)</p>
<p>[murphy]</p>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=75182010-01-05T04:03:43Zbitsweat (Jeremy Daer)jeremydaer@gmail.com
<ul></ul><p>=begin<br>
On Mon, Jan 4, 2010 at 10:52 AM, Kornelius Kalnbach <a href="mailto:murphy@rubychan.de" class="email">murphy@rubychan.de</a> wrote:</p>
<blockquote>
<p>On 04.01.10 17:28, Haase, Konstantin wrote:</p>
<blockquote>
<p>+1 for metaclass, as is it compatible with ActiveSupport, Rubinius<br>
and _why.</p>
</blockquote>
<p>The current methods are all named singleton_*, so anything else than<br>
singleton_class would be inconsistent.</p>
</blockquote>
<p>Agreed.</p>
<p>It's an appropriate name that makes its role in Ruby easier to understand.</p>
<p>"Meta" and "eigen" are less concrete and make Ruby seem more like<br>
arcane spellbook.</p>
<blockquote>
<p>ActiveSupport can (and will) still implement metaclass. And I didn't<br>
know Rubinius was having its own Ruby language. Compatibility with<br>
_why's metaid can be installed as a gem.</p>
</blockquote>
<p>Active Support always prefers Ruby's choice and will gladly change.</p>
<p>Best,<br>
jeremy</p>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=75202010-01-05T08:37:06Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul></ul><p>=begin<br>
Hi,</p>
<p>In message "Re: <a href="https://blade.ruby-lang.org/ruby-core/27394">[ruby-core:27394]</a> Re: [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: add Object#singleton_class method (Closed)" href="https://bugs.ruby-lang.org/issues/1082">#1082</a>] add Object#singleton_class method"<br>
on Tue, 5 Jan 2010 02:05:19 +0900, Yusuke ENDOH <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a> writes:<br>
|<br>
|2010/1/4 Yukihiro Matsumoto <a href="mailto:matz@ruby-lang.org" class="email">matz@ruby-lang.org</a>:<br>
|> We haven't met any consensus of a name for the method.<br>
|> singleton_class, singletonclass, eigenclass, or whatever.<br>
|<br>
|The draft of ruby-std uses eigenclass. (13.4 Eigenclass)</p>
<p>Of course I know. I was right there when we made the decision.</p>
<pre><code> matz.
</code></pre>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=75212010-01-05T08:41:08Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul></ul><p>=begin<br>
Hi,</p>
<p>In message "Re: <a href="https://blade.ruby-lang.org/ruby-core/27385">[ruby-core:27385]</a> Re: [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: add Object#singleton_class method (Closed)" href="https://bugs.ruby-lang.org/issues/1082">#1082</a>] add Object#singleton_class method"<br>
on Mon, 4 Jan 2010 15:46:32 +0900, Kornelius Kalnbach <a href="mailto:murphy@rubychan.de" class="email">murphy@rubychan.de</a> writes:</p>
<p>|_why suggested "metaclass" back in 2005. But since we already have<br>
|#define_singleton_method and #singleton_methods, "singleton_class"<br>
|should be the name of it.</p>
<p>"metaclass" means "a class of a class" but "that something" is not<br>
really a metaclass, since it's not only for classes, but for any<br>
object. "singleton_class" is too easily confused with a class appears<br>
in the Singleton Pattern.</p>
<p>|I'd like to see it included in future Ruby versions.</p>
<p>Me too. But I will wait for the right word.</p>
<pre><code> matz.
</code></pre>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=75222010-01-05T11:26:54Zshugo (Shugo Maeda)
<ul></ul><p>=begin<br>
Hi,</p>
<p>2010/1/5 Yusuke ENDOH <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a>:</p>
<blockquote>
<blockquote>
<p>We haven't met any consensus of a name for the method.<br>
singleton_class, singletonclass, eigenclass, or whatever.</p>
</blockquote>
<p>The draft of ruby-std uses eigenclass. (13.4 Eigenclass)</p>
</blockquote>
<p>Yes, it does. However, we can choose another word.</p>
<p>I prefer singleton_class than eigenclass. I suppose that "singleton<br>
class" is not so confusing with a class which implements the Singleton<br>
pattern because the word singleton remind Ruby users of singleton<br>
methods rather than the Singleton pattern.</p>
<p>--<br>
Shugo Maeda</p>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=75242010-01-05T11:41:23Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul></ul><p>=begin<br>
Hi,</p>
<p>In message "Re: <a href="https://blade.ruby-lang.org/ruby-core/27407">[ruby-core:27407]</a> Re: [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: add Object#singleton_class method (Closed)" href="https://bugs.ruby-lang.org/issues/1082">#1082</a>] add Object#singleton_class method"<br>
on Tue, 5 Jan 2010 11:26:41 +0900, Shugo Maeda <a href="mailto:shugo@ruby-lang.org" class="email">shugo@ruby-lang.org</a> writes:</p>
<p>|I prefer singleton_class than eigenclass. I suppose that "singleton<br>
|class" is not so confusing with a class which implements the Singleton<br>
|pattern because the word singleton remind Ruby users of singleton<br>
|methods rather than the Singleton pattern.</p>
<p>Basically, I agree. But I cannot deny the fact that we already have<br>
singleton.rb in the distribution, which provide Singleton class. I<br>
confess I did. Probably I shouldn't have.</p>
<pre><code> matz.
</code></pre>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=75252010-01-05T11:56:24Zaustin (Austin Ziegler)halostatue@gmail.com
<ul></ul><p>=begin<br>
On Mon, Jan 4, 2010 at 9:41 PM, Yukihiro Matsumoto <a href="mailto:matz@ruby-lang.org" class="email">matz@ruby-lang.org</a> wrote:</p>
<blockquote>
<p>In message "Re: <a href="https://blade.ruby-lang.org/ruby-core/27407">[ruby-core:27407]</a> Re: [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: add Object#singleton_class method (Closed)" href="https://bugs.ruby-lang.org/issues/1082">#1082</a>] add Object#singleton_class method"<br>
on Tue, 5 Jan 2010 11:26:41 +0900, Shugo Maeda <a href="mailto:shugo@ruby-lang.org" class="email">shugo@ruby-lang.org</a> writes:<br>
|I prefer singleton_class than eigenclass. I suppose that "singleton<br>
|class" is not so confusing with a class which implements the Singleton<br>
|pattern because the word singleton remind Ruby users of singleton<br>
|methods rather than the Singleton pattern.<br>
Basically, I agree. But I cannot deny the fact that we already have<br>
singleton.rb in the distribution, which provide Singleton class. I<br>
confess I did. Probably I shouldn't have.</p>
</blockquote>
<p>I just did a quick check of 1.8's singleton.rb, and Singleton is a<br>
module, not a class (which I'm sure you really knew, but it's<br>
important to my point).</p>
<p>I think that it's easy enough to say that every object can have a<br>
singleton_class, which sits between the object and any of its<br>
ancestors; not every object, however, implements the Singleton Pattern<br>
through the Singleton module.</p>
<p>That said, taking my interpretation above (that the<br>
{singleton,eigen}class sits between the object and its ancestors, if<br>
it's correct) a quick thesaurus check suggests either:</p>
<ul>
<li>betwixt_class</li>
<li>inter_class (as in "international", "existing or occurring between classes")</li>
</ul>
<p>betwixt is more fun, but the idea of calling it an interclass makes a<br>
lot of sense to me.</p>
<a name="-austin"></a>
<h2 >-austin<a href="#-austin" class="wiki-anchor">¶</a></h2>
<p>Austin Ziegler • <a href="mailto:halostatue@gmail.com" class="email">halostatue@gmail.com</a> • <a href="mailto:austin@halostatue.ca" class="email">austin@halostatue.ca</a><br>
<a href="http://www.halostatue.ca/" class="external">http://www.halostatue.ca/</a> • <a href="http://twitter.com/halostatue" class="external">http://twitter.com/halostatue</a></p>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=75262010-01-05T12:24:40Zbitsweat (Jeremy Daer)jeremydaer@gmail.com
<ul></ul><p>=begin<br>
On Mon, Jan 4, 2010 at 6:41 PM, Yukihiro Matsumoto <a href="mailto:matz@ruby-lang.org" class="email">matz@ruby-lang.org</a> wrote:</p>
<blockquote>
<p>Hi,</p>
<p>In message "Re: <a href="https://blade.ruby-lang.org/ruby-core/27407">[ruby-core:27407]</a> Re: [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: add Object#singleton_class method (Closed)" href="https://bugs.ruby-lang.org/issues/1082">#1082</a>] add Object#singleton_class method"<br>
on Tue, 5 Jan 2010 11:26:41 +0900, Shugo Maeda <a href="mailto:shugo@ruby-lang.org" class="email">shugo@ruby-lang.org</a> writes:</p>
<p>|I prefer singleton_class than eigenclass. I suppose that "singleton<br>
|class" is not so confusing with a class which implements the Singleton<br>
|pattern because the word singleton remind Ruby users of singleton<br>
|methods rather than the Singleton pattern.</p>
<p>Basically, I agree. But I cannot deny the fact that we already have<br>
singleton.rb in the distribution, which provide Singleton class. I<br>
confess I did. Probably I shouldn't have.</p>
</blockquote>
<p>That can't be denied, but I think this confusion is mostly hypothetical.</p>
<p>I sympathize with your aesthetic concerns with collision, but the term<br>
"singleton class" has been in common usage for years and has proven<br>
understandable to new Ruby users crossing the "class << self" chasm<br>
for the first time.</p>
<p>It's a good name that has stood the test of time. Let's officially<br>
adopt what we've already unofficially chosen.</p>
<p>jeremy</p>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=75372010-01-05T20:13:38Zmurphy (Kornelius Kalnbach)murphy@rubychan.de
<ul></ul><p>=begin<br>
why not add both? eigenclass could be an alias for singleton_class.<br>
[murphy]</p>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=75382010-01-05T21:31:08ZEregon (Benoit Daloze)
<ul></ul><p>=begin<br>
Hi,</p>
<p>2010/1/5 James Edward Gray II <a href="mailto:james@graysoftinc.com" class="email">james@graysoftinc.com</a></p>
<blockquote>
<p>Surely, seeing:</p>
<p>obj.bad_name_class</p>
<p>is preferable to:</p>
<p>class << obj; self end</p>
<p>and we can do even better than that with singleton_class. :)</p>
<p>James Edward Gray II</p>
</blockquote>
<p>+1 for eigenclass:</p>
<p>I think something is confusing for me between</p>
<p>(1) class << obj<br>
self<br>
end</p>
<p>and</p>
<p>(2) class << MyClass<br>
def method # this is a class method, a method that MyClass-Object owns,<br>
alone (without needing to make an instance to use)<br>
end<br>
end</p>
<p>Here, I feel far less confusing the eigenclass.<br>
Well, the syntax we are trying to name,<br>
is describing a class who allow us to write methods that concern the object<br>
globally(1), as a single object(2).</p>
<p>Eigenclass means then the "proper"(~ global,single) class to that Object, a<br>
class who concerns only one Object, but that Object doesn't look like a<br>
singleton especially, it's just a single object. We didn't build it with a<br>
class describing it (or that doesn't matter), we are just speaking to it<br>
directly, ignoring what's around.</p>
<p>For me, singleton is confusing, and wrong, as it has a name of "created and<br>
it's the only one of a 'class' ", while that 'class' means nothing here.</p>
<p>"eigenclass" seem, according to me, the only alternative in the 3 proposed<br>
to name both the 2 situations above.<br>
(While I think we'll still use a lot of class << MyClass; def m(); end; end,<br>
that is kind of very useful)</p>
<p>"singleton_class" is already used in Ruby, yes, but not very wide, and it<br>
can still change if needed:<br>
$> ri singleton<br>
1 Numeric#singleton_method_added<br>
2 Object#define_singleton_method<br>
3 Object#singleton_methods<br>
4 RDoc::Generator::Method#singleton<br>
(I must admit a singleton method SEEMS more clear here than a eigen<br>
method..., but it would not be obfuscating neither I think)</p>
<p>And the last reason: eigenclass is original, sounds cool, is not so<br>
confusing and unique (like Ruby) !</p>
<p>Here was my piece of advice to name this.</p>
<p>Benoit Daloze</p>
<p>Hi,<br><br>2010/1/5 James Edward Gray II <span dir="ltr"><<a href="mailto:james@graysoftinc.com" class="email"></a><a href="mailto:james@graysoftinc.com" class="email">james@graysoftinc.com</a>></span><br></p><div>
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Surely, seeing:<br><br>
<br><br>
obj.bad_name_class<br><br>
<br><br>
is preferable to:<br><br>
<br><br>
class << obj; self end<br><br>
<br><br>
and we can do even better than that with singleton_class. :)<br><br>
<br><br>
James Edward Gray II<br><br>
<br>
</blockquote>
<div>
<br>+1 for eigenclass:<br><br>I think something is confusing for me between<br><br>(1) class << obj<br> self<br>end<br><br>and<br><br>(2) class << MyClass<br> def method # this is a class method, a method that MyClass-Object owns, alone (without needing to make an instance to use)<br><br>
end<br>end<br><br>Here, I feel far less confusing the eigenclass.<br>Well, the syntax we are trying to name,<br>is describing a class who allow us to write methods that concern the object globally(1), as a single object(2).<br><br>
<br>Eigenclass means then the "proper"(~ global,single) class to that Object, a class who concerns only one Object, but that Object doesn't look like a singleton especially, it's just a single object. We didn't build it with a class describing it (or that doesn't matter), we are just speaking to it directly, ignoring what's around.<br><br>
<br>For me, singleton is confusing, and wrong, as it has a name of "created and it's the only one of a 'class' ", while that 'class' means nothing here.<br><br>"eigenclass" seem, according to me, the only alternative in the 3 proposed to name both the 2 situations above.<br><br>
(While I think we'll still use a lot of class << MyClass; def m(); end; end, that is kind of very useful)<br><br>"singleton_class" is already used in Ruby, yes, but not very wide, and it can still change if needed:<br><br>
$> ri singleton<br> 1 Numeric#singleton_method_added<br> 2 Object#define_singleton_method<br> 3 Object#singleton_methods<br> 4 RDoc::Generator::Method#singleton<br>(I must admit a singleton method SEEMS more clear here than a eigen method..., but it would not be obfuscating neither I think)<br><br>
<br>And the last reason: eigenclass is original, sounds cool, is not so confusing and unique (like Ruby) !<br><br>Here was my piece of advice to name this.<br><br>Benoit Daloze<br>
</div>
</div>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=75442010-01-06T07:25:41Zammar (Ammar Ali)ammarabuali@gmail.com
<ul></ul><p>=begin<br>
Suggesting new terms might be completely unwelcome, but...</p>
<p>The distinction between a "regular" class and a singleton/eigen/whatever class appears similar to the distinction between phonetic and phonemic in phonology. Some shorten these terms and broaden their meaning; "emic" (loosley meaning below the surface) and "etic" (loosely meaning on the surface). Would emic-class make sense to others?</p>
<p>Also from linguistics, the prefix "allo-" generally means "differing from the normal"... so I wonder if "alloclass" is a good possible name.</p>
<p>Just a thought,<br>
ammar<br>
=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=75452010-01-06T08:01:10ZRickDeNatale (Rick DeNatale)rick.denatale@gmail.com
<ul></ul><p>=begin<br>
On Tue, Jan 5, 2010 at 5:25 PM, Ammar Ali <a href="mailto:redmine@ruby-lang.org" class="email">redmine@ruby-lang.org</a> wrote:</p>
<blockquote>
<p>Issue <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: add Object#singleton_class method (Closed)" href="https://bugs.ruby-lang.org/issues/1082">#1082</a> has been updated by Ammar Ali.</p>
<p>Suggesting new terms might be completely unwelcome, but...</p>
<p>The distinction between a "regular" class and a singleton/eigen/whatever class appears similar to the distinction between phonetic and phonemic in phonology. Some shorten these terms and broaden their meaning; "emic" (loosley meaning below the surface) and "etic" (loosely meaning on the surface). Would emic-class make sense to others?</p>
<p>Also from linguistics, the prefix "allo-" generally means "differing from the normal"... so I wonder if "alloclass" is a good possible name.</p>
</blockquote>
<p>In the edition of the Pickaxe corresponding to Ruby 1.8. Dave Thomas<br>
used the term Virtual class, which never seems to get mentioned in<br>
these discussions.</p>
<p>Not that I think that that's the right term either, in fact, it's<br>
really the opposite of the characteristic which I think the 'classes'<br>
which provide singleton methods, and the 'classes' which provide class<br>
methods (which IMHO really aren't singleton methods because they apply<br>
to subclasses as well) share.</p>
<p>There's an old CS joke.</p>
<p>If it's there and you can see it, it's real,<br>
If it's not there and you can see it, it's virtual<br>
If it's there and you can't see it, it's transparent,<br>
If it's not there and you can't see it it's gone.</p>
<p>I would suggest transparent_class for singleton classes whether they<br>
are singleton classes of regular objects (which really do provide<br>
methods ONLY for one object) or 'singleton' classes of Class objects.<br>
The key aspect is that the Ruby implementation does its best to hide<br>
these from the Ruby programmer.</p>
<p>Or perhaps, since in a kind of heisenberg effect, providing an<br>
official method to make them visible means that they wouldn't really<br>
be totally transparent, perhaps hidden_class, and for<br>
transparent/hidden classes which are the (meta?)class of a class, a<br>
hiddden_superclass method, so that</p>
<p>String.hidden_class.hidden_superclass would return Object.hidden_class</p>
<p>--<br>
Rick DeNatale</p>
<p>Blog: <a href="http://talklikeaduck.denhaven2.com/" class="external">http://talklikeaduck.denhaven2.com/</a><br>
Twitter: <a href="http://twitter.com/RickDeNatale" class="external">http://twitter.com/RickDeNatale</a><br>
WWR: <a href="http://www.workingwithrails.com/person/9021-rick-denatale" class="external">http://www.workingwithrails.com/person/9021-rick-denatale</a><br>
LinkedIn: <a href="http://www.linkedin.com/in/rickdenatale" class="external">http://www.linkedin.com/in/rickdenatale</a></p>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=75472010-01-06T10:57:03Zdblack (David Black)dblack@rubypal.com
<ul></ul><p>=begin<br>
Hi --</p>
<p>On Tue, 5 Jan 2010, Yukihiro Matsumoto wrote:</p>
<blockquote>
<p>Hi,</p>
<p>In message "Re: <a href="https://blade.ruby-lang.org/ruby-core/27407">[ruby-core:27407]</a> Re: [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: add Object#singleton_class method (Closed)" href="https://bugs.ruby-lang.org/issues/1082">#1082</a>] add Object#singleton_class method"<br>
on Tue, 5 Jan 2010 11:26:41 +0900, Shugo Maeda <a href="mailto:shugo@ruby-lang.org" class="email">shugo@ruby-lang.org</a> writes:</p>
<p>|I prefer singleton_class than eigenclass. I suppose that "singleton<br>
|class" is not so confusing with a class which implements the Singleton<br>
|pattern because the word singleton remind Ruby users of singleton<br>
|methods rather than the Singleton pattern.</p>
<p>Basically, I agree. But I cannot deny the fact that we already have<br>
singleton.rb in the distribution, which provide Singleton class. I<br>
confess I did. Probably I shouldn't have.</p>
</blockquote>
<p>I've heard lots of people say that the similarity of names presents a<br>
problem, but I've seen no evidence that there's actually a problem.<br>
I've only very, very rarely heard anyone express confusion, and the<br>
confusion only lasts for about two seconds until the difference is<br>
explained:</p>
<pre><code>Student: Is that related to the Singleton pattern?
Me: No, "singleton" here has to do with object-specific
behavior in Ruby's object model. It's a different
concept that happens to have a similar-sounding name.
Student: Oh, OK.
</code></pre>
<p>And that's all there is to it (if even that much).</p>
<p>David</p>
<p>--<br>
David A. Black<br>
Senior Developer, Cyrus Innovation Inc.<br>
THE COMPLEAT RUBYIST, Ruby training with Black/Brown/McAnally!<br>
January 22-23, Tampa, Florida<br>
Info and registration at <a href="http://www.thecompleatrubyist.com" class="external">http://www.thecompleatrubyist.com</a></p>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=83952010-02-23T16:14:34Zshugo (Shugo Maeda)
<ul></ul><p>=begin<br>
Hi,</p>
<p>2010/1/5 Yukihiro Matsumoto <a href="mailto:matz@ruby-lang.org" class="email">matz@ruby-lang.org</a>:</p>
<blockquote>
<p>Basically, I agree. But I cannot deny the fact that we already have<br>
singleton.rb in the distribution, which provide Singleton class. I<br>
confess I did. Probably I shouldn't have.</p>
</blockquote>
<p>Today, I talked with Matz, and he has finally agreed with the use of<br>
the term "singleton class." The reason why he has chosen the term<br>
"singleton class" is that we have already had<br>
Kernel#singleton_methods.</p>
<p>Then, the next issue is whether Kernel#singleton_class should create<br>
an eigenclass when the receiver has no eigenclass. It would be better<br>
to have an optional argument (singleton_class(true/false) or<br>
singleton_class(:create => true)?) to switch the behavior.</p>
<p>Any thoughts?</p>
<p>--<br>
Shugo Maeda</p>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=83962010-02-23T16:46:44Zmurphy (Kornelius Kalnbach)murphy@rubychan.de
<ul></ul><p>=begin<br>
On 23.02.10 08:14, Shugo Maeda wrote:</p>
<blockquote>
<p>Today, I talked with Matz, and he has finally agreed with the use of<br>
the term "singleton class." The reason why he has chosen the term<br>
"singleton class" is that we have already had<br>
Kernel#singleton_methods.<br>
Yay! \o/</p>
</blockquote>
<blockquote>
<p>Then, the next issue is whether Kernel#singleton_class should create<br>
an eigenclass when the receiver has no eigenclass. It would be better<br>
to have an optional argument (singleton_class(true/false) or<br>
singleton_class(:create => true)?) to switch the behavior.<br>
I always perceived singleton classes to be transparently created in the<br>
background. Would it be wise to give the programmer access to its<br>
existence status? (I assume singleton_class(false) == nil would behave<br>
like a singleton_class? method.) Today, Ruby has no way of telling<br>
whether an object already has a singleton class, or am I wrong?</p>
</blockquote>
<p>Also, why would I ask for a singleton_class without using it?</p>
<p>[murphy]</p>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=83992010-02-23T23:26:45Zshugo (Shugo Maeda)
<ul></ul><p>=begin<br>
Hi,</p>
<p>2010/2/23 Kornelius Kalnbach <a href="mailto:murphy@rubychan.de" class="email">murphy@rubychan.de</a>:</p>
<blockquote>
<blockquote>
<p>Then, the next issue is whether Kernel#singleton_class should create<br>
an eigenclass when the receiver has no eigenclass. It would be better<br>
to have an optional argument (singleton_class(true/false) or<br>
singleton_class(:create => true)?) to switch the behavior.<br>
I always perceived singleton classes to be transparently created in the<br>
background. Would it be wise to give the programmer access to its<br>
existence status? (I assume singleton_class(false) == nil would behave<br>
like a singleton_class? method.) Today, Ruby has no way of telling<br>
whether an object already has a singleton class, or am I wrong?</p>
</blockquote>
</blockquote>
<p>You are right, and it is why Matz wondered whether singleton_class<br>
should create singleton classes. If it always creates singleton<br>
classes, obj.singleton_class is just a short form of class << obj;<br>
self; end. He said that it may be worth considering whether<br>
singleton_class should provide an (optional) way to tell the existence<br>
of a singleton class.</p>
<p>I think transparent creation of singleton classes is reasonable, but<br>
it sometimes annoys me when I'm investigating the behavior of Ruby.<br>
However, I don't come up with such a situation in a real-world<br>
application.</p>
<p>--<br>
Shugo Maeda</p>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=84002010-02-23T23:49:07Zshugo (Shugo Maeda)
<ul></ul><p>=begin<br>
Hi,</p>
<p>2010/2/23 James Edward Gray II <a href="mailto:james@graysoftinc.com" class="email">james@graysoftinc.com</a>:</p>
<blockquote>
<blockquote>
<p>He said that it may be worth considering whether<br>
singleton_class should provide an (optional) way to tell the existence<br>
of a singleton class.</p>
</blockquote>
<p>I think I would rather have another method for that, than a boolean flag:</p>
</blockquote>
<p>Then, how about to introduce singleton_class as just a short form of<br>
class <<obj; self; end at first?<br>
We can add another method or an optional argument of singleton_class later.</p>
<blockquote>
<p> singleton_class?</p>
</blockquote>
<p>x.singleton_class? sounds like "Is x a singleton class?", doesn't it?</p>
<p>--<br>
Shugo Maeda</p>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=84152010-02-26T00:08:03Zshugo (Shugo Maeda)
<ul></ul><p>=begin<br>
Hi,</p>
<p>2010/2/23 Shugo Maeda <a href="mailto:shugo@ruby-lang.org" class="email">shugo@ruby-lang.org</a>:</p>
<blockquote>
<p>Then, how about to introduce singleton_class as just a short form of<br>
class <<obj; self; end at first?</p>
</blockquote>
<p>I have attached a patch with a test.</p>
<p>--<br>
Shugo Maeda</p>
<p>Attachment: singleton_class.diff<br>
=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=84172010-02-26T03:54:31Zwycats (Yehuda Katz)wycats@gmail.com
<ul></ul><p>=begin<br>
I think the idea that some objects don't have a singleton class is an internal detail that is, as yet, not part of Ruby's semantics. I don't think we should add it to Ruby's semantics.<br>
=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=90512010-03-17T23:05:57Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul></ul><p>=begin<br>
Hi Shugo,</p>
<blockquote>
<blockquote>
<p>Then, how about to introduce singleton_class as just a short form of<br>
class <<obj; self; end at first?</p>
</blockquote>
<p>I have attached a patch with a test.</p>
</blockquote>
<p>Any update here? Why don't you commit it?<br>
Does Matz still hate "just a short form"?</p>
<p>--<br>
Yusuke ENDOH <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a><br>
=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=90682010-03-18T15:22:37Zshugo (Shugo Maeda)
<ul></ul><p>=begin<br>
Hi,</p>
<p>2010/3/17 Yusuke Endoh <a href="mailto:redmine@ruby-lang.org" class="email">redmine@ruby-lang.org</a>:</p>
<blockquote>
<blockquote>
<blockquote>
<p>Then, how about to introduce singleton_class as just a short form of<br>
class <<obj; self; end at first?</p>
</blockquote>
<p>I have attached a patch with a test.</p>
</blockquote>
<p>Any update here? Why don't you commit it?</p>
</blockquote>
<p>I'm not sure whether it should be included in Ruby 1.9.2 or not.<br>
What do you think of it, Yugui?</p>
<blockquote>
<p>Does Matz still hate "just a short form"?</p>
</blockquote>
<p>I don't think so.<br>
Do you accept the patch, Matz?</p>
<p>--<br>
Shugo Maeda</p>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=91112010-03-19T19:01:44Zyugui (Yuki Sonoda)yugui@yugui.jp
<ul></ul><p>=begin<br>
On Thu, Mar 18, 2010 at 3:22 PM, Shugo Maeda <a href="mailto:shugo@ruby-lang.org" class="email">shugo@ruby-lang.org</a> wrote:</p>
<blockquote>
<p>I'm not sure whether it should be included in Ruby 1.9.2 or not.<br>
What do you think of it, Yugui?</p>
</blockquote>
<p>You do not seem to have reached an agreement. We need more discussion.</p>
<p>-- Yuki Sonoda (Yugui)</p>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=91132010-03-19T19:20:59Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul></ul><p>=begin<br>
Hi,</p>
<p>2010/3/19 Yugui <a href="mailto:yugui@yugui.jp" class="email">yugui@yugui.jp</a>:</p>
<blockquote>
<p>On Thu, Mar 18, 2010 at 3:22 PM, Shugo Maeda <a href="mailto:shugo@ruby-lang.org" class="email">shugo@ruby-lang.org</a> wrote:</p>
<blockquote>
<p>I'm not sure whether it should be included in Ruby 1.9.2 or not.<br>
What do you think of it, Yugui?</p>
</blockquote>
<p>You do not seem to have reached an agreement. We need more discussion.</p>
</blockquote>
<p>What should we discuss?</p>
<p>I think that there is no one who disagree with signleton_class<br>
as "a short form of class << obj; self; end", except matz :-)</p>
<p>And, I thought matz was likely to accept "a short form" because<br>
Shugo finally sent a patch for it. <a href="https://blade.ruby-lang.org/ruby-core/28338">[ruby-core:28338]</a></p>
<p>--<br>
Yusuke ENDOH <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a></p>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=91142010-03-19T19:22:24Zshugo (Shugo Maeda)
<ul></ul><p>=begin<br>
Hi,</p>
<p>2010/3/19 Yugui <a href="mailto:yugui@yugui.jp" class="email">yugui@yugui.jp</a>:</p>
<blockquote>
<p>On Thu, Mar 18, 2010 at 3:22 PM, Shugo Maeda <a href="mailto:shugo@ruby-lang.org" class="email">shugo@ruby-lang.org</a> wrote:</p>
<blockquote>
<p>I'm not sure whether it should be included in Ruby 1.9.2 or not.<br>
What do you think of it, Yugui?</p>
</blockquote>
<p>You do not seem to have reached an agreement. We need more discussion.</p>
</blockquote>
<p>My proposal is to introduce Object#singleton_class as just a short<br>
form of class <<obj; self; end.<br>
Any objections?</p>
<p>It's OK for me to postpone it until Ruby 1.9.3 because users can<br>
easily implement it on their on.<br>
However, I think it's important to agree with the method name.</p>
<p>--<br>
Shugo Maeda</p>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=91232010-03-19T23:48:51Zyugui (Yuki Sonoda)yugui@yugui.jp
<ul></ul><p>=begin<br>
On Fri, Mar 19, 2010 at 7:20 PM, Yusuke ENDOH <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a> wrote:</p>
<blockquote>
<p>I think that there is no one who disagree with signleton_class<br>
as "a short form of class << obj; self; end", except matz :-)</p>
<p>And, I thought matz was likely to accept "a short form" because<br>
Shugo finally sent a patch for it. <a href="https://blade.ruby-lang.org/ruby-core/28338">[ruby-core:28338]</a></p>
</blockquote>
<p>I see. There is no problem to add it to Ruby 1.9.2 if there is an<br>
agreement as the result of the discussion.</p>
<p>-- Yuki Sonoda (Yugui)</p>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=91912010-03-22T09:37:27Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul></ul><p>=begin<br>
Hi,</p>
<p>In message "Re: <a href="https://blade.ruby-lang.org/ruby-core/28731">[ruby-core:28731]</a> Re: [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: add Object#singleton_class method (Closed)" href="https://bugs.ruby-lang.org/issues/1082">#1082</a>] add Object#singleton_class method"<br>
on Thu, 18 Mar 2010 15:22:23 +0900, Shugo Maeda <a href="mailto:shugo@ruby-lang.org" class="email">shugo@ruby-lang.org</a> writes:</p>
<p>|> Does Matz still hate "just a short form"?<br>
|<br>
|I don't think so.<br>
|Do you accept the patch, Matz?</p>
<p>I accept.</p>
<pre><code> matz.
</code></pre>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=92262010-03-23T18:41:39Zshugo (Shugo Maeda)
<ul></ul><p>=begin<br>
Hi,</p>
<p>2010/3/22 Yukihiro Matsumoto <a href="mailto:matz@ruby-lang.org" class="email">matz@ruby-lang.org</a>:</p>
<blockquote>
<p>|> Does Matz still hate "just a short form"?<br>
|<br>
|I don't think so.<br>
|Do you accept the patch, Matz?</p>
<p>I accept.</p>
</blockquote>
<p>I have committed it to the SVN trunk. Thank you.</p>
<p>--<br>
Shugo Maeda</p>
<p>=end</p> Ruby master - Feature #1082: add Object#singleton_class methodhttps://bugs.ruby-lang.org/issues/1082?journal_id=92272010-03-23T18:47:05Zshugo (Shugo Maeda)
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>=begin<br>
This issue was solved with changeset r27022.<br>
Suraj, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<p>=end</p>