Last followup for tonight: $ git diff diff --git a/minimalist-classes.js b/minimalist-classes.js index 7d8195e..d6bdab2 100644 --- a/minimalist-classes.js +++ b/minimalist-classes.js @@ -212,9 +212,9 @@ class Monster { public flair, // you should have 37 pieces of public flair - constructor(name, health) { - @name = name; - @health = health; + // Yes, shorthand for @name = name given formal param name, etc. -- just as + // in CoffeeScript! + constructor(@name, @health) { @flair = 0; } $ git commit -a -m"constructor(@foo) shorthand." [master 7d1228f] constructor(@foo) shorthand. 1 files changed, 3 insertions(+), 3 deletions(-)
/be On Nov 2, 2011, at 7:02 PM, Brendan Eich wrote: > On Nov 2, 2011, at 7:00 PM, Brendan Eich wrote: > >> Updated: https://gist.github.com/1332193 >> >> $ git commit -a -m"Updates per conversations with @dflanagan and @allenwb." >> >> git diff output below. Exec. summary: prefix groups via { ... } and public >> @-namespace population to avoid "this." sad-making verbosity. >> >> /be >> >> diff --git a/minimalist-classes.js b/minimalist-classes.js >> index 18a7a8c..6f25144 100644 >> --- a/minimalist-classes.js >> +++ b/minimalist-classes.js >> @@ -188,8 +188,11 @@ class Monster { >> // See the new sameName method for an example of infix and prefix @ in >> action. >> // >> // David Flanagan suggests keeping the unary-prefix @foo shorthand, but >> making >> -// the long-hand obj.@foo. Breaks E4X but no matter -- I'm open to it, but >> it >> -// is not essential to bikeshed here. >> +// the long-hand obj.@foo. Breaks E4X but no matter -- but the win is that >> the >> +// [no LineTerminator here] restriction on the left of unary-prefix @ is not >> +// needed. Also the references don't grep like email addresses, which counts >> +// with David and me. So I've incorporated David's suggestion. See >> other.@name >> +// etc. below. >> // >> // There is no const instance variable declaration. Non-writable instance >> vars >> // (properties to most people) are quite rare. Use ES5's >> Object.defineProperty >> @@ -203,15 +206,17 @@ class Monster { >> >> class Monster { >> >> - private name, health; >> + private { name, health }, // can group a prefix, same for const and static >> + public flair, // you should have 37 pieces of public flair >> >> constructor(name, health) { >> @name = name; >> @health = health; >> + @flair = 0; >> } >> >> sameName(other) { >> - return @name === other@name; >> + return @name === other.@name; >> } >> >> private attackHelper(target) { >> > > Quick followup: > > $ git diff > diff --git a/minimalist-classes.js b/minimalist-classes.js > index 6f25144..7d8195e 100644 > --- a/minimalist-classes.js > +++ b/minimalist-classes.js > @@ -206,7 +206,10 @@ class Monster { > > class Monster { > > - private { name, health }, // can group a prefix, same for const and static > + private { name, health } // can group a prefix, same for const and static > + // note comma optional after closing brace, as > for > + // method definitions > + > public flair, // you should have 37 pieces of public flair > > constructor(name, health) { > $ git commit -a -m"More comma elision." > [master 4f47332] More comma elision. > 1 files changed, 4 insertions(+), 1 deletions(-) > > /be > >> On Nov 1, 2011, at 6:56 PM, Brendan Eich wrote: >> >>> On Nov 1, 2011, at 5:18 PM, Brendan Eich wrote: >>> >>>> On Oct 31, 2011, at 6:57 PM, Jeremy Ashkenas wrote: >>>> >>>>> 'Evening, ES-Discuss. >>>>> >>>>> After poking a stick in the bees' nest this morning (apologies, Allen), >>>>> and in the spirit of loyal opposition, it's only fair that I throw my hat >>>>> in the ring. >>>>> >>>>> Here is a proposal for minimalist JavaScript classes that enable behavior >>>>> that JavaScripters today desire (as evidenced by libraries and languages >>>>> galore), without adding any new semantics beyond what already exists in >>>>> ES3. >>>>> >>>>> https://gist.github.com/1329619 >>>>> >>>>> Let me know what you think, and feel free to fork. >>>> >>>> Thanks, I did fork, and I made a Rich Corinthian Leather version, for the >>>> reasons given in the comments. In brief, I contend that over-minimizing >>>> will please no one: class haters still gonna hate, while class lovers used >>>> to batteries-and-leather-included will find the bare sheet metal poky and >>>> painful. >>>> >>>> Love it or hate it, I'm ok either way :-P. But I do crave intelligent >>>> responses. >>> >>> Handy link included: https://gist.github.com/1332193 >>> >>> /be >>> >>> _______________________________________________ >>> es-discuss mailing list >>> es-discuss@mozilla.org >>> https://mail.mozilla.org/listinfo/es-discuss >> >> _______________________________________________ >> es-discuss mailing list >> es-discuss@mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss > > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss