this() not executing code on structs

zoli galap at freemail.hu
Wed Oct 21 11:42:03 PDT 2009


> > If the new "operator" for the class is redesigned to have multiply allocation types
> > (allocate on heap, allocate on stack, etc.?), there is no main drawback of using
> classes instead of structs for small objects( like vec2, vec3) as well.
> 
> Yes there is.  How about the cost of storing vtbl and monitor?  Actually, just

I keep forgetting those (4-8) extra bytes per instance :)
And what about the final classes (with no ancestors)? Is there a vtbl for them since they cannot be derived and they have no virtual parent to inherit members from ? Or the Object with opHash and the other operators are virtual by nature in all classes ? (sorry, I don't know D that much)

Well, actually it seems as struct is a much better and clear solution. In that case I vote for this().




More information about the Digitalmars-d mailing list