Alternative syntax for <|

Brendan Eich brendan at
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:


Let me try a more carefully constructed example:

class First() {
  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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list