LWN.net Logo

Dennis Ritchie RIP

Dennis Ritchie RIP

Posted Oct 15, 2011 0:51 UTC (Sat) by HelloWorld (guest, #56129)
In reply to: Dennis Ritchie RIP by dashesy
Parent article: Dennis Ritchie RIP

C syntax is so natural and addictive.
Yeah right. Stuff like void (*signal(int, void (*)(int)))(int); is totally natural. And this is not some random contrived example, but a declaration from the standard library.


(Log in to post comments)

Dennis Ritchie RIP

Posted Oct 15, 2011 11:12 UTC (Sat) by mpr22 (subscriber, #60784) [Link]

The syntax for declaring objects of pointer-to-function type being a bit hairy does not invalidate the general sentiment, and that particular case (declaring a function with a function-pointer argument and a function-pointer return type) is only a problem because the standards committee declined to set up the obvious typedef.

Dennis Ritchie RIP

Posted Oct 15, 2011 16:50 UTC (Sat) by HelloWorld (guest, #56129) [Link]

The syntax for declaring objects of pointer-to-function type being a bit hairy does not invalidate the general sentiment,
It's not only that, the syntax for declaring pointers to arrays suffers the same problem. And what bugs me most about it is that it would have been trivial to fix this: make * a postfix operator and use "i int;" instead of "int i;" for simple declarations. signal then becomes
signal(*(int) void) *(int) void;
Unfortunately, it's not going to happen :(

Dennis Ritchie RIP

Posted Oct 17, 2011 0:56 UTC (Mon) by ncm (subscriber, #165) [Link]

That's just its FORTRAN heritage.

When familiar element of a new language has stupid syntax, it's unforgivable -- yet they all do, even Go. Old languages get a free pass, because who knew, then? C has bad declaration syntax. LISP has ... well, everything. Yet they are above criticism. They have succeeded where so many others failed. To complain about them only reveals your insecurity.

C and C++ could still be fixed very simply by allowing a postfix dereference operator (in addition to the prefix one). "@" would serve.

Dennis Ritchie RIP

Posted Oct 17, 2011 11:45 UTC (Mon) by jwakely (subscriber, #60262) [Link]

auto signal(int, void(*)(int)) -> void(*)(int);

Dennis Ritchie RIP

Posted Oct 17, 2011 13:21 UTC (Mon) by HelloWorld (guest, #56129) [Link]

auto signal(int, void(*)(int)) -> void(*)(int);
Hey, let's be consequent ;)
 auto signal(int, auto (*)(int)->void) -> auto (*)(int) -> void;

Dennis Ritchie RIP

Posted Oct 19, 2011 8:02 UTC (Wed) by ncm (subscriber, #165) [Link]

That's just its FORTRAN heritage. When some element of a new language is stupid, it's unforgivable -- yet they all have them, even Go. Old languages get a free pass, because who knew, then?

C and C++ could still be fixed very simply by allowing a postfix dereference operator (in addition to the prefix one). @ would serve.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds