Thread overview | ||||||
---|---|---|---|---|---|---|
|
January 02, 2004 classes | ||||
---|---|---|---|---|
| ||||
Why must all classes be created on the heap in D ? Where is the logic in that? Michael |
January 02, 2004 Re: classes | ||||
---|---|---|---|---|
| ||||
Posted in reply to Michael | > Why must all classes be created on the heap in D ? They do not. > Where is the logic in > that? Not withstanding the lack of factual basis to your post, it sounds like you're more interested in having a whinge than asking a real question. Nonetheless, I'll offer some reasons: 1. You don't have to worry about slicing 2. There's no opportunity for mis-aligned allocation 3. Non-RAII types can be garbage-collected which in most, although certainly not all, circumstances can lead to performance improvements 4. There's no chance of holding dead-references to dead stack-based instances. ftr, there's no one right approach to most things in IT, and there is certainly no proven case that either stack-based or heap-based objects are superior to the other. Horses for courses. Happy New Year -- Matthew Wilson STLSoft moderator (http://www.stlsoft.org) Contributing editor, C/C++ Users Journal (www.synesis.com.au/articles.html#columns) "You can tell a Yorkshireman, but you can't tell him much!" -- Uncle Michael ---------------------------------------------------------------------------- --- |
January 02, 2004 Re: classes | ||||
---|---|---|---|---|
| ||||
Posted in reply to Michael | Michael wrote:
>Why must all classes be created on the heap in D ? Where is the logic in
>that?
>
>Michael
>
>
>
>
If you want a stackbased - like class use a struct.
|
Copyright © 1999-2021 by the D Language Foundation