Peter Federighi:

> So, on the thought that the global declaration of the class just creates an
> instance and doesn't actually allocate it in memory,

In code like:

class Foo {}
void main() {
    Foo x;
}

x isn't an instance, it is just an empty (null) reference to class instances.


> What's with D not actually allocating a class in a declaration?  Isn't that
> syntactically odd?  If I say 'int x' , I get an int.  I don't have to say 
> 'int x =
> new int'.  So, it seems logical to me that I should be able to say 'MyClass 
> mc'
> and get a MyClass.

In D structs are values, so in this code x is an instance of Foo, on the stack:

Struct Foo {}
void main() {
    Foo x;
}

But in D objects are reference types, they are always composed by a reference 
that points to the instance (as in Java) that is often on the heap.
To avoid other bugs/troubles, I suggest you to read the basics about D from the 
site.

Bye,
bearophile

Reply via email to