Const function

Jason House jason.james.house at gmail.com
Tue Dec 4 10:48:10 PST 2007


Graham St Jack Wrote:

> On Thu, 29 Nov 2007 02:16:40 -0500, Gilles G. wrote:
> 
> > there are two ways to express function
> > constness for now:
> >    const int foo();
> >    int foo() const;
> > To my mind, both solutions are unintuitive. I would expect something
> > like that:
> >    int const foo();
> > Is there any big argument against this?
> 
> I agree. A definition like:
> 
> const T foo();
> 
> looks to me like the returned T is const, and putting the const after the 
> function is way too non-D for me, so all that is left that makes sense is:
> 
> T const foo();

I've seen Walter argue that he wants to be able to declare const functions in batch with
const{
  T foo();
  T bar();
}

I guess you could say that he wants const{X;} and const X; to be the same, but doesn't want const(X) and const X to be the same.  There's nothing like mixing two hotly debated threads together!  I apologize in advance for it.  I just couldn't resist since the parallels were so striking.



More information about the Digitalmars-d mailing list