.
Had we adopting it into ES5, it would have this meaning clearly. It may still
be a good idea, but consider the new complexity. Now the second form also
causes an early error on old ES5 browsers, where the script might otherwise
have been able to run strictly.
--
Dr. Axel Rauschmayer
?
The former is part of Crockford’s proposal [1]. The latter is very useful
indeed.
[1] http://wiki.ecmascript.org/doku.php?id=strawman:default_operator
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
something similar).
TODO: This method probably makes more sense as an iterator (e.g. implemented
via a generator). Then one could even omit the upper limit and produce an
unlimited sequence.
[1] http://wiki.ecmascript.org/doku.php?id=harmony:array_comprehensions
--
Dr. Axel Rauschmayer
}) - 0, 3, 6, 9, ...
Array.range({ start: -2, step: -1 }) - -2, -3, -4, -5, ...
etc.
The defaults of start and end and the comparison operator depend on the sign of
step.
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
, Jan 3, 2012 at 11:42 AM, Axel Rauschmayer a...@rauschma.de wrote:
I think it's fairly common for range implementations to provide an optional
`step` parameter
Good point. Maybe all of these parameters should be options:
Array.range() - 0, 1, 2, 3, ...
Array.range({ start: 3 }) - 3, 4, 5
obsoleting for-in
in favor of for-of.
That would be some kind of iteration protocol(?) I’d be perfectly happy with
not supporting for-in at all.
I was thinking about the relational operator `in`:
if (key in myMap) {
...
}
if (element in mySet) {
...
}
--
Dr. Axel
as the following code:
String.prototype.until = function (needle) {
return this.substr(0, this.indexOf(needle));
}
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
___
es-discuss mailing list
es
.
On Mon, Jan 2, 2012 at 11:55, Axel Rauschmayer a...@rauschma.de wrote:
Isn’t that usually better handled via a regular expression?
One of the use cases for quasis [1][2] is to make it easy to insert literal
text into a regular expression. That seems pertinent here. Example:
re`\d
= len * times;
for(var i = 0; i resultLen; i++) {
result.push(this[i % len]);
}
return result;
}
In use:
$ [1,2,3].repeat(3)
[ 1, 2, 3, 1, 2, 3, 1, 2, 3 ]
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com
, number, string for primitive values
- [[Class]] for objects (String, Date, etc.)
--
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
? in JavaScript, because it wouldn’t clash with the
conditional operator in JavaScript (which CoffeeScript doesn’t need, due to its
functional if statement). Then the thing to add to the proposal would be ??
used as a unary postfix operator:
if (x??) ...
Prefix might work, too.
--
Dr. Axel
)?
--
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
});
Alternative: wrap a function around define(), make define a parameter, perform
the (same!) check when immediately-invoking the function.
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
such as
`exists`. Furthermore, it might be more consistent with
value ?? default
to make ?? a postfix operator, but I can’t judge the grammatical implications
of that.
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
(exists globalUnknown); // false
// undefined and null in several variations
var myvar;
console.log(exists myvar); // false
console.log(exists undefined); // false
console.log(exists null); // false
var obj = {};
console.log(exists obj.prop); // false
--
Dr. Axel
property is
accessed.
--
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
of ES6
goodies such as destructuring or spread/rest.
I’m not entirely sure, but introducing two new dialects (ES5.5 and ES6, if you
will) at the same time seems problematic. It might be easier to stick to the
simpler rule of “global = ES5”.
Apart from that: sold.
--
Dr. Axel Rauschmayer
such the #5 getTypeName() could take care of use
case #4, as well.
Ideas for getTypeName(): http://www.2ality.com/2011/11/improving-typeof.html
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
___
es
://jsfiddle.net/xavierm02/exwtg/
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
.)
--
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
/sequences-20070301.pdf
- Programming languages with collection APIs (among many others): Smalltalk,
Java
- Guava
http://code.google.com/p/guava-libraries/
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
to standardize simple guard methods now, for example:
function foo(x) {
Object.guard(x, Number);
}
Advantages: Helps tools (to infer types, to generate documentation), can later
be refactored to real guards.
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter
seems hard, and
3) we'd like to avoid yet more under-specification. The similar
under-specification of Array.prototype.sort is already bad enough.
On Tue, Dec 27, 2011 at 7:22 AM, Axel Rauschmayer a...@rauschma.de wrote:
http://wiki.ecmascript.org/doku.php?id=harmony:simple_maps_and_sets
It’d be nice if stack traces were standardized. Are there any plans to do so?
The following project could be used for shims:
http://stacktracejs.org/
Axel
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
. That’s a part of it I really like.
--
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
= function() {
console.log(hi!);
};
window.addEventListener('load', {||
this.foo(); // hi!
}, false);
http://wiki.ecmascript.org/doku.php?id=strawman:block_lambda_revival#semantics
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
simply like
their way of thinking about object-orientation.
--
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
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
___
es-discuss mailing list
es-discuss
On Dec 28, 2011, at 17:13 , John J Barton wrote:
Doesn't Object.keys() solve this problem?
For getting elements, yes. For setting, the problem with the illegal own
property name __proto__ remains.
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog
Node packages use the module, it would give Node committers
a way to scan the package.json info to find out if define() use is
used enough to warrant consideration in their core.
I’m still examining all available, but eventually a campaign might be in order.
--
Dr. Axel Rauschmayer
http://wiki.ecmascript.org/doku.php?id=harmony:simple_maps_and_sets
Currently, using Object.is() is hard-coded. But one could allow a comparator
function being handed in (with Object.is being the default).
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com
. 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
= F.apply(null, A.map(require)) } }).
define([ ./module1, ./module2 ],
function (module1, module2) {
return ...
}
);
[1] http://www.2ality.com/2011/11/module-gap.html
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog
by F() over to exports). But I am
focusing on Node.js, at the moment, so I can afford to rely on this
functionality.
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
___
es-discuss mailing list
...succeeded, then it did.
As an aside, one benefit of the above boilerplate is that it is just a prefix
(easier to copy and paste than solutions that are wrapped around an AMD).
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
Is there a list somewhere of ECMAScript.next features that have already been
implemented in Firefox?
Thanks!
Axel
--
Dr. Axel Rauschmayer
a...@rauschma.de
twitter.com/rauschma
Home: rauschma.de
Blog: 2ality.com
___
es-discuss mailing list
es
the harmony flag? ( http://codereview.chromium.org/9008031 )
On Sun, Dec 25, 2011 at 9:31 AM, Axel Rauschmayer a...@rauschma.de wrote:
Is there a list somewhere of ECMAScript.next features that have already been
implemented in Firefox?
Thanks!
Axel
--
Dr. Axel Rauschmayer
I would love to have something like Python’s locals():
http://docs.python.org/py3k/library/functions.html#locals
It would not allow modifications, but it would still be very useful.
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
Math.log(x) / Math.log(b);
}
Have they been considered and rejected?
--
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
/what-is-a-polyfill/
...I still don't understand how it differs from shim
--
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
?
Axel
--
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
is a big thing to ignore.] Sect. 3 of
[1] argues that point and gives several code examples.
[1] http://www.2ality.com/2011/06/prototypes-as-classes.html
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
to detect via static analysis.
= Can forbid non-method properties in prototypes.
--
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
Sorry I don't understand the question, or how it is related to my
quest.
I would argue that your quest can be fulfilled by class declarations that
desugar to object exemplars. Do you agree?
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog
a class declaration will desugar to something. And desugaring to an
object exemplar is more elegant than desugaring to a function exemplar.
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
, but it’s probably too late
for that, because this approach has become standard.
--
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
, ...) from working.
--
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
prototype to avoid the
longish “the value of the prototype property of the constructor”. But that’s
confusing! It’ll get worse should constructors become prototypes of each other
in the future.
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog
,
though.
I can even imagine class declarations being used as syntactic sugar for object
exemplars.
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
___
es-discuss mailing list
es-discuss
an object exemplar
y: 0,
new(x,y) {
this.x = x;
this.y=y;
}
};
--
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
):
http://www.mail-archive.com/es-discuss@mozilla.org/msg11194.html
Axel
--
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
-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
--
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
that has been rejected before (and is taken by the for
loop).
obj of { foo: 12 } of { bar: 13 } of { baz: 17 }
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
___
es-discuss mailing
decisions. Such a library is such a core element of a
programming language that we should have a good one as soon as possible. The
same holds for other utility functionality (IMHO, ES.next is still too frugal
in this department).
Axel
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
there shouldn’t be any surprise that it looks
like many things that we have seen already.
“Once again” also sounds impolite, but maybe that’s just me.
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
there shouldn’t be any surprise that it
looks like many things that we have seen already.
I’m might be wrong about that, though, but using | in the extended manner that
he shows has been proposed before.
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog
[cc-ing es-discuss again]
On Nov 17, 2011, at 14:20 , Russell Leggett wrote:
On Thu, Nov 17, 2011 at 6:17 AM, Axel Rauschmayer a...@rauschma.de wrote:
obj with { foo: 12 } with { bar: 13 } with { baz: 17 }
I like the idea! As it is syntactically different in this role, errors should
-speaking programmers!).
Going from
P --has-prototype-- o
to
P --has-instance-- o
is fine with me, but it’s not the directionality of [[Prototype]].
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
the semantics of this would be. Are you inventing
multiple-prototype inheritance? That's not going to happen.
Single inheritance, a prototype chain composed from the given objects, in the
given order. An infix operator is probably better for this, though.
--
Dr. Axel Rauschmayer
a...@rauschma.de
home
be a moot point.
--
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
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
___
es-discuss
FWIW: I’ve created a gist that demonstrates static super references (in the
manner that Allen proposes them).
https://gist.github.com/1367052
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
(whichever it will be) should
be at _least_ much better than all these libs. Including syntactically.
Cheers,
Dmitry.
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
--
Dr. Axel Rauschmayer
` (the object containing the method making a
super-reference). Hence, my solution can handle “holes” in the prototype chain,
Ashkenas’ solution can’t.
But I would not want to use that solution, a static approach is much more
elegant.
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter
It’s not a big deal, just an illustration of Allen’s work.
On Nov 15, 2011, at 15:34 , Dmitry Soshnikov wrote:
On 15.11.2011 18:02, Axel Rauschmayer wrote:
FWIW: I’ve created a gist that demonstrates static super references (in the
manner that Allen proposes them).
https://gist.github.com
Sorry to be petty about this – I suggested it in June:
https://mail.mozilla.org/pipermail/es-discuss/2011-June/015084.html
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
___
es-discuss mailing
Never mind – I misread both Allen’s email and Russel’s gist.
Sorry!
Axel
On Nov 14, 2011, at 21:35 , Axel Rauschmayer wrote:
1. I like the more radical approach (need to ruminate on it more). Usability
remains my concern for classes as sugar (the Cordova edition).
2. Credit to Russell
property instanceof tests a specific
inheritance relationship.
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com
objectExemplar: “turn the `objectExemplar` into a class”
2. class obj: “get the class of obj”
I would give operator #2 the name `classof` and let `class` only return the own
property value of `constructor`.
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog
embarrassed about that. I thought it was about the idea of object
exemplars, but I’ve completely misread both Russell’s gist and Allen’s email.
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
___
es
]
But the description is *not* “determine the constructor function that created
the operand”.
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
___
es-discuss mailing list
es-discuss@mozilla.org
tired):
let Foo = { constructor: function() {} }; // or any valid object exemplar
on the RHS, really
var f = new Foo();
classof f === Foo // true
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
--
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
.
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
___
es-discuss
to have support for a
private section here
function MyClass(stuff) {
this.@private_stuff = stuff; // same as this[private_stuff]
}
MyClass.prototype.method1 = function () {
return this.@private_stuff; // same as this[private_stuff]
}
--
Dr. Axel Rauschmayer
a...@rauschma.de
twitter.com
with Claus Reinke that naming is tricky: Is destructuring assignment
the reverse of invoking a constructor? Is it a desctructor, then? But that
clashes with C++ terminology.
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
| [...values].{
[Array.derivedArrayKey](){return proto| [ ]}
}
}
@derivedArrayKey would normally be in the prototype, right?
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
___
es
as a function, on an existing
instance.
--
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
Person(name) {
this.name = name;
}
Person.prototype . {
describe() {
return Person called +this.name;
}
};
That's a good point -- it preserves .constructor, unlike assigning a fresh
object literal to Person.prototype.
/be
--
Dr. Axel Rauschmayer
] (with k = l-(n+m)) whose
elements are determined via
[a1, ⋯ , an, r1, ⋯, rk, b1, ⋯, bm] = [c1, ⋯, cl]
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
___
es-discuss mailing list
es-discuss
) {
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
? Suggestions for improvements welcome.
--
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
= {|| // note the double pipe
let something;
// |this| is the global object
// ...
return something;
}
With a single expression, you don’t even have to return:
var C = {|| // note the double pipe
foo()
}
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter
as a
function.
True. My bad. It should work if the return is removed.
Related to the discussion:
http://wiki.ecmascript.org/doku.php?id=harmony:completion_reform
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
effort and more power.
--
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
);
SubArray.prototype.pushAll = function() {
Array.prototype.push.apply(this, arguments);
return this;
}
var s = new SubArray().pushAll(3,4,5);
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
___
es
the code below.
function createArraySubclass(proto,...values) {
return proto | [...values].{
[Array.derivedArrayKey](){return proto| [ ]}
}
}
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
= y;
Object.seal(this);
}
Variant 2: allows subtyping, not very pretty.
function Point(x, y) {
this.x = x;
this.y = y;
if (Object.getPrototypeOf(this) === Point.prototype) {
Object.seal(this);
}
}
--
Dr. Axel Rauschmayer
Object.create( Object.getPrototypeOf( this ),
Object.getOwnPropertyDescriptors( this ) );
};
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter
, though: Normally
methods in sub-instances expect the super-instance to be completely
initialized. So performing the super-initialization last is a bit more risky
than performing it first.
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
:
[...r, b0, b1, b2] = arr
means: assign the three last elements of arr to b0, b1, b2 (and assign
everything until these elements to r)
It would be nice if r was optional:
[..., b0, b1, b2] = arr
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog
) {
}
--
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
...@mozilla.com wrote:
On Nov 9, 2011, at 3:48 PM, Axel Rauschmayer wrote:
We talked about lexical this for functions long ago (Jan. 2008? at Google
anyway) and IIRC Mark found a subtler flaw.
I think my original example was smaller and more elegant. But the following
is adequate
the
scope chain.
On Nov 10, 2011, at 15:11 , Andreas Rossberg wrote:
On 10 November 2011 14:49, Axel Rauschmayer a...@rauschma.de wrote:
getX() is designed for a dynamic `this` (i.e. `this` is an instance of
InnerPoint). My proposal would allow an external party to switch to lexical
)
(The hidden parameter is in angle brackets.)
--
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
best keep the two styles apart, perhaps @elementGet
should use Object.setProperty() instead of square braces.
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
___
es-discuss mailing list
es
I've posted a new strawman proposal for the ideas originally discussed in
this thread.
http://wiki.ecmascript.org/doku.php?id=strawman:object_model_reformation
I forgot: +1
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
when not invoked as
methods? It seems like that could work in strict mode where no one expects
`this` to have a value.
--
Dr. Axel Rauschmayer
a...@rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
___
es-discuss mailing
= {
method: func
}
console.log(obj2.method() === obj2); // true, dynamic this overrides lexical
`this`
Sorry for bringing up this issue again, I’m still a bit hazy as to what the
arguments against such a solution are, especially after having seen the
semantics of block lambdas.
--
Dr. Axel
(*) then everyone will automatically do
the right thing in practically all cases. That would be really cool.
(*) I recently heard a story of someone being surprised by seeing the word
“function” in object literals – “Isn’t that supposed to be a method? Why is it
called a function, then?”
--
Dr. Axel
701 - 800 of 1092 matches
Mail list logo