Unofficial wish list status.(Jul 2008)

Simen Kjaeraas simen.kjaras at gmail.com
Wed Jul 23 11:01:34 PDT 2008


Steven Schveighoffer <schveiguy at yahoo.com> wrote:

> In fact, a pure member function would have tobe marked as:
>  pure invariant void f();

While I agree a pure member function would also need to be invariant,
it seems superfluous to have to write that in the function signature.
It /has/ to be, so why should I need to specify it?

> As for how useful would an invariant (but not pure) function be?   
> Consider
> something like:
>
> class C
> {
>    int x;
>    invariant void printTo(stream s) { s.print(x); }
> }

Could this not just as easily have been done with a const
function, as invariant is implicitly castable to const?

-- Simen



More information about the Digitalmars-d mailing list