Interesting question in fact.
This way it should work:
MyClass c = new MyClass();
delete c;
class instances are the heap beasts.
structs in D are 'primitive' types ( int, double, etc. )
E.g. to *allocate* an int you need to do int* myintptr = new int;
And to delete - delete myintptr;
Same for structures:
struct MyStruct { ... }
MyStruct *pms = new MyStruct;
delete pms;
I am not sure though :)

Craig Black wrote:
> How do you use new/delete instead of GC? Are you stuck using struct instead
> of class? If so, then I guess I can't define constructors when I use
> new/delete.
Everything (even structs) is under control of the GC. structs will get
cleaned up like everything else, when there are no references to them.
Likewise with anything else allocated with new, such as arrays or
individual ints.
However, you can explicitly delete anything, if you want; but you are
responsible for making sure that the thing you are deleting hasn't
already been collected by the GC, and that you never use it again.
If you want the GC to not collect your data, then you have two choices:
1) use malloc/free
2) Keep a reference to the thing

Russ Lewis wrote:
<snip>
> However, you can explicitly delete anything, if you want; but you are
> responsible for making sure that the thing you are deleting hasn't
> already been collected by the GC, and that you never use it again.
<snip>
If you still have a reference to the thing in order to delete it, of
course it won't be collected by the GC. Of course you could (for the
time being) use the tricks it tells you not to to hide the pointer from
the GC, but what would be the point?
Stewart.
--
My e-mail is valid but not my primary mailbox. Please keep replies on
the 'group where everyone may benefit.