I just got it! (invariant/const)

Steven Schveighoffer schveiguy at yahoo.com
Wed Apr 9 07:23:14 PDT 2008


"Simen Kjaeraas" wrote
> On Wed, 09 Apr 2008 15:40:37 +0200, Janice Caron  wrote:
>
>> On 09/04/2008, Jason House  wrote:
>>>  Consider this example:
>>> <snip>
>>
>> Oh well, that's obvious. f() can't call D.invMemberFunc() because
>> D.invMemberFunc() isn't pure. Pure functions can only call other pure
>> functions.
>>
>> You know that. I know that. Why would anyone think it strange?
>
> I think it is because invMemberFunc is invariant. Many read this as
> "will not change anything", even though it is not what it means.

I think there was a suggestion at one point to change const/invariant 
functions to be like:

const(this) int f();

instead of

const int f();

Which I think is much clearer.

-Steve 





More information about the Digitalmars-d mailing list