On Sunday, 4 November 2012 at 17:41:17 UTC, Andrei Alexandrescu
wrote:
I don't think that claim is valid. As a simple example,
polymorphism requires indirection (due to variations in size of
the dynamic type compared to the static type) and indirection
is strongly correlated with dynamic allocation.
Sure, there are situations where heap allocation is always
needed. But couldn't the question of "whether to heap or stack
allocate" be considered just an implementation detail of the
language. And hide that implementation detail so that the
programmer doesn't even need to know what the words heap and
stack mean.
I mean, wouldn't it be theoretically possible to sometimes even
let the compiler allocate class objects in D from the stack, if
the compiler can see that it's safe to do so (if that variable's
exact type is known at compile time and never changes).