Defining Eigenclass

M

Matt Todd

So, what is an eigenclass? I googled it, and couldn't find anything
about it (other than Mauricio's great blog/wiki). Wikipedia doesn't
have anything on it other than an indirect relation to Metaprogramming
(which I already know it's a part of, just not sure wherein).

Can someone provide some information on the idea of an eigenclass?

Thanks,

M.T.
 
H

Hal Fulton

Matt said:
So, what is an eigenclass? I googled it, and couldn't find anything
about it (other than Mauricio's great blog/wiki). Wikipedia doesn't
have anything on it other than an indirect relation to Metaprogramming
(which I already know it's a part of, just not sure wherein).

Can someone provide some information on the idea of an eigenclass?

I'll try. (I call it "singleton class" since that is what I learned.)

It's the "place" where things go that are associated with a specific
*object* rather than a *class* of objects.

For example, if I add a method to an object, that method "lives" in
the singleton class.

superman = "Clark Kent"
def superman.fly
puts "Look! I'm flying!"
end

Here the "fly" method is certainly not part of the String class. No
other string responds to that method -- only this one. It's a
singleton method, and it "lives" in the "singleton class."

You can see more clearly the class-like nature of this thing if
we use this syntax:

class << superman
def fly
#...
end
end

That at least "looks" like a class. But also be aware:
1. It's not a "real" class in that it can't be instantiated.
2. Matz has said that this "thing" *may* not be considered a
class in the future (IIRC).

Note that we can capture the actual value of the singleton class
if we want to:

ssc = class << superman # ssc = superman's singleton class
self # return self as last expression
end

puts ssc.class # Class

Finally, note that what we call "class methods" are just a special
case of singleton methods. Suppose Dog inherits from Mammal; then
suppose we make a Dog.bark class method.

Where does "bark" live? Clearly not "in" Dog (as an instance method
would be "in" it). Not in the parent class, either. It lives in the
singleton class of Dog.

So a "class method" is really just "a singleton method on an object
which happens to be a class."

Does that help any?


Hal
 
M

Matt Todd

Yeah, that was very clear. Thanks for the explanation. I just didn't
connect Eigenclasses with Singleton classes.

But, actually, that's a good description of Singleton classes as well.

Thanks!

M.T.
 
R

Rick DeNatale

Google Singleton class. That'll surely help ;-)

The 'official' ruby docs talk about singleton classes, but eigenclass
seems to have been proposed by someone, somewhere, sometime as an
alternative.

This seems to be confined to the ruby community and provides the
subtext for things like eigenclass.org, but I can't seem to find where
the term came from originally.

I'd love enlightenment on that.

Now I guess that the etymology comes from the German word "eigen"
which can be translated to "own" or "individual", and also forms the
root of the mathematical terms "eigenvector" and "eigenvalue". If we
look at "eigenclass" from the perspective of "eigenvector" though, it
doesn't fit that well, since an "eigenvector" of a transformation in
linear algebra is a vector which is unchanged in direction (or more
properly only changes by being multiplied by a scalar) under that
transformation.
 
T

Tom Werner

Rick said:
The 'official' ruby docs talk about singleton classes, but eigenclass
seems to have been proposed by someone, somewhere, sometime as an
alternative.

I recalled seeing the discussion in which eigenclass was first proposed.
Here's the post by csaba on April 21, 2005:

<quote>
"Own class" is the best I've heard 'till now in terms of correctness,
it's just a bit "pale". I mean, when you say "I go there by my own
car", then the "own" doesn't refer to a special type of car, it just
refers to some relation of the car with other things. It refers to a
non-intrinsic thing. But if you say
"I go there by my batcar", that makes a difference. Such a thing is
what we need for ruby.
What about "eigenclass", like in eigenvalue?
</quote>

Which was part of the "Article: Seeing Metaclasses Clearly" thread
started by _why on April 17, 2005.
See http://tinyurl.com/mjy3m.


I much prefer the name "eigenclass" to "singleton class" when referring
to an object's own class. Avoids people having to always qualify what
they mean by singleton class, as you will constantly see people say
things like "when you have a Singleton class (one that include
Singleton, not the eigenclass)", which is just annoying. The term
singleton has already been taken by a design pattern. Besides,
eigenclass is just a neat word. =)

Tom

--
Tom Werner
Helmets to Hardhats
Software Developer
(e-mail address removed)
www.helmetstohardhats.org
 
T

ts

T> to an object's own class. Avoids people having to always qualify what
T> they mean by singleton class, as you will constantly see people say

Never look at the ruby source, or you'll have a surprise

moulon% grep ^rb_singleton_class ruby-1.8.5/*.c
ruby-1.8.5/class.c:rb_singleton_class_clone(obj)
ruby-1.8.5/class.c:rb_singleton_class_attached(klass, obj)
ruby-1.8.5/class.c:rb_singleton_class(obj)
moulon%


Guy Decoux
 
T

Tom Werner

ts said:
Never look at the ruby source, or you'll have a surprise

moulon% grep ^rb_singleton_class ruby-1.8.5/*.c
ruby-1.8.5/class.c:rb_singleton_class_clone(obj)
ruby-1.8.5/class.c:rb_singleton_class_attached(klass, obj)
ruby-1.8.5/class.c:rb_singleton_class(obj)
moulon%


Guy Decoux

Indeed the source code tells us what it calls the thing (singleton
class), but should that forbid us from adopting a different, less
ambiguous term when writing about and discussing the concept?

Tom

--
Tom Werner
Helmets to Hardhats
Software Developer
(e-mail address removed)
www.helmetstohardhats.org
 
T

ts

T> Indeed the source code tells us what it calls the thing (singleton
T> class), but should that forbid us from adopting a different, less
T> ambiguous term when writing about and discussing the concept?

It's ambiguous only for you :)

What is the next step, eigen method ?


Guy Decoux
 
T

Tom Werner

ts said:
T> Indeed the source code tells us what it calls the thing (singleton
T> class), but should that forbid us from adopting a different, less
T> ambiguous term when writing about and discussing the concept?

It's ambiguous only for you :)

If that were true, we wouldn't be having this discussion. =)

Also, see the "nonce" thread going right now for others struggling with
the less-than-stellarness of the currently used "singleton class".

Tom

--
Tom Werner
Helmets to Hardhats
Software Developer
(e-mail address removed)
www.helmetstohardhats.org
 
T

ts

T> Also, see the "nonce" thread going right now for others struggling with
T> the less-than-stellarness of the currently used "singleton class".

This is the same thread, made by someone which has always had problems
with this term ...

Rien de nouveau sous le soleil ...

Guy Decoux
 
C

Chad Perrin

T> Also, see the "nonce" thread going right now for others struggling with
T> the less-than-stellarness of the currently used "singleton class".

This is the same thread, made by someone which has always had problems
with this term ...

Funny . . . I've seen several people suggesting other names for it,
including David Black's "own class" recommendation (which predates
"eigenclass" as a suggestion).
 
D

dblack

Hi --

Funny . . . I've seen several people suggesting other names for it,
including David Black's "own class" recommendation (which predates
"eigenclass" as a suggestion).

The history of it, as I recall it, is that Matz doesn't want to
implement RCR 231 (http://www.rcrchive.net/rcr/show/231), unless and
until he comes up with what he considers the perfect name. Then
there's the "What does Matz have to do with it?", fait-accompli
campaign for eigenclass :) And various other branchings off,
generalizations of "metaclass", and so on -- so that, unfortunately,
the singleton class is now most commonly known as something like:

this thing that doesn't really have a name and is known sometimes as
singleton class, but also as eigenclass, or metaclass, or
something-else-class -- and it's really, really confusing and
hard to understand....


David

--
http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
----> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! <-----
http://dablog.rubypal.com => D[avid ]A[. ]B[lack's][ Web]log
http://www.manning.com/black => book, Ruby for Rails
http://www.rubycentral.org => Ruby Central, Inc.
 
C

Chad Perrin

The history of it, as I recall it, is that Matz doesn't want to
implement RCR 231 (http://www.rcrchive.net/rcr/show/231), unless and
until he comes up with what he considers the perfect name. Then
there's the "What does Matz have to do with it?", fait-accompli
campaign for eigenclass :) And various other branchings off,
generalizations of "metaclass", and so on -- so that, unfortunately,
the singleton class is now most commonly known as something like:

this thing that doesn't really have a name and is known sometimes as
singleton class, but also as eigenclass, or metaclass, or
something-else-class -- and it's really, really confusing and
hard to understand....

Works for me. Let's call it that.
 
C

Chad Perrin

Great! But put underscores in there for the RCR.

Oh, of course.

I'm inspired to make an industrial cover of the Depeche Mode song
"Personal Jesus". I'll call it Eigensavior.
 
M

M. Edward (Ed) Borasky

Rick said:
The 'official' ruby docs talk about singleton classes, but eigenclass
seems to have been proposed by someone, somewhere, sometime as an
alternative.

This seems to be confined to the ruby community and provides the
subtext for things like eigenclass.org, but I can't seem to find where
the term came from originally.

I'd love enlightenment on that.

Now I guess that the etymology comes from the German word "eigen"
which can be translated to "own" or "individual", and also forms the
root of the mathematical terms "eigenvector" and "eigenvalue". If we
look at "eigenclass" from the perspective of "eigenvector" though, it
doesn't fit that well, since an "eigenvector" of a transformation in
linear algebra is a vector which is unchanged in direction (or more
properly only changes by being multiplied by a scalar) under that
transformation.
Hmpf ... I just realized that the typical definition of an eigenvector is

A vector 'x' such that 'A*x = lambda*x', where A is a square matrix.
'lambda' is the eigenvalue.

So, was eigenclass named after the eigenvalue or the eigenvector?
 
T

Trans

We could add some magic that every method matching /_class/ returns
the singleton class... :)

foo.eigen_class
foo.singleton_class
foo.ueber_class

Hehe. That's fitting. Well, we could drop all pretenses

foo._class

And call it the "under class".

T.
 
M

Matt Todd

Ummmm... class object? Like, not the instance of the class, but the
class object itself.

Would that be too transparent? :) (Or, alternatively... just plain
wrong... if I'm being slow.)

M.T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top