Alternative syntax for <|
Brendan Eich
brendan at mozilla.com
Wed Nov 16 11:16:55 PST 2011
On Nov 16, 2011, at 11:12 AM, 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.
Allen suggested classes can't hoist here:
https://mail.mozilla.org/pipermail/es-discuss/2011-August/016212.html
Quoting:
Let me try a more carefully constructed example:
class First() {
class:
partner = (new Second).getPartner();
competitor = (new Second).getCompetitor();
}
class Second() {
constructor() {
this.getCompetitor = function() {/*whatever*/*}
}
getPartner() {/*whatever*/}}
}
which viewed using the obvious desugaring with hosting ould presumably be:
function First() {}
function Second() {ihis.getCompetitor = function() {/*whatever*/*}}
...
First.partner = (new Second).getPartner(); //but getPartner is not defined yet
First. competitor = (new Second).getCompetitor(); //but getCompetitor is ok
Second.prototype.getPartner = function() {/*whatever*/}}
Hosting of function works for resolving references from within function bodies. But individual property initialization expressions for a class are evaluated in order and can have order dependencies. Function declarations don't have any corresponding parts that expose such dependencies but classes do. Hosting does not eliminate those dependencies.
----
This may seem to rely on class ("static") properties, but we want to be future-proof even if classes don't support those at first.
/be
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111116/f6fd0d90/attachment.html>
More information about the es-discuss
mailing list