RE: Design principles for extending ES object abstractions

2011-07-14 Thread Luke Hoban
Well, I think I understand what you're getting at: there's a sense in which generators don't add the ability to do something that's *absolutely impossible* to express in ES5. OTOH, generators make it possible to express something that otherwise -- in general -- requires a deep

Re: Design principles for extending ES object abstractions

2011-07-14 Thread Brendan Eich
On Jul 14, 2011, at 12:00 AM, Luke Hoban wrote: I don't want to quibble about philosophical pedantry, but that's really all I mean by my shyness about General Principles. They're strictly *harder* to decide on than the problem at hand. It's too easy to lose focus and waste time arguing

Re: Design principles for extending ES object abstractions

2011-07-12 Thread Brendan Eich
On Jul 11, 2011, at 10:38 PM, Luke Hoban wrote: If so, it seems safe to consider generators as sugar for producing objects whose visible behavior could have been built independently. And interoperation appears to work cleanly in both directions using these objects. You're talking

Re: Design principles for extending ES object abstractions

2011-07-12 Thread David Herman
My understanding of generators was naively that they are syntactic sugar for defining an iterator. Well, I think I understand what you're getting at: there's a sense in which generators don't add the ability to do something that's *absolutely impossible* to express in ES5. OTOH, generators

Re: Design principles for extending ES object abstractions

2011-07-12 Thread Allen Wirfs-Brock
On Jul 12, 2011, at 11:28 AM, David Herman wrote: No pejorative overtones intended. We just don't yet have any decent terminology for distinguishing the full ES.next front end from the backwards-compatible one. In the working draft of the specification I'm using extended code to mean the

Re: Design principles for extending ES object abstractions

2011-07-11 Thread Allen Wirfs-Brock
On Jul 10, 2011, at 4:01 PM, Brendan Eich wrote: On Jul 10, 2011, at 3:54 PM, Brendan Eich wrote: On Jul 10, 2011, at 3:02 PM, David Herman wrote: I'm not sure what Array.prototype methods would or wouldn't work on instances of SubArray. All of them. They are all generic. We're

RE: Design principles for extending ES object abstractions

2011-07-11 Thread Luke Hoban
I agree wholeheartedly with these. In fact, I'd go further on (2), and say Anything that can be done declaratively can also be done imperatively, using ES5 syntax. Like most principles, I think these are reasonable to keep in mind but not absolute. In particular, I see no sensible

Re: Design principles for extending ES object abstractions

2011-07-11 Thread Brendan Eich
On Jul 11, 2011, at 10:00 PM, Luke Hoban wrote: So I was wrong about iterators being the general interoperable runtime mechanism, but next/send/throw/close objects appear to be fully iterable and consumable in generators. Is that right? That's right, there is no nominal type test. If

RE: Design principles for extending ES object abstractions

2011-07-11 Thread Luke Hoban
If so, it seems safe to consider generators as sugar for producing objects whose visible behavior could have been built independently. And interoperation appears to work cleanly in both directions using these objects. You're talking about interoperation in the old script calls new generator

Re: Design principles for extending ES object abstractions

2011-07-10 Thread David Herman
I'm not sure what Array.prototype methods would or wouldn't work on instances of SubArray. All of them. They are all generic. We're speaking too broadly here. It depends on what we want to work how. For example, .map can't magically know how to produce a SubArray as its result if that's

Re: Design principles for extending ES object abstractions

2011-07-10 Thread Brendan Eich
On Jul 10, 2011, at 3:02 PM, David Herman wrote: I'm not sure what Array.prototype methods would or wouldn't work on instances of SubArray. All of them. They are all generic. We're speaking too broadly here. It depends on what we want to work how. For example, .map can't magically

Re: Design principles for extending ES object abstractions

2011-07-10 Thread Brendan Eich
On Jul 10, 2011, at 3:54 PM, Brendan Eich wrote: On Jul 10, 2011, at 3:02 PM, David Herman wrote: I'm not sure what Array.prototype methods would or wouldn't work on instances of SubArray. All of them. They are all generic. We're speaking too broadly here. It depends on what we want

Design principles for extending ES object abstractions

2011-07-08 Thread Allen Wirfs-Brock
On Jul 8, 2011, at 2:58 PM, Brendan Eich wrote on the thread using Private name objects for declarative property definition. : But whatever the class syntax, and the disposition of private in class and even classes in ES.next, I agree we should expect private declarative and expression

Re: Design principles for extending ES object abstractions

2011-07-08 Thread Brendan Eich
On Jul 8, 2011, at 3:49 PM, Allen Wirfs-Brock wrote: On Jul 8, 2011, at 2:58 PM, Brendan Eich wrote on the thread using Private name objects for declarative property definition. : But whatever the class syntax, and the disposition of private in class and even classes in ES.next, I agree

Re: Design principles for extending ES object abstractions

2011-07-08 Thread Brendan Eich
On Jul 8, 2011, at 3:59 PM, Brendan Eich wrote: But the stronger reason for function* as mandator mandatory of course (need new keyboard). generator syntax introducer came when we considered yield* (yield from in Python's PEP380): the utility of a zero-iterations basis case for a

RE: Design principles for extending ES object abstractions

2011-07-08 Thread Luke Hoban
[mailto:es-discuss-boun...@mozilla.org] On Behalf Of Allen Wirfs-Brock Sent: Friday, July 08, 2011 3:49 PM To: es-discuss@mozilla.org Subject: Design principles for extending ES object abstractions [snip...] I wanted to generalize this a bit. In designing classes and other new ES abstractions

Re: Design principles for extending ES object abstractions

2011-07-08 Thread Brendan Eich
On Jul 8, 2011, at 4:05 PM, Luke Hoban wrote: I agree wholeheartedly with these. In fact, I’d go further on (2), and say “Anything that can be done declaratively can also be done imperatively, using ES5 syntax”. The problem here is that some new syntax cannot be faked with old syntax,

RE: Design principles for extending ES object abstractions

2011-07-08 Thread Luke Hoban
I agree wholeheartedly with these. In fact, I'd go further on (2), and say Anything that can be done declaratively can also be done imperatively, using ES5 syntax. The problem here is that some new syntax cannot be faked with old syntax, namely function calls, without quoting code in

Re: Design principles for extending ES object abstractions

2011-07-08 Thread Allen Wirfs-Brock
On Jul 8, 2011, at 4:27 PM, Luke Hoban wrote: I agree wholeheartedly with these. In fact, I’d go further on (2), and say “Anything that can be done declaratively can also be done imperatively, using ES5 syntax”. The problem here is that some new syntax cannot be faked with old

Re: Design principles for extending ES object abstractions

2011-07-08 Thread Brendan Eich
On Jul 8, 2011, at 4:27 PM, Luke Hoban wrote: I agree wholeheartedly with these. In fact, I’d go further on (2), and say “Anything that can be done declaratively can also be done imperatively, using ES5 syntax”. The problem here is that some new syntax cannot be faked with old

Re: Design principles for extending ES object abstractions

2011-07-08 Thread Brendan Eich
On Jul 8, 2011, at 3:49 PM, Allen Wirfs-Brock wrote: 2) Anything that can be done declaratively can also be done imperatively. What's the imperative API for | (which has the syntactic property that it operators on newborns on the right, and cannot mutate the [[Prototype]] of an object that

Re: Design principles for extending ES object abstractions

2011-07-08 Thread David Herman
I think I still haven't fully grokked what | means on array literals, but could it also be used to subclass Array? For example: function SubArray() { return SubArray.prototype | []; } SubArray.prototype = new Array; I'm not sure what Array.prototype methods would or

Re: Design principles for extending ES object abstractions

2011-07-08 Thread Brendan Eich
On Jul 8, 2011, at 5:48 PM, Allen Wirfs-Brock wrote: On Jul 8, 2011, at 5:16 PM, Brendan Eich wrote: What's the imperative API for | (which has the syntactic property that it operators on newborns on the right, and cannot mutate the [[Prototype]] of an object that was already created and

Re: Design principles for extending ES object abstractions

2011-07-08 Thread Brendan Eich
On Jul 8, 2011, at 5:53 PM, David Herman wrote: I think I still haven't fully grokked what | means on array literals, but could it also be used to subclass Array? For example: function SubArray() { return SubArray.prototype | []; } SubArray.prototype = new Array;

Re: Design principles for extending ES object abstractions

2011-07-08 Thread Allen Wirfs-Brock
On Jul 8, 2011, at 5:53 PM, David Herman wrote: I think I still haven't fully grokked what | means on array literals, but could it also be used to subclass Array? For example: yes, it creates a new object that is an array instance ([[Class]]=='Array', support the length constraints, etc.)

Re: Design principles for extending ES object abstractions

2011-07-08 Thread Allen Wirfs-Brock
On Jul 8, 2011, at 6:03 PM, Brendan Eich wrote: On Jul 8, 2011, at 5:48 PM, Allen Wirfs-Brock wrote: On Jul 8, 2011, at 5:16 PM, Brendan Eich wrote: What's the imperative API for | (which has the syntactic property that it operators on newborns on the right, and cannot mutate the

Re: Design principles for extending ES object abstractions

2011-07-08 Thread Brendan Eich
On Jul 8, 2011, at 6:38 PM, Allen Wirfs-Brock wrote: And likewise for Function.create and RegExp.create. Boolean, Number, String, and Date get nothing :-P. Actually in the | proposal I define it to work with boolean, number, and string literals on the LHS. Sorta useless but I included