<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    On 13.06.2011 1:18, Brendan Eich wrote:
    <blockquote
      cite="mid:1501B6F7-EEB2-4A7A-94C0-6D7B04C01C1C@mozilla.com"
      type="cite">
      <div>
        <div>On Jun 12, 2011, at 2:22 AM, Irakli Gozalishvili wrote:</div>
        <br class="Apple-interchange-newline">
        <blockquote type="cite">
          <div>
            <div> <span>Hi,</span></div>
            <div><span><br>
              </span><span>Is there anything else (other than starting
                this thread) I can do to make committee consider
                `Function.prototype.extend` as an alternative to a
                proposed class sugar ?   <br>
              </span></div>
          </div>
        </blockquote>
        <div><br>
        </div>
        Could you show Function.prototype.extend again, and say how it
        solves the super-construct and super-method-call problems?</div>
      <div><br>
      </div>
    </blockquote>
    <br>
    If interested, I know at least three versions of normal `super`
    sugar in ES3 code:<br>
    <br>
    1. using wrappers for every descendant method with the same name
    (the technique is to (a) set `this.super` to parent, (b) activate
    parent method and get result, (c) return result to child)<br>
    <br>
    2. using `Object.prototype` to store `super`<br>
    <br>
    3. using `arguments.caller` (banned in ES5-strict, non-standard in
    ES3, but I normally used it in my projects)<br>
    <br>
    If will be needed, I can write the code for all three techniques
    (the later though can be found here:
    <a class="moz-txt-link-freetext" href="https://github.com/DmitrySoshnikov/def.js/blob/master/def.js#L80">https://github.com/DmitrySoshnikov/def.js/blob/master/def.js#L80</a><br>
    <br>
    That is, it's not actually the main issue, we normally can write in
    ES3/5 code something like this:<br>
    <br>
    var Foo = Class({<br>
      constructor: function (a) {<br>
        this.a = a;<br>
      },<br>
      activate: function () {<br>
        return this.a;<br>
      }<br>
    });<br>
    <br>
    var Bar = Class({<br>
      constructor: function (a, b) {<br>
        this.super(a);<br>
        this.b = b;<br>
      },<br>
      activate: function () {<br>
        console.log(this.b + this.super());<br>
      }<br>
    });<br>
    <br>
    var bar = new Bar(10, 20);<br>
    bar.activate(); // 30!<br>
    <br>
    P.S.: of course this.super() is much more convenient than (real code
    from e.g. ExtJS) `Bar.superclass.constructor.apply(this, arguments)`
    (what? are you kidding me, guys? Seems you just like syntactic
    noise). But unfortunately because of hack-nature (`caller` is
    not-standard and banned, people afraid to augment
    `Object.prototype`, wrappers are not so efficient), so it's not e.g.
    for cross-browser code. Though, I was pleased to use it in my
    library in the project where I had SpiderMonkey-only stuff (patched
    Thunderbird), so there I used that `this.super` actively (OK,
    actually `this._super`, because only since ES5 we can use keywords
    as properties).<br>
    <br>
    However, regardless that we _can_ implement convinient and sugared
    super calls as a library, classes from the box will be more
    convenient IMO.<br>
    <br>
    Dmitry.<br>
    <br>
    <blockquote
      cite="mid:1501B6F7-EEB2-4A7A-94C0-6D7B04C01C1C@mozilla.com"
      type="cite">
      <div>/be</div>
      <div><br>
        <blockquote type="cite">
          <div>
            <div><span><br clear="all">
                Thanks<br>
                <span style="color: rgb(153, 153, 153);">--</span><br
                  style="color: rgb(153, 153, 153);">
                <span style="color: rgb(153, 153, 153);">Irakli
                  Gozalishvili</span><br style="color: rgb(153, 153,
                  153);">
                <span style="color: rgb(153, 153, 153);">Web: <a
                    moz-do-not-send="true" style="color: rgb(153, 153,
                    153);" href="http://www.jeditoolkit.com/"
                    target="_blank">http://www.jeditoolkit.com/</a></span><br
                  style="color: rgb(153, 153, 153);">
                <span style="color: rgb(153, 153, 153);"></span><span
                  style="color: rgb(153, 153, 153);">Address: <a
                    moz-do-not-send="true"
                    href="http://goo.gl/maps/3CHu" target="_blank">29
                    Rue Saint-Georges, 75009 Paris, France</a></span><br>
                <br>
              </span>
              <p style="color: rgb(160, 160, 160);">On Tuesday,
                2011-05-24 at 24:48 , Brendan Eich wrote:</p>
              <blockquote type="cite" style="border-left-style: solid;
                border-width: 1px; margin-left: 0px; padding-left:
                10px;"> <span>
                  <div>
                    <div>
                      <div>
                        <div>On May 23, 2011, at 11:25 AM, Bob Nystrom
                          wrote:</div>
                        <br>
                        <blockquote type="cite">
                          <div>
                            <div>
                              <div>
                                <div>One thing I'd like the proposal to
                                  support, which it doesn't currently,
                                  is initializers on instance property
                                  declarations. Then you could do:</div>
                                <div><br>
                                </div>
                              </div>
                            </div>
                            <blockquote type="cite">
                              <div>
                                <div>
                                  <div>
                                    <div><font face="'courier new',
                                        monospace">class C {</font></div>
                                  </div>
                                </div>
                                <div>
                                  <div>
                                    <div><font face="'courier new',
                                        monospace">  public _list = [];</font></div>
                                  </div>
                                </div>
                                <div>
                                  <div>
                                    <div>
                                      <font face="'courier new',
                                        monospace">}</font></div>
                                  </div>
                                </div>
                              </div>
                            </blockquote>
                            <div>
                              <div>
                                <div><br>
                                </div>
                                <div>With that, you'll correctly get a
                                  new <font face="'courier new',
                                    monospace">_list</font> on each
                                  instance of C when it's created.</div>
                              </div>
                            </div>
                          </div>
                        </blockquote>
                        <br>
                      </div>
                      <div>But (we've argued, I forget where so
                        repeating it here), this looks like [] is
                        evaluated once when the class declaration is
                        evaluated. That is not what you intend.</div>
                      <div><br>
                      </div>
                      <div>Then at some point (in the last thread on
                        this) I remembered parameter default values, but
                        they cover only missing parameters to the
                        constructor. This _list member could be private.
                        But it has to be initialized in a body that
                        executes once per instantiation, which is not
                        the class body -- it's the constructor body.</div>
                      <div><br>
                      </div>
                      <div>/be</div>
                      <br>
                    </div>
                    <div>_______________________________________________<br>
                      es-discuss mailing list<br>
                      <a moz-do-not-send="true"
                        href="mailto:es-discuss@mozilla.org">es-discuss@mozilla.org</a><br>
                      <a moz-do-not-send="true"
                        href="https://mail.mozilla.org/listinfo/es-discuss">https://mail.mozilla.org/listinfo/es-discuss</a><br>
                    </div>
                  </div>
                </span> </blockquote>
              <div> <br>
              </div>
            </div>
          </div>
          _______________________________________________<br>
          es-discuss mailing list<br>
          <a moz-do-not-send="true" href="mailto:es-discuss@mozilla.org">es-discuss@mozilla.org</a><br>
          <a class="moz-txt-link-freetext" href="https://mail.mozilla.org/listinfo/es-discuss">https://mail.mozilla.org/listinfo/es-discuss</a><br>
        </blockquote>
      </div>
      <br>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
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>
  </body>
</html>