Unofficial wish list status.(Jul 2008)
Steven Schveighoffer
schveiguy at yahoo.com
Thu Jul 24 07:11:29 PDT 2008
"Jason House" wrote
> Steven Schveighoffer Wrote:
>
>> >> They don't make any less sense than declaring invariant variables. Or
>> >> declaring invariant parameters.
>> >>
>> >> Can you see use in the following function signature:
>> >>
>> >> void f(invariant(somestruct) *x) {...}
>> >>
>> >> If so, an invariant member function is no different.
>> >
>> > Will the fields of somestruct be accessed directly? If so, there's no
>> > change in functionality. If not, will the invariant functions of
>> > somestruct be used to modify global state? If not, there's not change
>> > in
>> > functionality... I don't think what I'm suggesting changes a lot of
>> > code.
>>
>> You are suggesting that invariant functions simply be illegal, and pure
>> functions not. I am saying that you are leaving a hole in the type
>> system
>> by doing that. It is analogous to saying, if a function has any
>> invariant
>> parameters, those functions should be marked pure, and all parameters
>> should
>> be marked invariant. I can see many places where some parameters could
>> be
>> invariant and some not. Pure functions (as Walter envisions them)
>> require
>> ALL invariant parameters.
>
>
> No, I'm not. I'm only suggesting that functions that are invariant and
> const functions are redefined to be like pure functions... Merging
> concepts together. There's no reason for an invariant argument to a
> function require the function itself to be invariant/pure.
An invariant function is defined as one that has an invariant argument (the
'this' pointer). There are no other special requirements for invariant
functions. So I think you still don't understand the concept.
invariant functions === invariant data.
-Steve
More information about the Digitalmars-d
mailing list