On 4 May 2012 16:53, H. S. Teoh <hst...@quickfur.ath.cx> wrote:

> On Fri, May 04, 2012 at 01:46:21AM -0700, Jonathan M Davis wrote:
> > On Friday, May 04, 2012 11:38:32 Manu wrote:
> > > I try rearranging the syntax to make the first issue stop complaining:
> > >
> > > ref const(Thing) func2() { return gThing; } // this seems to work now,
> but
> > > i don't like the inconsistency...
> >
> > That's thanks to the nonsense that putting const on the left-hand side
> > of a member function is legal, making it so that you _must_ use parens
> > with const and return types for the const to apply to the return type
> > rather than the function.
>
> Yeah, I've recently started building the habit of always using
> parentheses with const applied to a type, in order to make it less
> confusing with const as applied to a function. Even though it's legal to
> write:
>
>        int func(const T t) {...}
>
> nowadays I prefer to write:
>
>        int func(const(T) t) {...}
>
> so that when you need to return const, the syntax is more consistent:
>
>        const(T) func(const(T) t) {...}
>
> and it doesn't visually clash so much with const as applied to the
> function itself:
>
>        const(T) func(const(T) t) const {...}
>
> This is one of the warts in D syntax that I find annoying.
>

Yeah I really hate this too. I'd like to see const(T) strictly enforced,
considering the potential for ambiguity in other situations.

But I'm still stuck! :(
How can I do what I need to do?

Reply via email to