Old problem with performance

Weed resume755 at mail.ru
Tue Feb 24 06:27:16 PST 2009


Don пишет:
> Weed wrote:
>> Weed пишет:
>>> Bill Baxter пишет:
>>>> On Sun, Feb 22, 2009 at 1:02 AM, Weed <resume755 at mail.ru> wrote:
>>>>> Bill Baxter пишет:
>>>>>> 2009/2/21 Weed <resume755 at mail.ru>:
>>>>>>> Weed пишет:
>>>>>>>> Bill Baxter пишет:
>>>>>>>>
>>>>>>>>> Why don't you just show us the class in the way you would like to
>>>>>>>>> write it in C++, and we'll show you how to write it in D, or
>>>>>>>>> finally
>>>>>>>>> agree with you that it's not possible.   But as long as you
>>>>>>>>> continue
>>>>>>>>> to be hand-wavy about "common base classes" we're at a bit of an
>>>>>>>>> impasse.  So far everyone thinks D can do what you want it to
>>>>>>>>> do based
>>>>>>>>> on your vague descriptions.
>>>>>>> As I said, you can write everything using "goto" and "if".
>>>>>>>
>>>>>>> ...But why you do not like the original example of this thread?
>>>>>> Please post again.  I don't seem to recall any detailed example.
>>>>>>
>>>>>> --bb
>>>>> http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=83506
>>>>>
>>>> You should use a struct there!   Your code does not show you doing
>>>> anything that would even remotely suggest using a class is worthwhile.
>>>>  You're doing value operations on value types.  That's what structs
>>>> are for.
>>>     
>>> Why?
>>>
>>> What if I have not substantiated the fact that c1 is a class I should
>>> use there a structure?
>>>
>>> Used in D a model of placement classes only in heap have a rule "if you
>>> made the class and trying to pass it by value is somewhere in your code,
>>> there is a design error?
>>
>> Explains why the question is given in this form:
>>
>> I am received or wrote a classes. Is it right to overload the operator
>> opAdd and use them? I think yes.
>> But why not allow this operation at the same speed that allows C++?
> 
> Actually, in D, it's really difficult to give a class value semantics.
> If a, b are members of some class, consider
> (1) a = a + b;
> (2) a += b;
> It is nearly impossible to efficiently make both of these have the same
> effect!!
> You can only do it with either copy-on-write, ie, even case (2) always
> allocates; or by using a proxy class.
> This is something which I consider to be a serious problem.
> Much more serious than the speed issue.

We already talked about this idea:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=81432
(see text "It is possible to think up other example where there is no
overload:")



More information about the Digitalmars-d mailing list