dmd 1.053 and 2.037 release

Nick Sabalausky a at a.a
Mon Dec 7 09:19:54 PST 2009


"Jeremie Pelletier" <jeremiep at gmail.com> wrote in message 
news:hfjbs4$v35$1 at digitalmars.com...
> klickverbot wrote:
>> Max Samukha wrote:
>>> I think the following real-world code is a good argument against comma
>>> operators:
>>>
>>> template <typename T>
>>> Q_INLINE_TEMPLATE void QList<T>::node_destruct(Node *from, Node *to)
>>> {
>>>     if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic)
>>>         while(from != to) --to, delete reinterpret_cast<T*>(to->v);
>>>     else if (QTypeInfo<T>::isComplex)
>>>         while (from != to) --to, reinterpret_cast<T*>(to)->~T();
>>> }
>>
>> I have never used the comma operator in my own code, but in my opinion 
>> this particular piece of code is really easy and fluent to 
>> read. »Maintainability« is admittedly, however, a different topic.
>
> It is still more readable than 'while(from != to--)' or '((--to)->v)'.
>
> I myself use the comma operator in for loops and simple assignments such 
> as 'if(something) x = a, y = b;'.
>
> The boost::assign namespace also declares operator,() overloads to ease up 
> assignments in C++ such as 'myVector += 1,2,3,4,5;'.

I've noticed that every use I've ever seen mentioned of the comma operator 
has only been a half-use of it. They all seem to fall into two categories: 
In one group, there's things like 'for' loops and the QList and if() 
examples above that don't make any use whatsoever of the comma operator's 
return value. Then in the other group there are operator overloading uses 
like boost::assign above that use only the comma operator's syntax, but 
throw away its semantics.




More information about the Digitalmars-d-announce mailing list