Thread overview | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
October 09, 2014 Make const, immutable, inout, and shared illegal as function attributes on the left-hand side of a function | ||||
---|---|---|---|---|
| ||||
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 |
October 09, 2014 Re: Make const, immutable, inout, and shared illegal as function attributes on the left-hand side of a function | ||||
---|---|---|---|---|
| ||||
Posted in reply to Martin Nowak | 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. |
October 09, 2014 Re: Make const, immutable, inout, and shared illegal as function attributes on the left-hand side of a function | ||||
---|---|---|---|---|
| ||||
Posted in reply to Martin Nowak Attachments: | On Thu, 09 Oct 2014 10:50:44 +0200
Martin Nowak via Digitalmars-d <digitalmars-d@puremagic.com> 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
i'm all for this. prefix function attributes are *VERY* confusing. i think this patch should be accepted as soon as possible. i'm already enjoying it. ;-)
|
October 09, 2014 Re: Make const, immutable, inout, and shared illegal as function attributes on the left-hand side of a function | ||||
---|---|---|---|---|
| ||||
Attachments: | On Thu, 9 Oct 2014 12:04:36 +0300 ketmar via Digitalmars-d <digitalmars-d@puremagic.com> wrote: i mean there were occasional discussions in NG about irritating "'const int bar();' is not 'const(int) bar();'" and i've seen nobody defending prefix attributes. it was either "i don't care" or "it's annoying". |
October 09, 2014 Re: Make const, immutable, inout, and shared illegal as function attributes on the left-hand side of a function | ||||
---|---|---|---|---|
| ||||
Posted in reply to Martin Nowak | 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. I'm all for it > 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 know it's not happening anytime soon, but I'm against this second idea. This will be an extra annoyance when "porting" old D code to a new version. Just removing the currently ambiguous attribute on the left should be plenty. No need to try to mimic C in this regard. |
October 09, 2014 Re: Make const, immutable, inout, and shared illegal as function attributes on the left-hand side of a function | ||||
---|---|---|---|---|
| ||||
Posted in reply to Martin Nowak | 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?
> 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
Yes, yes, yes YES ! YYYEEEEEESSSSSS !
|
October 09, 2014 Re: Make const, immutable, inout, and shared illegal as function attributes on the left-hand side of a function | ||||
---|---|---|---|---|
| ||||
Posted in reply to Martin Nowak | 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?
> 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
I'm for going ahead with that.
---
/Paolo
|
October 09, 2014 Re: Make const, immutable, inout, and shared illegal as function attributes on the left-hand side of a function | ||||
---|---|---|---|---|
| ||||
Posted in reply to Martin Nowak | Martin Nowak: > 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; +1 from me. > 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();` In this case I think it's better to focus on the most important thing first. Bye, bearophile |
October 09, 2014 Re: Make const, immutable, inout, and shared illegal as function attributes on the left-hand side of a function | ||||
---|---|---|---|---|
| ||||
Posted in reply to Martin Nowak | Am Thu, 09 Oct 2014 10:50:44 +0200 schrieb Martin Nowak <code@dawg.eu>: > Would this affect your code? Most old code, yes. I used to write all attributes on the left hand side, but switched to right hand side some time ago. > Do you think it makes your code better or worse? Probably better, although I tried to be careful with the left hand side attributes so it shouldn't change to much. > Is this just a pointless style change? > Anything else? Code will probably look nicer, but I'm not sure if it's consistent. with const(int) it's obvious that the return value is const. With const int abcd() @safe this might be less obvious. Also fixing old code manually would be very tedious. |
October 09, 2014 Re: Make const, immutable, inout, and shared illegal as function attributes on the left-hand side of a function | ||||
---|---|---|---|---|
| ||||
Posted in reply to Johannes Pfau | Am Thu, 9 Oct 2014 12:27:11 +0200
schrieb Johannes Pfau <nospam@example.com>:
> Am Thu, 09 Oct 2014 10:50:44 +0200
> schrieb Martin Nowak <code@dawg.eu>:
>
>
> > Would this affect your code?
> Most old code, yes. I used to write all attributes on the left hand side, but switched to right hand side some time ago.
>
> > Do you think it makes your code better or worse?
> Probably better, although I tried to be careful with the left hand side attributes so it shouldn't change to much.
>
> > Is this just a pointless style change?
> > Anything else?
> Code will probably look nicer, but I'm not sure if it's consistent.
> with const(int) it's obvious that the return value is const. With
> const int abcd() @safe
> this might be less obvious.
>
> Also fixing old code manually would be very tedious.
>
Forgot to some overall I'm for this change. I'd just like some automated way to fix old code ;-)
|
Copyright © 1999-2021 by the D Language Foundation