what was wrong with struct & class in C++?
James Dennett
jdennett at acm.org
Wed Dec 26 06:54:54 PST 2007
Walter Bright wrote:
> Russell Lewis wrote:
>> Walter Bright wrote:
>>> Russell Lewis wrote:
>>>> Hear, hear! Good arguments, all! It still doesn't answer why we
>>>> left out the little star on class-reference variable assignments.
>>>> As I've argued before, the question of syntax is orthogonal to the
>>>> question of legal operations. Make value-style operations illegal
>>>> for classes, and keep the star there, IMHO.
>>>
>>> It would make writing generic code unnecessarily difficult.
>>
>> ???? I thought that one of the key arguments for putting the syntax
>> back to the C++ way was that it would make generic code easier to
>> write. Right now, when we perform an assignment, generic code can't
>> know (without specialization) whether it is assigning a value or a
>> reference type.
>
> Because if I replace a struct with a class, then I have to go through
> every use of the struct and add a *.
That's the *problem* that we have in D today, that this
change of syntax is intended to solve.
The wonderful thing is that you would NOT have to do this
with explicit dereferencing a la C++, but you DO have to
do this if you change a class to a struct with D today
because D lacks uniform ways to access value and reference
types (as dereferencing is implicit in one case and explicit
in the other). D uses the same syntax to mean utterly
different things depending on context, and that's anathema
to genericity.
Maybe examples are needed if people are talking past each
other this obviously?
-- James
More information about the Digitalmars-d
mailing list