5 ms·
He didn't say he still works on code like this, but like me, this program is obviously fine, there's no point in asking why it works because c is backward compa
by hnriot 14y ago
He didn't say he still works on code like this, but like me, this program is obviously fine, there's no point in asking why it works because c is backward compatible and it's pretty clear to anyone who knows c that this will work. It doesn't mean we'd write code like that...
- asveikau 14y agoThis is what bothers me about a lot of programmer communities these days. What is a very mundane detail of K&R legacy, that C programmers know very well either from looking at old source trees or making sense of error messages, suddenly turns into something where 116 people (current stack overflow +1 count) are totally amazed and breathless that they've discovered something deep. I suppose it's fair if they just don't know C, so they've not seen it and find it interesting, but could this person's dilemma not be resolved with a simple google search? Or even taking a guess?
- Retric 14y agoIt can be really hard to Google things when you don't know the terms involved. Until, someone posts source code and you get directed to stack overflow etc. Thus, the fact that out of millions of people with some familiarity with C 100 or 1000 chose to up vote an obvious post does not really seem that strange.
- greenyoda 14y agoYou don't even have to Google it. The Wikipedia article on C talks about K&R C vs. modern C: https://en.wikipedia.org/wiki/C_%28programming_language%29#K.26R_C https://en.wikipedia.org/wiki/C_%28programming_language%29#K...
- kelnos 14y agoThing is, the C standard (compared to many other standards) isn't even that complicated. Googling for the C standard doc, and then grepping through for "function declaration" would likely clear that up. But it's way easier to consult the lazyweb than to do your own research.
- Retric 14y agoSearching for "C standard doc" does not actually work. "C99 standard doc" let's you find http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf but searching for "function declaration" does not take you anywhere useful. That's not to say reading the whole thing is a waste of time, just beyond the scope of most new programmers.
- fayden 14y agoWhy do you assume 116 people are "amazed and breathless"? It's an interesting question and I don't believe the answer is obvious unless you've been exposed to legacy C code before, and such users may arguably constitute a large part of SO's audience. You may be able to solve the question by a simple search, but it still fits in on StackOverflow. The fact that it was upvoted a lot is irrelevant to me, it just means a few people bothered to press a button.
- kelnos 14y agoMaybe "amazed and breathless" is a bit hyperbolic, but I assume the parent is referring to the number of people who had up-voted it at the time of his posting. Perhaps for people who don't really know C, that's interesting information, but anyone who calls themselves a "C programmer" should not be surprised by that bit of code (well, you should be surprised if anyone still writes code like that, but not surprised that it's valid). It's not even just an "exposed to legacy code" thing: C is a fairly simple language in both syntax and concepts (esp. when compared to most other languages people are using today), and I don't believe you can call yourself fluent in C without this kind of knowledge. (I could also argue from the other angle: if you haven't been exposed to that sort of legacy C code, you probably haven't done it enough to call yourself fluent.) I think it's an interesting question from the perspective of "what are some cool language gotchas that people not familiar with the language would find neat?"... or from the perspective of someone who is new to C, came across some code like that, and is trying to learn what's going on (and is apparently too lazy to google the C specification and spend 2 minutes reading it).
- vaxdigitalnh 14y agoI agree with you. Maybe the better question is why does anyone think it shouldn't compile? And then we can ask how much programming history they know. I think it's useful to know how C compilers, the C specification and C coding styles have evolved over the years. For one, it helps put some of the arguments for/against certain styles and syntax in perspective. In short, make an effort to learn from history before you make the minimal effort required to learn from a contemporary forum like stackexchange.