digitalmars.D - Poll/discussion: dfmt option for single vs double indents for
- Prajwal S N (40/40) Dec 29 2023 Hi everyone,
- Richard (Rikki) Andrew Cattermole (4/7) Dec 29 2023 Keep it.
- JN (14/25) Dec 30 2023 If it were my code, I'd format it like this:
- deadalnix (2/20) Dec 30 2023 That is what sdfmt will do.
- An Pham (3/36) Jan 01 Why not using 'int' instead as type for number of tabs. For
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (2/4) Jan 02 Can you share a link to dmdfmt, please?
- Richard (Rikki) Andrew Cattermole (2/3) Jan 02 https://github.com/dlang-community/dfmt/pull/589
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (3/6) Jan 09 Thanks!
Hi everyone, As a part of SAOC 2023, I've been working on porting dfmt to use the AST from DMD instead of libdparse (you might have come across my weekly updates). There are a few passes in the original dfmt that seem to allow for a purely aesthetic formatting inconsistency, and I wanted some community opinion on whether these should be made available in dmdfmt, or whether it would be better to retire them. - `dfmt_single_template_constraint_indent`: If set to true, indents multi-line template constraints with a single tab. The default is false. E.g. ```d // default void foo(T)() if (is(T == char) || is(T == dchar)) // true void foo(T)() if (is(T == char) || is(T == dchar)) ``` - `dfmt_single_indent`: If set to true, indents multi-line function declarations with a single tab. The default is false. E.g. ```d // default void foo(int a, char b, string c, int d, char e, string f) {} // true void foo(int a, char b, string c, int d, char e, string f) {} ``` IMO, code on the following line should ideally be indented by a single tab, irrespective of the context of the newline. This ensures formatting consistency across all types of expressions. With these options, it causes the reader to flip between single tab and double tab indents across different items like if/else/for/while and function declarations/template constraints, which is quite jarring. What do you think about this? Would it be better to maintain a single standard for indentation and not allow configuration, or should a knob be provided at the cost of consistency?
Dec 29 2023
On 29/12/2023 10:08 PM, Prajwal S N wrote:What do you think about this? Would it be better to maintain a single standard for indentation and not allow configuration, or should a knob be provided at the cost of consistency?Keep it. Let's not introduce behaviors which differs from the original dfmt. It only introduces a wedge between old and new, which prevents adoption.
Dec 29 2023
On Friday, 29 December 2023 at 09:08:33 UTC, Prajwal S N wrote:- `dfmt_single_indent`: If set to true, indents multi-line function declarations with a single tab. The default is false. E.g. ```d // default void foo(int a, char b, string c, int d, char e, string f) {} // true void foo(int a, char b, string c, int d, char e, string f) {} ```If it were my code, I'd format it like this: ```d void foo(int a, char b, string c, int d, char e, string f) {} ``` PEP8 for Python also recommends such vertical alignment. Alternatively: ```d void foo( int a, char b, string c, int d, char e, string f) {} ```
Dec 30 2023
On Saturday, 30 December 2023 at 14:54:54 UTC, JN wrote:On Friday, 29 December 2023 at 09:08:33 UTC, Prajwal S N wrote:That is what sdfmt will do.- `dfmt_single_indent`: If set to true, indents multi-line function declarations with a single tab. The default is false. E.g. ```d // default void foo(int a, char b, string c, int d, char e, string f) {} // true void foo(int a, char b, string c, int d, char e, string f) {} ```If it were my code, I'd format it like this: ```d void foo(int a, char b, string c, int d, char e, string f) {} ```
Dec 30 2023
On Friday, 29 December 2023 at 09:08:33 UTC, Prajwal S N wrote:Hi everyone, As a part of SAOC 2023, I've been working on porting dfmt to use the AST from DMD instead of libdparse (you might have come across my weekly updates). There are a few passes in the original dfmt that seem to allow for a purely aesthetic formatting inconsistency, and I wanted some community opinion on whether these should be made available in dmdfmt, or whether it would be better to retire them. - `dfmt_single_template_constraint_indent`: If set to true, indents multi-line template constraints with a single tab. The default is false. E.g. ```d // default void foo(T)() if (is(T == char) || is(T == dchar)) // true void foo(T)() if (is(T == char) || is(T == dchar)) ``` - `dfmt_single_indent`: If set to true, indents multi-line function declarations with a single tab. The default is false. E.g. ```d // default void foo(int a, char b, string c, int d, char e, string f) {} // true void foo(int a, char b, string c, int d, char e, string f) {} ```What do you think about this? Would it be better to maintain a single standard for indentation and not allow configuration, or should a knob be provided at the cost of consistency?Why not using 'int' instead as type for number of tabs. For template restriction, I do not want any tab
Jan 01
On Friday, 29 December 2023 at 09:08:33 UTC, Prajwal S N wrote:Hi everyone, As a part of SAOC 2023, I've been working on porting dfmt to ...Can you share a link to dmdfmt, please?
Jan 02
On 03/01/2024 8:01 PM, Per Nordlöw wrote:Can you share a link to dmdfmt, please?https://github.com/dlang-community/dfmt/pull/589
Jan 02
On Wednesday, 3 January 2024 at 07:03:05 UTC, Richard (Rikki) Andrew Cattermole wrote:On 03/01/2024 8:01 PM, Per Nordlöw wrote:Thanks!Can you share a link to dmdfmt, please?https://github.com/dlang-community/dfmt/pull/589
Jan 09