Indentation standard of D

I’ve got a little problem over here:

align (2) struct S {
  align (1):
    byte a; // placed at offset 0
    int b; // placed at offset 1
    long c; // placed at offset 5
}

taken from attribute.html vs.

struct ByRecord(Fields...)
{
private:
    File file;
    char[] line;

from stdio.d
Now my question is: Which indent for align/private is more acceptable as a D standard?
– To have an outdent for colon-finished attributes or not to have them?

2 Comments

  • vines
    January 17, 2013 - 12:53 am | Permalink

    Ain’t that a dig at the K&R bracing style? :) In BSD / Allman style the former sample looks equally good:

    align (2) struct S
    {
    align (1):
    byte a; // placed at offset 0
    int b; // placed at offset 1
    long c; // placed at offset 5
    }

    Suppose it would be nice to have indenting and bracing styles tied together…

    • alex
      January 17, 2013 - 1:03 am | Permalink

      Oh, well it’s primarily not about the bracing style – that’s a thing I didn’t even notice :D
      So you think it was better to out-dent attributes etc., and indent child declarations? [The formatting in your message got removed but I've seen it in the mail]
      - I probably don’t want to kick off huge and endless debates, so I better let it stay the way it is, namely the kind of indentation you’ve proposed. Regarding the bracing, well that’s something I’m about to handle now (speaking for the next weeks *cough*) as part of a larger formatting engine. I have to look how it’s done in MD to halfway copy the algorithms ;)
      Then, things will be finally awesome!

  • Leave a Reply

    Your email address will not be published. Required fields are marked *


    six × = 12

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>