Boost logo

Boost :

From: E. Gladyshev (egladysh_at_[hidden])
Date: 2003-10-30 17:43:29


--- Brian McNamara <lorgon_at_[hidden]> wrote:

> > > Everyone "needs" the basic guarantee; without it you're sunk.
> >
> > What I mean is this.
> > Typically when I call a function f(),
> > I expect only two results.
> > 1. Everything went as expected (if there is an error code, it is fine).
> > 2. There was an exception.
> >
> > Now if there is an exception, as a rule of thumb
> > I assume that nothing is safe anymore.
> > Your best chance is that there is seprate
> > watchdog process or hardware interlock
> > that can shut everything down safely,
> > if not, you are hosed... there
> > could a physical RAM fault after all.
> >
> > I dont' understand how can I fit basic guarantees
> > into this picture.
> >
> > Don't get me wrong, I am not against guarantees,
> > I just don't know how to use them in practice.
>
> I think maybe I understand you now. In that case, the way I see the
> basic guarantee is this:
>
> If we take away the computer (hardware, RAM, etc.) and are just left
> with the "C++ abstract machine" as defined by the language standard
> document, then...the basic guarantee says that, when an exception occurs during a call
> to f(), things are still "safe". For example, objects are still in
> "safe" states

I don't think that it is a true statement. In general
you cannot make this assumption.
Basic guarantees allow you to break invariants,
so the objects may not be in a "safe" state
at the *moment* of exception.

(which will not throw new exceptions from destructors),
> memory has not leaked, etc. (The actual state of objects touched by f()
> is undefined, but we can still safely use/destroy these objects, for
> example.)

Even if we assume that the abstract objects are "safe",
we all know that in practice there is not such thing
as abstract C++ machine. If we add the h/w factor into
the picture, the question is is it still safe to try
to use/destroy objects and possible screw everything up
even more? I know that there is probably
no a definite answer to this one... just brought it up
for the heck of it. :)

Given these two issues with basic guarantees
(possible not safe state and h/w factor)
I still don't see what good they do in practice.

Eugene

__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/


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