I just got it! (invariant/const)

Janice Caron caron800 at googlemail.com
Wed Apr 9 11:48:39 PDT 2008


On 09/04/2008, Steven Schveighoffer <schveiguy at yahoo.com> wrote:
>  class C
>  {
>     int *m;
>     invariant(int *) i;
>  }
>
>  pure int getI(C c)
>  {
>     return *i;
>  }
>
>  There may be a reason to use i, but not m in a pure function.  Why should
>  pure restrict this?  It's technically correct and statically verifiable.

Except that there's no way to initialise i.

My understanding of the whole raw vs cooked thing in
accu-functional.pdf is that it's a way of making an entirely invariant
class. There would still be no way to create a class with some members
invariant and others not, except for those that can be initialised at
compile time.



More information about the Digitalmars-d mailing list