Pure not acting pure.
schveiguy at yahoo.com
Thu Jun 16 11:59:38 PDT 2011
On Thu, 16 Jun 2011 14:33:17 -0400, Jonathan M Davis <jmdavisProg at gmx.com>
> On 2011-06-16 10:38, Charles McAnany wrote:
>> Ok, I think I get it. That cleared it up. =).
>> So, if you have a functioned labelled pure, it's your job to not pass it
>> mutable arguments, but the compiler's job to make sure it doesn't mutate
>> anything not in the arguments. And that's why a strongly pure function
>> call a weakly pure one - only the first function's internal state can be
>> mutated by a weakly pure function. Thanks!
> Well, essentially. But it's a question of parameters, not arguments. It
> doesn't matter whether you pass the function mutable arguments or not.
Actually, it can matter. For instance, a pure function like this:
pure int foo(const(int)* m);
can be strong pure if you pass it a pointer to immutable data.
More information about the Digitalmars-d-learn