Make const, immutable, inout, and shared illegal as function attributes on the left-hand side of a function
Jonathan M Davis via Digitalmars-d
digitalmars-d at puremagic.com
Thu Oct 9 11:31:04 PDT 2014
On Thursday, October 09, 2014 10:50:44 Martin Nowak via Digitalmars-d 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?
> Do you think it makes your code better or worse?
> Is this just a pointless style change?
> Anything else?
>
> https://github.com/D-Programming-Language/dmd/pull/4043
Well, since I'm the one who created the enhancement request that this is for,
I'm obviously for it. It's a change that's long past due. Allowing them on the
left only causes trouble - both in terms of bugs and confusion - and I think
that most of us would agree that it's already considered good practice to
stick them on the right rather than the left. Allowing them on the left has no
real benefit IMHO beyond avoiding code breakage, and the fix for that is
trivial.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list