Re: ES6 doesn't need opt-in

2012-01-04 Thread Axel Rauschmayer
. 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

?? operator (was: ES6 doesn't need opt-in)

2012-01-03 Thread 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

Array.range() (was: Suggestion: Array.prototype.repeat)

2012-01-03 Thread Axel Rauschmayer
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

Re: Array.range() (was: Suggestion: Array.prototype.repeat)

2012-01-03 Thread 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

Re: Array.range() (was: Suggestion: Array.prototype.repeat)

2012-01-03 Thread Axel Rauschmayer
, 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

Re: Object Model Reformation – elementIn?

2012-01-02 Thread Axel Rauschmayer
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

Re: String.prototype.until

2012-01-02 Thread Axel Rauschmayer
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

Re: String.prototype.until

2012-01-02 Thread Axel Rauschmayer
. 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

Suggestion: Array.prototype.repeat

2012-01-02 Thread Axel Rauschmayer
= 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

Re: ES6 doesn't need opt-in

2012-01-02 Thread Axel Rauschmayer
, 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

Re: ES6 doesn't need opt-in

2012-01-02 Thread Axel Rauschmayer
? 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

Object Model Reformation – elementIn?

2012-01-01 Thread Axel Rauschmayer
)? -- 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

Re: ES6 doesn't need opt-in

2012-01-01 Thread Axel Rauschmayer
}); 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

Re: ES6 doesn't need opt-in

2012-01-01 Thread Axel Rauschmayer
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

Re: ES6 doesn't need opt-in

2012-01-01 Thread Axel Rauschmayer
(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

Re: ES6 doesn't need opt-in

2012-01-01 Thread Axel Rauschmayer
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

Re: ES6 doesn't need opt-in

2011-12-31 Thread Axel Rauschmayer
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

Re: ES6 doesn't need opt-in

2011-12-31 Thread 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

Re: Sorted arrays

2011-12-30 Thread Axel Rauschmayer
://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

Re: How to clean up __proto__ (was: Why we need to clean up __proto__)

2011-12-29 Thread Axel Rauschmayer
.) -- 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

Re: Simple maps/sets: parameterize the comparator?

2011-12-29 Thread Axel Rauschmayer
/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

Preparing for type guards

2011-12-29 Thread Axel Rauschmayer
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

Re: Simple maps/sets: parameterize the comparator?

2011-12-29 Thread Axel Rauschmayer
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

Standardizing stack straces?

2011-12-29 Thread Axel Rauschmayer
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

Re: Preparing for type guards

2011-12-29 Thread Axel Rauschmayer
. 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

Re: function() {}.bind(this) - this.function(){} ?

2011-12-29 Thread Axel Rauschmayer
= 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

Re: Simple maps/sets: parameterize the comparator?

2011-12-29 Thread Axel Rauschmayer
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

Re: Why we need to clean up __proto__

2011-12-28 Thread Axel Rauschmayer
___ 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

Re: Why we need to clean up __proto__

2011-12-28 Thread Axel Rauschmayer
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

Re: ES5 Module Systems (was: Alternative proposal to privateName.public)

2011-12-27 Thread Axel Rauschmayer
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

Simple maps/sets: parameterize the comparator?

2011-12-27 Thread 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

Confused by Firefox: own property with a descriptor not listed by getOwnPropertyNames()

2011-12-26 Thread Axel Rauschmayer
. 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

Re: Alternative proposal to privateName.public

2011-12-26 Thread Axel Rauschmayer
= 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

Re: ES5 Module Systems (was: Alternative proposal to privateName.public)

2011-12-26 Thread Axel Rauschmayer
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

Re: ES5 Module Systems (was: Alternative proposal to privateName.public)

2011-12-26 Thread Axel Rauschmayer
...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

ECMAScript.next features in Firefox?

2011-12-25 Thread Axel Rauschmayer
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

Re: ECMAScript.next features in Firefox?

2011-12-25 Thread Axel Rauschmayer
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

Re: Have the scope accessible as an object and implement a new with operator / block

2011-12-20 Thread 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

Re: Math: n-th root, logarithm with arbitrary base

2011-12-19 Thread Axel Rauschmayer
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

Re: Versioning?

2011-12-19 Thread Axel Rauschmayer
/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

Math: n-th root, logarithm with arbitrary base

2011-12-18 Thread Axel Rauschmayer
? 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

Re: Property vs Behavior inheritance

2011-12-16 Thread Axel Rauschmayer
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

Re: Property vs Behavior inheritance

2011-12-16 Thread Axel Rauschmayer
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

Re: Property vs Behavior inheritance

2011-12-16 Thread Axel Rauschmayer
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

Re: Property vs Behavior inheritance

2011-12-16 Thread Axel Rauschmayer
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

Reifying References?

2011-12-04 Thread Axel Rauschmayer
, 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

What prevents built-in constructors from being extended?

2011-12-02 Thread Axel Rauschmayer
, ...) 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

Re: motivating | as structure representation, not operator

2011-11-19 Thread Axel Rauschmayer
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

Re: motivating | as structure representation, not operator

2011-11-19 Thread Axel Rauschmayer
, 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

Re: why not new instead of constructor?

2011-11-19 Thread Axel Rauschmayer
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

Re: default this binding for ES-next strict mode.

2011-11-18 Thread Axel Rauschmayer
): 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

Re: default this binding for ES-next strict mode.

2011-11-18 Thread Axel Rauschmayer
-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

Re: with

2011-11-17 Thread Axel Rauschmayer
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

Re: Nov 16 meeting notes

2011-11-17 Thread Axel Rauschmayer
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

Re: with

2011-11-17 Thread Axel Rauschmayer
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

Re: with

2011-11-17 Thread Axel Rauschmayer
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

Re: with

2011-11-17 Thread Axel Rauschmayer
[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

Re: with

2011-11-17 Thread Axel Rauschmayer
-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

Re: with

2011-11-17 Thread Axel Rauschmayer
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

Re: with

2011-11-17 Thread Axel Rauschmayer
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

Re: The class operator: a bridge between object and function exemplers

2011-11-17 Thread Axel Rauschmayer
___ 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

Demo: static super references

2011-11-15 Thread Axel Rauschmayer
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

Re: r-proto-class

2011-11-15 Thread Axel Rauschmayer
(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

Re: r-proto-class

2011-11-15 Thread 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

Re: Demo: static super references

2011-11-15 Thread Axel Rauschmayer
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

Re: The class operator: a bridge between object and function exemplers

2011-11-14 Thread Axel Rauschmayer
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

Re: The class operator: a bridge between object and function exemplers

2011-11-14 Thread Axel Rauschmayer
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

Re: The class operator: a bridge between object and function exemplers

2011-11-14 Thread Axel Rauschmayer
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

Re: The class operator: a bridge between object and function exemplers

2011-11-14 Thread Axel Rauschmayer
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

Re: The class operator: a bridge between object and function exemplers

2011-11-14 Thread Axel Rauschmayer
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

Re: The class operator: a bridge between object and function exemplers

2011-11-14 Thread Axel Rauschmayer
] 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

Re: The class operator: a bridge between object and function exemplers

2011-11-14 Thread Axel Rauschmayer
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

Re: Minimalist (why) classes ?

2011-11-13 Thread Axel Rauschmayer
-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

Re: Minimalist (why) classes ?

2011-11-13 Thread Axel Rauschmayer
. ___ 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

Re: Minimalist (why) classes ?

2011-11-13 Thread Axel Rauschmayer
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

Re: An array destructing specification choice

2011-11-12 Thread Axel Rauschmayer
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

Re: Subclassing an array and array methods

2011-11-12 Thread Axel Rauschmayer
| [...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

Re: Subclassing an array and array methods

2011-11-12 Thread Axel Rauschmayer
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

Re: Using monocle mustache for chaining.

2011-11-12 Thread Axel Rauschmayer
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

Re: An array destructing specification choice

2011-11-12 Thread 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

Re: Using monocle mustache for chaining.

2011-11-12 Thread Axel Rauschmayer
) { 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

Extending constructors with frozen instances

2011-11-12 Thread Axel Rauschmayer
? 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

Re: (Almost) everything is expression

2011-11-11 Thread Axel Rauschmayer
= {|| // 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

Re: (Almost) everything is expression

2011-11-11 Thread Axel Rauschmayer
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

Re: Strawman: Decouple [ ] and property access

2011-11-11 Thread Axel Rauschmayer
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

Re: Subclassing an array and array methods

2011-11-11 Thread Axel Rauschmayer
); 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

Re: Subclassing an array and array methods

2011-11-11 Thread Axel Rauschmayer
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

Preventing instance extension

2011-11-11 Thread Axel Rauschmayer
= 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

Re: Object.getOwnPropertyDescriptors

2011-11-11 Thread 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

Re: Preventing instance extension

2011-11-11 Thread Axel Rauschmayer
, 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

Re: An array destructing specification choice

2011-11-11 Thread Axel Rauschmayer
: [...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

Re: An array destructing specification choice

2011-11-11 Thread Axel Rauschmayer
) { } -- 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

Re: `this`: methods versus functions

2011-11-10 Thread Axel Rauschmayer
...@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

Re: `this`: methods versus functions

2011-11-10 Thread Axel Rauschmayer
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

Re: `this`: methods versus functions

2011-11-10 Thread Axel Rauschmayer
) (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

Re: Strawman: Decouple [ ] and property access

2011-11-10 Thread Axel Rauschmayer
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

Re: Strawman: Decouple [ ] and property access

2011-11-10 Thread Axel Rauschmayer
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

Re: for own(...) loop (spin-off from Re: for..in, hasOwnProperty(), and inheritance)

2011-11-09 Thread Axel Rauschmayer
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

`this`: methods versus functions

2011-11-09 Thread Axel Rauschmayer
= { 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

Re: `this`: methods versus functions

2011-11-09 Thread Axel Rauschmayer
(*) 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

<    3   4   5   6   7   8   9   10   11   >