<div class="gmail_quote">On 4 May 2012 16:53, H. S. Teoh <span dir="ltr"><<a href="mailto:hsteoh@quickfur.ath.cx" target="_blank">hsteoh@quickfur.ath.cx</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Fri, May 04, 2012 at 01:46:21AM -0700, Jonathan M Davis wrote:<br>
> On Friday, May 04, 2012 11:38:32 Manu wrote:<br>
> > I try rearranging the syntax to make the first issue stop complaining:<br>
> ><br>
> > ref const(Thing) func2() { return gThing; } // this seems to work now, but<br>
> > i don't like the inconsistency...<br>
><br>
> That's thanks to the nonsense that putting const on the left-hand side<br>
> of a member function is legal, making it so that you _must_ use parens<br>
> with const and return types for the const to apply to the return type<br>
> rather than the function.<br>
<br>
</div>Yeah, I've recently started building the habit of always using<br>
parentheses with const applied to a type, in order to make it less<br>
confusing with const as applied to a function. Even though it's legal to<br>
write:<br>
<br>
        int func(const T t) {...}<br>
<br>
nowadays I prefer to write:<br>
<br>
        int func(const(T) t) {...}<br>
<br>
so that when you need to return const, the syntax is more consistent:<br>
<br>
        const(T) func(const(T) t) {...}<br>
<br>
and it doesn't visually clash so much with const as applied to the<br>
function itself:<br>
<br>
        const(T) func(const(T) t) const {...}<br>
<br>
This is one of the warts in D syntax that I find annoying.<br></blockquote><div><br></div><div>Yeah I really hate this too. I'd like to see const(T) strictly enforced, considering the potential for ambiguity in other situations.</div>
<div><br></div><div>But I'm still stuck! :(</div><div>How can I do what I need to do?</div></div>