Boost logo

Boost :

From: Fernando Cacciola (fernando_cacciola_at_[hidden])
Date: 2003-10-29 23:43:08


"E. Gladyshev" <egladysh_at_[hidden]> escribió en el mensaje
news:20031030041316.23613.qmail_at_web40808.mail.yahoo.com...
>
> --- Fernando Cacciola <fernando_cacciola_at_[hidden]> wrote:
> [...]
> > > > > struct type
> > > > > {
> > > > > //invariant is x + y = 10
> > > > > int x;
> > > > > int y;
> > > > >
> > > > > void f( int n )
> > > > > {
> > > > > x = n; //* invariant is broken
> > > > > f1(); //* is this allowed?
> > > > > y = 10-n; //* invariant restored
> > > > > }
> > > > >
> > > > The way I see it, if f1() is not public, then the above is most
likely
> > OK.
> > > > If is it public, then it is most likely not OK.
> > >
>
> [...]
>
> > Invariants are realted to design *contracts* and not all calls are
routing
> > contract messages. Implementation calls typically don't, and as you
pointed
> > out, outside calls might be also contract unrelated, thus the invariant
need
> > not hold during the call.
>
> You mentioned before:
> > > > If is it public, then it is most likely not OK.
>
> So "most likely" means "if the public methods contract related"...
> if f1() is contract unrelated, then it is Ok?
>
As a general guideline, yes, it's OK.

Fernando Cacciola
SciSoft


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk