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

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Thu Oct 9 07:17:48 PDT 2014


On 10/9/14 4:50 AM, 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?
> 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

First, I'm all for the change. If it affects my code, I don't care, I'll 
fix it.

Just one point to make, this will still work, right?:

const {
    int foo();
}

const:
    int foo();

I'm not sure I agree with the future plan to allow const on the lhs to 
apply to the return type, but we can decide that in the future.

-Steve


More information about the Digitalmars-d mailing list