const/invariant bug?

Dave Dave_member at pathlink.com
Sat Apr 5 12:38:31 PDT 2008


"Walter Bright" <newshound1 at digitalmars.com> wrote in message 
news:ft380r$13vn$1 at digitalmars.com...
> Extrawurst wrote:
>> Why do we need the suffix "const" anyway ? Isnt unambiguity a virtue ?
>
> Some people prefer it.

> const void setX(int nx) { x = nx; }

Since there has, understandably, been some confusion about what const refers 
to with the prefixed form, why don't we get rid of the prefixed form 
altogether for 2.0?

You could still allow:

class C
{
const
{
  int[] foo() { }         // int[] foo() const { }
  double[] bar() { }  // double[] bar() const { }
}
}

because you have to do const(int[]) foo() to specify it for the return type 
anyhow, which is consistent between member and non-member functions.

I doubt at this point it would break all that much code and the deprecated 
switch could serve in the interim.

I really think this change would be worth it considering all of the 
confusion the prefix form will cause down the road, especially for C++ 
users.

Thanks,

- Dave




More information about the Digitalmars-d mailing list