www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Style guide for indentation of template restrictions

reply Per =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
Is there code convention for the indentation of template 
restrictions?

Should a restriction be indented as

     void f(U)(U a, ref U b)
         if (isUnsigned!U)

or not as in

     void f(U)(U a, ref U b)
     if (isUnsigned!U)

?
Aug 22 2020
parent reply MoonlightSentinel <moonlightsentinel disroot.org> writes:
On Saturday, 22 August 2020 at 20:26:40 UTC, Per Nordlöw wrote:
 Is there code convention for the indentation of template 
 restrictions?

 Should a restriction be indented as

     void f(U)(U a, ref U b)
         if (isUnsigned!U)

 or not as in

     void f(U)(U a, ref U b)
     if (isUnsigned!U)

 ?
The D Style suggests the latter, see https://dlang.org/dstyle.html#phobos_declarations
Aug 22 2020
parent Per =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
On Saturday, 22 August 2020 at 22:15:04 UTC, MoonlightSentinel 
wrote:
 On Saturday, 22 August 2020 at 20:26:40 UTC, Per Nordlöw wrote:
 Is there code convention for the indentation of template 
 restrictions?

 Should a restriction be indented as

     void f(U)(U a, ref U b)
         if (isUnsigned!U)

 or not as in

     void f(U)(U a, ref U b)
     if (isUnsigned!U)

 ?
The D Style suggests the latter, see https://dlang.org/dstyle.html#phobos_declarations
If so, dfmt's `dfmt_template_constraint_style` [1] should default to conditional_newline or always_newline instead of conditional_newline_indent [1] https://github.com/dlang-community/dfmt#dfmt-specific-properties
Aug 23 2020