<div dir="ltr">2013/2/4 Andrej Mitrovic <span dir="ltr"><<a href="mailto:andrej.mitrovich@gmail.com" target="_blank">andrej.mitrovich@gmail.com</a>></span><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im">On 2/4/13, Andrei Alexandrescu <<a href="mailto:SeeWebsiteForEmail@erdani.org">SeeWebsiteForEmail@erdani.org</a>> wrote:<br>
> I'm unclear that's a problem.<br>
<br>
</div>The problem is you cannot replace a field with a @property function<br>
without breaking user-code when you take into account operator<br>
overloading. Consider:<br></blockquote><div><br></div><div style>As an essential question, how often occurs rewriting fields to property?</div><div style><br></div><div style>As far as I thought, such rewriting will cause:</div>
<div style>1. compile error by type mismatch (if you use &obj.field),</div><div style>2. or, success of compilation *without any semantic breaking* (if you don't use &obj.field).</div><div style><br></div><div style>
<div>I think the result is not so harmful.</div><div> <br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

struct S<br>
{<br>
    S opBinary(string op : "&", S)(S s)<br>
    {<br>
        return this;<br>
    }<br>
}<br>
<br>
struct M<br>
{<br>
    S s;<br>
}<br>
<br>
void main()<br>
{<br>
    M m;<br>
    auto s = m.s & m.s;  // ok<br>
}<br>
<br>
Suppose you want to turn 's' into a read-only property, so you write:<br>
<br>
struct S<br>
{<br>
    S opBinary(string op : "&", S)(S s)<br>
    {<br>
        return this;<br>
    }<br>
}<br>
<br>
struct M<br>
{<br>
    @property S s() { return _s; }<br>
    private S _s;<br>
}<br>
<br>
void main()<br>
{<br>
    M m;<br>
    auto s = m.s & m.s;  // fail<br>
}<br>
<br>
Now the user-code fails.<br></blockquote><div><br></div><div style>This is not correct."<span style="font-family:arial,sans-serif;font-size:14px">m.s & m.s" is always parsed as binary bitwise AND expression.</span></div>
<div style><span style="font-family:arial,sans-serif;font-size:14px">So there is no address expression.</span></div><div></div></div><br></div><div class="gmail_extra" style>Kenji Hara</div></div>