News for hackers. Stuff that matters.
Re: Strangest language feature by huhtenberg on Sunday March 24, 2013 @05:02PM (#5433575)
For C it should most certainly be the ability to interleave the switch-case and a block statement as per Duff's device:

    register n = (count + 7) / 8;
    switch(count % 8) {
    case 0: do {    *to = *from++;
    case 7:         *to = *from++;
    case 6:         *to = *from++;
    case 5:         *to = *from++;
    case 4:         *to = *from++;
    case 3:         *to = *from++;
    case 2:         *to = *from++;
    case 1:         *to = *from++;
        } while(--n > 0);
    }
[0] http://en.wikipedia.org/wiki/Duff%27s_device
Re: Strangest language feature by niggler on Sunday March 24, 2013 @07:45PM (#5434396)
I wouldn't necessarily call this strange if you think about how this directly translates to assembly instructions.
Re: Strangest language feature by podperson on Sunday March 24, 2013 @10:54PM (#5435082)
It's pretty strange nonetheless that it compiles at all. Underlying it is that a switch statement isn't a proper control structure but syntax sugar for goto.
Re: Strangest language feature by smsm42 on Monday March 25, 2013 @02:17AM (#5435759)
while() loops are really syntax sugar for goto too. And whole C is arguably just a syntax sugar for assembler :) That's why we use it.
Re: Strangest language feature by podperson on Monday March 25, 2013 @05:43PM (#5439907)
They're not syntax sugar for goto the way switch is though. You can't pull stunts like that with two intermingled while loops because a while loop operates on a single block.