From: Arne Vajhøj on
On 15-02-2010 15:05, Lew wrote:
> Patricia Shanahan wrote:
>> How frequently does ++ appear in typical Java programs?
>
> Rather a lot, I should think.
>
> for ( int ix = 0; ix < limit; ++ix ) ...
>
> int count = 0;
> for ( Foo foo : foos )
> {
> blahBlah();
> ++count;
> }
>
> etc.
>
> Or did you mean specifically how often an atomic ++ for volatiles would
> be needed?

It seems likely that she is talking about the required atomic ++.

BTW, isn't ++something a C++'ism?

Arne

From: Lew on
Arne Vajhøj wrote:
> BTW, isn't ++something a C++'ism?

It's been around longer than that, since C.

--
Lew
From: Arne Vajhøj on
On 15-02-2010 17:17, Lew wrote:
> Arne Vajhøj wrote:
>> BTW, isn't ++something a C++'ism?
>
> It's been around longer than that, since C.

I know, but the ++something is better than something++
because it is faster is rooted in C++ classes I believe.

Arne
From: Eric Sosman on
On 2/15/2010 5:48 PM, Arne Vajhøj wrote:
> On 15-02-2010 17:17, Lew wrote:
>> Arne Vajhøj wrote:
>>> BTW, isn't ++something a C++'ism?
>>
>> It's been around longer than that, since C.
>
> I know, but the ++something is better than something++
> because it is faster is rooted in C++ classes I believe.

When I actually want the value of the expression, I write
whichever I need (usually a[x++] or a[--x]). When all I want
is the side-effect, I write ++x because "increment x" seems to
read more smoothly than "x increment."

In neither case do I waste even one deci-neuron's worth of
brain power on the question of which is faster -- or which was
once said to have been found to be faster by someone whom the
sayer didn't actually know but had heard about from someone
else who might possibly have known the experimenter's second
cousin's first wife's roommate.

--
Eric Sosman
esosman(a)ieee-dot-org.invalid
From: Mike Schilling on
Arne Vajh�j wrote:
> On 15-02-2010 17:17, Lew wrote:
>> Arne Vajh�j wrote:
>>> BTW, isn't ++something a C++'ism?
>>
>> It's been around longer than that, since C.
>
> I know, but the ++something is better than something++
> because it is faster is rooted in C++ classes I believe.

Right, in classes which overload '++".

y = ++x + z;

simply calls the ++ method and add z to the result, while

y = x++ + z;

needs to make a copy of x, add z to it, assign the result to y, and then
call the ++ method on the "real" x. Depending on how complicated "x" is,
the copy may be a significant expense.


First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Prev: 64-bit JNI
Next: Problem with interface implementation