On 16.11.2011 23:53, Rick Waldron wrote:


On Wed, Nov 16, 2011 at 2:34 PM, Dmitry Soshnikov <[email protected] <mailto:[email protected]>> wrote:

    But why do we need new keyword?


The discussion originated around how ugly <| is; an infix operator keyword is easier to introduce into the language then an infix operator made of symbols


Yes, I understand, but it doesn't answer the question -- why do we need _additional_ keyword if to represent e.g. like this:

// declaration

var foo extends bar {
  x: 100
}

// or via expression:

var foo = extends (debug ? bar { x: 100 } : baz { y : 200});

// or even
var foo = extends (debug ? bar : baz) {x : 100}

Anyway, forms with assignment are additions. The main part which I notice is the declarative form. Once again, a good thing is that we have the same syntactic form for defining/inhering simple objects and classes (only var/let and class keywords change).

Dmitry.


    Actually, I can accept a new keyword in case if reasons will
    really be serious. But in this case -- `extends' may fit quite nice.


See: https://mail.mozilla.org/pipermail/es-discuss/2011-October/017775.html

I believe I saw this discussion; it doesn't explain also why we can't do as I showed above (i.e. the declarative form with correct placemend of `extends').


    P.S.: In general, it's just funny picture. Somehow ES4 made nice
    classes with nice syntax. Why (Why Y NO?) now we invent some scary
    things such as const Point = Point <|
    {}.constructor.{}.prototype{}. Just... why? What has happened with
    syntax idea even from ES4?


By the way, the question is still open and I'll be glad to hear at least small historical note on it.

P.S.: on <| -- speaking the truth I don't think it's ugly. Well, perhaps maybe I use to Ruby's < inheritance op. Maybe it's just "pipe part" | of it is ugly? :P

Dmitry.


    On 16.11.2011 23:31, Rick Waldron wrote:
    As stated previously[1], my support for "begets" as pure win is
    unwavering.


    Rick

    [1]
    https://mail.mozilla.org/pipermail/es-discuss/2011-October/017758.html




    On Wed, Nov 16, 2011 at 2:16 PM, Dmitry Soshnikov
    <[email protected] <mailto:[email protected]>>
    wrote:

        On 16.11.2011 23:12, Erik Arvidsson wrote:

            One thing that all of these discussions are missing is
            the hoisting
            property of function and any possible future classes. If
            we use "let
            Point = ..." we lose all hoisting and the order of your
            declarations
            starts to matter and we will end up in the C mess where
            forward
            references do not work.

        No matter, we may rewrite it with `var':

        // parent object
        var point = {x: 10, y: 20};

        // child object
        var point3D extends point {

         z: 30
        }

        // a class
        class Point3D extends Point {
         constructor (x, y, z) { ... }
        }

        It seems interesting for me, since we define both -- child
        classes and child objects with the same syntactic
        construction; only `var' and `class' keywords change.

        Dmitry.

        _______________________________________________
        es-discuss mailing list
        [email protected] <mailto:[email protected]>
        https://mail.mozilla.org/listinfo/es-discuss





_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to