<div dir="ltr">This is an interesting problem with the ref-is-not-part-of-the-type design. You can't really have a const(ref) in D, and a ref const(int) is kinda backwards logic.<div style>I've never understood why ref isn't part of the type... can someone explain why this is a good thing? It seems to cause all sorts of troublesome problems... auto ref in templates for one.</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On 12 April 2013 10:50, Nicholas Smith <span dir="ltr"><<a href="mailto:nmsmith65@gmail.com" target="_blank">nmsmith65@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I don't know how to file bug reports but I'm sure this shouldn't happen :)<br>
DMD gives an error.<br>
<br>
import std.stdio;<br>
<br>
void main()<br>
{<br>
        immutable Cat cat = cast(immutable) new Cat(5);<br>
        happyBirthday(cat.age);<br>
        writefln("My 5 year old cat is %s years old!", cat.age);<br>
}<br>
<br>
void happyBirthday(ref int i)<br>
{<br>
        i++;<br>
}<br>
<br>
class Cat<br>
{<br>
        public int age;<br>
<br>
        this(int a)<br>
        {<br>
                this.age = age;<br>
        }<br>
}<br>
<br>
<br>
Output:<br>
My 5 year old cat is 6 years old!<br>
</blockquote></div><br></div>