On 07/11/2012 08:17 PM, Andrei Alexandrescu wrote:
On 7/11/12 2:03 PM, Timon Gehr wrote:
I think they should be pure as much as I think they should be const.
The reasoning is analogous for both.
We have immutable class instances that want to provide the methods =>
make them const.
We have pure functions that want to provide the methods => make them
pure.
oops. I meant to write "We have pure functions that want to use the
methods."
This reasoning is not taking into account the whole picture because
We have implementations of those methods that want to use non-const
methods in their implementation. (eg. database connection)
We have implementation of those methods that want to use non-pure
methods in their implementation (eg. database connection, logging)
The essential difference is there's no "pure" object, so there's no
motivation to plant "pure" on its methods.
Andrei
auto foo(Object o)pure{
// o is a "pure" object here
}