Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Postdecrement is inefficient and dangerous

Name: Anonymous 2009-10-11 20:02

http://www.codeguru.com/forum/showthread.php?t=231052

(If this is true, why is the language not named ++C? I don't understand.)

Name: Anonymous 2009-10-11 20:07

>>1
First of all, it should be called ++C, except that nowadays It's more like C-=10. Secondly, I would think that the compiler would take care of any optimising any uses of ++i and i++ appropriately and that worrying about such a micro-optimisation (if it ever was) is stupid.

Name: Anonymous 2009-10-11 20:07

>>1
Because C++ is inefficient and dangerous.

Name: Anonymous 2009-10-11 20:08

>>3
I see what you did there

Name: Anonymous 2009-10-11 20:46


mov mem32, reg32
inc reg32


is the same as:

[code]
inc reg32
mov mem32, reg32
[code]

in terms of CPU cycles.

What is the problem here?

Name: Anonymous 2009-10-11 20:52

It's the oldest troll in the book.  Get kids that dig micro-efficiency to spend hours going through their code changing all post to pre, without realizing the compiler does this for them.

Name: Anonymous 2009-10-11 21:00

>>6
loli trol u

Name: Anonymous 2009-10-11 21:12

GOD FUCKING DAMN NOT MOTHERFUCKING AGAIN THIS SHITTY DISCUSSION

Name: Anonymous 2009-10-11 21:49

the only reason postdecrement should be considered harmful is because of this *variable++.
a well known newbie mistake

Name: Anonymous 2009-10-11 22:02

(With apologies to Avril Lavigne)

(Chorus)
Hey hey, you you, I don’t like your girlfriend
No way, no way, I think you need a cow one
Hey hey, moo moo, I could be your girlfriend

Hey hey, you you, I know that you like cows
No way, no way, no it’s not a secret
Hey hey, moo moo, I want to be your cow-girl

Milk’s so fine, and you want mine, it’s so delicious
You want to milk me all the time, it’s so addictive
Don’t you know what I can do to make you drink all night?

Don’t pretend, I think you know I’m lactating
And hell yeah, sure my titties are milk-making
I can tell you like ‘em too, and you know I’m right

She’s like, so flat-chested
Her breasts are so untested

I think we should get to milking now
And that’s what everyone’s talking about

(Chorus)
I can see the way, I can see the way you look at tits
And even when you look away, I know you think of tits
I know you wank over me all the time again and again (and again and again and again)

So come over here and hook me to the milk machine
Or better yet, hand-milk ‘em (cause it’s fresh and clean)
I don’t wanna hear you try to fight this urge again (not again, not again, not again)

Because...

She’s like, so flat-chested
Her breasts are so untested

I think we should get to milking now
And that’s what everyone’s talking about

(Chorus)
In a second, hands are wrapped around my nipples
‘Cause milking, milking’s so much better
There’s no other, so when will you start drinking
She’s no cow-girl, what the hell were you thinking?

In a second, hands are wrapped around my nipples
‘Cause milking, milking’s so much better
There’s no other, so when will you start drinking
She’s no cow-girl, what the hell were you thinking?

(Chorus x2)
Moo moo!

Name: Anonymous 2009-10-11 22:22

__________________________
< >>11 Avril lavigne sucks >
 --------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Name: Anonymous 2009-10-11 23:03

          ∧_∧   / ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
          ( ´∀`) < cowsay sucks
        /    |    \________
       /       .|     
       / "⌒ヽ |.イ |
   __ |   .ノ | || |__
  .    ノく__つ∪∪   \
   _((_________\
    ̄ ̄ヽつ ̄ ̄ ̄ ̄ ̄ ̄ | | ̄
   ___________| |
    ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄| |

Name: Anonymous 2009-10-11 23:23



           ,. -ー- 、
          {∧_∧}
           (´・ω・`) Tablecats considered harmful!
         (二二二)
            \  /
           i´  `i
     ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
    .      ___  *pkunk*
         (二二二)
            \  /
           i´  `i
     ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄

Name: Anonymous 2009-10-11 23:43

           ,. -ー- 、
          {∧_∧}
----------------------------KATTO-------------------------(✂゚∀゚)✂
           (´・ω・`) Tablecats considered harmful!
         (二二二)
----------------------------KATTO-------------------------(✂゚∀゚)✂
            \  /
           i´  `i
     ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
    .      ___  *pkunk*
         (二二二)
----------------------------KATTO-------------------------(✂゚∀゚)✂
            \  /
           i´  `i
     ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄

Name: Anonymous 2009-10-12 0:16

>>14
what is KATTO

Name: Anonymous 2009-10-12 0:18


               ______      _______
|       |     /           |       |
----------------KATTO-----------------(✂゚∀゚)✂
|___    |    _______/     |

Name: Anonymous 2009-10-12 5:24

C++0X: THE DAWNING OF A NEW ERA
PROPOSED NEW FEATURES WILL REVOLUTIONIZE THE WAY YOU CODE
http://mjxads.internet.com/RealMedia/ads/adstream_lx.ads/intm/webdev/www.codeguru.com/forum/L11/1462211591/336x280/WMBrands/SSO_CPlus_SpecialReport_1a/C++OX_bob_2.jpg/6648714d71306f354264514143596357?

...perhaps the idiot hasn't learned about anything that isn't C++.

Name: Anonymous 2009-10-12 10:33

What about ++i++;

Name: Anonymous 2009-10-12 10:38


(incf x)
(prog1 x (incf x))

thread over

Name: Anonymous 2009-10-12 11:08

>>19
have you learned absolutely nothing about functional programming

Name: Anonymous 2009-10-12 11:57

>>20
I think >>19 just translated >>18's line into Lisp as an example. It looks correct: the first line increments x, the second line saves the value of x to be returned from the expression, and then increments x once again, which is the same as C's ++x++. Purely functional programming has nothing to do with this thread, and most Lispers will write side-effecting code when it makes sense to do so. Even if >>19's code is side-effecting, it's still returning a value, which doesn't make it non-functional, it just makes it side-effecting.

IHBT

Name: >>21 2009-10-12 12:01

And if I was >>19, I would have just written (prog2 (incf x) x (incf x)) instead

Name: 19 2009-10-12 13:08

>>21
No, I'm not translating >>18's anything. OP posted some crap about post increment/decrement being dangerous. I posted the versions of post/pre incrementation in lisp, pointing out the infallability of these forms, thus, thread over.

If I were to translate >>18, first I'd have to give my own meaning to ++i++ since it's undefined behavior in both C and that other language; secondly, if we assume it to be what you provided, then I'd write the code as:

(prog1 #1=(incf x) #1#)

Or

(1- (incf x 2))

Name: Anonymous 2009-10-12 13:49

>>23
have you learned absolutely nothing about functional programming

Name: Anonymous 2009-10-12 14:12

>>24
Like what in particular do you have in mind? Care to explain why you're bawing about functional programming when the expression with which this discussion spawned is state-changing?

Name: Anonymous 2009-10-12 14:19

>>25
YABT GIVE UP ALREADY!

Name: Anonymous 2009-10-12 14:52

>>26
You Are Bean Tolled?

Name: Anonymous 2009-10-12 15:05

C++: Where artifacts of the language dictate how you write your code. Because properly designing things is harder than throwing random shit together and see if it works out.

Name: Anonymous 2009-10-12 15:28

>>27
Yet Another Brainless Troll??

Name: Anonymous 2009-10-12 21:41

>>22
Can we get progk involved?

Name: Anonymous 2009-10-12 21:47

>>27,29
You are being trolled.

Name: Anonymous 2009-10-12 23:27

>>31
YHBT

Name: Anonymous 2009-10-13 0:30

>>5
I think you mean that

mov mem32, reg32
inc mem32


is the same as:

inc reg32
mov mem32, reg32

Name: Anonymous 2009-10-13 0:53

>>33
I was thinking that if the loop variable is stored in some register for the duration of the loop, then in terms of CPU cycles, it doesn't matter if you increment the register before or after whatever operation requires the value of the loop variable. (In this case, the mov was just an example of such an operation).

Of course in the example you wrote, the former case would take more CPU cycles than the latter.  But then again, if your loop has so many statements that you don't have a spare register in which to store your loop variable, the efficiency of pre/postdecrement is insignificant.

Name: Anonymous 2009-10-13 11:39

They aren't always the same, with CPU pipelining etc.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List