On Mon, 20 Dec 2010 05:43:08 -0500
bearophile <bearophileh...@lycos.com> wrote:

> Nick Voronin:
> 
> > Here is where we diverge. Choosing struct vs class on criteria of their 
> > placement makes no sense to me. 
> 
> In D you use a class if you want inheritance or when you (often) need 
> reference semantics, and you use a struct when you need a little value passed 
> around by value or when you want a simple form of RAII or when you want to 
> implement something manually (like using PIMPL), or when you want max 
> performance (and you manage structs by pointer, you may even put a tag inside 
> the stuct or the pointer and implement manually some kind of inheritance). 
> With structs you have a literal syntax, postblits, in-place allocation, and 
> you are free to use align() too.

Well said. Plenty of differences there more important than stack/heap 
allocation.

-- 
Nick Voronin <elfy...@gmail.com>

Reply via email to