Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Do not place spaces around code in parentheses or square brackets

The violation of this rule in Mono code is probably 60% of the reason I'd never want to contribute to it. I simply can't stand the abomination of looking at method calls like:

    foo.bar( baz );
Ugh.


I used to be like this, but I have recently warmed to this idea. foo.bar( baz ) is a little "verbose looking", but when you generalize to arbitrary expressions:

   foo.bar( baz => quux, gorch => 42 );
it starts looking a lot nicer. The foo.bar(baz) is really the outlier, and for the sake of consistency, you might as well add a space.

(That said, sometimes I don't, and I would never "care" one way or the other. If you are writing good code, where the spaces are is of little importance.)


foo.bar(baz => quux, gorch => 42); looks pretty good too.


Why?

Much of our non-.NET code adheres to this convention, and I've found I kinda like it. We don't require it for .NET code (C#, primarily), simply because that would require tweaking the IDE's default formatting behavior.


I am accustomed to something like the GNU style for method calls, which is foo.bar (baz) One of the things about Ruby that drives me nuts is that I can't always do this any more because of the complex lexical rules; in particular foo[4] and foo [4] mean different things.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: