bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: error-verbose yycheck overrun


From: Akim Demaille
Subject: Re: error-verbose yycheck overrun
Date: Fri, 28 Mar 2003 15:54:30 +0100
User-agent: Gnus/5.090016 (Oort Gnus v0.16) Emacs/21.2 (gnu/linux)

| On Thu, 2003-03-13 at 01:08, Paul Eggert wrote:
| > > From: Akim Demaille
| > > Date: Tue, 04 Mar 2003 08:22:39 +0100
| > 
| > > I would nevertheless encourage ++i over i++ :(
| > > Not for contradicting, but in order to augment as much as possible
| > > the similarity between all the skeletons, and therefore use more C++
| > > standards (where people pay more attention to the difference between
| > > post- and pre-increment).
| > 
| > But if i is a local integer variable, what is the difference between
| > "i++;" and "++i;" in C++?  In C, they're equivalent.
| 
| No they're not - but there probably isn't a single (real-world) compiler
| that doesn't optimize away the difference if the returned value is
| ignored.
| 
| ++i -> { i += 1; return i; }
| i++ -> { int __temp = i; i += 1; return __temp; }
| 
| > had thought they were the same in C++ too, but I'm no C++ expert.
| 
| No, like in C, post-increment needs to use a temporary - for ints this
| isn't a big deal, and it's often optimized away by the compiler.  For
| objects this is a potentially much bigger deal (and since in such cases
| the increment operators are user-defined, the compiler can't optimize
| anything away).  So "use pre-increment unless you absolutely need
| post-increment's behaviour" is a very typical C++ coding convention.
| Making distinctions here because it is an int is not a great idea -
| consistency in coding style is a Good Thing(tm).

I very much agree wrt this.  I'm just part of a group who decided that
consistency across languages and concepts was a Good Thing TM too, and
therefore that ++i was to be promoted in all the languages, and all
the data types.  You meant prefix ++, so why use postfix ++, including
in the case of i++ (but for sake of consistency with a dubious past
:).




reply via email to

[Prev in Thread] Current Thread [Next in Thread]