DStyle: Braces on same line

Timon Gehr via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jul 13 11:11:57 PDT 2014


On 07/13/2014 07:51 PM, Brian Rogoff wrote:
> On Sunday, 13 July 2014 at 17:24:40 UTC, Timon Gehr wrote:
>> On 07/13/2014 06:45 PM, Joseph Rushton Wakeling via
>> Digitalmars-d-learn wrote:
>> Wrong. There are things which are simply bad ideas.
>>
>>> E.g. in this case, "Egyptian"-style braces definitely make your code
>>> more compact,
>>
>> I.e. you see where everything is.
>
> Yes, the same argument for books and slides is also applicable to all
> other media.

Exactly.

> This style has also caught on amongst the other curly
> braced languages that I use, so that most of the code I read (and write)
> has adopted it (C/C++/Java/Javascript code, that is). The Phobos style
> is incredibly wasteful IMO, but that's what D has adopted, so if you
> intend to contribute to Phobos, you had better get used to it.
>
> The Rust community appears to have made the right choice with Egyptian
> for everything.
> ...

Yup, but they also do horrible things like using '+' to denote 
intersection (multiple trait bounds).

>>> but separate-line opening braces definitely make it easier
>>> to see where scopes begin and end.
>
> All of this is subjective, of course, but I definitely don't find that
> the Phobos style provides this advantage.
>>
>> This is the only argument I have heard in favour of doing this, but it
>> is not actually valid. This critique might apply to Lisp style.
>
> Not sure I follow you here. Most of the Lisp I've read is indented like
> Python, the idea being that you learn not to not see all of the parens
> and rely on tools like paredit to do the trivial balancing. I'd hate to
> read Lisp with separate lines for parens that open scopes. I'm sure
> that's not what you mean!

I was suggesting that if someone does this:
http://en.wikipedia.org/wiki/Indent_style#Lisp_style

Then I would have an easier time seeing where a person is coming from 
who claims that it makes it in some way harder to see at a glance where 
scopes begin and end.


More information about the Digitalmars-d-learn mailing list