D benchmark code review

Chris Cain clcain at uncg.edu
Fri Dec 13 14:29:01 PST 2013


On Friday, 13 December 2013 at 22:10:13 UTC, Ali Çehreli wrote:
> I used to dislike it until I started working at my current job 
> where Egyptian style is the standard.
>
> I am happy that it is common D-style as well.
>
> I am still not sure why I don't like it everywhere (e.g. 
> struct, class, function definitions, etc.) :)
>
> void foo()
> {                  // <-- why not here as well? I don't know. :p
>     if (cond) {
>         // ...
>     }
> }
>
> Ali

TBH I'm more of an egyptian style user myself. But for function 
definitions, struct definitions, etc... I feel it's better to 
give it its own line because of other D features.

For instance:
---
void foo(T)(T input) if(isIntegral!T) {
     //...
}
---

It emphasizes its significance to give it its own line, despite 
it being a bit more verbose:
---
void foo(T)(T input)
if(isIntegral!T)
{
     //...
}
---

Plus consider in/out/body like things:
---
void foo(T)(T input) in {
     assert(input > 0);
} body {
     //...
}
---
  vs.
---
void foo(T)(T input)
in
{
     assert(input > 0);
}
body
{
     //...
}
---

IMO, it looks like the "in" section is actually the body 
initially. This would especially matter when the in section is a 
bit larger.

(And before you suggest giving "in {" its own line in the first 
example, I don't like that because it seems like too special of a 
rule, but that was typically what I did originally).

So, Ali, I'm like you that I prefer declarations to have braces 
on their own line but other things to use egyptian style.


More information about the Digitalmars-d mailing list