>> function Point(x, y) { >> this.{x,y}; >> } > > Ok, maybe. But > > >> function Monster(name) { >> this.{ >> name: name, > > just name here should do, not name: name -- right?
Ah, I thought one couldn’t mix the key-value form and the value-less syntactic sugar. But it makes sense to allow that. >> @strength: 10, >> @age: 0 >> }; >> } > > Someone had to declare private strength, age; first. Correct, implied. I was too lazy to look up the import statement, but actually, object literals should have a “private” section, too. And one could allow these sections anywhere. >> // namespace exists in multiple files (possibly less relevant with modules) >> namespace.{ >> function1() { >> }, >> function2() { >> } >> } > > This caused a double-take because of the leading 'function' names > distinguished only by trailing "1" vs "2". There is something to the > complaints about method definition syntax being too terse in certain > applications. Just changing to method1 and method2 helps, though. Right, they are technically methods, but “semantically” functions. > Maybe that's part of the whole Grawlix thing. o.{m(){}} vs. Object.extend(o, > {m: function(){}}). The latter is JS we've known for many years. Here is what it looks like with .= (I still think it’s intuitive, even though its functionality goes beyond mere batch property assignments). function Point(x, y) { this .= {x,y}; } // namespace exists in multiple files (possibly less relevant with modules) namespace .= { func1() { }, func2() { } } // Allow anywhere: syntactic sugar for // module name from "@name"; // let strength = name.create(), age = name.create(); private { strength, age } function Monster(name) { this .= { name, @strength: 10, @age: 0 }; } Unexpectedly, the classic constructor pattern plus .{, <|, super, and abbreviated method syntax is now my favorite class pattern. -- Dr. Axel Rauschmayer a...@rauschma.de home: rauschma.de twitter: twitter.com/rauschma blog: 2ality.com _______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss