Unofficial wish list status.(Jul 2008)

Jason House jason.james.house at gmail.com
Wed Jul 23 14:28:42 PDT 2008


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.





More information about the Digitalmars-d mailing list