<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p>I agree with everyone, that the proxy object should not equal the
      proxied object.</p>
    <p>What you really want to ask for is for JavaScript support for
      overriding the comparison operator for a class. (and other
      operators, too...)<br>
    </p>
    <br>
    <div class="moz-cite-prefix">On 30.03.2017 21:44, Michael Lewis
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAMwbx0Bfqkog_6Fz2uQPUkrf5z_aUpp+7qJt-LJN6bffhK_fdg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span
            style="font-size:12.8px">I don't believe Proxies are
            designed to give you any encapsulation to a user who also
            has a reference to the target object</span><span
            style="font-size:12.8px"><br>
          </span></blockquote>
        <span style="font-size:12.8px">
          <div><span style="font-size:12.8px"><br>
            </span></div>
          So the Proxy wasn't designed to proxy real objects that
          operate with real code?</span>
        <div><span style="font-size:12.8px"><br>
          </span></div>
        <div><span style="font-size:12.8px">`myRealFunction(obj)`
            <---> `myRealFunction(proxy)`</span></div>
        <div><span style="font-size:12.8px"><br>
          </span></div>
        <div><span style="font-size:12.8px">This could be incredibly
            useful. You could log every get/set/method call on the
            obj. And, this *will* work in 99% of use cases. Just cross
            your fingers that your code doesn't use the comparison
            operator.</span></div>
        <div><span style="font-size:12.8px"><br>
          </span></div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span
            style="font-size:12.8px">you'd have to never provide the
            reference to the target object in the first place.</span></blockquote>
        <div><br>
        </div>
        <div>Yea, that's what I'm doing. But inside a constructor, you
          basically have to create the proxy first thing, call all
          initialization logic on the proxy instead of `this`, and
          return the proxy. And when you're only proxying if `log:
          true` has been set, you have to maybe proxy, but maybe not. I
          can work around it, but I'm not happy about it ;) </div>
        <div><br>
        </div>
        <div>ljharb ftw! (I amdelevoperon IRC, the one frequently
          ranting about the software revolution)</div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Thu, Mar 30, 2017 at 1:53 PM, Jordan
          Harband <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:ljharb@gmail.com" target="_blank">ljharb@gmail.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="ltr">I don't believe Proxies are designed to give
              you any encapsulation to a user who also has a reference
              to the target object - you'd have to never provide the
              reference to the target object in the first place.<br>
            </div>
            <div class="gmail_extra"><br>
              <div class="gmail_quote">
                <div>
                  <div class="h5">On Thu, Mar 30, 2017 at 11:50 AM,
                    Michael Lewis <span dir="ltr"><<a
                        moz-do-not-send="true"
                        href="mailto:mike@lew42.com" target="_blank">mike@lew42.com</a>></span>
                    wrote:<br>
                  </div>
                </div>
                <blockquote class="gmail_quote" style="margin:0 0 0
                  .8ex;border-left:1px #ccc solid;padding-left:1ex">
                  <div>
                    <div class="h5">
                      <div dir="ltr">Hello community,
                        <div><br>
                        </div>
                        <div>The proxy is almost an<i> </i>identical to
                          the underlying object, but it<b>fails a
                            comparison check with the underlying object.</b></div>
                        <div><br>
                        </div>
                        <div>This means that if anyone gets a reference
                          to the underlying object before it is proxied,
                          then we have a problem. For example:</div>
                        <div><br>
                        </div>
                        <div>
                          <table
                            class="m_-7937008281402793648m_-1621987562726856570gmail-highlight
m_-7937008281402793648m_-1621987562726856570gmail-tab-size
m_-7937008281402793648m_-1621987562726856570gmail-js-file-line-container"
style="box-sizing:border-box;border-collapse:collapse;color:rgb(36,41,46);font-family:-apple-system,blinkmacsystemfont,"segoe
ui",helvetica,arial,sans-serif,"apple color
                            emoji","segoe ui
                            emoji","segoe ui
                            symbol";font-size:14px">
                            <tbody style="box-sizing:border-box">
                              <tr style="box-sizing:border-box">
                                <td id="m_-7937008281402793648m_-1621987562726856570gmail-file-gistfile1-js-LC1" class="m_-7937008281402793648m_-1621987562726856570gmail-blob-code m_-7937008281402793648m_-1621987562726856570gmail-blob-code-inner m_-7937008281402793648m_-1621987562726856570gmail-js-file-line" style="box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;overflow:visible;font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap"><span class="m_-7937008281402793648m_-1621987562726856570gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">var</span> obj <span class="m_-7937008281402793648m_-1621987562726856570gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> {};</td>
                              </tr>
                              <tr style="box-sizing:border-box">
                                <td id="m_-7937008281402793648m_-1621987562726856570gmail-file-gistfile1-js-LC2" class="m_-7937008281402793648m_-1621987562726856570gmail-blob-code m_-7937008281402793648m_-1621987562726856570gmail-blob-code-inner m_-7937008281402793648m_-1621987562726856570gmail-js-file-line" style="box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;overflow:visible;font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap"><span class="m_-7937008281402793648m_-1621987562726856570gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">var</span> proxy <span class="m_-7937008281402793648m_-1621987562726856570gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> <span class="m_-7937008281402793648m_-1621987562726856570gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">new</span> <span class="m_-7937008281402793648m_-1621987562726856570gmail-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Proxy</span>(obj, {});</td>
                              </tr>
                              <tr style="box-sizing:border-box">
                                <td id="m_-7937008281402793648m_-1621987562726856570gmail-file-gistfile1-js-LC3" class="m_-7937008281402793648m_-1621987562726856570gmail-blob-code m_-7937008281402793648m_-1621987562726856570gmail-blob-code-inner m_-7937008281402793648m_-1621987562726856570gmail-js-file-line" style="box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;overflow:visible;font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap">obj <span class="m_-7937008281402793648m_-1621987562726856570gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">==</span> proxy; <span class="m_-7937008281402793648m_-1621987562726856570gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_-7937008281402793648m_-1621987562726856570gmail-pl-c" style="box-sizing:border-box">//</span> false</span></td>
                              </tr>
                            </tbody>
                          </table>
                        </div>
                        <div><br>
                        </div>
                        <div><b>Isn't the purpose of the proxy to
                            beexchanged with the original</b><b>,
                            without any negative side effects? </b>Maybe
                          that's not the intended use case, but it's a
                          useful one. And, besides the comparison, I
                          can't think of any other "negative side
                          effects".</div>
                        <div><b><br>
                          </b></div>
                        <div>It seems like the Proxy could have a <b>comparison
                            trap</b>. The comparison could pass by
                          default, and you could use the trap if you
                          wanted to make `proxy == obj` fail.</div>
                        <div><br>
                        </div>
                        <div>Also, a slight tangent: it would be awesome
                          if you could <b>skip debugging proxy
                            trapswhen stepping through code. </b>When
                          you proxy both `get` and `apply` for all
                          objects/methods, you have 10x the work when
                          trying to step through your code.</div>
                        <div><br>
                        </div>
                        <div>I just subscribed to this list. Is this an
                          appropriate venue for this type of inquiry? I
                          appreciate any feedback.</div>
                        <div><br>
                        </div>
                        <div><br>
                        </div>
                        <div><br>
                        </div>
                        <div>Thanks!</div>
                        <span class="m_-7937008281402793648HOEnZb"><font
                            color="#888888">
                            <div><br>
                            </div>
                            <div>Michael</div>
                            <div><br>
                            </div>
                            <div></div>
                          </font></span></div>
                      <br>
                    </div>
                  </div>
                  ______________________________<wbr>_________________<br>
                  es-discuss mailing list<br>
                  <a moz-do-not-send="true"
                    href="mailto:es-discuss@mozilla.org" target="_blank">es-discuss@mozilla.org</a><br>
                  <a moz-do-not-send="true"
                    href="https://mail.mozilla.org/listinfo/es-discuss"
                    rel="noreferrer" target="_blank">https://mail.mozilla.org/listi<wbr>nfo/es-discuss</a><br>
                  <br>
                </blockquote>
              </div>
              <br>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
es-discuss mailing list
<a class="moz-txt-link-abbreviated" href="mailto:es-discuss@mozilla.org">es-discuss@mozilla.org</a>
<a class="moz-txt-link-freetext" href="https://mail.mozilla.org/listinfo/es-discuss">https://mail.mozilla.org/listinfo/es-discuss</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Michael Kriegel  Head of R&D  Actifsource AG  Haldenstrasse 1  CH-6340 Baar  <a class="moz-txt-link-abbreviated" href="http://www.actifsource.com">www.actifsource.com</a>  +41 56 250 40 02</pre>
  </body>
</html>