On Tue, Mar 20, 2012 at 2:09 PM, Rick Waldron <[email protected]>wrote:
> [ ... snip ]
>
>> class Animal {
>>>
>>> constructor(name){
>>>
>>> this.name = name;
>>>
>>> }
>>>
>>> move(meters){
>>>
>>> alert(this.name + " moved " + meters + "m.");
>>>
>>> }
>>>
>>> }
>>>
>>
> Russ,
>
> I'm trying to write up some supporting examples, but ran into a snag
> regarding "static" properties. eg
>
> function Foo( stuff ) {
> this.stuff = stuff || "";
> }
>
> Foo.prototype.getStuff = function() {
> return this.stuff;
> };
>
> Foo.Bar = function() {
> return new Foo("bar");
> };
>
>
> How would I make Foo.Bar ?
>
In my opinion, because it is a point of contention, there should be no
special support for statics. It would be written exactly as you have it
above, or you could do
Foo.{
Bar() {
return new Foo("bar");
}
//potentially more here
};
I will reiterate the goal here of a *safety syntax*. Right now, my goal is
to just get some agreement on a class syntax where the future options are
open in case we can't find something better. I would still be happy to use
my minimal proposed class syntax because it gets past the hard part and
nails the 80% of code that's annoying. Some support for statics could be
added later if agreed upon but I'd hate to see it stop classes from
happening.
- Russ
>
>
> Rick
>
>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss