I just got it! (invariant/const)
Steven Schveighoffer
schveiguy at yahoo.com
Wed Apr 9 09:53:14 PDT 2008
"guslay" wrote
> Janice Caron Wrote:
>
>> On 09/04/2008, Georg Wrede wrote:
>>
>> int f(invariant D d) invariant pure { ... }
>
> Shouldn't it be
>
> int f(invariant D d) pure { ... }
>
> Pure functions are a subset of invariant functions, no?
No.
A function does not necessarily need to take an invariant 'this' pointer to
be pure.
For example:
class C
{
invariant int x;
pure int getX() { return x;}
}
void foo()
{
C c = new C;
c.getX(); // ok
}
-Steve
More information about the Digitalmars-d
mailing list