Why can't structs be derived from?

Max Samukha max at spam.box
Tue Mar 15 14:15:48 PDT 2011


On 03/15/2011 10:46 PM, Jens wrote:
> Daniel Gibson wrote:
>> Am 15.03.2011 21:29, schrieb Jens:
>>> Daniel Gibson wrote:
>>>> Am 15.03.2011 21:07, schrieb Jens:
>>>>> How is it different in D where all polymorphic objects are
>>>>> reference types? Take have the design space away, make everything
>>>>> a glorified pointer and things are better?
>>>>
>>>> They obviously are. Successful languages like Java and C# do it.
>>>> It's less error-prone and you don't have to worry about
>>>> dereferencing stuff all the time (sometimes even multiple
>>>> dereferences at once, like in my example).
>>>
>>> More toward Java-class-language then than C++-level language.
>>> Sacrificing stack objects was like throwing out sharp knives from
>>> the kitchen. I understand.
>>>
>>
>> If you want value types use structs. Maybe with alias this or mixins
>> to "extend" them.
>> Or use emplace (see
>> http://www.digitalmars.com/d/2.0/phobos/std_conv.html ) with classes
>> if you wanna play with sharp tools.
>> It's not like you can't (risk to) cut yourself with D, it's just
>> easier not to.
>
> While the above was off-topic, I was alluding to class objects on the
> stack. So not to turn the thread into a critique of the entire language,
> I'll leave it at that.
>
>

Class objects are possible on stack in D.


More information about the Digitalmars-d mailing list