<div class="gmail_quote">On 4 May 2012 11:46, Jonathan M Davis <span dir="ltr"><<a href="mailto:jmdavisProg@gmx.com" target="_blank">jmdavisProg@gmx.com</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 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>
</div>That's thanks to the nonsense that putting const on the left-hand side of a<br>
member function is legal, making it so that you _must_ use parens with const<br>
and return types for the const to apply to the return type rather than the<br>
function.<br>
<div class="im"><br>
> ref const(Thing) function() blah2 = &func;<br>
><br>
> Error: variable remedy.hud.blah2 only parameters or foreach declarations<br>
> can be ref<br>
<br>
</div>Hmm. Well assuming that you can't fix the problem with parens (and I don't<br>
think that you can), you should probably use typeof. Either<br>
<br>
typeof(ref const(Thing) function()) blah2 = &func2;<br></blockquote><div><br></div><div>This fails quite spectacularly:</div><div><div>  remedy\modules\hud.d(33):expression expected, not 'ref'</div><div>  remedy\modules\hud.d(33):found 'const' when expecting ')'</div>
<div>  remedy\modules\hud.d(33):function declaration without return type. (Note that constructors are always named 'this')</div><div>  remedy\modules\hud.d(33):no identifier for declarator typeof(0)(Thing)</div><div>
  remedy\modules\hud.d(33):semicolon expected following function declaration</div><div>  remedy\modules\hud.d(33):Declaration expected, not 'function'</div></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
will work (I'm not sure if it will), or if you have a function (e.g. foo) of<br>
type ref const(Thing) function(), then you could do<br>
<br>
typeof(foo) blah2 = &foo;<br></blockquote><div><br></div><div>This also fails:</div><div>  Error: variable remedy.hud.blah2 cannot be declared to be a function</div><div><br></div><div>>_<</div></div>