D - more or less power than C++?
Kevin Bealer
Kevin_member at pathlink.com
Sat Mar 4 10:43:30 PST 2006
In article <duckkp$25nc$1 at digitaldaemon.com>, Andrew Fedoniouk says...
>
>>>
>>> D will GPF on something like this I guess.
>>
>> In my book, this is a Feature of D.
>
>Are you saying in your book that:
>"D will GPF" is a Feature of D?
>
>It is not for book then - it is something to be graffited
>on the wall I guess.
In your example, s0 is in a stack frame. This stack frame is gone when test()
exits. If you want to fix this, you have to allocate stack frames on the heap.
Allocation of stack frames on the heap incurs a massive performance hit. This
feature isn't beneficial enough to offset that performance hit.
An alternative would be to allocate stack frames on the heap only if this
behavior is used. This would probably make things very complex when returning
from / jumping to such functions, which implies another (maybe smaller, maybe
not) performance hit.
Languages like javascript, ruby, take the low performance route. In D you can
accomplish an equivalent thing by putting the field in question in a class and
calling new. Then the performance hit is only for this one instance.
Kevin
More information about the Digitalmars-d
mailing list