A few more module questions

2011-04-04 Thread Axel Rauschmayer
: http://www.2ality.com/2011/03/first-look-at-upcoming-javascript.html -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org

Re: A few more module questions

2011-04-04 Thread Axel Rauschmayer
} = ... some expression ...; also binds the identifier |drawShape|. Got it. Makes sense. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org https

Minimal API support for inheritance?

2011-04-04 Thread Axel Rauschmayer
. Object.create() feels like a good start. I’ve tried my hand at a purely prototypal API, but I find it difficult to make the syntax as beautiful as plain object literals. http://www.2ality.com/2011/01/going-completely-prototypal-in.html -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma

Approaching class initializers differently?

2011-04-05 Thread Axel Rauschmayer
of classes in JavaScript. [1] http://wiki.ecmascript.org/doku.php?id=strawman:obj_initialiser_class_abstraction -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es

Re: A few more module questions

2011-04-06 Thread Axel Rauschmayer
list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org https

Re: A few more module questions

2011-04-06 Thread Axel Rauschmayer
globals inside a module are module-relative. Then everything would work out fine. I don't understand this comment. Dave -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss

Dependency injection and modules?

2011-04-10 Thread Axel Rauschmayer
I'm not sure how this would be done best or how useful it would be, but: has dependency injection been considered as a use case for modules (e.g. to swap modules during testing)? One possibility might be to give modules parameters that module clients have to provide. Axel -- Dr. Axel

Setting a property in the prototype chain?

2011-04-10 Thread Axel Rauschmayer
other, e.g. global, reference). -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Setting a property in the prototype chain?

2011-04-10 Thread Axel Rauschmayer
; } On Apr 10, 2011, at 10:24 AM, Axel Rauschmayer wrote: As far as I am aware, there is no way to change a property that isn’t at the beginning of the property chain, because the change will create a new property there. Are there plans to change this? It would be nice to have something

Re: Setting a property in the prototype chain?

2011-04-10 Thread Axel Rauschmayer
it there. Thanks, Axel -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Setting a property in the prototype chain?

2011-04-10 Thread Axel Rauschmayer
. Thus, a better solution would be while (!Object.prototype.hasOwnProperty.call(obj, key)) But I usually prefer David’s more readable version and take the risk of a name clash. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com

Re: Dependency injection and modules?

2011-04-11 Thread Axel Rauschmayer
to use, people don't use them. Yes, I’m all for simplicity. Module loaders do give you the ability to do dependency injection, though, by changing the semantics of module URL's. Right. This should give one everything one needs. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma

Re: Dependency injection and modules?

2011-04-11 Thread Axel Rauschmayer
means? DI is an important issue and I'd like to understand how it is intended to be achieved in the future module system. Module loaders do give you the ability to do dependency injection, though, by changing the semantics of module URL's. -- Dr. Axel Rauschmayer a...@rauschma.de

Re: Setting a property in the prototype chain?

2011-04-11 Thread Axel Rauschmayer
in strict mode and in non-strict mode, as explained in the comment. Thanks! Axel -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org

Re: Setting a property in the prototype chain?

2011-04-12 Thread Axel Rauschmayer
() with more obvious semantics. I try to avoid expert magic when using a programming language and it seems like a shame that this kind of magic is necessary here ( {} and valueOf()). Greetings, Axel -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com

ES5: LexicalEnvironment versus VariableEnvironment?

2011-04-19 Thread Axel Rauschmayer
are highly appreciated. Greetings, Axel -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Best practices for exception handling?

2011-04-29 Thread Axel Rauschmayer
Would it make sense to standardize more exception/error types, for example to add a MissingParameterError in ES.next? -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es

Re: Best practices for exception handling?

2011-04-29 Thread Axel Rauschmayer
motivated by Java having several predefined exceptions with descriptive names that are easy to reuse. With JavaScript, is throwing a string considered bad style (now or in the future)? That is, is throwing a new Error(msg) better than throwing msg directly? Axel -- Dr. Axel Rauschmayer

Re: Function Syntax

2011-05-12 Thread Axel Rauschmayer
must have noticed the variety of opinions on this list alone!). Someone has to make the hard decisions: Fred Brooks says that (the core of) good design can only be done by a team of one (two if one of them is dominant). Axel -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home

Non-method functions and this

2011-05-15 Thread Axel Rauschmayer
. Isn’t (1) a better solution? I’m assuming (2) is done, because (1) would be too radical a change (execution contexts etc.)? (1) could be simulated by always binding |this| in non-method functions, but that isn’t done because of performance issues(?) Thanks! Axel -- Dr. Axel Rauschmayer

Re: Non-method functions and this

2011-05-15 Thread Axel Rauschmayer
an explicit (this = ...) parameter. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Non-method functions and this

2011-05-16 Thread Axel Rauschmayer
): a function that does not have an implicit |this| parameter. Hm, you've lost me... [...] -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org https

Re: Non-method functions and this

2011-05-16 Thread Axel Rauschmayer
meant what you call object reference. Similar to Common Lisp places (setf etc.), I suppose. If you use the conditional operator, you can force the dereferencing of an object reference: (true ? obj.method : null)(arg) -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home

Re: arrow syntax unnecessary and the idea that function is too long

2011-05-17 Thread Axel Rauschmayer
actually want to program in it. This is difficult enough, given all the parties that have to be pleased. Listening to feedback from compiler writers should be a secondary goal. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com

Re: I noted some open issues on Classes with Trait Composition

2011-05-19 Thread Axel Rauschmayer
. Still missing is convenient subtyping The remaining missing functionality is subtyping, but that could be added as an API (let me know if I should give an example, it would look a lot like YUI, but with less impedance mismatch). -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home

Strawman: Object Literal Extensions

2011-05-20 Thread Axel Rauschmayer
= title; } Worker.prototype = Object.create(Person.prototype); Worker.prototype.describe = function() { return Person.prototype.describe.call(this)+ (+this.title+); }; -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com

Re: block lambda revival

2011-05-21 Thread Axel Rauschmayer
for functions)? Thus: are blocks completely different from functions or are they translated to the same construct (internally). I can imagine this being done to make |arguments| lexical, but it seems tricky for handling lexical |this|. Axel -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma

Re: Proposal: Object.defineProperty shorthand

2011-05-31 Thread Axel Rauschmayer
for specifying enumerability. I would prefer something like var foo = { { !conf !enum !write } high_integrity: 42, ... }; Yes, it is more verbose, but also more descriptive. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com

Quasi-literals for templating?

2011-06-12 Thread Axel Rauschmayer
like identifier names are accessible to quasi handlers, which would make this difficult. BTW: “Desugaring” at the beginning of “Semantics” seems mangled. [1] http://api.jquery.com/template Axel -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com

Classes: suggestions for improvement

2011-06-12 Thread Axel Rauschmayer
about the proposal? Is there anything he doesn’t like? Axel -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es

Re: Classes: suggestions for improvement

2011-06-12 Thread Axel Rauschmayer
; } equals(p) { return this.@x === p.@x this.@y === p.@y; } ... } Maybe something like the following would work, too: private.x = x; ... return this.private.x === p.private.x; -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com

Re: es-discuss Digest, Vol 52, Issue 58

2011-06-15 Thread Axel Rauschmayer
. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Classes: suggestions for improvement

2011-06-15 Thread Axel Rauschmayer
to be applied to any object so feel free to take credit. I do agree that this beats inventing a new protocol. Very clever. On Jun 15, 2011, at 8:35 , Brendan Eich wrote: On Jun 14, 2011, at 11:25 PM, Axel Rauschmayer wrote: Cool! That’s what I meant when I wrote the following: From: Axel

Re: Prototypes as the new class declaration

2011-06-15 Thread Axel Rauschmayer
be inherited: const SkinnedMeshExtended = SkinnedMesh | { ... } Then the following class method could also be called: SkinnedMeshExtended.cm() Right? -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es

Re: Quasi-literals for templating?

2011-06-15 Thread Axel Rauschmayer
would be easy. I am assuming that order matters, if not, then there is something fundamental about handler parameters that I haven’t understood. Using jQuery templates to validate template support: good choice, I really like this templating engine. Axel -- Dr. Axel Rauschmayer

Re: Quasi-literals for templating?

2011-06-15 Thread Axel Rauschmayer
two different types, one for literal parts, one for substitutions. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo

Re: Quasi-literals for templating?

2011-06-15 Thread Axel Rauschmayer
Right, I feel stupid: Even though the literal does not really exist as a reified construct (separate from code), the corresponding code can be executed multiple times. On Jun 15, 2011, at 18:04 , Mark S. Miller wrote: On Wed, Jun 15, 2011 at 8:36 AM, Axel Rauschmayer a...@rauschma.de

Re: Quasi-literals for templating?

2011-06-15 Thread Axel Rauschmayer
front. Added http://wiki.ecmascript.org/doku.php?id=harmony:quasis#callsiteid and renamed rawLP and unescapedLP. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es

Re: Quasi-literals for templating?

2011-06-15 Thread Axel Rauschmayer
, Allen Wirfs-Brock al...@wirfs-brock.com wrote: On Jun 15, 2011, at 4:43 PM, Mark S. Miller wrote: On Wed, Jun 15, 2011 at 4:42 PM, Axel Rauschmayer a...@rauschma.de wrote: Ah, very clever. It’d be nice to have an example of using this to compile templates (like jQuery templates). Maybe

Re: Quasi-literals for templating?

2011-06-16 Thread Axel Rauschmayer
]); This is bike-shedding, but I’d also prefer uninterpreted and interpreted instead of raw and cooked. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss

Re: Quasis: assignable substitutions?

2011-06-16 Thread Axel Rauschmayer
the desugaring is local. Axel -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Quasis: assignable substitutions?

2011-06-17 Thread Axel Rauschmayer
Syntax error (in some cases)? On Jun 17, 2011, at 21:38 , Mark S. Miller wrote: On Fri, Jun 17, 2011 at 12:18 PM, Mike Samuel mikesam...@gmail.com wrote: 2011/6/17 Axel Rauschmayer a...@rauschma.de: and redefines the SVE of ${=x.y} to be function () { return arguments.length

Re: Prototypes as the new class declaration

2011-06-18 Thread Axel Rauschmayer
a [[Construct]] internal method that invokes the constructor method, its really just an alternative way to specify the same thing.) -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing

Re: Prototypes as the new class declaration

2011-06-18 Thread Axel Rauschmayer
by Allen: new SkinnedMesh(...) = new SkinnedMesh.constructor(...) However: THREE.Mesh would have to refer to the prototype (similarly to how things are done above), for this to work. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com

Re: Prototypes as the new class declaration

2011-06-19 Thread Axel Rauschmayer
that everything (modulo builtins) works fine if the above assignment is made *somewhere*. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org https

Prototypes as the new class declaration

2011-06-19 Thread Axel Rauschmayer
(especially subclassing). With “prototypes as classes”, a proto operator (such as |) and super, we would have a long-term simplification that to me almost feels like a clarification of what is going on already. Axel -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de

Re: Making super work outside a literal?

2011-06-19 Thread Axel Rauschmayer
have here === this. Axel On Jun 19, 2011, at 19:44 , Peter Michaux wrote: On Sun, Jun 19, 2011 at 10:20 AM, Axel Rauschmayer a...@rauschma.de wrote: It would be nice if super could work in any method and not just those methods that are defined inside an object literal. Then, a method would have

Re: Prototypes as the new class declaration

2011-06-20 Thread Axel Rauschmayer
, such things could still be wired up manually (most likely by somebody wanting to create procedural abstractions for class-like definitions. Are you thinking along the lines of the following example? var MyClass = class({ ... }); -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma

Re: A shorthand for Object.defineProperty?

2011-06-20 Thread Axel Rauschmayer
, then ES.next might even be at the center of a triangle (Java, Smalltalk, Lisp) – which is a good thing. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org

Re: Making super work outside a literal?

2011-06-20 Thread Axel Rauschmayer
day, give us the ability to *set* a property that is not at the beginning of a property chain. For now, programmers would never directly see |here|, only |super|. |super| would be computed on demand, only when someone asks for that value. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com

Making super work outside a literal?

2011-06-20 Thread Axel Rauschmayer
' is not bound dynamically per call site, as 'this' is. It's a hidden property of the function object. /be -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss

Re: A shorthand for Object.defineProperty?

2011-06-20 Thread Axel Rauschmayer
be retasked as keywords, especially not with the name of the function in a function expression optional. Ah, damn, I knew it was a very convincing argument. ;-) There is still the faint hope that this isn’t actually used in practice, but still. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com

Re: A shorthand for Object.defineProperty?

2011-06-20 Thread Axel Rauschmayer
and methods - lexical this -- new, more compact construct, mainly used as the argument of functions and methods. This distinction works well as a rule of thumb and keeps things easy to explain. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com

Re: A shorthand for Object.defineProperty?

2011-06-20 Thread Axel Rauschmayer
to pass in |this| plus property name plus value for properties and be used for all kinds of things. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org

Re: A shorthand for Object.defineProperty?

2011-06-21 Thread Axel Rauschmayer
have |this| parameters, whether created by old function or new arrow syntax. Right. That could be a problem, the abstraction I have in mind might become leaky at some point. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com

Re: Making super work outside a literal?

2011-06-21 Thread Axel Rauschmayer
things) would be a static value, not a dynamic one (unlike |this|). Or (a static) |super| might just be used directly. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es

Re: Making super work outside a literal?

2011-06-21 Thread Axel Rauschmayer
is not used there is little computational cost! (Other than a binding per function call which may still be prohibitive.) -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es

Analog to Object.getPropertyDescriptor() for *changing* a property value?

2011-06-21 Thread Axel Rauschmayer
(obj, propName): http://www.mail-archive.com/es-discuss@mozilla.org/msg06652.html But I can also imagine syntactic sugar: obj.foo := abc desugars to Object.getDefiningObject(obj, foo).foo = abc -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog

Re: A shorthand for Object.defineProperty?

2011-06-21 Thread Axel Rauschmayer
naturally, that would be great. But as that seems impossible, forcing things does not make sense. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org https

Re: Analog to Object.getPropertyDescriptor() for *changing* a property value?

2011-06-21 Thread Axel Rauschmayer
: - Property lookup = returns a place, e.g. a pair (object, property name) - Use the place to either read the property value or to change it. Can’t comment on Proxies, though. On Jun 21, 2011, at 21:36 , Brendan Eich wrote: On Jun 21, 2011, at 8:24 AM, Axel Rauschmayer wrote: As a loose analog

Re: Making super work outside a literal?

2011-06-22 Thread Axel Rauschmayer
=== String.prototype, but this === s. Otherwise String.prototype.trim() could not access the properties of s (such as s.length). -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss

Re: Analog to Object.getPropertyDescriptor() for *changing* a property value?

2011-06-22 Thread Axel Rauschmayer
at the same time: const red = new Color(FF); const green = new Color(00FF00); Color.prototype.getAllColors().forEach(...); But you could also produce the colors with a factory. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com

Re: Making super work outside a literal?

2011-06-22 Thread Axel Rauschmayer
| { foo: function me(x) { me.super.foo.call(this, x); } } Does the named function expression cost nothing here? -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es

Re: Analog to Object.getPropertyDescriptor() for *changing* a property value?

2011-06-23 Thread Axel Rauschmayer
wrote: On Jun 21, 2011, at 9:50 PM, Axel Rauschmayer wrote: That sounds like the opposite argument you are making with regard to the hypothetical |here|: BTW I do not agree we can or should try to reserve 'here' or expose the method's home object -- that breaks abstractions built using

Re: Analog to Object.getPropertyDescriptor() for *changing* a property value?

2011-06-23 Thread Axel Rauschmayer
this, e.g. Array.prototype.myClassMethod(), then this.myClassVariable would *still* work. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org https

Re: Analog to Object.getPropertyDescriptor() for *changing* a property value?

2011-06-23 Thread Axel Rauschmayer
for getters, you have your way to change a value directly on the prototype chain. Of course, if you want to change the property descriptor on the prototype chain, none of what I said apply. David Le 21/06/2011 17:24, Axel Rauschmayer a écrit : As a loose analog to the prototype-chain

Re: block-lambda revival

2011-06-24 Thread Axel Rauschmayer
. If we introduce multiple special forms that can introduce a this-rebinding boundary, where the new ones are easily missed, we make this burden worse. Is - easily missed? (I would guess so.) And if it is, what are we getting in exchange, and is it worth it? -- Dr. Axel Rauschmayer

Re: block-lambda revival

2011-06-24 Thread Axel Rauschmayer
provided a counter-example. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Understanding Irakli’s code (new protocol)

2011-06-24 Thread Axel Rauschmayer
a this gist https://gist.github.com/1033258 -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Understanding Irakli’s code (new protocol)

2011-06-24 Thread Axel Rauschmayer
() { var constr = (this instanceof Function ? this : this.constructor); var instance = Object.create(constr.prototype); constr.apply(instance, arguments); }; -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com

JavaScript parser API

2011-06-28 Thread Axel Rauschmayer
. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Summary: prototypes as classes (PaCs)

2011-06-28 Thread Axel Rauschmayer
(that are muddled with constructor functions – see subclassing): - Instantiation: Creating a new instance - Initialization: Setting up a new instance -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss

Re: es-discuss Digest, Vol 52, Issue 161

2011-06-28 Thread Axel Rauschmayer
to check the following? o instanceof C You look for C.prototype in the prototype chain of o. Axel -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss

Re: JavaScript parser API

2011-06-28 Thread Axel Rauschmayer
these lines become standard in some later edition. On Tue, Jun 28, 2011 at 4:34 PM, Axel Rauschmayer a...@rauschma.de wrote: http://blog.mozilla.com/dherman/2011/06/28/the-js-parser-api-has-landed/ I’ve just read D. Herman’s post on Firefox’s parser API. Is there any chance that this kind

Re: Summary: prototypes as classes

2011-06-28 Thread Axel Rauschmayer
, title) { Person.call(this, name); this.title = title; } Worker.prototype = Person.prototype | { constructor: Worker, describe: function() { return Person.prototype.describe.call(this)+ (+this.title+); } }; -- Dr. Axel Rauschmayer

Re: Summary: prototypes as classes (PaCs)

2011-06-28 Thread Axel Rauschmayer
. On the other hand, having PaCs and classes/constructors is more complex than just having one. And we do not get the choice of just having PaCs. True! -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com

Re: Summary: prototypes as classes

2011-06-28 Thread Axel Rauschmayer
from the constructor as the dominant construct (conceptually, – nothing changes under the hood). -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org

Re: Summary: prototypes as classes

2011-06-28 Thread Axel Rauschmayer
with current semantics. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Summary: prototypes as classes

2011-06-29 Thread Axel Rauschmayer
constructor() only has to play role (2), whereas constructor functions have to sometimes play both roles, sometimes only role (2) (when called from a sub-constructor). -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com

Re: Summary: prototypes as classes

2011-06-29 Thread Axel Rauschmayer
that method constructor() is called. Anyway, the die was cast long ago. I agree that this might be one of those cases where the cost of breaking compatibility is not worth the benefits (especially if we even can’t agree that there are benefits ;-) -- Dr. Axel Rauschmayer a...@rauschma.de

Re: Summary: prototypes as classes

2011-06-29 Thread Axel Rauschmayer
literals. But the abstraction argument might apply to both cases: If people see a class C, they just want to instantiate it via new C(x,y). As long as instanceof works accordingly afterwards, I’m not sure much has changed *superficially*. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma

Re: Summary: prototypes as classes

2011-06-29 Thread Axel Rauschmayer
On the other hand people may find Point.new(x, y) as intuitive, as they will think of ruby instead of java. As an aside, you can see API code for the above functionality here: - https://github.com/Gozala/selfish [Irakli, updated] - http://dl.2ality.com/dl/2011/06/Proto.js [me] -- Dr. Axel

prototype focus

2011-06-30 Thread Axel Rauschmayer
= zero; // Now make some objects. var two = new Real(2); var i = new Imaginary(2); var oneone = new Complex(1, 1); Isn't that prototype-focused enough? -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com

Re: prototype focus

2011-07-01 Thread Axel Rauschmayer
is that it is a bad idea to have two class mechanisms. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: prototype focus

2011-07-01 Thread Axel Rauschmayer
) this.age = age } Child.__proto__ = Parent Child::__proto__ = Parent.prototype Child::describe = function () { return 'I am called ' + this.name + ' and I am ' + this.age + ' years old' } -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com

Re: prototype focus

2011-07-01 Thread Axel Rauschmayer
2011 21:10, Axel Rauschmayer a...@rauschma.de wrote: I don't think JavaScript has ever been far from its prototype roots especially if the programmer shifts to thinking about a prototype object instead of thinking about a functions prototype property. That is basically the point

Re: Mailing list reminder: password is sent in the clear

2011-07-01 Thread Axel Rauschmayer
://mail.mozilla.org/options/es-discuss Can this be fixed? I’ve already sent feedback, but didn’t get a response. Preferably, passwords would also be encrypted for storage. -- Dr. Axel Rauschmayer axel at rauschma.de twitter.com/rauschma Home: rauschma.de Blog: 2ality.com -- Dr. Axel

Re: prototype focus

2011-07-01 Thread Axel Rauschmayer
(?) What else? IDE support would be a pro-class literal argument, I guess. Another question: If *everything* is encapsulated (instantiation, subclassing, instanceof, etc.) then it doesn’t matter any more what goes on under the hood. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma

Writing a desktop app in JavaScript?

2011-07-03 Thread Axel Rauschmayer
. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Desugaring for and let

2011-07-11 Thread Axel Rauschmayer
++) { (function() { var iCopy = i; a.push(function () { return iCopy; }); }()); } }()); print(a[0]()); // 0 Axel -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com

Re: Summary: prototypes as classes

2011-07-11 Thread Axel Rauschmayer
/flexibility (comflexibility?). Consider Smalltalk, CLOS, Python, Ruby, or C#. You can have classes in a beautiful language. - bob -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing

Re: Desugaring for and let

2011-07-11 Thread Axel Rauschmayer
is used to increment a non-local variable. That is, loops should be allowed to have side effects. I’m not sure how this applies to iterators, as they are handled by reference. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com

Collections API

2011-07-13 Thread Axel Rauschmayer
observed in providing support for this protocol in a Common Lisp, including ensuring that there is no performance impact from its inclusion. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es

An extend operator is a natural companion to |

2011-07-18 Thread Axel Rauschmayer
been created for it) and not a method that instantiates and initializes at the same time. initialize() works together very well with super-references, because in subclasses, you simply call the super-initialize method. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home

Re: An extend operator is a natural companion to |

2011-07-18 Thread Axel Rauschmayer
of parameterized object literals. But then I have no idea where class properties would go: class Point(x,y) { x: x, y: y, prototype { manhattanDistance() { return Math.abs(this.x) + Math.abs(this.y); } } } -- Dr. Axel Rauschmayer a...@rauschma.de

Re: An extend operator is a natural companion to |

2011-07-19 Thread Axel Rauschmayer
' -- users get to name the module. With ES.next modules, one can even selectively import: import createFunction from @proxy; This is awesome! A lot of “static” methods will go away now that we finally can have real modules. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home

Re: An extend operator is a natural companion to |

2011-07-19 Thread Axel Rauschmayer
properties are actually added to the constructor). To me the class literal proposal looks like prototypes-as-classes, with desugaring to constructor-functions-as-classes. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com

Re: An extend operator is a natural companion to |

2011-07-20 Thread Axel Rauschmayer
do? Wouldn't point simply return an object literal (no this )? No, because the [[Construct]] internal method set this to a new object whose [[Prototype]] is correctly initialized to Point.prototype. You could return: Point.prototype | { ... Got it. Nice. -- Dr. Axel Rauschmayer

Re: An extend operator is a natural companion to |

2011-07-20 Thread Axel Rauschmayer
code and use the operator in Harmony-only code. -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: An extend operator is a natural companion to |

2011-07-20 Thread Axel Rauschmayer
increment to obj increment increments obj increment overrides obj -- Dr. Axel Rauschmayer a...@rauschma.de twitter.com/rauschma home: rauschma.de blog: 2ality.com ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org

  1   2   3   4   5   6   7   8   9   10   >