• Goes-To operator (humor)

    From Nightfox to All on Wed Dec 30 14:52:46 2009
    Is anyone familiar with the "Goes-To" operator? Consider the following code:

    #include <stdio.h>
    int main(int argc, char* argv[])
    {
    int x = 10;
    while( x --> 0 ) // x goes to 0
    {
    printf("%d ", x);
    }

    return 0;
    }

    This actually compiles and runs (seriously). Source: http://stackoverflow.com/questions/1642028/what-is-the-name-of-this-operator

    In all seriousness, there is no "Goes-To" operator in C/C++. The "x -->" in that code is equivalent to "x-- >". I wouldn't have thought that a C/C++ parser would consider that valid, but it turns out that it is valid - I was able to compile and run that code.

    Someone I used to work with sent me that.. I thought it was amusing. :)

    Nightfox
  • From Phill Terry@GPLBBS to NIGHTFOX on Thu Dec 31 15:31:00 2009
    Is anyone familiar with the "Goes-To" operator? Consider the following code:

    Nope....


    #include <stdio.h>
    int main(int argc, char* argv[])
    {
    int x = 10;
    while( x --> 0 ) // x goes to 0
    {
    printf("%d ", x);
    }

    return 0;
    }

    This actually compiles and runs (seriously). Source:


    Crap like thqat is a pet peeve of mine ...

    While (even)


    while(x-->0)

    might compile, I'd feel a LOT better seeing



    while( x-- > 0 )

    .. I ain't no damed 'puter, let IT read that crap if i wants to. ;)

    Phill

    * OLX 2.2 * Man who lays woman on ground, get piece on earth.
    ---
    ■ Synchronet ■ Ginger's Port Limited _ Columbus, Ohio _ telnet//gplbbs.net
  • From Nightfox to Phill Terry on Thu Dec 31 15:53:35 2009
    Re: Goes-To operator (humor)
    By: Phill Terry to NIGHTFOX on Thu Dec 31 2009 15:31:00

    Crap like thqat is a pet peeve of mine ...
    While (even)
    while(x-->0)
    might compile, I'd feel a LOT better seeing
    while( x-- > 0 )
    .. I ain't no damed 'puter, let IT read that crap if i wants to. ;)

    I know what you mean, and I feel the same way.. I think source code should be easily readable. Another one of my pet peeves is source code that uses very little spaces - For example:
    int x=3;
    for (int y=0; y<5; y++)

    I think those are more easily readable as:
    int x = 3;
    for (int y = 0; y < 5; y++)

    Nightfox
  • From Phill Terry@GPLBBS to NIGHTFOX on Fri Jan 1 01:01:00 2010
    Re: Goes-To operator (humor)
    By: Phill Terry to NIGHTFOX on Thu Dec 31 2009 15:31:00

    Crap like thqat is a pet peeve of mine ...
    While (even)
    while(x-->0)
    might compile, I'd feel a LOT better seeing
    while( x-- > 0 )
    .. I ain't no damed 'puter, let IT read that crap if i wants to. ;)

    I know what you mean, and I feel the same way.. I think source code should b
    easily readable. Another one of my pet peeves is source code that uses very NI>little spaces - For example:
    int x=3;
    for (int y=0; y<5; y++)

    I think those are more easily readable as:
    int x = 3;
    for (int y = 0; y < 5; y++)


    Need we mention indentation? ;)

    Phill

    * OLX 2.2 * SELECT * FROM Users WHERE Clue > 0
    ---
    ■ Synchronet ■ Ginger's Port Limited _ Columbus, Ohio _ telnet//gplbbs.net