Boost logo

Boost :

From: Andrei Alexandrescu \(See Website for Email\) (andrewalex_at_[hidden])
Date: 2004-07-08 12:38:30


"Vladimir Prus" <ghost_at_[hidden]> wrote in message
news:200407081142.06605.ghost_at_cs.msu.su...
> Darren Cook wrote:
>
> > > No. This is a common misconception and a common source of bugs that
only
> > > show up when optimizations are turned on. It's also a source of
> > > exception-unsafe code, as detailed in Exceptional C++ and a GOTW
column.
> >
> > That kind of validates using v+=foo(),bar(); then, but also says why you
> > shouldn't use it: a common source of bugs.
> >
> > I think with an initialization library in particular people will write,
and
> > expect to always work, something like:
> > v+= get(), get(), get();
>
> They surely will expect this to work and it might fail if 'get()' result
> depend on the call order. In fact *any* convenient initialization syntax
will
> have this problem just becase you'd have single expression, and the order
of
> evaluation is not specified.

I think Darren was referring to get() as of a read() function that bumps
some stream pointer. At any rate, I believe your comment is inaccurate. The
classic array initialization { expr, expr, expr ... } does not have that
problem, and is convenient.

> So, the question is whether use of "," above makes user think that the
order
> of evaluation is specified? I think it does not matter. Most users don't
know
> about sequence points and operator,. The mostly use operator,() inside
header
> of 'for' loop and don't think much about it.

"Nobody knows what most programmers do" -- Bjarne Stroustrup :o)

(The emoticon is mine.)

Unfortunately, the discussion does not flow the way I had hoped :o). My
intent is to figure out the opinion of the boost community about the advice
against overloading the comma, and, and or operators, given by people like
Scott Meyers and others. Is that a good coding standard or not?

Andrei


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