This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: GCC's statement expression extension


In article <orvgxolqo1.fsf@guarana.lsd.ic.unicamp.br> you write:
>
>Maybe the way to go is to require statement expressions to contain
>explicit `return' statements, at least in C++.  This would at least
>make it easier to support them in C++.  Is `return' currently usable
>within statement expressions?

I think this would be a _wonderful_ rule.

Yes, it would break current practice and require changes.  But it would
make a ton of sense, and I always thought that the "use the last value"
rule was a bit ugly (yes, I realize that is how K&R C compilers actually
_used_ to work even for normal functins, and that "return" wasn't
actually required back in the Elder Days.  Even so, requiring a "return"
statement at the end of functions was a GoodThing(tm), and would be a
good thing for statement expressions too). 

If adding an explicit "return", and really making statement expressions
look more like "anonymous inline functions" would be all it took to make
them more palatable to C++, then I think this is definitely worth doing.
Much better than just getting rid of them. An dit would make them
cleaner in C too.

(And by making it warn about missing returns, it would be really easy to
fix up existing code even for people who weren't aware of the change)

		Linus

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]