[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[RCR] Object#inside_metaclass?

Ara.T.Howard

5/4/2005 12:39:00 PM

55 Answers

Ilias Lazaridis

5/4/2005 1:16:00 PM

0

Ara.T.Howard wrote:
>
> this is very useful for meta-programming:
>
> jib:~/eg/ruby > cat a.rb
> class Object
> def inside_metaclass?
[...]

> i believe the implementaion is correct iff the following statement is true:
>
> all meta-classes descend from the meta-class of Object.

the statement is false.

The Ruby Language, in it's current implementation, has no MetaClasses:

http://laz.../case/lang/ruby/...

-

Please avoid this amateurish re-definition of terminology.

.

--
http://laz...

Martin DeMello

5/4/2005 1:27:00 PM

0

Ara.T.Howard <Ara.T.Howard@noaa.gov> wrote:
>
>
> i believe the implementaion is correct iff the following statement is true:
>
> all meta-classes descend from the meta-class of Object.

That's a very neat approach. Much more satisfying than string-scraping.

martin

dblack

5/4/2005 2:37:00 PM

0

Ilias Lazaridis

5/4/2005 3:03:00 PM

0

David A. Black wrote:
> On Wed, 4 May 2005, Ara.T.Howard wrote:
[...]

>> all meta-classes descend from the meta-class of Object.
>
> I fear the terminology issue raises its head here. Is there any
> reason not to use the customary "singleton class",

"singleton class" has already a meaning within OOP.

like this: "a class which has only one instance"

> pending some
> pronouncement from Matz that it's no longer the right term?

You don't need a pronouncement from the language-designer.

The community should ensure a quick adoption of the Ruby Language.

concise terminology, which does not ignore the status-quo, is an
essential part of this.

http://laz.../case/lang/ruby/...

.

--
http://laz...

Jim Weirich

5/4/2005 4:07:00 PM

0


David A. Black said:
>> i believe the implementaion is correct iff the following statement is
>> true:
>>
>> all meta-classes descend from the meta-class of Object.
>
> I fear the terminology issue raises its head here. Is there any
> reason not to use the customary "singleton class", pending some
> pronouncement from Matz that it's no longer the right term?

There is a distinction, although some people blur it. Those things that
are almost metaclasses (but aren't because Ruby doesn't have metaclasses)
are a subset of all singleton classes. As noted, these almost-metaclasses
inherit from the almost-metaclass of Object. These almost-metaclasses are
the singleton classes of Class objects.

All almost-metaclasses are singleton classes. Not all singleton classes
are almost-metaclasses.

--
-- Jim Weirich jim@weirichhouse.org http://onest...
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)



dblack

5/4/2005 4:21:00 PM

0

Mark Hubbart

5/4/2005 4:29:00 PM

0

On 5/4/05, Jim Weirich <jim@weirichhouse.org> wrote:
>
> David A. Black said:
> >> i believe the implementaion is correct iff the following statement is
> >> true:
> >>
> >> all meta-classes descend from the meta-class of Object.
> >
> > I fear the terminology issue raises its head here. Is there any
> > reason not to use the customary "singleton class", pending some
> > pronouncement from Matz that it's no longer the right term?
>
> There is a distinction, although some people blur it. Those things that
> are almost metaclasses (but aren't because Ruby doesn't have metaclasses)
> are a subset of all singleton classes. As noted, these almost-metaclasses
> inherit from the almost-metaclass of Object. These almost-metaclasses are
> the singleton classes of Class objects.
>
> All almost-metaclasses are singleton classes. Not all singleton classes
> are almost-metaclasses.

All the more reason to give them a different name... At this point, I
care very little what they're called; virtual class, idioclass, own
class, whatever. Just give us a nice, non-overlapping name to call
them by. I guess singleton class will have to do until then, though...

With all these different names being thrown around, it feels like an
election year again! :)

cheers,
Mark



dblack

5/4/2005 4:46:00 PM

0

Jim Weirich

5/4/2005 5:08:00 PM

0


David A. Black said:
> Hi --
>
> On Thu, 5 May 2005, Jim Weirich wrote:
>
>>
>> David A. Black said:
>>>> i believe the implementaion is correct iff the following statement is
>>>> true:
>>>>
>>>> all meta-classes descend from the meta-class of Object.
>>>
>>> I fear the terminology issue raises its head here. Is there any
>>> reason not to use the customary "singleton class", pending some
>>> pronouncement from Matz that it's no longer the right term?
>>
>> There is a distinction, although some people blur it.
>
> That's what I mean (in case it wasn't clear): the two terms are not
> synonymous, and we're seeing more and more of this blurring, and more
> and more use of "metaclass" where Matz and most practitioners have
> always said "singleton class". I'm hoping we can steer away from
> this.

Then I wasn't clear either. In answer to your question 'Is there any
reason not to use the customary "singleton class"', the answer is "Yes,
because the original posters statement becomes false if you substitute
singleton class for metaclass".

(1) The statement "all singleton classes descend from the singleton class
of Object" is false.

(2) The statement "all metaclasses descend from the metaclass of Object"
is true

(given that that in this context metaclass refers to those things that are
almost-metaclasses, i.e. singleton classes of classes.[1]).

There is a difference in meaning between the word singleton class and
metaclass. The original poster was using the correct terminology and
substituting the term "singleton class" would be incorrect.

--
-- Jim Weirich jim@weirichhouse.org http://onest...
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

[1] I'm trying to sidestep the issue of whether these almost-metaclasses
are TRUE metaclasses. They certainly are very much like metaclasses[2].

[2] Pickaxe II, page 382. "Eventually, Matz weighed in with the
following: [...] * Singleton classes for classes behave just like
Smalltalk's metaclasses"



Ara.T.Howard

5/4/2005 5:23:00 PM

0