LWN.net Logo

Think carefully

Think carefully

Posted Jan 27, 2010 23:37 UTC (Wed) by nevyn (subscriber, #33129)
In reply to: Think carefully by ncm
Parent article: GCC to merge Go support

> Postfix dereference is better precisely because dwheeler's mistaken
> interpretation is possible only with prefix dereference.

You can always get it wrong:

while (*dst++ = *src++) ;

!=

while (dst^++ = src^++) ;

...and:

++*dst;

!=

++dst^;

...maybe if you are used to it, it does seem marginally better (and I guess both of the above postfix examples could give warnings). But IMO the much bigger win is to have something that 99.999% of the programmers on the planet will instantly understand (and make porting code easier), instead of having them say WTF!


(Log in to post comments)

Think carefully

Posted Jan 28, 2010 1:36 UTC (Thu) by droundy (subscriber, #4559) [Link]

Fortunately, these examples don't apply to go, since go lacks pointer
arithmetic. Also, the ++ operator is changed to a statement in go, also to
avoid this sort of confusion.

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