www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: Slides from my ACCU Silicon Valley talk

reply bearophile <bearophileHUGS lycos.com> writes:
Jonathan M Davis:

 I don't see what that poster thought would be gained by enforcing that,

If you read that part in the Reddit thread you see that the gain is in a (supposed) higher understandability of the code that uses the operators.
 but it's _really_ easy to have useful and legitimate overloaded operators
which can't be pure.

Do you have examples? Bye, bearophile
Dec 13 2010
parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Monday 13 December 2010 04:05:33 bearophile wrote:
 Jonathan M Davis:
 I don't see what that poster thought would be gained by enforcing that,

If you read that part in the Reddit thread you see that the gain is in a (supposed) higher understandability of the code that uses the operators.
 but it's _really_ easy to have useful and legitimate overloaded operators
 which can't be pure.

Do you have examples?

At the momement, pretty much none of the operator overloads in std.datetime are pure, and while some of them _may_ be able to become pure with the pure nothrow bug fixed, I don't think that they'll all be able to. All it takes is _one_ function in the whole call chain which can't be pure, and then _none_ of them can pure. It's _really_ easy to make purity not possible. Things will improve as more of Phobos becomes pure, but forcing stuff to be pure is generally a _bad_ idea. - Jonathan M Davis
Dec 13 2010