LWN.net Logo

Syntax flubs

Syntax flubs

Posted Jan 28, 2010 17:09 UTC (Thu) by tjc (subscriber, #137)
In reply to: Syntax flubs by ikm
Parent article: GCC to merge Go support

Could you comment on why should postfix be deemed superior?
You didn't ask me, but that didn't stop anyone else, so here I go. :-)

As a real-world example, here's the prototype for the Unix signal function:

void (*signal(int sig, void (*disp)(int)))(int);

Here it is again with postfix pointer notation:

void signal(int sig, void disp*(int)) *(int);

This is left-to-right-- with the exception of the base types-- so it's easier to read, at least for me.

Here it is again, with the base types left-to-right:

func signal(sig int, disp*(int) void) *(int) void;

This requires using a declarator like "func" so that the parser can figure out what is going on.


(Log in to post comments)

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