Order of constructor/destructor invocation

Christian Tanzer tanzer at swing.co.at
Fri Mar 8 10:45:30 EST 2002


Björn Lindberg <d95-bli.no at spam.nada.kth.se> wrote:

> > Agreed. I relied on that.
> >
> > > In this example s1 will be constructed first followed by s2.
> >
> > And here I am wary. Does the standard prescribe this? For normal
> > expressions at least, you can't rely on evaluation order. But then, in
> > comma separated expressions you can. So maybe this is safe after all.
>
> I believe it is, but I'm not certain. As you say, evaluation order for
> comma separated expressions are defined. I'd have to ask someone with a
> copy of the standard handy for this.

OTOH, evaluation order for the arguments of a call is not defined,
IIRC. To be safe, I wouldn't rely on the destruction order of things
like

    Sentry s1, s2;

Nor-do-I-have-to-as-a-happy-Python-user-ly yr's,

-- 
Christian Tanzer                                         tanzer at swing.co.at
Glasauergasse 32                                       Tel: +43 1 876 62 36
A-1130 Vienna, Austria                                 Fax: +43 1 877 66 92





More information about the Python-list mailing list