This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC's statement expression extension
- To: Mark Mitchell <mark at codesourcery dot com>
- Subject: Re: GCC's statement expression extension
- From: Kamil Iskra <kamil at wins dot uva dot nl>
- Date: Fri, 4 Aug 2000 21:33:19 +0200 (CEST)
- cc: gcc at gcc dot gnu dot org
On Thu, 3 Aug 2000, Mark Mitchell wrote:
> RCS file: /cvs/gcc/egcs/gcc/extend.texi,v
> retrieving revision 1.58
> diff -c -p -r1.58 extend.texi
> *** extend.texi 2000/07/28 13:24:20 1.58
> --- extend.texi 2000/08/03 23:06:26
[snip]
> + @example
> + #define foo(a) (@{int b = (a); b + 3; @})
> + @end example
> +
> + @noindent
> + does not work the same way as:
> +
> + @example
> + inline int foo(a) @{ int b = a; return b + 3; @}
> + @end example
I think there are two issues regarding the inline function.
First, "a" in the parameter list is typeless. It should be "int",
shouldn't it?
Second, this inline function looks very artificial. Why have an extra
local variable "b", if you can just "return a + 3"? I have little
experience with C++, but no sane C programmer would write it like this,
and I'm sure you agree. This makes me wonder: is this necessary for your
example, or not? Common sense suggests "not". I guess you did it like this
to make it look more similar to the statement expression, but that's just
my guess, and, at least for me, this extra obfuscation makes the whole
issue even more fuzzy than it already is.
I think you should either adjust the example, or add more explanation.
Examples should be cristal clear. This one is not, and thus it fails to
make the point.
Regards,
--
/ Kamil Iskra kamil@wins.uva.nl \
| Section Computational Science, Faculty FNWI, Universiteit van Amsterdam |
| tel. +31 20 525 75 35 fax. +31 20 525 74 90 |
\ Kruislaan 403 room F.202 1098 SJ Amsterdam (NL) /