Fwd: Alternative syntax for <|

Dmitry Soshnikov dmitry.soshnikov at gmail.com
Wed Nov 16 11:27:14 PST 2011


On 16.11.2011 23:19, Quildreen Motta wrote:
> But with `var', only the declaration is hoisted, the actual assignment 
> is not. Such that:
>
> var point3d = extends point { z: 1 }
> var point = { x: 1, y : 1 }
>
>

Right, but I used declarative form, w/o assignment:

var point3d extends point { z: 1}

OTOH, an expression (yours example w/ assignment) will be eval'ed in the 
runtime, yes.

P.S.: Kh-mm... but how the declarative form can eval the block on 
entering the context if the block contains some complex data? .. it 
means all the data should be defined already anyway.

E.g.:

var point3D extends point { z: calculate(); }

calculate should be defined and the execution is made in the runtime, 
i.e. again, just `var' is hoisted. But, it seems OK -- the same as with 
classes.

Dmitry.

> Would still fail, as far as I know, whereas:
>
> class point3d extends point { z: 1 }
> class point { x: 1, y: 1 }
>
> Should work, if class is hoisted.
>
>
> 2011/11/16 Dmitry Soshnikov <dmitry.soshnikov at gmail.com 
> <mailto:dmitry.soshnikov at gmail.com>>
>
>     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
>     es-discuss at mozilla.org <mailto:es-discuss at mozilla.org>
>     https://mail.mozilla.org/listinfo/es-discuss
>
>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111116/7455c54b/attachment.html>


More information about the es-discuss mailing list