Partager via


Yet another reason I hate C++

for

(long i = 0; parameters.GetCount(); i++) {

What could be wrong with that??

Aaaaaaaaaaaaaaaaaargh. Curse you C++!!!!!!!!!!!!!!!! Can't that at least be a warning?

Comments

  • Anonymous
    June 25, 2004
    The conditional part of the for(...) is constant, and therefore, an infinite loop will occur.

    (Duh;)
  • Anonymous
    June 25, 2004
    Austin: the "What could be wrong with that??" was rhetorical.

    I was more angry that C++ allows non boolean conditionals.

    Bane of my life I tell you.
  • Anonymous
    June 25, 2004
    I know. (Hence the ;) by the Duh).
  • Anonymous
    June 25, 2004
    While annoying at times, it's one of those power features certain people like myself miss when working with C#.

    Orion Adrian
  • Anonymous
    June 25, 2004
    Orion: I'm not sure I see anything powerful about that feature at all.
  • Anonymous
    June 25, 2004
    Austin: Sorry :-)

    Missed that.
  • Anonymous
    June 26, 2004
    Cyrus,

    i disagree. its nice to have non-boolean conditions. in c#, i hate it to be forces to write...

    object o = null;

    if( o == null)

    instead of if( o)

    yes, the c# compiler makes sure that i make sure i know what i do. but quite often, i'd rather decide myself. each time i have to write '== null', for example.

    WM_DISAGREE
    thomas woelfer
  • Anonymous
    June 26, 2004
    The comment has been removed
  • Anonymous
    June 26, 2004
    The comment has been removed
  • Anonymous
    June 26, 2004
    The comment has been removed
  • Anonymous
    June 27, 2004
    The comment has been removed
  • Anonymous
    June 27, 2004
    Doug: Don't even get me started on implicit conversions!! :-)

    Bleagh......
  • Anonymous
    July 01, 2004
    "What could be wrong with that??

    Aaaaaaaaaaaaaaaaaargh. Curse you C++!!!!!!!!!!!!!!!! Can't that at least be a warning?"

    What's it meant to warn you about?

    For all the compiler knows the code could be:
    for(int i(0); parameters.GetCount(); ++i)
    {
    cout << "The " << i << "th parameter is " << parameters.Top() << endl;
    parameters.PopTop();
    }
  • Anonymous
    July 01, 2004
    Dr Pizza: It's meant to warn me that the conditional expression is not actually a boolean conditional.

    As all the posts in here have shown, i don't believe in implicit conversions. Especially between something like numbers and booleans. 0 does not mean false in any system for me. Just as non-zero doesn't mean true either.

    I'm well aware of why that code compiles and runs. But what I would like is to tell the compiler "warn me if the expression in the condition does not evaluate to a boolean expression.

    Does that clarify it?
  • Anonymous
    July 09, 2004
    The comment has been removed
  • Anonymous
    July 09, 2004
    Dung: What about it?

    That seems perfectly reasonable if mouseExists was a boolean type...
  • Anonymous
    July 22, 2004
    No. Stick shifts rule. :-)

    http://weblogs.asp.net/mikhailarkhipov/archive/2004/07/22/191682.aspx
  • Anonymous
    August 03, 2004
    why hate it? say the function returns a value based on a shared memory that changes everytime? say a register, etc. isn't it a good feature?
  • Anonymous
    August 03, 2004
    Piping Pepito: How would that change anything?