On 4/1/18 2:22 AM, Uknown wrote:
On Sunday, 1 April 2018 at 05:27:38 UTC, Uknown wrote:
[...]
I knew I was missing something. Fixed it, thanks
https://run.dlang.io/is/tZeZrP
Sorry for the spam, but I also managed to miss `immutable`, `const` and
when T has mutable indirections
Final version that I'm sure covers all the cases:
https://run.dlang.io/is/kGoU4X
That's a great initiative, and a worthy trait for the stdlib. I think
you'd have an easier time if you reasoned from the other end. A function
is strongly pure if all of the following are true:
* Each parameter:
- is immutable, OR
- can be converted automatically to immutable (i.e. has no mutable
indirections) AND is passed by value
* The return type:
- is immutable, OR
- can be converted automatically to immutable
(We don't want to give const this much power yet for other reasons.)
The template should support taking the function name as a string, too,
and the parameter types so as to easily distinguish across overloads.
This would be a great addition to std.traits. Once we have it, we'll
have a precise unified definition of strongly pure across the language
spec and the stdlib definition. Please follow up, thanks!
Andrei