new principle of division between structures and classes
Weed
resume755 at mail.ru
Fri Jan 9 17:02:59 PST 2009
Weed пишет:
> Weed пишет:
>> (Here I generalise my sentence with supplement)
>>
>>
>> The POD data and the data supporting polymorphism are necessary to us.
>> POD the data is stored in structs and polymorphic objects is classes.
>>
>> Both types (class and struct) can be instanced in a heap or on a stack.
>> (And in invariant ROM too, but there it is not important)
>>
>> Classes and structures support inheritance. But structures do not
>> support polymorphism (as are POD type without vptr) - at attempt to
>> implement virtual function in structure the compiler will give out an
>> error: "struct StructName is POD type, it is not support polymorphism,
>> use class instead of". (And certainly structures are not inherited from
>> classes, including from super class Object)
>>
>> Thus, the programmer always knows the object is POD-data or not. The
>> problem of simple alteration of structure to a class and vice versa when
>> necessary also solved.
>>
>> For an exception of splitting of objects it is necessary to check during
>> compilation: or to forbid assignment on value for types not being to the
>> data (how now it works for the structs objects on value) or to forbid
>> the access to the fields added at descending inheritance (its more
>> difficult but desirable)
>
> And similar it will not break an existing code
(If for a while to keep support "scope")
>
>> Please, state critical remarks
Tell, what it is necessary to make that discussion of this question has
taken place?
I in despair. I even think to wait supports 2.0 in open source compiler
using LLVM and to add there this functionality (I hope, my skills will
just grow for such operation.)
More information about the Digitalmars-d
mailing list