DStyle: Braces on same line

Brian Rogoff via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jul 13 10:51:26 PDT 2014


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. 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.

>> 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!


More information about the Digitalmars-d-learn mailing list