dmd 1.053 and 2.037 release

Jeremie Pelletier jeremiep at gmail.com
Mon Dec 7 08:52:20 PST 2009


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;'.


More information about the Digitalmars-d-announce mailing list