Return-Path: X-Original-To: apmail-flex-dev-archive@www.apache.org Delivered-To: apmail-flex-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 938B117E7A for ; Thu, 28 May 2015 13:38:06 +0000 (UTC) Received: (qmail 79178 invoked by uid 500); 28 May 2015 13:37:44 -0000 Delivered-To: apmail-flex-dev-archive@flex.apache.org Received: (qmail 79140 invoked by uid 500); 28 May 2015 13:37:44 -0000 Mailing-List: contact dev-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list dev@flex.apache.org Received: (qmail 79127 invoked by uid 99); 28 May 2015 13:37:43 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 May 2015 13:37:43 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 51913182202 for ; Thu, 28 May 2015 13:37:43 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.88 X-Spam-Level: *** X-Spam-Status: No, score=3.88 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_REPLY=1, HTML_MESSAGE=3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 2BLVTDU2XdoU for ; Thu, 28 May 2015 13:37:37 +0000 (UTC) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com [209.85.215.42]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id 09EB543DA6 for ; Thu, 28 May 2015 13:37:37 +0000 (UTC) Received: by labpy14 with SMTP id py14so20181778lab.0 for ; Thu, 28 May 2015 06:36:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=inhQFbv49LqSCmK0YpHUZ2v6a1mTI9WQM+Ns4Jwx0zA=; b=cR6DJj6hZ0bpxAqMTLK9W3LiKfChEQXBzAY4EUxbk+X3Nj6dGeit+QxmlFWLJVR0ft JKw4AP4vg0OfXGaA6qRPY2tkTQGA5l5PTzwOSsQBwuQGujkLNv/s/cJF8G7G6Dc5saz8 28D8vzcV4gcH/o3gYI0JNYxEi/zIq+PSqVqD/522UC2cPFrv7+h1JpYU7OJGEYa86o6t sYdIiDMkDx9JLmC92op/5p2iDbrq9/E3IDaPJroMhwlCvwYShKjPX4lDr/YxDzUaAYRL rEEc+/Wdy5xT2kWjIrQTjQv7TlOScas421qInXkzwsH7eUL36QosEh+vi1ZN+A2x9Kp6 lxcA== MIME-Version: 1.0 X-Received: by 10.152.238.1 with SMTP id vg1mr251075lac.13.1432820210946; Thu, 28 May 2015 06:36:50 -0700 (PDT) Received: by 10.114.78.1 with HTTP; Thu, 28 May 2015 06:36:50 -0700 (PDT) In-Reply-To: References: Date: Thu, 28 May 2015 09:36:50 -0400 Message-ID: Subject: Re: [FalconJX] JXEmitter accessors From: Michael Schmalle To: dev@flex.apache.org Content-Type: multipart/alternative; boundary=001a1134930eb357ba051724733b --001a1134930eb357ba051724733b Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable So Alex, you are saying try what Bable produces for get/set and make sure I make it swappable and not coupled in the emitter right? What are you doing for nested function scopes? Just creating local variables outside the function and referencing the current scope? Mike On Thu, May 28, 2015 at 9:33 AM, Alex Harui wrote: > FWIW, I did not test goog.inherit against Object.getPrototypeOf. It migh= t > not work as some libraries may not use vanilla prototype inheritance. So > abstracting that piece will provide more flexibility. > > -Alex > > On 5/28/15, 6:25 AM, "Michael Schmalle" wrote= : > > >Fred, > > > >I said TS only because Josh said it looked nice, the came Josh with Babl= e > >and Joa said Babel. > > > >Right now it's the whole class structure that needs a template. > > > >> Yes but given I'm more than busy, would be nice if you write it first = in > >AS :) > > > >I meant copy and paste, I didn't mean write it. Don't worry about it. > > > >I'm still confused as usual so I guess I will wait until things sink in > >more. I have done this a couple times and what I learned is I need a spe= c > >first before I start writing the code. > > > >I'm setting aside about 3 hours a day to work on this, so I guess I will > >start with the basic tests in expression and start to fiddle form there. > > > >Alex, Josh any thoughts? > > > >Mike > > > > > >On Thu, May 28, 2015 at 9:14 AM, Fr=C3=A9d=C3=A9ric THOMAS > > >wrote: > > > >> > You mean if AS3 and ES6 inherit the same way correct? I wouldn't kno= w > >>the > >> > answer to this I guess all we can do is try it right? :) > >> > >> Nope, I meant Babel and TS because you said you will base your tests o= n > >> the TS ones, so, if you emit a such utility function, be sure first we > >> extend classes in the same way than Babel hoping TS does the same. > >> > >> > I guess one of the other questions is how it handles/outputs anonymo= us > >> > function call scope, you want to do a test with that? Like three or = so > >> > levels nested. > >> > >> Yes but given I'm more than busy, would be nice if you write it first = in > >> AS :) > >> > >> Thanks > >> Fr=C3=A9d=C3=A9ric THOMAS > >> > >> > Date: Thu, 28 May 2015 08:51:20 -0400 > >> > Subject: Re: [FalconJX] JXEmitter accessors > >> > From: teotigraphixllc@gmail.com > >> > To: dev@flex.apache.org > >> > > >> > On Thu, May 28, 2015 at 8:41 AM, Fr=C3=A9d=C3=A9ric THOMAS < > >> webdoublefx@hotmail.com> > >> > wrote: > >> > > >> > > > So what is different about this? > >> > > > > >> > > > The only thing I can think of is that we introduce utility > >>functions > >> to > >> > > do > >> > > > the work > >> > > > >> > > Yes, that, I guess both of the language inherit in the same way, i= f > >> yes, > >> > > this function is re-usable IMO > >> > > > >> > > >> > > >> > You mean if AS3 and ES6 inherit the same way correct? I wouldn't kno= w > >>the > >> > answer to this I guess all we can do is try it right? :) > >> > > >> > I'm going to create a branch in falcon jxemitter and start working o= n > >>it. > >> > > >> > I guess one of the other questions is how it handles/outputs anonymo= us > >> > function call scope, you want to do a test with that? Like three or = so > >> > levels nested. > >> > > >> > Mike > >> > > >> > > >> > > >> > > > >> > > Fr=C3=A9d=C3=A9ric THOMAS > >> > > > >> > > > Date: Thu, 28 May 2015 08:38:16 -0400 > >> > > > Subject: Re: [FalconJX] JXEmitter accessors > >> > > > From: teotigraphixllc@gmail.com > >> > > > To: dev@flex.apache.org > >> > > > > >> > > > Well yes, I follow the logic. I don't understand if this is a > >> solution, > >> > > why > >> > > > TypeScript doesn't use the same algorithm. > >> > > > > >> > > > I read what the developers said and they said they had talked > >>about > >> it in > >> > > > length when the project first started and came to the conclusion > >> there > >> > > > really is no solution. > >> > > > > >> > > > So what is different about this? > >> > > > > >> > > > The only thing I can think of is that we introduce utility > >>functions > >> to > >> > > do > >> > > > the work and they didn't want to do that, I did get this from th= e > >> > > > conversation, they stated they wanted it to be plain javascript, > >>the > >> only > >> > > > helper they use is _extends function they write out for > >>inheritance. > >> > > > > >> > > > I was thinking about TypeScript, other than the language > >>difference, > >> > > there > >> > > > is really NO difference in our compiler and what they do. Which = is > >> cool > >> > > > because all the usecases that they have will apply to this > >>emitter. > >> > > > > >> > > > Plus we have libraries and IDE support and possible MXML in the > >> future. > >> > > > > >> > > > Mike > >> > > > > >> > > > On Thu, May 28, 2015 at 8:27 AM, Fr=C3=A9d=C3=A9ric THOMAS < > >> > > webdoublefx@hotmail.com> > >> > > > wrote: > >> > > > > >> > > > > I'm not a javascript guru either, but it was easy to create ES= 6 > >> classes > >> > > > > (left pane) and see the output (right pane), so, for the > >>setter, it > >> > > creates: > >> > > > > > >> > > > > For class A (simple): > >> > > > > > >> > > > > get: function () { > >> > > > > return this._property; > >> > > > > }, > >> > > > > set: function (value) { > >> > > > > this._property =3D value; > >> > > > > } > >> > > > > > >> > > > > For class B: > >> > > > > > >> > > > > > >> > > > > set: function (value) { > >> > > > > _set(Object.getPrototypeOf(B.prototype), "property= ", > >> value, > >> > > > > this); > >> > > > > } > >> > > > > > >> > > > > Which calls: > >> > > > > > >> > > > > var _set =3D function set(object, property, value, receiver) { > >> > > > > var desc =3D Object.getOwnPropertyDescriptor(object, > >>property); > >> // > >> > > Get > >> > > > > the property on B > >> > > > > if (desc =3D=3D=3D undefined) { // If not overrided, will = set the > >> parent > >> > > > > recursively if the parent doesn't override the property either= . > >> > > > > var parent =3D Object.getPrototypeOf(object); > >> > > > > if (parent !=3D=3D null) { > >> > > > > set(parent, property, value, receiver); > >> > > > > } > >> > > > > } else if ("value" in desc && desc.writable) { // didn't g= et > >> this > >> > > part > >> > > > > desc.value =3D value; > >> > > > > } else { // Else call the setterv of this Object > >> > > > > var setter =3D desc.set; > >> > > > > if (setter !=3D=3D undefined) { > >> > > > > setter.call(receiver, value); > >> > > > > } > >> > > > > } > >> > > > > return value; > >> > > > > }; > >> > > > > > >> > > > > > >> > > > > get: function () { > >> > > > > return _get(Object.getPrototypeOf(B.prototype), > >> "property", > >> > > > > this); > >> > > > > }, > >> > > > > > >> > > > > Which calls: > >> > > > > > >> > > > > this for the getter, do recursive call to the prototype to che= ck > >> if the > >> > > > > property has been overriden, if Yes, get the value. > >> > > > > > >> > > > > var _get =3D function get(_x, _x2, _x3) { > >> > > > > var _again =3D true; > >> > > > > _function: while (_again) { > >> > > > > var object =3D _x, property =3D _x2, receiver =3D _x3; > >> > > > > desc =3D parent =3D getter =3D undefined; > >> > > > > _again =3D false; > >> > > > > var desc =3D Object.getOwnPropertyDescriptor(object, > >> property); > >> > > > > if (desc =3D=3D=3D undefined) { > >> > > > > var parent =3D Object.getPrototypeOf(object); > >> > > > > if (parent =3D=3D=3D null) { > >> > > > > return undefined; > >> > > > > } else { > >> > > > > _x =3D parent; > >> > > > > _x2 =3D property; > >> > > > > _x3 =3D receiver; > >> > > > > _again =3D true; > >> > > > > continue _function; > >> > > > > } > >> > > > > } else if ("value" in desc) { > >> > > > > return desc.value; > >> > > > > } else { > >> > > > > var getter =3D desc.get; > >> > > > > if (getter =3D=3D=3D undefined) { > >> > > > > return undefined; > >> > > > > } > >> > > > > return getter.call(receiver); > >> > > > > } > >> > > > > } > >> > > > > }; > >> > > > > > >> > > > > Does it do the trick ? > >> > > > > > >> > > > > Fr=C3=A9d=C3=A9ric THOMAS > >> > > > > > >> > > > > > Date: Thu, 28 May 2015 07:47:45 -0400 > >> > > > > > Subject: Re: [FalconJX] JXEmitter accessors > >> > > > > > From: teotigraphixllc@gmail.com > >> > > > > > To: dev@flex.apache.org > >> > > > > > > >> > > > > > Interesting Fred, I am no javascript guru so I need people t= o > >> "tell" > >> > > me > >> > > > > > what I should have output. > >> > > > > > > >> > > > > > So let me get this straight, the left pane is ES6 and it > >> converted > >> > > it to > >> > > > > > ES5 in the right pane? > >> > > > > > > >> > > > > > Mike > >> > > > > > > >> > > > > > On Thu, May 28, 2015 at 7:19 AM, Fr=C3=A9d=C3=A9ric THOMAS < > >> > > > > webdoublefx@hotmail.com> > >> > > > > > wrote: > >> > > > > > > >> > > > > > > I just tried in babel, see what it generates: > >> > > > > > > > >> > > > > > > > >> > > > > > > > >> > > > > > >> > > > >> > >> > http://babeljs.io/repl/#?experimental=3Dtrue&evaluate=3Dtrue&loose=3Dfals= e&spec > >>=3Dfalse&code=3Dclass%20A%20{%0A%09constructor%28%29%20{%0A%09%20%20thi= s._pro > >>perty%20%3D%20%22init%22%3B%0A%09}%0A%09get%20property%28%29%3Astring%2= 0{ > >>%0A%09%09return%20this._property%3B%0A%09}%0A%09%0A%09set%20property%28= va > >>lue%3Astring%29%20{%0A%09%09this._property%20%3D%20value%3B%0A%09}%20%0= A% > >>09%0A%09showMyValue%28%29%20{%0A%09%09alert%28this._property%29%3B%0A%0= 9} > >>%0A%0A}%0A%0Aclass%20B%20extends%20A%20{%0A%09get%20property%28%29%3Ast= ri > >>ng%20{%0A%09%09return%20super.property%3B%0A%09}%0A%09%0A%09set%20prope= rt > >>y%28value%3Astring%29%20{%0A%09%09super.property%20%3D%20value%3B%0A%09= }% > >>0A} > >> > > > > > > > >> > > > > > > Fr=C3=A9d=C3=A9ric THOMAS > >> > > > > > > > >> > > > > > > > Date: Thu, 28 May 2015 06:54:31 -0400 > >> > > > > > > > Subject: Re: [FalconJX] JXEmitter accessors > >> > > > > > > > From: teotigraphixllc@gmail.com > >> > > > > > > > To: dev@flex.apache.org > >> > > > > > > > > >> > > > > > > > > I=E2=80=99m still surprised that in 2015, TS hasn=E2= =80=99t been forced > >>to > >> > > handle > >> > > > > > > super. > >> > > > > > > > Are people not using inheritance much in TS? > >> > > > > > > > > >> > > > > > > > They tell them to use standard getValue(), setValue() in > >>the > >> > > > > property if > >> > > > > > > > they need inheritance overrides. > >> > > > > > > > > >> > > > > > > > I'm kind of bummed about this whole thing, I stuck my > >>foot in > >> > > mouth > >> > > > > here, > >> > > > > > > > since I totally forgot about this stuff. Since I really > >> wanted > >> > > to do > >> > > > > this > >> > > > > > > > for Josh's POC, I am interested in what he "needs" to ge= t > >>his > >> > > project > >> > > > > > > > working, Josh? > >> > > > > > > > > >> > > > > > > > Mike > >> > > > > > > > > >> > > > > > > > > >> > > > > > > > On Wed, May 27, 2015 at 7:51 PM, Alex Harui < > >> aharui@adobe.com> > >> > > > > wrote: > >> > > > > > > > > >> > > > > > > > > > >> > > > > > > > > > >> > > > > > > > > On 5/27/15, 4:16 PM, "Michael Schmalle" < > >> > > teotigraphixllc@gmail.com > >> > > > > > > >> > > > > > > wrote: > >> > > > > > > > > > >> > > > > > > > > >Ok, This needs to be clear to me before I go off to O= Z. > >> > > > > > > > > > > >> > > > > > > > > >In Flex JS you have; > >> > > > > > > > > > > >> > > > > > > > > >Object.defineProperties(Base.prototype, /** @lends > >> > > > > {Base.prototype} > >> > > > > > > */ { > >> > > > > > > > > >/** @expose */ > >> > > > > > > > > >text: { > >> > > > > > > > > >get: /** @this {Base} */ function() { > >> > > > > > > > > > return "A" + > >> > > org_apache_flex_utils_Language.superGetter(Base, > >> > > > > this, > >> > > > > > > > > >'text'); > >> > > > > > > > > >}, > >> > > > > > > > > >set: /** @this {Base} */ function(value) { > >> > > > > > > > > > if (value !=3D > >> > > org_apache_flex_utils_Language.superGetter(Base, > >> > > > > this, > >> > > > > > > > > >'text')) { > >> > > > > > > > > > org_apache_flex_utils_Language.superSetter(Base, > >>this, > >> > > 'text', > >> > > > > > > "B" + > >> > > > > > > > > >value); > >> > > > > > > > > > } > >> > > > > > > > > >}}} > >> > > > > > > > > >); > >> > > > > > > > > > > >> > > > > > > > > >I must use this obviously since hardly any actionscri= pt > >> could > >> > > be > >> > > > > cross > >> > > > > > > > > >compiled if you can't call super accessors. > >> > > > > > > > > > >> > > > > > > > > I=E2=80=99m still surprised that in 2015, TS hasn=E2= =80=99t been forced > >>to > >> > > handle > >> > > > > > > super. > >> > > > > > > > > Are people not using inheritance much in TS? > >> > > > > > > > > > >> > > > > > > > > > > >> > > > > > > > > >Alex, when you have time, can you explain what this i= s > >> doing > >> > > so I > >> > > > > can > >> > > > > > > > > >implement it. > >> > > > > > > > > > >> > > > > > > > > I have not read the spec, but Object.defineProperties > >> appears > >> > > to > >> > > > > > > associate > >> > > > > > > > > a data structure with a =E2=80=9Cclass=E2=80=9D. When= asked to > >> > > interpret/execute > >> > > > > > > > > > >> > > > > > > > > Someinstance.someprop > >> > > > > > > > > > >> > > > > > > > > the JS runtime appears to check this data structure > >>first, > >> and > >> > > > > call the > >> > > > > > > > > get or set as needed. As I see it, there is no way to > >> switch > >> > > from > >> > > > > > > > > > >> > > > > > > > > SomeSubClass.someProp > >> > > > > > > > > > >> > > > > > > > > back to > >> > > > > > > > > > >> > > > > > > > > SomeBaseClass.someProp > >> > > > > > > > > > >> > > > > > > > > and retain the =E2=80=98this=E2=80=99 pointer and scop= e. If you had a > >> variable > >> > > > > called > >> > > > > > > > > super it would still point to the same instance so > >> > > super.someProp > >> > > > > would > >> > > > > > > > > just cause the runtime to find the subclass=E2=80=99s = property > >>map. > >> > > > > > > > > > >> > > > > > > > > In looking around the internet, the solutions seemed t= o: > >> > > > > > > > > 1) get the superclass > >> > > > > > > > > 2) get the property map of defined properties > >> > > > > > > > > 3) get the getter or setter from the data structure > >> > > > > > > > > 4) call it with the right =E2=80=98this=E2=80=99 point= er. > >> > > > > > > > > > >> > > > > > > > > So that=E2=80=99s what is in the current JSFlexJSEmitt= er, but it > >> > > assumes > >> > > > > > > > > goog.inherit is going to leave references to the base > >> class in > >> > > a > >> > > > > > > > > particular way. TS probably leaves references to base > >> classes > >> > > some > >> > > > > > > how so > >> > > > > > > > > some abstraction around step 1 is probably required, b= ut > >> steps > >> > > 2 > >> > > > > > > through 4 > >> > > > > > > > > can be the same. > >> > > > > > > > > > >> > > > > > > > > It is step 4 that re-introduces =E2=80=9Cre-writing=E2= =80=9D that you > >>may > >> be > >> > > > > referring > >> > > > > > > to > >> > > > > > > > > as hell. The super setter again becomes a function > >>call, > >> so > >> > > the > >> > > > > AST > >> > > > > > > walk > >> > > > > > > > > needs to know that and walk the tree differently, > >>saving a > >> > > whole > >> > > > > > > branch to > >> > > > > > > > > be evaluated as the parameter to the function call. > >>IOW, a > >> > > binary > >> > > > > > > > > operator becomes a function call. I=E2=80=99ll bet th= ere are > >>still > >> > > bugs > >> > > > > in the > >> > > > > > > > > current JSFlexJSEmitter. > >> > > > > > > > > > >> > > > > > > > > And I think I still haven=E2=80=99t fixed the scenario= where > >>only a > >> > > getter > >> > > > > or > >> > > > > > > > > setter is overridden. The generated code must > >>propagate a > >> > > =E2=80=9Cpass > >> > > > > > > through=E2=80=9D > >> > > > > > > > > for the missing getter or setter to the subclass=E2=80= =99s data > >> > > structure > >> > > > > > > > > otherwise the runtime will not find the setter or gett= er > >> and > >> > > think > >> > > > > the > >> > > > > > > > > property is now read-only or write-only. > >> > > > > > > > > > >> > > > > > > > > > > >> > > > > > > > > >So correct me if I am wrong but, since there is reall= y > >>no > >> > > solution > >> > > > > > > without > >> > > > > > > > > >an external utility to call a super accessor, we can'= t > >> really > >> > > say > >> > > > > that > >> > > > > > > > > >this > >> > > > > > > > > >transpiler is producing vanilla javascript. Chicken e= gg > >> thing. > >> > > > > > > > > > >> > > > > > > > > Technically, you could inline everything in the utilit= y > >> > > function > >> > > > > and > >> > > > > > > still > >> > > > > > > > > called it vanilla. But it would be high-fat vanilla. > >>;-) > >> > > > > > > > > > >> > > > > > > > > A question for Josh is whether it would be ok to have = a > >> Google > >> > > > > Closure > >> > > > > > > > > Library dependency. These libraries exist to > >>encapsulate > >> some > >> > > of > >> > > > > these > >> > > > > > > > > object oriented patterns like finding the base class a= nd > >> > > loading > >> > > > > > > > > dependency definitions in a particular order. It seem= s > >>to > >> be > >> > > > > somewhat > >> > > > > > > > > pay-as-you-go. If no inheritance, then almost no > >>=E2=80=9Cgoog=E2=80=9D. > >> > > > > > > > > > >> > > > > > > > > -Alex > >> > > > > > > > > > >> > > > > > > > > > >> > > > > > > > >> > > > > > > > >> > > > > > >> > > > > > >> > > > >> > > > >> > >> > > --001a1134930eb357ba051724733b--