const int vs. int const

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Sat Aug 16 14:42:58 PDT 2014


On Saturday, 16 August 2014 at 18:50:08 UTC, Jacob Carlborg wrote:
> On 2014-08-16 01:33, Mike wrote:
>
>> Sounds like a worthwhile impromement to me.
>
> Sounds like a breaking change to me. Which will include the 
> usual complains.

Yes, but it's either that or have people running into this
problem and complaining about it and the bugs that it causes for
years to come. And it's _already_ bad practice to put const,
immutable, inout, or shared on the left-hand side without parens,
and pretty much everyone has run into the problem at one time or
another when trying to return const from a function and would
know to avoid putting those atributes on the left. So, the vast
majority of code wouldn't be affected. And of course, we'd do it
via deprecation, so it wouldn't immediately break code.

So, yes, I can see why "it's a breaking change" would be given as
a reason not to do it, but given that this is a definite wart in
the language that is consistently giving problems to D newbies
and just outright avoided by D veterans, most code that would be
affected is probably wrong anyway, and it's not a feature that's
at all desirable to have, so I _definitely_ think that the change
is worth it. Certainly, I would want to know every line of code
that I have that has any of these attributes no the left-hand
side of a function without parens, because that would mean that
there's a bug in my code that I didn't catch.

- Jonathan M Davis


More information about the Digitalmars-d mailing list