Make const, immutable, inout, and shared illegal as function attributes on the left-hand side of a function

Joseph Rushton Wakeling via Digitalmars-d digitalmars-d at puremagic.com
Thu Oct 9 15:25:07 PDT 2014


> Would this affect your code?

No, but is it fixed on the ddoc side?  The last ddoc I generated had function 
attributes first, even though in the code they were on the right.  It would be 
pretty awful to have function attributes obliged to be on the right in code, but 
still appearing on the left in documentation.

> Do you think it makes your code better or worse?

I like the style, and it certainly helps to avoid the confusion with C/C++'s 
const interpretation.

>> Then at some future point we could apply the left hand side qualifiers to the
>> return type, e.g. `const int foo();` == `const(int) foo();`

I like this idea less.  const(int) is explicit in a way that const int isn't.

> Anything else?

I'm not sure whether I care to _enforce_ this style rather than strongly 
encourage it, as it's a breaking change.  I'd rather deprecation of 
left-hand-side attributes, rather than illegality, if that is possible.


More information about the Digitalmars-d mailing list