[Top][All Lists]

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

Re: [Lilypond-auto] Issue 2546 in lilypond: Prefix incrementers may be p

From: lilypond
Subject: Re: [Lilypond-auto] Issue 2546 in lilypond: Prefix incrementers may be preferred for non-primitive types.
Date: Mon, 21 May 2012 13:32:22 +0000

Comment #6 on issue 2546 by address@hidden: Prefix incrementers may be preferred for non-primitive types.

This battle has been lost long ago, anyway. I remember looking at the output of some C compiler under CP/M and seeing that x++ created worse code than ++x. Using x++ in a loop condition insinuates post-increment, and as a beginner I was somewhat confused into guessing that the post-loopbody-increment action was in some manner related to the use of the postfix operator.

Also standalone statements tend to be x++ rather than ++x without discernible reason. But that battle has been lost in K&R times, when performance was quite more affected. The recommendation "for non-primitive types" makes clear that the fight has been ceded for primitive types, relying on the optimizer to straighten things out.

I should guess that we are in a similar "hopefully the optimizer is smart enough to not make a difference" predicament nowadays.

In my opinion, it does not really make sense to replace operators for "non-primitive types" only. Styles should be kept consistent: a programmer is not supposed to know about the level of primitivities involved: that is the point of abstraction.

So in my book, this change should be planned as either all or nothing. And, quite to my personal dissatisfaction, the generally adopted style has been postfix for decades, the obviously less efficient choice without optimization since it has to keep an old state around while calculating a new one.

reply via email to

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