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

Brian Schott via Digitalmars-d digitalmars-d at puremagic.com
Thu Oct 9 02:02:41 PDT 2014


On Thursday, 9 October 2014 at 08:50:52 UTC, Martin Nowak wrote:
> Kenji just proposed a slightly controversial pull request so I 
> want to reach out for more people to discuss it's tradeoffs.
> It's about deprecating function qualifiers on the left hand 
> side of a function.
>
> So instead of
>     const int foo();
> you'd should write
>     int foo() const;
>
> 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();`
>
> Would this affect your code?

No. D-Scanner's style checker yells at you when you try to do 
this, so I've fixed all my personal code already. These checks 
run as part of the CI process at EMSI and the results are 
uploaded to our local SonarQube server. We shouldn't have any 
uses of the to-be-removed syntax hiding in our code.

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

Better. Explaining why "const int foo" is "const(int)" and "const 
int foo();" is "int" is not something I enjoy doing.

> Is this just a pointless style change?

No.

> Anything else?

This will be moderately difficult to imlement in dfix.


More information about the Digitalmars-d mailing list