gabriele renzi wrote:

> you can do
> Foo foo = clazz.getInstance() ;
>
>
Ah, I missed that shortcut. Strangely, the short version only works for 
the no-arg constructor, though. Also, here's it's real form:

Foo foo;
try {
 foo = (Foo) clazz.getInstance(); //needs explicit downcast
} catch(InstantiationException e) {
 ...
} catch(IllegalAccessException e) {
 ...
}

To be fair, in Java 1.4+, that'd probably look like this:
Foo foo;
try {
 foo = (Foo) clazz.getInstance(); //needs explicit downcast
} catch(Exception e) {
 throw new RuntimeException(e); //unchecked, so it doesn't need to be caught
}

And yes, I agree, "classes are objects" is sort of a vacuous statement, 
especially when Class#new is secretly implemented in C, and more 
especially when Class.class == Class. I think what we mean by "classes 
are objects" is two-fold:

1. The Class objects are the *only* way to deal with classes. e.g. You 
call foo = Foo.new just as you call foo.new (though the latter will give 
you method_missing). There are two exceptions to this, I guess - the 
class keyword and the def keyword.
2. Classes are really easy to mess with. This is partly because they're 
objects, and so they have a clean API, and partly because classes are 
open in Ruby.

Devin