const property don't wont return const reference to value

Jonathan M Davis jmdavisProg at gmx.com
Sun Dec 23 12:06:23 PST 2012


On Sunday, December 23, 2012 15:41:09 Namespace wrote:
> On Sunday, 23 December 2012 at 13:37:33 UTC, Rainer Schuetze
> 
> wrote:
> > On 23.12.2012 14:20, Zhenya wrote:
> >>     @property const ref int bar() const
> > 
> > The first const does not bind to the return type, but to the
> > whole declaration, so it does the same as the const at the end.
> > You should use
> > 
> >     @property ref const(int) bar() const
> 
> Shouldn't we fix this? Most of the Newcomer are confused with the
> fact, that there are two ways to define a function/method as
> const and that they have to write const(ReturnType) and not const
> ReturnType.

No one has been able to convince Walter. He thinks that the consistency of 
allowing function attributes on both sides trumps fixing the problems caused by 
having const or immutable on the left.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list