Group: comp.lang.c++
From: peter koch
Date: Tuesday, April 08, 2008 4:14 PM
Subject: Re: C++ more efficient than C?

On 8 Apr., 20:21, Keith Thompson wrote:
> peter koch writes:
> > On 8 Apr., 19:20, Kelsey Bjarnason wrote:
> [...]
> >> =A0 int x =3D 3, y;
>
> >> =A0 y =3D func(x);
>
> >> Quick: what's the value of x?
> [...]
> > A much larger problem has been in absurd declaration such as the
> > above. Are you quite sure that it should read int x =3D 3; int y; (as
> > you imply) and not int x =3D (3,y); ? ;-)
>
> [...]
>
> Yes. =A0An initializer must be an assigment-expression, which means it
> cannot have a comma operator at its top level.
>
> The same restriction applies to function arguments. =A0In both cases,
> it's because the comma is used as a delimiter in that context, so it's
> not allowed as an operator.
>
> I suppose this:
> =A0 =A0 int x =3D 3;
> =A0 =A0 int y;
> would be clearer, but I have no problem with either form.

Yup - it would be much clearer. I probably would not let that one pass
in a C++ code review (also because there is a potentially
uninitialised variable), but of course C is a different beast.

I certainly would not let int* i,j pass in either language.

/Peter

Safety Articles | Usenet Groups | Usenet News | Bluegrass