December 13, 2013
On 12/13/2013 08:40 AM, Manu wrote:

> On 14 December 2013 02:12, Timon Gehr <timon.gehr@gmx.ch> wrote:
>
>> On 12/13/2013 05:05 PM, Manu wrote:
>>
>>>
>>> Is it idiomatic to use egyptian braces in D?

Thanks for teaching me a new term. :)

>> Brackets? Yes.
>
>
> [] is brackets, {} is braces.

I used to call the latter "curly braces" as well but I was corrected some time ago. Now I call them curly brackets.

>   I've never seen D code written this way...

It is very common in D.learn as well.

Ali

December 13, 2013
On 12/13/2013 10:20 AM, Brian Rogoff wrote:

> On Friday, 13 December 2013 at 17:30:09 UTC, Manu wrote:

>> Possibly following Andrei's lead, and possible consideration for print?
>
> Or possibly Ali just prefers this style?

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

December 13, 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.
December 13, 2013
On Friday, December 13, 2013 13:04:13 Andrei Alexandrescu wrote:
> Facebook uses Egyptian braces in its D code.

My condolences. ;)

- Jonathan M Davis
December 13, 2013
Jonathan M Davis:

> On Friday, December 13, 2013 13:04:13 Andrei Alexandrescu wrote:
>> Facebook uses Egyptian braces in its D code.
>
> My condolences. ;)

Rosettacode D entries code use Egyptian braces (also to reduce waste vertical space in the page).

Bye,
bearophile
December 13, 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've always disliked it... It's almost as painful as nails on a chalkboard for me. The last job I worked at was a small Java shop that used this style exclusively, and I did get used to writing code in it after awhile, but I would never use it if given the choice. I vastly prefer Allman style.
December 14, 2013
On 14 December 2013 04:53, David Nadlinger <code@klickverbot.at> wrote:

> On Friday, 13 December 2013 at 17:30:09 UTC, Manu wrote:
>
>> I take druntime and phobos as they are the largest and most widely used body of D code, along with many other projects I've run into that also follow that lead. I'm yet to encounter any exceptions.
>>
>
> If you ever used the Derelict-style bindings for Assimp I threw together (and which are hopelessly out of date at this point), which I remember you mentioning quite some while ago, that's not true. ;)
>
> I prefer this style and use it for all my personal projects, as I feel it makes inferring the structure glancing over the code a bit easier for me. Though, honestly, it doesn't really matter to me at this point. I just want to point out that I would hardly consider it to be a Java-only thing. The style is not only used in the K&R book, but also in many well-known C/C++ projects such as LLVM, and IIRC is also called for in Google's internal C++ style guide.


Fair enough. I concede.
The reason I raise the issue is that I like the sense of agreement within
Java. I'd like to think there's opportunity to promote a prevailing
standard in D the same as in Java (especially in code presented for public
scrutiny). The argument simply doesn't come up when writing Java code, and
I like that everyone agrees that way.
I don't care which, I just like consistency. And it seemed to me that the
largest body of D code as maintained by the official community should
probably define such a standard, but clearly that boat has long sailed, so
I guess it doesn't matter.


December 14, 2013
On 14 December 2013 08:02, Ali Çehreli <acehreli@yahoo.com> wrote:

> On 12/13/2013 08:40 AM, Manu wrote:
> >> Brackets? Yes.
> >
> >
> > [] is brackets, {} is braces.
>
> I used to call the latter "curly braces" as well but I was corrected some time ago. Now I call them curly brackets.


http://en.wikipedia.org/wiki/Bracket
The big text in the top right says braces. Reading further... seems there's
a lot of disagreement on the matter. However, the very first term; it's
unusual the UK and the US both allegedly agree on something. I accept that
as a sign! ;)


December 14, 2013
On 14 December 2013 08:10, Ali Çehreli <acehreli@yahoo.com> wrote:

> On 12/13/2013 10:20 AM, Brian Rogoff wrote:
>
> > On Friday, 13 December 2013 at 17:30:09 UTC, Manu wrote:
>
> >> Possibly following Andrei's lead, and possible consideration for print?
> >
> > Or possibly Ali just prefers this style?
>
> 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) {
>         // ...
>     }
> }


Mmm, I prefer C braces for this reason.
I just can't feel comfortable with egyptian braces applied universally. I
figure, if I can't accept it universally, I can't accept it at all ;) ..
Where are the lines drawn? What are the rules? I don't even know! It's
chaos!
Obviously, I suffer from OCD... I'm one of those whitespace nazi's too :/


December 14, 2013
On 12/13/2013 06:08 PM, Jonathan M Davis wrote:
> On Friday, December 13, 2013 13:04:13 Andrei Alexandrescu wrote:
>> Facebook uses Egyptian braces in its D code.
>
> My condolences. ;)

+1

I recently coded my first D program with Egyptian brackets, but when I later removed that style, my code instantly became clear and more readable!!

I am going to stay away from the Egyptian brackets as if it's a curse of the Pharaohs! :)