You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Michael Schmalle <te...@gmail.com> on 2015/05/28 01:16:48 UTC
[FalconJX] JXEmitter accessors
Ok, This needs to be clear to me before I go off to OZ.
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 != 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 actionscript could be cross
compiled if you can't call super accessors.
Alex, when you have time, can you explain what this is doing so I can
implement it.
Josh, you could chime into because your framework would use super
accessors, so this has to be solved before any work is done.
By solved I mean I need to know what the plan its. As stated, in Randori we
uses get_, set_ rewriting.
BTW, this new vanilla transpiler is just plain FalconJX with a JXEmitter
and custom backend.
So correct me if I am wrong but, since there is really no solution without
an external utility to call a super accessor, we can't really say that this
transpiler is producing vanilla javascript. Chicken egg thing.
Mike
Re: [FalconJX] JXEmitter accessors
Posted by Josh Tynjala <jo...@gmail.com>.
I think it's okay to start with an extra dependency in order to get
something working faster.
- Josh
On May 28, 2015 7:55 AM, "Alex Harui" <ah...@adobe.com> wrote:
>
>
> On 5/28/15, 6:36 AM, "Michael Schmalle" <te...@gmail.com> wrote:
>
> >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?
>
> I don’t really have a recommendation, just trying to find things in
> common. The code in org.apache.flex.utils.Language.superSetter and
> superGetter are pretty close to what Babel showed. Theirs might be more
> robust or handle some edge case I haven’t hit yet. I think the key
> difference is how you find the super class. It looks to me like
> goog.inherit doesn’t use Object.create() and Object.getPrototypeOf.
>
> IMO, you can definitely couple certain code gen to an emitter since we can
> have multiple emitters.
>
> >
> >What are you doing for nested function scopes? Just creating local
> >variables outside the function and referencing the current scope?
>
> There is a local variable called “self” that is created if needed, and
> lexical references in nested functions use ‘self.property' instead of
> ‘this.property’. I think local scoping is the same in AS and JS.
>
> In my mind, if it were me exploring Josh’s idea, I would have still
> required Language.superSetter/superGetter and used goog.inherits and
> goog.provide/require just to get something up quickly. We’ll need an
> emitter like this if we switch to writing all of the FlexJS JS in AS. But
> that’s probably because I know the current emitter.
>
> -Alex
>
>
Re: [FalconJX] JXEmitter accessors
Posted by Alex Harui <ah...@adobe.com>.
On 5/28/15, 6:36 AM, "Michael Schmalle" <te...@gmail.com> wrote:
>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?
I don’t really have a recommendation, just trying to find things in
common. The code in org.apache.flex.utils.Language.superSetter and
superGetter are pretty close to what Babel showed. Theirs might be more
robust or handle some edge case I haven’t hit yet. I think the key
difference is how you find the super class. It looks to me like
goog.inherit doesn’t use Object.create() and Object.getPrototypeOf.
IMO, you can definitely couple certain code gen to an emitter since we can
have multiple emitters.
>
>What are you doing for nested function scopes? Just creating local
>variables outside the function and referencing the current scope?
There is a local variable called “self” that is created if needed, and
lexical references in nested functions use ‘self.property' instead of
‘this.property’. I think local scoping is the same in AS and JS.
In my mind, if it were me exploring Josh’s idea, I would have still
required Language.superSetter/superGetter and used goog.inherits and
goog.provide/require just to get something up quickly. We’ll need an
emitter like this if we switch to writing all of the FlexJS JS in AS. But
that’s probably because I know the current emitter.
-Alex
RE: [FalconJX] JXEmitter accessors
Posted by Frédéric THOMAS <we...@hotmail.com>.
> I suspect Closure is trying to be more backwards compatible. I think
> Object. create() was added in ES5, and maybe they're aiming for ES3 there.
Correct, using Closure we guaranty compatibility < ES5 but I wonder if we are good to do so, the reason was that companies were very stricks and allow only one browser and update rarely, my experience tells me it less true and most of the broswer are now autoupdated, (eg. Chrome, Firefox and even Opera now, ok, maybe not IE), what others have as experience now days ?
A lot of work has been done with the Closure API already, not sure it has been discussed before but another option would have been to write for ES5 browsers and have a bootstrap to load ES5 polyfills if the Application runs under an older browser, doing so, we could have emit the nice, out of the box more powerfull ES5 code and I might be wrong but also faster than using Closure and eventually emulate extra JS higher level functions like what Alex said about the C -> B -> A issue when B doesn't override a A accessor and we want to access it from C.
But maybe also, I don't see the all picture why we didn't do that.
Frédéric THOMAS
> Date: Thu, 28 May 2015 07:46:10 -0700
> Subject: Re: [FalconJX] JXEmitter accessors
> From: joshtynjala@gmail.com
> To: dev@flex.apache.org
>
> I suspect Closure is trying to be more backwards compatible. I think
> Object. create() was added in ES5, and maybe they're aiming for ES3 there.
>
> - Josh
> On May 28, 2015 7:11 AM, "Michael Schmalle" <te...@gmail.com>
> wrote:
>
> > See this is where I am clueless, is this a difference between backward
> > compatibility or something?
> >
> > Like Object.create() not all older browsers support?
> >
> > Mike
> >
> > On Thu, May 28, 2015 at 10:06 AM, Frédéric THOMAS <webdoublefx@hotmail.com
> > >
> > wrote:
> >
> > > Btw, this is the diff between Closure and Babel:
> > >
> > > goog.inherits = function (childCtor, parentCtor) {
> > > /** @constructor */
> > > function tempCtor() {
> > > };
> > > tempCtor.prototype = parentCtor.prototype;
> > > childCtor.superClass_ = parentCtor.prototype;
> > > childCtor.prototype = new tempCtor();
> > > /** @override */
> > > childCtor.prototype.constructor = childCtor;
> > > };
> > >
> > > function _inherits(subClass, superClass) {
> > > if (typeof superClass !== "function" && superClass !== null) {
> > > throw new TypeError("Super expression must either be null or a
> > > function, not " + typeof superClass);
> > > }
> > > subClass.prototype = Object.create(superClass &&
> > superClass.prototype,
> > > {
> > > constructor: {
> > > value: subClass,
> > > enumerable: false,
> > > writable: true,
> > > configurable: true
> > > }
> > > });
> > > if (superClass) subClass.__proto__ = superClass;
> > > }
> > >
> > >
> > > Frédéric THOMAS
> > >
> > > > Date: Thu, 28 May 2015 09:36:50 -0400
> > > > Subject: Re: [FalconJX] JXEmitter accessors
> > > > From: teotigraphixllc@gmail.com
> > > > To: dev@flex.apache.org
> > > >
> > > > 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 <ah...@adobe.com> wrote:
> > > >
> > > > > FWIW, I did not test goog.inherit against Object.getPrototypeOf. It
> > > might
> > > > > 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" <te...@gmail.com>
> > > wrote:
> > > > >
> > > > > >Fred,
> > > > > >
> > > > > >I said TS only because Josh said it looked nice, the came Josh with
> > > Bable
> > > > > >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
> > > spec
> > > > > >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édéric THOMAS <
> > > webdoublefx@hotmail.com
> > > > > >
> > > > > >wrote:
> > > > > >
> > > > > >> > You mean if AS3 and ES6 inherit the same way correct? I wouldn't
> > > know
> > > > > >>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 on
> > > > > >> 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
> > > anonymous
> > > > > >> > 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édéric 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édéric 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, if
> > > > > >> yes,
> > > > > >> > > this function is re-usable IMO
> > > > > >> > >
> > > > > >> >
> > > > > >> >
> > > > > >> > You mean if AS3 and ES6 inherit the same way correct? I wouldn't
> > > know
> > > > > >>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 on
> > > > > >>it.
> > > > > >> >
> > > > > >> > I guess one of the other questions is how it handles/outputs
> > > anonymous
> > > > > >> > function call scope, you want to do a test with that? Like three
> > > or so
> > > > > >> > levels nested.
> > > > > >> >
> > > > > >> > Mike
> > > > > >> >
> > > > > >> >
> > > > > >> >
> > > > > >> > >
> > > > > >> > > Frédéric 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
> > > the
> > > > > >> > > > 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édéric THOMAS <
> > > > > >> > > webdoublefx@hotmail.com>
> > > > > >> > > > wrote:
> > > > > >> > > >
> > > > > >> > > > > I'm not a javascript guru either, but it was easy to
> > create
> > > ES6
> > > > > >> 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 = value;
> > > > > >> > > > > }
> > > > > >> > > > >
> > > > > >> > > > > For class B:
> > > > > >> > > > >
> > > > > >> > > > >
> > > > > >> > > > > set: function (value) {
> > > > > >> > > > > _set(Object.getPrototypeOf(B.prototype),
> > > "property",
> > > > > >> value,
> > > > > >> > > > > this);
> > > > > >> > > > > }
> > > > > >> > > > >
> > > > > >> > > > > Which calls:
> > > > > >> > > > >
> > > > > >> > > > > var _set = function set(object, property, value,
> > receiver) {
> > > > > >> > > > > var desc = Object.getOwnPropertyDescriptor(object,
> > > > > >>property);
> > > > > >> //
> > > > > >> > > Get
> > > > > >> > > > > the property on B
> > > > > >> > > > > if (desc === undefined) { // If not overrided, will
> > set
> > > the
> > > > > >> parent
> > > > > >> > > > > recursively if the parent doesn't override the property
> > > either.
> > > > > >> > > > > var parent = Object.getPrototypeOf(object);
> > > > > >> > > > > if (parent !== null) {
> > > > > >> > > > > set(parent, property, value, receiver);
> > > > > >> > > > > }
> > > > > >> > > > > } else if ("value" in desc && desc.writable) { //
> > > didn't get
> > > > > >> this
> > > > > >> > > part
> > > > > >> > > > > desc.value = value;
> > > > > >> > > > > } else { // Else call the setterv of this Object
> > > > > >> > > > > var setter = desc.set;
> > > > > >> > > > > if (setter !== 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
> > > check
> > > > > >> if the
> > > > > >> > > > > property has been overriden, if Yes, get the value.
> > > > > >> > > > >
> > > > > >> > > > > var _get = function get(_x, _x2, _x3) {
> > > > > >> > > > > var _again = true;
> > > > > >> > > > > _function: while (_again) {
> > > > > >> > > > > var object = _x, property = _x2, receiver = _x3;
> > > > > >> > > > > desc = parent = getter = undefined;
> > > > > >> > > > > _again = false;
> > > > > >> > > > > var desc = Object.getOwnPropertyDescriptor(object,
> > > > > >> property);
> > > > > >> > > > > if (desc === undefined) {
> > > > > >> > > > > var parent = Object.getPrototypeOf(object);
> > > > > >> > > > > if (parent === null) {
> > > > > >> > > > > return undefined;
> > > > > >> > > > > } else {
> > > > > >> > > > > _x = parent;
> > > > > >> > > > > _x2 = property;
> > > > > >> > > > > _x3 = receiver;
> > > > > >> > > > > _again = true;
> > > > > >> > > > > continue _function;
> > > > > >> > > > > }
> > > > > >> > > > > } else if ("value" in desc) {
> > > > > >> > > > > return desc.value;
> > > > > >> > > > > } else {
> > > > > >> > > > > var getter = desc.get;
> > > > > >> > > > > if (getter === undefined) {
> > > > > >> > > > > return undefined;
> > > > > >> > > > > }
> > > > > >> > > > > return getter.call(receiver);
> > > > > >> > > > > }
> > > > > >> > > > > }
> > > > > >> > > > > };
> > > > > >> > > > >
> > > > > >> > > > > Does it do the trick ?
> > > > > >> > > > >
> > > > > >> > > > > Frédéric 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 to
> > > > > >> "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édéric THOMAS <
> > > > > >> > > > > webdoublefx@hotmail.com>
> > > > > >> > > > > > wrote:
> > > > > >> > > > > >
> > > > > >> > > > > > > I just tried in babel, see what it generates:
> > > > > >> > > > > > >
> > > > > >> > > > > > >
> > > > > >> > > > > > >
> > > > > >> > > > >
> > > > > >> > >
> > > > > >>
> > > > > >>
> > > > >
> > >
> > http://babeljs.io/repl/#?experimental=true&evaluate=true&loose=false&spec
> > > > >
> > >
> > >>=false&code=class%20A%20{%0A%09constructor%28%29%20{%0A%09%20%20this._pro
> > > > >
> > >
> > >>perty%20%3D%20%22init%22%3B%0A%09}%0A%09get%20property%28%29%3Astring%20{
> > > > >
> > >
> > >>%0A%09%09return%20this._property%3B%0A%09}%0A%09%0A%09set%20property%28va
> > > > >
> > >
> > >>lue%3Astring%29%20{%0A%09%09this._property%20%3D%20value%3B%0A%09}%20%0A%
> > > > >
> > >
> > >>09%0A%09showMyValue%28%29%20{%0A%09%09alert%28this._property%29%3B%0A%09}
> > > > >
> > >
> > >>%0A%0A}%0A%0Aclass%20B%20extends%20A%20{%0A%09get%20property%28%29%3Astri
> > > > >
> > >
> > >>ng%20{%0A%09%09return%20super.property%3B%0A%09}%0A%09%0A%09set%20propert
> > > > >
> > >
> > >>y%28value%3Astring%29%20{%0A%09%09super.property%20%3D%20value%3B%0A%09}%
> > > > > >>0A}
> > > > > >> > > > > > >
> > > > > >> > > > > > > Frédéric 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’m still surprised that in 2015, TS hasn’t 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
> > > get
> > > > > >>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 OZ.
> > > > > >> > > > > > > > > >
> > > > > >> > > > > > > > > >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 !=
> > > > > >> > > 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
> > > actionscript
> > > > > >> could
> > > > > >> > > be
> > > > > >> > > > > cross
> > > > > >> > > > > > > > > >compiled if you can't call super accessors.
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > > > I’m still surprised that in 2015, TS hasn’t been
> > > forced
> > > > > >>to
> > > > > >> > > handle
> > > > > >> > > > > > > super.
> > > > > >> > > > > > > > > Are people not using inheritance much in TS?
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > > > >
> > > > > >> > > > > > > > > >Alex, when you have time, can you explain what
> > > this is
> > > > > >> doing
> > > > > >> > > so I
> > > > > >> > > > > can
> > > > > >> > > > > > > > > >implement it.
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > > > I have not read the spec, but
> > > Object.defineProperties
> > > > > >> appears
> > > > > >> > > to
> > > > > >> > > > > > > associate
> > > > > >> > > > > > > > > a data structure with a “class”. 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 ‘this’ pointer and scope. 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’s
> > > property
> > > > > >>map.
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > > > In looking around the internet, the solutions
> > > seemed to:
> > > > > >> > > > > > > > > 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 ‘this’ pointer.
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > > > So that’s what is in the current JSFlexJSEmitter,
> > > 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, but
> > > > > >> steps
> > > > > >> > > 2
> > > > > >> > > > > > > through 4
> > > > > >> > > > > > > > > can be the same.
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > > > It is step 4 that re-introduces “re-writing” 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’ll bet there
> > > are
> > > > > >>still
> > > > > >> > > bugs
> > > > > >> > > > > in the
> > > > > >> > > > > > > > > current JSFlexJSEmitter.
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > > > And I think I still haven’t fixed the scenario
> > where
> > > > > >>only a
> > > > > >> > > getter
> > > > > >> > > > > or
> > > > > >> > > > > > > > > setter is overridden. The generated code must
> > > > > >>propagate a
> > > > > >> > > “pass
> > > > > >> > > > > > > through”
> > > > > >> > > > > > > > > for the missing getter or setter to the subclass’s
> > > data
> > > > > >> > > structure
> > > > > >> > > > > > > > > otherwise the runtime will not find the setter or
> > > getter
> > > > > >> and
> > > > > >> > > think
> > > > > >> > > > > the
> > > > > >> > > > > > > > > property is now read-only or write-only.
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > > > >
> > > > > >> > > > > > > > > >So correct me if I am wrong but, since there is
> > > really
> > > > > >>no
> > > > > >> > > solution
> > > > > >> > > > > > > without
> > > > > >> > > > > > > > > >an external utility to call a super accessor, we
> > > can't
> > > > > >> really
> > > > > >> > > say
> > > > > >> > > > > that
> > > > > >> > > > > > > > > >this
> > > > > >> > > > > > > > > >transpiler is producing vanilla javascript.
> > > Chicken egg
> > > > > >> thing.
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > > > Technically, you could inline everything in the
> > > utility
> > > > > >> > > 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 and
> > > > > >> > > loading
> > > > > >> > > > > > > > > dependency definitions in a particular order. It
> > > seems
> > > > > >>to
> > > > > >> be
> > > > > >> > > > > somewhat
> > > > > >> > > > > > > > > pay-as-you-go. If no inheritance, then almost no
> > > > > >>“goog”.
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > > > -Alex
> > > > > >> > > > > > > > >
> > > > > >> > > > > > > > >
> > > > > >> > > > > > >
> > > > > >> > > > > > >
> > > > > >> > > > >
> > > > > >> > > > >
> > > > > >> > >
> > > > > >> > >
> > > > > >>
> > > > > >>
> > > > >
> > > > >
> > >
> > >
> >
Re: [FalconJX] JXEmitter accessors
Posted by Josh Tynjala <jo...@gmail.com>.
I suspect Closure is trying to be more backwards compatible. I think
Object. create() was added in ES5, and maybe they're aiming for ES3 there.
- Josh
On May 28, 2015 7:11 AM, "Michael Schmalle" <te...@gmail.com>
wrote:
> See this is where I am clueless, is this a difference between backward
> compatibility or something?
>
> Like Object.create() not all older browsers support?
>
> Mike
>
> On Thu, May 28, 2015 at 10:06 AM, Frédéric THOMAS <webdoublefx@hotmail.com
> >
> wrote:
>
> > Btw, this is the diff between Closure and Babel:
> >
> > goog.inherits = function (childCtor, parentCtor) {
> > /** @constructor */
> > function tempCtor() {
> > };
> > tempCtor.prototype = parentCtor.prototype;
> > childCtor.superClass_ = parentCtor.prototype;
> > childCtor.prototype = new tempCtor();
> > /** @override */
> > childCtor.prototype.constructor = childCtor;
> > };
> >
> > function _inherits(subClass, superClass) {
> > if (typeof superClass !== "function" && superClass !== null) {
> > throw new TypeError("Super expression must either be null or a
> > function, not " + typeof superClass);
> > }
> > subClass.prototype = Object.create(superClass &&
> superClass.prototype,
> > {
> > constructor: {
> > value: subClass,
> > enumerable: false,
> > writable: true,
> > configurable: true
> > }
> > });
> > if (superClass) subClass.__proto__ = superClass;
> > }
> >
> >
> > Frédéric THOMAS
> >
> > > Date: Thu, 28 May 2015 09:36:50 -0400
> > > Subject: Re: [FalconJX] JXEmitter accessors
> > > From: teotigraphixllc@gmail.com
> > > To: dev@flex.apache.org
> > >
> > > 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 <ah...@adobe.com> wrote:
> > >
> > > > FWIW, I did not test goog.inherit against Object.getPrototypeOf. It
> > might
> > > > 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" <te...@gmail.com>
> > wrote:
> > > >
> > > > >Fred,
> > > > >
> > > > >I said TS only because Josh said it looked nice, the came Josh with
> > Bable
> > > > >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
> > spec
> > > > >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édéric THOMAS <
> > webdoublefx@hotmail.com
> > > > >
> > > > >wrote:
> > > > >
> > > > >> > You mean if AS3 and ES6 inherit the same way correct? I wouldn't
> > know
> > > > >>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 on
> > > > >> 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
> > anonymous
> > > > >> > 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édéric 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édéric 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, if
> > > > >> yes,
> > > > >> > > this function is re-usable IMO
> > > > >> > >
> > > > >> >
> > > > >> >
> > > > >> > You mean if AS3 and ES6 inherit the same way correct? I wouldn't
> > know
> > > > >>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 on
> > > > >>it.
> > > > >> >
> > > > >> > I guess one of the other questions is how it handles/outputs
> > anonymous
> > > > >> > function call scope, you want to do a test with that? Like three
> > or so
> > > > >> > levels nested.
> > > > >> >
> > > > >> > Mike
> > > > >> >
> > > > >> >
> > > > >> >
> > > > >> > >
> > > > >> > > Frédéric 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
> > the
> > > > >> > > > 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édéric THOMAS <
> > > > >> > > webdoublefx@hotmail.com>
> > > > >> > > > wrote:
> > > > >> > > >
> > > > >> > > > > I'm not a javascript guru either, but it was easy to
> create
> > ES6
> > > > >> 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 = value;
> > > > >> > > > > }
> > > > >> > > > >
> > > > >> > > > > For class B:
> > > > >> > > > >
> > > > >> > > > >
> > > > >> > > > > set: function (value) {
> > > > >> > > > > _set(Object.getPrototypeOf(B.prototype),
> > "property",
> > > > >> value,
> > > > >> > > > > this);
> > > > >> > > > > }
> > > > >> > > > >
> > > > >> > > > > Which calls:
> > > > >> > > > >
> > > > >> > > > > var _set = function set(object, property, value,
> receiver) {
> > > > >> > > > > var desc = Object.getOwnPropertyDescriptor(object,
> > > > >>property);
> > > > >> //
> > > > >> > > Get
> > > > >> > > > > the property on B
> > > > >> > > > > if (desc === undefined) { // If not overrided, will
> set
> > the
> > > > >> parent
> > > > >> > > > > recursively if the parent doesn't override the property
> > either.
> > > > >> > > > > var parent = Object.getPrototypeOf(object);
> > > > >> > > > > if (parent !== null) {
> > > > >> > > > > set(parent, property, value, receiver);
> > > > >> > > > > }
> > > > >> > > > > } else if ("value" in desc && desc.writable) { //
> > didn't get
> > > > >> this
> > > > >> > > part
> > > > >> > > > > desc.value = value;
> > > > >> > > > > } else { // Else call the setterv of this Object
> > > > >> > > > > var setter = desc.set;
> > > > >> > > > > if (setter !== 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
> > check
> > > > >> if the
> > > > >> > > > > property has been overriden, if Yes, get the value.
> > > > >> > > > >
> > > > >> > > > > var _get = function get(_x, _x2, _x3) {
> > > > >> > > > > var _again = true;
> > > > >> > > > > _function: while (_again) {
> > > > >> > > > > var object = _x, property = _x2, receiver = _x3;
> > > > >> > > > > desc = parent = getter = undefined;
> > > > >> > > > > _again = false;
> > > > >> > > > > var desc = Object.getOwnPropertyDescriptor(object,
> > > > >> property);
> > > > >> > > > > if (desc === undefined) {
> > > > >> > > > > var parent = Object.getPrototypeOf(object);
> > > > >> > > > > if (parent === null) {
> > > > >> > > > > return undefined;
> > > > >> > > > > } else {
> > > > >> > > > > _x = parent;
> > > > >> > > > > _x2 = property;
> > > > >> > > > > _x3 = receiver;
> > > > >> > > > > _again = true;
> > > > >> > > > > continue _function;
> > > > >> > > > > }
> > > > >> > > > > } else if ("value" in desc) {
> > > > >> > > > > return desc.value;
> > > > >> > > > > } else {
> > > > >> > > > > var getter = desc.get;
> > > > >> > > > > if (getter === undefined) {
> > > > >> > > > > return undefined;
> > > > >> > > > > }
> > > > >> > > > > return getter.call(receiver);
> > > > >> > > > > }
> > > > >> > > > > }
> > > > >> > > > > };
> > > > >> > > > >
> > > > >> > > > > Does it do the trick ?
> > > > >> > > > >
> > > > >> > > > > Frédéric 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 to
> > > > >> "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édéric THOMAS <
> > > > >> > > > > webdoublefx@hotmail.com>
> > > > >> > > > > > wrote:
> > > > >> > > > > >
> > > > >> > > > > > > I just tried in babel, see what it generates:
> > > > >> > > > > > >
> > > > >> > > > > > >
> > > > >> > > > > > >
> > > > >> > > > >
> > > > >> > >
> > > > >>
> > > > >>
> > > >
> >
> http://babeljs.io/repl/#?experimental=true&evaluate=true&loose=false&spec
> > > >
> >
> >>=false&code=class%20A%20{%0A%09constructor%28%29%20{%0A%09%20%20this._pro
> > > >
> >
> >>perty%20%3D%20%22init%22%3B%0A%09}%0A%09get%20property%28%29%3Astring%20{
> > > >
> >
> >>%0A%09%09return%20this._property%3B%0A%09}%0A%09%0A%09set%20property%28va
> > > >
> >
> >>lue%3Astring%29%20{%0A%09%09this._property%20%3D%20value%3B%0A%09}%20%0A%
> > > >
> >
> >>09%0A%09showMyValue%28%29%20{%0A%09%09alert%28this._property%29%3B%0A%09}
> > > >
> >
> >>%0A%0A}%0A%0Aclass%20B%20extends%20A%20{%0A%09get%20property%28%29%3Astri
> > > >
> >
> >>ng%20{%0A%09%09return%20super.property%3B%0A%09}%0A%09%0A%09set%20propert
> > > >
> >
> >>y%28value%3Astring%29%20{%0A%09%09super.property%20%3D%20value%3B%0A%09}%
> > > > >>0A}
> > > > >> > > > > > >
> > > > >> > > > > > > Frédéric 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’m still surprised that in 2015, TS hasn’t 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
> > get
> > > > >>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 OZ.
> > > > >> > > > > > > > > >
> > > > >> > > > > > > > > >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 !=
> > > > >> > > 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
> > actionscript
> > > > >> could
> > > > >> > > be
> > > > >> > > > > cross
> > > > >> > > > > > > > > >compiled if you can't call super accessors.
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > I’m still surprised that in 2015, TS hasn’t been
> > forced
> > > > >>to
> > > > >> > > handle
> > > > >> > > > > > > super.
> > > > >> > > > > > > > > Are people not using inheritance much in TS?
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > >
> > > > >> > > > > > > > > >Alex, when you have time, can you explain what
> > this is
> > > > >> doing
> > > > >> > > so I
> > > > >> > > > > can
> > > > >> > > > > > > > > >implement it.
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > I have not read the spec, but
> > Object.defineProperties
> > > > >> appears
> > > > >> > > to
> > > > >> > > > > > > associate
> > > > >> > > > > > > > > a data structure with a “class”. 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 ‘this’ pointer and scope. 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’s
> > property
> > > > >>map.
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > In looking around the internet, the solutions
> > seemed to:
> > > > >> > > > > > > > > 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 ‘this’ pointer.
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > So that’s what is in the current JSFlexJSEmitter,
> > 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, but
> > > > >> steps
> > > > >> > > 2
> > > > >> > > > > > > through 4
> > > > >> > > > > > > > > can be the same.
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > It is step 4 that re-introduces “re-writing” 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’ll bet there
> > are
> > > > >>still
> > > > >> > > bugs
> > > > >> > > > > in the
> > > > >> > > > > > > > > current JSFlexJSEmitter.
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > And I think I still haven’t fixed the scenario
> where
> > > > >>only a
> > > > >> > > getter
> > > > >> > > > > or
> > > > >> > > > > > > > > setter is overridden. The generated code must
> > > > >>propagate a
> > > > >> > > “pass
> > > > >> > > > > > > through”
> > > > >> > > > > > > > > for the missing getter or setter to the subclass’s
> > data
> > > > >> > > structure
> > > > >> > > > > > > > > otherwise the runtime will not find the setter or
> > getter
> > > > >> and
> > > > >> > > think
> > > > >> > > > > the
> > > > >> > > > > > > > > property is now read-only or write-only.
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > >
> > > > >> > > > > > > > > >So correct me if I am wrong but, since there is
> > really
> > > > >>no
> > > > >> > > solution
> > > > >> > > > > > > without
> > > > >> > > > > > > > > >an external utility to call a super accessor, we
> > can't
> > > > >> really
> > > > >> > > say
> > > > >> > > > > that
> > > > >> > > > > > > > > >this
> > > > >> > > > > > > > > >transpiler is producing vanilla javascript.
> > Chicken egg
> > > > >> thing.
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > Technically, you could inline everything in the
> > utility
> > > > >> > > 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 and
> > > > >> > > loading
> > > > >> > > > > > > > > dependency definitions in a particular order. It
> > seems
> > > > >>to
> > > > >> be
> > > > >> > > > > somewhat
> > > > >> > > > > > > > > pay-as-you-go. If no inheritance, then almost no
> > > > >>“goog”.
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > -Alex
> > > > >> > > > > > > > >
> > > > >> > > > > > > > >
> > > > >> > > > > > >
> > > > >> > > > > > >
> > > > >> > > > >
> > > > >> > > > >
> > > > >> > >
> > > > >> > >
> > > > >>
> > > > >>
> > > >
> > > >
> >
> >
>
RE: [FalconJX] JXEmitter accessors
Posted by Frédéric THOMAS <we...@hotmail.com>.
You are right:
Chrome Firefox (Gecko) Internet Explorer Opera Safari
5 4.0 (2) 9 11.60 5
For oldest, there are polyfills
Frédéric THOMAS
> Date: Thu, 28 May 2015 10:09:59 -0400
> Subject: Re: [FalconJX] JXEmitter accessors
> From: teotigraphixllc@gmail.com
> To: dev@flex.apache.org
>
> See this is where I am clueless, is this a difference between backward
> compatibility or something?
>
> Like Object.create() not all older browsers support?
>
> Mike
>
> On Thu, May 28, 2015 at 10:06 AM, Frédéric THOMAS <we...@hotmail.com>
> wrote:
>
> > Btw, this is the diff between Closure and Babel:
> >
> > goog.inherits = function (childCtor, parentCtor) {
> > /** @constructor */
> > function tempCtor() {
> > };
> > tempCtor.prototype = parentCtor.prototype;
> > childCtor.superClass_ = parentCtor.prototype;
> > childCtor.prototype = new tempCtor();
> > /** @override */
> > childCtor.prototype.constructor = childCtor;
> > };
> >
> > function _inherits(subClass, superClass) {
> > if (typeof superClass !== "function" && superClass !== null) {
> > throw new TypeError("Super expression must either be null or a
> > function, not " + typeof superClass);
> > }
> > subClass.prototype = Object.create(superClass && superClass.prototype,
> > {
> > constructor: {
> > value: subClass,
> > enumerable: false,
> > writable: true,
> > configurable: true
> > }
> > });
> > if (superClass) subClass.__proto__ = superClass;
> > }
> >
> >
> > Frédéric THOMAS
> >
> > > Date: Thu, 28 May 2015 09:36:50 -0400
> > > Subject: Re: [FalconJX] JXEmitter accessors
> > > From: teotigraphixllc@gmail.com
> > > To: dev@flex.apache.org
> > >
> > > 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 <ah...@adobe.com> wrote:
> > >
> > > > FWIW, I did not test goog.inherit against Object.getPrototypeOf. It
> > might
> > > > 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" <te...@gmail.com>
> > wrote:
> > > >
> > > > >Fred,
> > > > >
> > > > >I said TS only because Josh said it looked nice, the came Josh with
> > Bable
> > > > >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
> > spec
> > > > >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édéric THOMAS <
> > webdoublefx@hotmail.com
> > > > >
> > > > >wrote:
> > > > >
> > > > >> > You mean if AS3 and ES6 inherit the same way correct? I wouldn't
> > know
> > > > >>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 on
> > > > >> 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
> > anonymous
> > > > >> > 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édéric 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édéric 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, if
> > > > >> yes,
> > > > >> > > this function is re-usable IMO
> > > > >> > >
> > > > >> >
> > > > >> >
> > > > >> > You mean if AS3 and ES6 inherit the same way correct? I wouldn't
> > know
> > > > >>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 on
> > > > >>it.
> > > > >> >
> > > > >> > I guess one of the other questions is how it handles/outputs
> > anonymous
> > > > >> > function call scope, you want to do a test with that? Like three
> > or so
> > > > >> > levels nested.
> > > > >> >
> > > > >> > Mike
> > > > >> >
> > > > >> >
> > > > >> >
> > > > >> > >
> > > > >> > > Frédéric 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
> > the
> > > > >> > > > 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édéric THOMAS <
> > > > >> > > webdoublefx@hotmail.com>
> > > > >> > > > wrote:
> > > > >> > > >
> > > > >> > > > > I'm not a javascript guru either, but it was easy to create
> > ES6
> > > > >> 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 = value;
> > > > >> > > > > }
> > > > >> > > > >
> > > > >> > > > > For class B:
> > > > >> > > > >
> > > > >> > > > >
> > > > >> > > > > set: function (value) {
> > > > >> > > > > _set(Object.getPrototypeOf(B.prototype),
> > "property",
> > > > >> value,
> > > > >> > > > > this);
> > > > >> > > > > }
> > > > >> > > > >
> > > > >> > > > > Which calls:
> > > > >> > > > >
> > > > >> > > > > var _set = function set(object, property, value, receiver) {
> > > > >> > > > > var desc = Object.getOwnPropertyDescriptor(object,
> > > > >>property);
> > > > >> //
> > > > >> > > Get
> > > > >> > > > > the property on B
> > > > >> > > > > if (desc === undefined) { // If not overrided, will set
> > the
> > > > >> parent
> > > > >> > > > > recursively if the parent doesn't override the property
> > either.
> > > > >> > > > > var parent = Object.getPrototypeOf(object);
> > > > >> > > > > if (parent !== null) {
> > > > >> > > > > set(parent, property, value, receiver);
> > > > >> > > > > }
> > > > >> > > > > } else if ("value" in desc && desc.writable) { //
> > didn't get
> > > > >> this
> > > > >> > > part
> > > > >> > > > > desc.value = value;
> > > > >> > > > > } else { // Else call the setterv of this Object
> > > > >> > > > > var setter = desc.set;
> > > > >> > > > > if (setter !== 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
> > check
> > > > >> if the
> > > > >> > > > > property has been overriden, if Yes, get the value.
> > > > >> > > > >
> > > > >> > > > > var _get = function get(_x, _x2, _x3) {
> > > > >> > > > > var _again = true;
> > > > >> > > > > _function: while (_again) {
> > > > >> > > > > var object = _x, property = _x2, receiver = _x3;
> > > > >> > > > > desc = parent = getter = undefined;
> > > > >> > > > > _again = false;
> > > > >> > > > > var desc = Object.getOwnPropertyDescriptor(object,
> > > > >> property);
> > > > >> > > > > if (desc === undefined) {
> > > > >> > > > > var parent = Object.getPrototypeOf(object);
> > > > >> > > > > if (parent === null) {
> > > > >> > > > > return undefined;
> > > > >> > > > > } else {
> > > > >> > > > > _x = parent;
> > > > >> > > > > _x2 = property;
> > > > >> > > > > _x3 = receiver;
> > > > >> > > > > _again = true;
> > > > >> > > > > continue _function;
> > > > >> > > > > }
> > > > >> > > > > } else if ("value" in desc) {
> > > > >> > > > > return desc.value;
> > > > >> > > > > } else {
> > > > >> > > > > var getter = desc.get;
> > > > >> > > > > if (getter === undefined) {
> > > > >> > > > > return undefined;
> > > > >> > > > > }
> > > > >> > > > > return getter.call(receiver);
> > > > >> > > > > }
> > > > >> > > > > }
> > > > >> > > > > };
> > > > >> > > > >
> > > > >> > > > > Does it do the trick ?
> > > > >> > > > >
> > > > >> > > > > Frédéric 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 to
> > > > >> "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édéric THOMAS <
> > > > >> > > > > webdoublefx@hotmail.com>
> > > > >> > > > > > wrote:
> > > > >> > > > > >
> > > > >> > > > > > > I just tried in babel, see what it generates:
> > > > >> > > > > > >
> > > > >> > > > > > >
> > > > >> > > > > > >
> > > > >> > > > >
> > > > >> > >
> > > > >>
> > > > >>
> > > >
> > http://babeljs.io/repl/#?experimental=true&evaluate=true&loose=false&spec
> > > >
> > >>=false&code=class%20A%20{%0A%09constructor%28%29%20{%0A%09%20%20this._pro
> > > >
> > >>perty%20%3D%20%22init%22%3B%0A%09}%0A%09get%20property%28%29%3Astring%20{
> > > >
> > >>%0A%09%09return%20this._property%3B%0A%09}%0A%09%0A%09set%20property%28va
> > > >
> > >>lue%3Astring%29%20{%0A%09%09this._property%20%3D%20value%3B%0A%09}%20%0A%
> > > >
> > >>09%0A%09showMyValue%28%29%20{%0A%09%09alert%28this._property%29%3B%0A%09}
> > > >
> > >>%0A%0A}%0A%0Aclass%20B%20extends%20A%20{%0A%09get%20property%28%29%3Astri
> > > >
> > >>ng%20{%0A%09%09return%20super.property%3B%0A%09}%0A%09%0A%09set%20propert
> > > >
> > >>y%28value%3Astring%29%20{%0A%09%09super.property%20%3D%20value%3B%0A%09}%
> > > > >>0A}
> > > > >> > > > > > >
> > > > >> > > > > > > Frédéric 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’m still surprised that in 2015, TS hasn’t 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
> > get
> > > > >>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 OZ.
> > > > >> > > > > > > > > >
> > > > >> > > > > > > > > >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 !=
> > > > >> > > 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
> > actionscript
> > > > >> could
> > > > >> > > be
> > > > >> > > > > cross
> > > > >> > > > > > > > > >compiled if you can't call super accessors.
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > I’m still surprised that in 2015, TS hasn’t been
> > forced
> > > > >>to
> > > > >> > > handle
> > > > >> > > > > > > super.
> > > > >> > > > > > > > > Are people not using inheritance much in TS?
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > >
> > > > >> > > > > > > > > >Alex, when you have time, can you explain what
> > this is
> > > > >> doing
> > > > >> > > so I
> > > > >> > > > > can
> > > > >> > > > > > > > > >implement it.
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > I have not read the spec, but
> > Object.defineProperties
> > > > >> appears
> > > > >> > > to
> > > > >> > > > > > > associate
> > > > >> > > > > > > > > a data structure with a “class”. 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 ‘this’ pointer and scope. 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’s
> > property
> > > > >>map.
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > In looking around the internet, the solutions
> > seemed to:
> > > > >> > > > > > > > > 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 ‘this’ pointer.
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > So that’s what is in the current JSFlexJSEmitter,
> > 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, but
> > > > >> steps
> > > > >> > > 2
> > > > >> > > > > > > through 4
> > > > >> > > > > > > > > can be the same.
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > It is step 4 that re-introduces “re-writing” 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’ll bet there
> > are
> > > > >>still
> > > > >> > > bugs
> > > > >> > > > > in the
> > > > >> > > > > > > > > current JSFlexJSEmitter.
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > And I think I still haven’t fixed the scenario where
> > > > >>only a
> > > > >> > > getter
> > > > >> > > > > or
> > > > >> > > > > > > > > setter is overridden. The generated code must
> > > > >>propagate a
> > > > >> > > “pass
> > > > >> > > > > > > through”
> > > > >> > > > > > > > > for the missing getter or setter to the subclass’s
> > data
> > > > >> > > structure
> > > > >> > > > > > > > > otherwise the runtime will not find the setter or
> > getter
> > > > >> and
> > > > >> > > think
> > > > >> > > > > the
> > > > >> > > > > > > > > property is now read-only or write-only.
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > >
> > > > >> > > > > > > > > >So correct me if I am wrong but, since there is
> > really
> > > > >>no
> > > > >> > > solution
> > > > >> > > > > > > without
> > > > >> > > > > > > > > >an external utility to call a super accessor, we
> > can't
> > > > >> really
> > > > >> > > say
> > > > >> > > > > that
> > > > >> > > > > > > > > >this
> > > > >> > > > > > > > > >transpiler is producing vanilla javascript.
> > Chicken egg
> > > > >> thing.
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > Technically, you could inline everything in the
> > utility
> > > > >> > > 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 and
> > > > >> > > loading
> > > > >> > > > > > > > > dependency definitions in a particular order. It
> > seems
> > > > >>to
> > > > >> be
> > > > >> > > > > somewhat
> > > > >> > > > > > > > > pay-as-you-go. If no inheritance, then almost no
> > > > >>“goog”.
> > > > >> > > > > > > > >
> > > > >> > > > > > > > > -Alex
> > > > >> > > > > > > > >
> > > > >> > > > > > > > >
> > > > >> > > > > > >
> > > > >> > > > > > >
> > > > >> > > > >
> > > > >> > > > >
> > > > >> > >
> > > > >> > >
> > > > >>
> > > > >>
> > > >
> > > >
> >
> >
Re: [FalconJX] JXEmitter accessors
Posted by Michael Schmalle <te...@gmail.com>.
See this is where I am clueless, is this a difference between backward
compatibility or something?
Like Object.create() not all older browsers support?
Mike
On Thu, May 28, 2015 at 10:06 AM, Frédéric THOMAS <we...@hotmail.com>
wrote:
> Btw, this is the diff between Closure and Babel:
>
> goog.inherits = function (childCtor, parentCtor) {
> /** @constructor */
> function tempCtor() {
> };
> tempCtor.prototype = parentCtor.prototype;
> childCtor.superClass_ = parentCtor.prototype;
> childCtor.prototype = new tempCtor();
> /** @override */
> childCtor.prototype.constructor = childCtor;
> };
>
> function _inherits(subClass, superClass) {
> if (typeof superClass !== "function" && superClass !== null) {
> throw new TypeError("Super expression must either be null or a
> function, not " + typeof superClass);
> }
> subClass.prototype = Object.create(superClass && superClass.prototype,
> {
> constructor: {
> value: subClass,
> enumerable: false,
> writable: true,
> configurable: true
> }
> });
> if (superClass) subClass.__proto__ = superClass;
> }
>
>
> Frédéric THOMAS
>
> > Date: Thu, 28 May 2015 09:36:50 -0400
> > Subject: Re: [FalconJX] JXEmitter accessors
> > From: teotigraphixllc@gmail.com
> > To: dev@flex.apache.org
> >
> > 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 <ah...@adobe.com> wrote:
> >
> > > FWIW, I did not test goog.inherit against Object.getPrototypeOf. It
> might
> > > 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" <te...@gmail.com>
> wrote:
> > >
> > > >Fred,
> > > >
> > > >I said TS only because Josh said it looked nice, the came Josh with
> Bable
> > > >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
> spec
> > > >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édéric THOMAS <
> webdoublefx@hotmail.com
> > > >
> > > >wrote:
> > > >
> > > >> > You mean if AS3 and ES6 inherit the same way correct? I wouldn't
> know
> > > >>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 on
> > > >> 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
> anonymous
> > > >> > 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édéric 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édéric 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, if
> > > >> yes,
> > > >> > > this function is re-usable IMO
> > > >> > >
> > > >> >
> > > >> >
> > > >> > You mean if AS3 and ES6 inherit the same way correct? I wouldn't
> know
> > > >>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 on
> > > >>it.
> > > >> >
> > > >> > I guess one of the other questions is how it handles/outputs
> anonymous
> > > >> > function call scope, you want to do a test with that? Like three
> or so
> > > >> > levels nested.
> > > >> >
> > > >> > Mike
> > > >> >
> > > >> >
> > > >> >
> > > >> > >
> > > >> > > Frédéric 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
> the
> > > >> > > > 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édéric THOMAS <
> > > >> > > webdoublefx@hotmail.com>
> > > >> > > > wrote:
> > > >> > > >
> > > >> > > > > I'm not a javascript guru either, but it was easy to create
> ES6
> > > >> 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 = value;
> > > >> > > > > }
> > > >> > > > >
> > > >> > > > > For class B:
> > > >> > > > >
> > > >> > > > >
> > > >> > > > > set: function (value) {
> > > >> > > > > _set(Object.getPrototypeOf(B.prototype),
> "property",
> > > >> value,
> > > >> > > > > this);
> > > >> > > > > }
> > > >> > > > >
> > > >> > > > > Which calls:
> > > >> > > > >
> > > >> > > > > var _set = function set(object, property, value, receiver) {
> > > >> > > > > var desc = Object.getOwnPropertyDescriptor(object,
> > > >>property);
> > > >> //
> > > >> > > Get
> > > >> > > > > the property on B
> > > >> > > > > if (desc === undefined) { // If not overrided, will set
> the
> > > >> parent
> > > >> > > > > recursively if the parent doesn't override the property
> either.
> > > >> > > > > var parent = Object.getPrototypeOf(object);
> > > >> > > > > if (parent !== null) {
> > > >> > > > > set(parent, property, value, receiver);
> > > >> > > > > }
> > > >> > > > > } else if ("value" in desc && desc.writable) { //
> didn't get
> > > >> this
> > > >> > > part
> > > >> > > > > desc.value = value;
> > > >> > > > > } else { // Else call the setterv of this Object
> > > >> > > > > var setter = desc.set;
> > > >> > > > > if (setter !== 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
> check
> > > >> if the
> > > >> > > > > property has been overriden, if Yes, get the value.
> > > >> > > > >
> > > >> > > > > var _get = function get(_x, _x2, _x3) {
> > > >> > > > > var _again = true;
> > > >> > > > > _function: while (_again) {
> > > >> > > > > var object = _x, property = _x2, receiver = _x3;
> > > >> > > > > desc = parent = getter = undefined;
> > > >> > > > > _again = false;
> > > >> > > > > var desc = Object.getOwnPropertyDescriptor(object,
> > > >> property);
> > > >> > > > > if (desc === undefined) {
> > > >> > > > > var parent = Object.getPrototypeOf(object);
> > > >> > > > > if (parent === null) {
> > > >> > > > > return undefined;
> > > >> > > > > } else {
> > > >> > > > > _x = parent;
> > > >> > > > > _x2 = property;
> > > >> > > > > _x3 = receiver;
> > > >> > > > > _again = true;
> > > >> > > > > continue _function;
> > > >> > > > > }
> > > >> > > > > } else if ("value" in desc) {
> > > >> > > > > return desc.value;
> > > >> > > > > } else {
> > > >> > > > > var getter = desc.get;
> > > >> > > > > if (getter === undefined) {
> > > >> > > > > return undefined;
> > > >> > > > > }
> > > >> > > > > return getter.call(receiver);
> > > >> > > > > }
> > > >> > > > > }
> > > >> > > > > };
> > > >> > > > >
> > > >> > > > > Does it do the trick ?
> > > >> > > > >
> > > >> > > > > Frédéric 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 to
> > > >> "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édéric THOMAS <
> > > >> > > > > webdoublefx@hotmail.com>
> > > >> > > > > > wrote:
> > > >> > > > > >
> > > >> > > > > > > I just tried in babel, see what it generates:
> > > >> > > > > > >
> > > >> > > > > > >
> > > >> > > > > > >
> > > >> > > > >
> > > >> > >
> > > >>
> > > >>
> > >
> http://babeljs.io/repl/#?experimental=true&evaluate=true&loose=false&spec
> > >
> >>=false&code=class%20A%20{%0A%09constructor%28%29%20{%0A%09%20%20this._pro
> > >
> >>perty%20%3D%20%22init%22%3B%0A%09}%0A%09get%20property%28%29%3Astring%20{
> > >
> >>%0A%09%09return%20this._property%3B%0A%09}%0A%09%0A%09set%20property%28va
> > >
> >>lue%3Astring%29%20{%0A%09%09this._property%20%3D%20value%3B%0A%09}%20%0A%
> > >
> >>09%0A%09showMyValue%28%29%20{%0A%09%09alert%28this._property%29%3B%0A%09}
> > >
> >>%0A%0A}%0A%0Aclass%20B%20extends%20A%20{%0A%09get%20property%28%29%3Astri
> > >
> >>ng%20{%0A%09%09return%20super.property%3B%0A%09}%0A%09%0A%09set%20propert
> > >
> >>y%28value%3Astring%29%20{%0A%09%09super.property%20%3D%20value%3B%0A%09}%
> > > >>0A}
> > > >> > > > > > >
> > > >> > > > > > > Frédéric 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’m still surprised that in 2015, TS hasn’t 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
> get
> > > >>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 OZ.
> > > >> > > > > > > > > >
> > > >> > > > > > > > > >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 !=
> > > >> > > 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
> actionscript
> > > >> could
> > > >> > > be
> > > >> > > > > cross
> > > >> > > > > > > > > >compiled if you can't call super accessors.
> > > >> > > > > > > > >
> > > >> > > > > > > > > I’m still surprised that in 2015, TS hasn’t been
> forced
> > > >>to
> > > >> > > handle
> > > >> > > > > > > super.
> > > >> > > > > > > > > Are people not using inheritance much in TS?
> > > >> > > > > > > > >
> > > >> > > > > > > > > >
> > > >> > > > > > > > > >Alex, when you have time, can you explain what
> this is
> > > >> doing
> > > >> > > so I
> > > >> > > > > can
> > > >> > > > > > > > > >implement it.
> > > >> > > > > > > > >
> > > >> > > > > > > > > I have not read the spec, but
> Object.defineProperties
> > > >> appears
> > > >> > > to
> > > >> > > > > > > associate
> > > >> > > > > > > > > a data structure with a “class”. 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 ‘this’ pointer and scope. 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’s
> property
> > > >>map.
> > > >> > > > > > > > >
> > > >> > > > > > > > > In looking around the internet, the solutions
> seemed to:
> > > >> > > > > > > > > 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 ‘this’ pointer.
> > > >> > > > > > > > >
> > > >> > > > > > > > > So that’s what is in the current JSFlexJSEmitter,
> 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, but
> > > >> steps
> > > >> > > 2
> > > >> > > > > > > through 4
> > > >> > > > > > > > > can be the same.
> > > >> > > > > > > > >
> > > >> > > > > > > > > It is step 4 that re-introduces “re-writing” 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’ll bet there
> are
> > > >>still
> > > >> > > bugs
> > > >> > > > > in the
> > > >> > > > > > > > > current JSFlexJSEmitter.
> > > >> > > > > > > > >
> > > >> > > > > > > > > And I think I still haven’t fixed the scenario where
> > > >>only a
> > > >> > > getter
> > > >> > > > > or
> > > >> > > > > > > > > setter is overridden. The generated code must
> > > >>propagate a
> > > >> > > “pass
> > > >> > > > > > > through”
> > > >> > > > > > > > > for the missing getter or setter to the subclass’s
> data
> > > >> > > structure
> > > >> > > > > > > > > otherwise the runtime will not find the setter or
> getter
> > > >> and
> > > >> > > think
> > > >> > > > > the
> > > >> > > > > > > > > property is now read-only or write-only.
> > > >> > > > > > > > >
> > > >> > > > > > > > > >
> > > >> > > > > > > > > >So correct me if I am wrong but, since there is
> really
> > > >>no
> > > >> > > solution
> > > >> > > > > > > without
> > > >> > > > > > > > > >an external utility to call a super accessor, we
> can't
> > > >> really
> > > >> > > say
> > > >> > > > > that
> > > >> > > > > > > > > >this
> > > >> > > > > > > > > >transpiler is producing vanilla javascript.
> Chicken egg
> > > >> thing.
> > > >> > > > > > > > >
> > > >> > > > > > > > > Technically, you could inline everything in the
> utility
> > > >> > > 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 and
> > > >> > > loading
> > > >> > > > > > > > > dependency definitions in a particular order. It
> seems
> > > >>to
> > > >> be
> > > >> > > > > somewhat
> > > >> > > > > > > > > pay-as-you-go. If no inheritance, then almost no
> > > >>“goog”.
> > > >> > > > > > > > >
> > > >> > > > > > > > > -Alex
> > > >> > > > > > > > >
> > > >> > > > > > > > >
> > > >> > > > > > >
> > > >> > > > > > >
> > > >> > > > >
> > > >> > > > >
> > > >> > >
> > > >> > >
> > > >>
> > > >>
> > >
> > >
>
>
RE: [FalconJX] JXEmitter accessors
Posted by Frédéric THOMAS <we...@hotmail.com>.
Btw, this is the diff between Closure and Babel:
goog.inherits = function (childCtor, parentCtor) {
/** @constructor */
function tempCtor() {
};
tempCtor.prototype = parentCtor.prototype;
childCtor.superClass_ = parentCtor.prototype;
childCtor.prototype = new tempCtor();
/** @override */
childCtor.prototype.constructor = childCtor;
};
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) subClass.__proto__ = superClass;
}
Frédéric THOMAS
> Date: Thu, 28 May 2015 09:36:50 -0400
> Subject: Re: [FalconJX] JXEmitter accessors
> From: teotigraphixllc@gmail.com
> To: dev@flex.apache.org
>
> 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 <ah...@adobe.com> wrote:
>
> > FWIW, I did not test goog.inherit against Object.getPrototypeOf. It might
> > 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" <te...@gmail.com> wrote:
> >
> > >Fred,
> > >
> > >I said TS only because Josh said it looked nice, the came Josh with Bable
> > >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 spec
> > >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édéric THOMAS <webdoublefx@hotmail.com
> > >
> > >wrote:
> > >
> > >> > You mean if AS3 and ES6 inherit the same way correct? I wouldn't know
> > >>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 on
> > >> 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 anonymous
> > >> > 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édéric 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édéric 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, if
> > >> yes,
> > >> > > this function is re-usable IMO
> > >> > >
> > >> >
> > >> >
> > >> > You mean if AS3 and ES6 inherit the same way correct? I wouldn't know
> > >>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 on
> > >>it.
> > >> >
> > >> > I guess one of the other questions is how it handles/outputs anonymous
> > >> > function call scope, you want to do a test with that? Like three or so
> > >> > levels nested.
> > >> >
> > >> > Mike
> > >> >
> > >> >
> > >> >
> > >> > >
> > >> > > Frédéric 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 the
> > >> > > > 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édéric THOMAS <
> > >> > > webdoublefx@hotmail.com>
> > >> > > > wrote:
> > >> > > >
> > >> > > > > I'm not a javascript guru either, but it was easy to create ES6
> > >> 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 = value;
> > >> > > > > }
> > >> > > > >
> > >> > > > > For class B:
> > >> > > > >
> > >> > > > >
> > >> > > > > set: function (value) {
> > >> > > > > _set(Object.getPrototypeOf(B.prototype), "property",
> > >> value,
> > >> > > > > this);
> > >> > > > > }
> > >> > > > >
> > >> > > > > Which calls:
> > >> > > > >
> > >> > > > > var _set = function set(object, property, value, receiver) {
> > >> > > > > var desc = Object.getOwnPropertyDescriptor(object,
> > >>property);
> > >> //
> > >> > > Get
> > >> > > > > the property on B
> > >> > > > > if (desc === undefined) { // If not overrided, will set the
> > >> parent
> > >> > > > > recursively if the parent doesn't override the property either.
> > >> > > > > var parent = Object.getPrototypeOf(object);
> > >> > > > > if (parent !== null) {
> > >> > > > > set(parent, property, value, receiver);
> > >> > > > > }
> > >> > > > > } else if ("value" in desc && desc.writable) { // didn't get
> > >> this
> > >> > > part
> > >> > > > > desc.value = value;
> > >> > > > > } else { // Else call the setterv of this Object
> > >> > > > > var setter = desc.set;
> > >> > > > > if (setter !== 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 check
> > >> if the
> > >> > > > > property has been overriden, if Yes, get the value.
> > >> > > > >
> > >> > > > > var _get = function get(_x, _x2, _x3) {
> > >> > > > > var _again = true;
> > >> > > > > _function: while (_again) {
> > >> > > > > var object = _x, property = _x2, receiver = _x3;
> > >> > > > > desc = parent = getter = undefined;
> > >> > > > > _again = false;
> > >> > > > > var desc = Object.getOwnPropertyDescriptor(object,
> > >> property);
> > >> > > > > if (desc === undefined) {
> > >> > > > > var parent = Object.getPrototypeOf(object);
> > >> > > > > if (parent === null) {
> > >> > > > > return undefined;
> > >> > > > > } else {
> > >> > > > > _x = parent;
> > >> > > > > _x2 = property;
> > >> > > > > _x3 = receiver;
> > >> > > > > _again = true;
> > >> > > > > continue _function;
> > >> > > > > }
> > >> > > > > } else if ("value" in desc) {
> > >> > > > > return desc.value;
> > >> > > > > } else {
> > >> > > > > var getter = desc.get;
> > >> > > > > if (getter === undefined) {
> > >> > > > > return undefined;
> > >> > > > > }
> > >> > > > > return getter.call(receiver);
> > >> > > > > }
> > >> > > > > }
> > >> > > > > };
> > >> > > > >
> > >> > > > > Does it do the trick ?
> > >> > > > >
> > >> > > > > Frédéric 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 to
> > >> "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édéric THOMAS <
> > >> > > > > webdoublefx@hotmail.com>
> > >> > > > > > wrote:
> > >> > > > > >
> > >> > > > > > > I just tried in babel, see what it generates:
> > >> > > > > > >
> > >> > > > > > >
> > >> > > > > > >
> > >> > > > >
> > >> > >
> > >>
> > >>
> > http://babeljs.io/repl/#?experimental=true&evaluate=true&loose=false&spec
> > >>=false&code=class%20A%20{%0A%09constructor%28%29%20{%0A%09%20%20this._pro
> > >>perty%20%3D%20%22init%22%3B%0A%09}%0A%09get%20property%28%29%3Astring%20{
> > >>%0A%09%09return%20this._property%3B%0A%09}%0A%09%0A%09set%20property%28va
> > >>lue%3Astring%29%20{%0A%09%09this._property%20%3D%20value%3B%0A%09}%20%0A%
> > >>09%0A%09showMyValue%28%29%20{%0A%09%09alert%28this._property%29%3B%0A%09}
> > >>%0A%0A}%0A%0Aclass%20B%20extends%20A%20{%0A%09get%20property%28%29%3Astri
> > >>ng%20{%0A%09%09return%20super.property%3B%0A%09}%0A%09%0A%09set%20propert
> > >>y%28value%3Astring%29%20{%0A%09%09super.property%20%3D%20value%3B%0A%09}%
> > >>0A}
> > >> > > > > > >
> > >> > > > > > > Frédéric 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’m still surprised that in 2015, TS hasn’t 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 get
> > >>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 OZ.
> > >> > > > > > > > > >
> > >> > > > > > > > > >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 !=
> > >> > > 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 actionscript
> > >> could
> > >> > > be
> > >> > > > > cross
> > >> > > > > > > > > >compiled if you can't call super accessors.
> > >> > > > > > > > >
> > >> > > > > > > > > I’m still surprised that in 2015, TS hasn’t been forced
> > >>to
> > >> > > handle
> > >> > > > > > > super.
> > >> > > > > > > > > Are people not using inheritance much in TS?
> > >> > > > > > > > >
> > >> > > > > > > > > >
> > >> > > > > > > > > >Alex, when you have time, can you explain what this is
> > >> doing
> > >> > > so I
> > >> > > > > can
> > >> > > > > > > > > >implement it.
> > >> > > > > > > > >
> > >> > > > > > > > > I have not read the spec, but Object.defineProperties
> > >> appears
> > >> > > to
> > >> > > > > > > associate
> > >> > > > > > > > > a data structure with a “class”. 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 ‘this’ pointer and scope. 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’s property
> > >>map.
> > >> > > > > > > > >
> > >> > > > > > > > > In looking around the internet, the solutions seemed to:
> > >> > > > > > > > > 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 ‘this’ pointer.
> > >> > > > > > > > >
> > >> > > > > > > > > So that’s what is in the current JSFlexJSEmitter, 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, but
> > >> steps
> > >> > > 2
> > >> > > > > > > through 4
> > >> > > > > > > > > can be the same.
> > >> > > > > > > > >
> > >> > > > > > > > > It is step 4 that re-introduces “re-writing” 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’ll bet there are
> > >>still
> > >> > > bugs
> > >> > > > > in the
> > >> > > > > > > > > current JSFlexJSEmitter.
> > >> > > > > > > > >
> > >> > > > > > > > > And I think I still haven’t fixed the scenario where
> > >>only a
> > >> > > getter
> > >> > > > > or
> > >> > > > > > > > > setter is overridden. The generated code must
> > >>propagate a
> > >> > > “pass
> > >> > > > > > > through”
> > >> > > > > > > > > for the missing getter or setter to the subclass’s data
> > >> > > structure
> > >> > > > > > > > > otherwise the runtime will not find the setter or getter
> > >> and
> > >> > > think
> > >> > > > > the
> > >> > > > > > > > > property is now read-only or write-only.
> > >> > > > > > > > >
> > >> > > > > > > > > >
> > >> > > > > > > > > >So correct me if I am wrong but, since there is really
> > >>no
> > >> > > solution
> > >> > > > > > > without
> > >> > > > > > > > > >an external utility to call a super accessor, we can't
> > >> really
> > >> > > say
> > >> > > > > that
> > >> > > > > > > > > >this
> > >> > > > > > > > > >transpiler is producing vanilla javascript. Chicken egg
> > >> thing.
> > >> > > > > > > > >
> > >> > > > > > > > > Technically, you could inline everything in the utility
> > >> > > 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 and
> > >> > > loading
> > >> > > > > > > > > dependency definitions in a particular order. It seems
> > >>to
> > >> be
> > >> > > > > somewhat
> > >> > > > > > > > > pay-as-you-go. If no inheritance, then almost no
> > >>“goog”.
> > >> > > > > > > > >
> > >> > > > > > > > > -Alex
> > >> > > > > > > > >
> > >> > > > > > > > >
> > >> > > > > > >
> > >> > > > > > >
> > >> > > > >
> > >> > > > >
> > >> > >
> > >> > >
> > >>
> > >>
> >
> >
Re: [FalconJX] JXEmitter accessors
Posted by Michael Schmalle <te...@gmail.com>.
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 <ah...@adobe.com> wrote:
> FWIW, I did not test goog.inherit against Object.getPrototypeOf. It might
> 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" <te...@gmail.com> wrote:
>
> >Fred,
> >
> >I said TS only because Josh said it looked nice, the came Josh with Bable
> >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 spec
> >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édéric THOMAS <webdoublefx@hotmail.com
> >
> >wrote:
> >
> >> > You mean if AS3 and ES6 inherit the same way correct? I wouldn't know
> >>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 on
> >> 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 anonymous
> >> > 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édéric 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édéric 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, if
> >> yes,
> >> > > this function is re-usable IMO
> >> > >
> >> >
> >> >
> >> > You mean if AS3 and ES6 inherit the same way correct? I wouldn't know
> >>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 on
> >>it.
> >> >
> >> > I guess one of the other questions is how it handles/outputs anonymous
> >> > function call scope, you want to do a test with that? Like three or so
> >> > levels nested.
> >> >
> >> > Mike
> >> >
> >> >
> >> >
> >> > >
> >> > > Frédéric 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 the
> >> > > > 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édéric THOMAS <
> >> > > webdoublefx@hotmail.com>
> >> > > > wrote:
> >> > > >
> >> > > > > I'm not a javascript guru either, but it was easy to create ES6
> >> 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 = value;
> >> > > > > }
> >> > > > >
> >> > > > > For class B:
> >> > > > >
> >> > > > >
> >> > > > > set: function (value) {
> >> > > > > _set(Object.getPrototypeOf(B.prototype), "property",
> >> value,
> >> > > > > this);
> >> > > > > }
> >> > > > >
> >> > > > > Which calls:
> >> > > > >
> >> > > > > var _set = function set(object, property, value, receiver) {
> >> > > > > var desc = Object.getOwnPropertyDescriptor(object,
> >>property);
> >> //
> >> > > Get
> >> > > > > the property on B
> >> > > > > if (desc === undefined) { // If not overrided, will set the
> >> parent
> >> > > > > recursively if the parent doesn't override the property either.
> >> > > > > var parent = Object.getPrototypeOf(object);
> >> > > > > if (parent !== null) {
> >> > > > > set(parent, property, value, receiver);
> >> > > > > }
> >> > > > > } else if ("value" in desc && desc.writable) { // didn't get
> >> this
> >> > > part
> >> > > > > desc.value = value;
> >> > > > > } else { // Else call the setterv of this Object
> >> > > > > var setter = desc.set;
> >> > > > > if (setter !== 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 check
> >> if the
> >> > > > > property has been overriden, if Yes, get the value.
> >> > > > >
> >> > > > > var _get = function get(_x, _x2, _x3) {
> >> > > > > var _again = true;
> >> > > > > _function: while (_again) {
> >> > > > > var object = _x, property = _x2, receiver = _x3;
> >> > > > > desc = parent = getter = undefined;
> >> > > > > _again = false;
> >> > > > > var desc = Object.getOwnPropertyDescriptor(object,
> >> property);
> >> > > > > if (desc === undefined) {
> >> > > > > var parent = Object.getPrototypeOf(object);
> >> > > > > if (parent === null) {
> >> > > > > return undefined;
> >> > > > > } else {
> >> > > > > _x = parent;
> >> > > > > _x2 = property;
> >> > > > > _x3 = receiver;
> >> > > > > _again = true;
> >> > > > > continue _function;
> >> > > > > }
> >> > > > > } else if ("value" in desc) {
> >> > > > > return desc.value;
> >> > > > > } else {
> >> > > > > var getter = desc.get;
> >> > > > > if (getter === undefined) {
> >> > > > > return undefined;
> >> > > > > }
> >> > > > > return getter.call(receiver);
> >> > > > > }
> >> > > > > }
> >> > > > > };
> >> > > > >
> >> > > > > Does it do the trick ?
> >> > > > >
> >> > > > > Frédéric 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 to
> >> "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édéric THOMAS <
> >> > > > > webdoublefx@hotmail.com>
> >> > > > > > wrote:
> >> > > > > >
> >> > > > > > > I just tried in babel, see what it generates:
> >> > > > > > >
> >> > > > > > >
> >> > > > > > >
> >> > > > >
> >> > >
> >>
> >>
> http://babeljs.io/repl/#?experimental=true&evaluate=true&loose=false&spec
> >>=false&code=class%20A%20{%0A%09constructor%28%29%20{%0A%09%20%20this._pro
> >>perty%20%3D%20%22init%22%3B%0A%09}%0A%09get%20property%28%29%3Astring%20{
> >>%0A%09%09return%20this._property%3B%0A%09}%0A%09%0A%09set%20property%28va
> >>lue%3Astring%29%20{%0A%09%09this._property%20%3D%20value%3B%0A%09}%20%0A%
> >>09%0A%09showMyValue%28%29%20{%0A%09%09alert%28this._property%29%3B%0A%09}
> >>%0A%0A}%0A%0Aclass%20B%20extends%20A%20{%0A%09get%20property%28%29%3Astri
> >>ng%20{%0A%09%09return%20super.property%3B%0A%09}%0A%09%0A%09set%20propert
> >>y%28value%3Astring%29%20{%0A%09%09super.property%20%3D%20value%3B%0A%09}%
> >>0A}
> >> > > > > > >
> >> > > > > > > Frédéric 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’m still surprised that in 2015, TS hasn’t 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 get
> >>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 OZ.
> >> > > > > > > > > >
> >> > > > > > > > > >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 !=
> >> > > 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 actionscript
> >> could
> >> > > be
> >> > > > > cross
> >> > > > > > > > > >compiled if you can't call super accessors.
> >> > > > > > > > >
> >> > > > > > > > > I’m still surprised that in 2015, TS hasn’t been forced
> >>to
> >> > > handle
> >> > > > > > > super.
> >> > > > > > > > > Are people not using inheritance much in TS?
> >> > > > > > > > >
> >> > > > > > > > > >
> >> > > > > > > > > >Alex, when you have time, can you explain what this is
> >> doing
> >> > > so I
> >> > > > > can
> >> > > > > > > > > >implement it.
> >> > > > > > > > >
> >> > > > > > > > > I have not read the spec, but Object.defineProperties
> >> appears
> >> > > to
> >> > > > > > > associate
> >> > > > > > > > > a data structure with a “class”. 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 ‘this’ pointer and scope. 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’s property
> >>map.
> >> > > > > > > > >
> >> > > > > > > > > In looking around the internet, the solutions seemed to:
> >> > > > > > > > > 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 ‘this’ pointer.
> >> > > > > > > > >
> >> > > > > > > > > So that’s what is in the current JSFlexJSEmitter, 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, but
> >> steps
> >> > > 2
> >> > > > > > > through 4
> >> > > > > > > > > can be the same.
> >> > > > > > > > >
> >> > > > > > > > > It is step 4 that re-introduces “re-writing” 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’ll bet there are
> >>still
> >> > > bugs
> >> > > > > in the
> >> > > > > > > > > current JSFlexJSEmitter.
> >> > > > > > > > >
> >> > > > > > > > > And I think I still haven’t fixed the scenario where
> >>only a
> >> > > getter
> >> > > > > or
> >> > > > > > > > > setter is overridden. The generated code must
> >>propagate a
> >> > > “pass
> >> > > > > > > through”
> >> > > > > > > > > for the missing getter or setter to the subclass’s data
> >> > > structure
> >> > > > > > > > > otherwise the runtime will not find the setter or getter
> >> and
> >> > > think
> >> > > > > the
> >> > > > > > > > > property is now read-only or write-only.
> >> > > > > > > > >
> >> > > > > > > > > >
> >> > > > > > > > > >So correct me if I am wrong but, since there is really
> >>no
> >> > > solution
> >> > > > > > > without
> >> > > > > > > > > >an external utility to call a super accessor, we can't
> >> really
> >> > > say
> >> > > > > that
> >> > > > > > > > > >this
> >> > > > > > > > > >transpiler is producing vanilla javascript. Chicken egg
> >> thing.
> >> > > > > > > > >
> >> > > > > > > > > Technically, you could inline everything in the utility
> >> > > 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 and
> >> > > loading
> >> > > > > > > > > dependency definitions in a particular order. It seems
> >>to
> >> be
> >> > > > > somewhat
> >> > > > > > > > > pay-as-you-go. If no inheritance, then almost no
> >>“goog”.
> >> > > > > > > > >
> >> > > > > > > > > -Alex
> >> > > > > > > > >
> >> > > > > > > > >
> >> > > > > > >
> >> > > > > > >
> >> > > > >
> >> > > > >
> >> > >
> >> > >
> >>
> >>
>
>
Re: [FalconJX] JXEmitter accessors
Posted by Alex Harui <ah...@adobe.com>.
FWIW, I did not test goog.inherit against Object.getPrototypeOf. It might
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" <te...@gmail.com> wrote:
>Fred,
>
>I said TS only because Josh said it looked nice, the came Josh with Bable
>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 spec
>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édéric THOMAS <we...@hotmail.com>
>wrote:
>
>> > You mean if AS3 and ES6 inherit the same way correct? I wouldn't know
>>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 on
>> 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 anonymous
>> > 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édéric 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édéric 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, if
>> yes,
>> > > this function is re-usable IMO
>> > >
>> >
>> >
>> > You mean if AS3 and ES6 inherit the same way correct? I wouldn't know
>>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 on
>>it.
>> >
>> > I guess one of the other questions is how it handles/outputs anonymous
>> > function call scope, you want to do a test with that? Like three or so
>> > levels nested.
>> >
>> > Mike
>> >
>> >
>> >
>> > >
>> > > Frédéric 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 the
>> > > > 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édéric THOMAS <
>> > > webdoublefx@hotmail.com>
>> > > > wrote:
>> > > >
>> > > > > I'm not a javascript guru either, but it was easy to create ES6
>> 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 = value;
>> > > > > }
>> > > > >
>> > > > > For class B:
>> > > > >
>> > > > >
>> > > > > set: function (value) {
>> > > > > _set(Object.getPrototypeOf(B.prototype), "property",
>> value,
>> > > > > this);
>> > > > > }
>> > > > >
>> > > > > Which calls:
>> > > > >
>> > > > > var _set = function set(object, property, value, receiver) {
>> > > > > var desc = Object.getOwnPropertyDescriptor(object,
>>property);
>> //
>> > > Get
>> > > > > the property on B
>> > > > > if (desc === undefined) { // If not overrided, will set the
>> parent
>> > > > > recursively if the parent doesn't override the property either.
>> > > > > var parent = Object.getPrototypeOf(object);
>> > > > > if (parent !== null) {
>> > > > > set(parent, property, value, receiver);
>> > > > > }
>> > > > > } else if ("value" in desc && desc.writable) { // didn't get
>> this
>> > > part
>> > > > > desc.value = value;
>> > > > > } else { // Else call the setterv of this Object
>> > > > > var setter = desc.set;
>> > > > > if (setter !== 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 check
>> if the
>> > > > > property has been overriden, if Yes, get the value.
>> > > > >
>> > > > > var _get = function get(_x, _x2, _x3) {
>> > > > > var _again = true;
>> > > > > _function: while (_again) {
>> > > > > var object = _x, property = _x2, receiver = _x3;
>> > > > > desc = parent = getter = undefined;
>> > > > > _again = false;
>> > > > > var desc = Object.getOwnPropertyDescriptor(object,
>> property);
>> > > > > if (desc === undefined) {
>> > > > > var parent = Object.getPrototypeOf(object);
>> > > > > if (parent === null) {
>> > > > > return undefined;
>> > > > > } else {
>> > > > > _x = parent;
>> > > > > _x2 = property;
>> > > > > _x3 = receiver;
>> > > > > _again = true;
>> > > > > continue _function;
>> > > > > }
>> > > > > } else if ("value" in desc) {
>> > > > > return desc.value;
>> > > > > } else {
>> > > > > var getter = desc.get;
>> > > > > if (getter === undefined) {
>> > > > > return undefined;
>> > > > > }
>> > > > > return getter.call(receiver);
>> > > > > }
>> > > > > }
>> > > > > };
>> > > > >
>> > > > > Does it do the trick ?
>> > > > >
>> > > > > Frédéric 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 to
>> "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édéric THOMAS <
>> > > > > webdoublefx@hotmail.com>
>> > > > > > wrote:
>> > > > > >
>> > > > > > > I just tried in babel, see what it generates:
>> > > > > > >
>> > > > > > >
>> > > > > > >
>> > > > >
>> > >
>>
>>http://babeljs.io/repl/#?experimental=true&evaluate=true&loose=false&spec
>>=false&code=class%20A%20{%0A%09constructor%28%29%20{%0A%09%20%20this._pro
>>perty%20%3D%20%22init%22%3B%0A%09}%0A%09get%20property%28%29%3Astring%20{
>>%0A%09%09return%20this._property%3B%0A%09}%0A%09%0A%09set%20property%28va
>>lue%3Astring%29%20{%0A%09%09this._property%20%3D%20value%3B%0A%09}%20%0A%
>>09%0A%09showMyValue%28%29%20{%0A%09%09alert%28this._property%29%3B%0A%09}
>>%0A%0A}%0A%0Aclass%20B%20extends%20A%20{%0A%09get%20property%28%29%3Astri
>>ng%20{%0A%09%09return%20super.property%3B%0A%09}%0A%09%0A%09set%20propert
>>y%28value%3Astring%29%20{%0A%09%09super.property%20%3D%20value%3B%0A%09}%
>>0A}
>> > > > > > >
>> > > > > > > Frédéric 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’m still surprised that in 2015, TS hasn’t 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 get
>>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 OZ.
>> > > > > > > > > >
>> > > > > > > > > >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 !=
>> > > 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 actionscript
>> could
>> > > be
>> > > > > cross
>> > > > > > > > > >compiled if you can't call super accessors.
>> > > > > > > > >
>> > > > > > > > > I’m still surprised that in 2015, TS hasn’t been forced
>>to
>> > > handle
>> > > > > > > super.
>> > > > > > > > > Are people not using inheritance much in TS?
>> > > > > > > > >
>> > > > > > > > > >
>> > > > > > > > > >Alex, when you have time, can you explain what this is
>> doing
>> > > so I
>> > > > > can
>> > > > > > > > > >implement it.
>> > > > > > > > >
>> > > > > > > > > I have not read the spec, but Object.defineProperties
>> appears
>> > > to
>> > > > > > > associate
>> > > > > > > > > a data structure with a “class”. 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 ‘this’ pointer and scope. 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’s property
>>map.
>> > > > > > > > >
>> > > > > > > > > In looking around the internet, the solutions seemed to:
>> > > > > > > > > 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 ‘this’ pointer.
>> > > > > > > > >
>> > > > > > > > > So that’s what is in the current JSFlexJSEmitter, 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, but
>> steps
>> > > 2
>> > > > > > > through 4
>> > > > > > > > > can be the same.
>> > > > > > > > >
>> > > > > > > > > It is step 4 that re-introduces “re-writing” 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’ll bet there are
>>still
>> > > bugs
>> > > > > in the
>> > > > > > > > > current JSFlexJSEmitter.
>> > > > > > > > >
>> > > > > > > > > And I think I still haven’t fixed the scenario where
>>only a
>> > > getter
>> > > > > or
>> > > > > > > > > setter is overridden. The generated code must
>>propagate a
>> > > “pass
>> > > > > > > through”
>> > > > > > > > > for the missing getter or setter to the subclass’s data
>> > > structure
>> > > > > > > > > otherwise the runtime will not find the setter or getter
>> and
>> > > think
>> > > > > the
>> > > > > > > > > property is now read-only or write-only.
>> > > > > > > > >
>> > > > > > > > > >
>> > > > > > > > > >So correct me if I am wrong but, since there is really
>>no
>> > > solution
>> > > > > > > without
>> > > > > > > > > >an external utility to call a super accessor, we can't
>> really
>> > > say
>> > > > > that
>> > > > > > > > > >this
>> > > > > > > > > >transpiler is producing vanilla javascript. Chicken egg
>> thing.
>> > > > > > > > >
>> > > > > > > > > Technically, you could inline everything in the utility
>> > > 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 and
>> > > loading
>> > > > > > > > > dependency definitions in a particular order. It seems
>>to
>> be
>> > > > > somewhat
>> > > > > > > > > pay-as-you-go. If no inheritance, then almost no
>>“goog”.
>> > > > > > > > >
>> > > > > > > > > -Alex
>> > > > > > > > >
>> > > > > > > > >
>> > > > > > >
>> > > > > > >
>> > > > >
>> > > > >
>> > >
>> > >
>>
>>
Re: [FalconJX] JXEmitter accessors
Posted by Michael Schmalle <te...@gmail.com>.
Fred,
I said TS only because Josh said it looked nice, the came Josh with Bable
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 spec
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édéric THOMAS <we...@hotmail.com>
wrote:
> > You mean if AS3 and ES6 inherit the same way correct? I wouldn't know 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 on
> 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 anonymous
> > 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édéric 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édéric 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, if
> yes,
> > > this function is re-usable IMO
> > >
> >
> >
> > You mean if AS3 and ES6 inherit the same way correct? I wouldn't know 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 on it.
> >
> > I guess one of the other questions is how it handles/outputs anonymous
> > function call scope, you want to do a test with that? Like three or so
> > levels nested.
> >
> > Mike
> >
> >
> >
> > >
> > > Frédéric 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 the
> > > > 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édéric THOMAS <
> > > webdoublefx@hotmail.com>
> > > > wrote:
> > > >
> > > > > I'm not a javascript guru either, but it was easy to create ES6
> 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 = value;
> > > > > }
> > > > >
> > > > > For class B:
> > > > >
> > > > >
> > > > > set: function (value) {
> > > > > _set(Object.getPrototypeOf(B.prototype), "property",
> value,
> > > > > this);
> > > > > }
> > > > >
> > > > > Which calls:
> > > > >
> > > > > var _set = function set(object, property, value, receiver) {
> > > > > var desc = Object.getOwnPropertyDescriptor(object, property);
> //
> > > Get
> > > > > the property on B
> > > > > if (desc === undefined) { // If not overrided, will set the
> parent
> > > > > recursively if the parent doesn't override the property either.
> > > > > var parent = Object.getPrototypeOf(object);
> > > > > if (parent !== null) {
> > > > > set(parent, property, value, receiver);
> > > > > }
> > > > > } else if ("value" in desc && desc.writable) { // didn't get
> this
> > > part
> > > > > desc.value = value;
> > > > > } else { // Else call the setterv of this Object
> > > > > var setter = desc.set;
> > > > > if (setter !== 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 check
> if the
> > > > > property has been overriden, if Yes, get the value.
> > > > >
> > > > > var _get = function get(_x, _x2, _x3) {
> > > > > var _again = true;
> > > > > _function: while (_again) {
> > > > > var object = _x, property = _x2, receiver = _x3;
> > > > > desc = parent = getter = undefined;
> > > > > _again = false;
> > > > > var desc = Object.getOwnPropertyDescriptor(object,
> property);
> > > > > if (desc === undefined) {
> > > > > var parent = Object.getPrototypeOf(object);
> > > > > if (parent === null) {
> > > > > return undefined;
> > > > > } else {
> > > > > _x = parent;
> > > > > _x2 = property;
> > > > > _x3 = receiver;
> > > > > _again = true;
> > > > > continue _function;
> > > > > }
> > > > > } else if ("value" in desc) {
> > > > > return desc.value;
> > > > > } else {
> > > > > var getter = desc.get;
> > > > > if (getter === undefined) {
> > > > > return undefined;
> > > > > }
> > > > > return getter.call(receiver);
> > > > > }
> > > > > }
> > > > > };
> > > > >
> > > > > Does it do the trick ?
> > > > >
> > > > > Frédéric 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 to
> "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édéric THOMAS <
> > > > > webdoublefx@hotmail.com>
> > > > > > wrote:
> > > > > >
> > > > > > > I just tried in babel, see what it generates:
> > > > > > >
> > > > > > >
> > > > > > >
> > > > >
> > >
> http://babeljs.io/repl/#?experimental=true&evaluate=true&loose=false&spec=false&code=class%20A%20{%0A%09constructor%28%29%20{%0A%09%20%20this._property%20%3D%20%22init%22%3B%0A%09}%0A%09get%20property%28%29%3Astring%20{%0A%09%09return%20this._property%3B%0A%09}%0A%09%0A%09set%20property%28value%3Astring%29%20{%0A%09%09this._property%20%3D%20value%3B%0A%09}%20%0A%09%0A%09showMyValue%28%29%20{%0A%09%09alert%28this._property%29%3B%0A%09}%0A%0A}%0A%0Aclass%20B%20extends%20A%20{%0A%09get%20property%28%29%3Astring%20{%0A%09%09return%20super.property%3B%0A%09}%0A%09%0A%09set%20property%28value%3Astring%29%20{%0A%09%09super.property%20%3D%20value%3B%0A%09}%0A}
> > > > > > >
> > > > > > > Frédéric 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’m still surprised that in 2015, TS hasn’t 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 get 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 OZ.
> > > > > > > > > >
> > > > > > > > > >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 !=
> > > 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 actionscript
> could
> > > be
> > > > > cross
> > > > > > > > > >compiled if you can't call super accessors.
> > > > > > > > >
> > > > > > > > > I’m still surprised that in 2015, TS hasn’t been forced to
> > > handle
> > > > > > > super.
> > > > > > > > > Are people not using inheritance much in TS?
> > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >Alex, when you have time, can you explain what this is
> doing
> > > so I
> > > > > can
> > > > > > > > > >implement it.
> > > > > > > > >
> > > > > > > > > I have not read the spec, but Object.defineProperties
> appears
> > > to
> > > > > > > associate
> > > > > > > > > a data structure with a “class”. 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 ‘this’ pointer and scope. 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’s property map.
> > > > > > > > >
> > > > > > > > > In looking around the internet, the solutions seemed to:
> > > > > > > > > 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 ‘this’ pointer.
> > > > > > > > >
> > > > > > > > > So that’s what is in the current JSFlexJSEmitter, 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, but
> steps
> > > 2
> > > > > > > through 4
> > > > > > > > > can be the same.
> > > > > > > > >
> > > > > > > > > It is step 4 that re-introduces “re-writing” 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’ll bet there are still
> > > bugs
> > > > > in the
> > > > > > > > > current JSFlexJSEmitter.
> > > > > > > > >
> > > > > > > > > And I think I still haven’t fixed the scenario where only a
> > > getter
> > > > > or
> > > > > > > > > setter is overridden. The generated code must propagate a
> > > “pass
> > > > > > > through”
> > > > > > > > > for the missing getter or setter to the subclass’s data
> > > structure
> > > > > > > > > otherwise the runtime will not find the setter or getter
> and
> > > think
> > > > > the
> > > > > > > > > property is now read-only or write-only.
> > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >So correct me if I am wrong but, since there is really no
> > > solution
> > > > > > > without
> > > > > > > > > >an external utility to call a super accessor, we can't
> really
> > > say
> > > > > that
> > > > > > > > > >this
> > > > > > > > > >transpiler is producing vanilla javascript. Chicken egg
> thing.
> > > > > > > > >
> > > > > > > > > Technically, you could inline everything in the utility
> > > 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 and
> > > loading
> > > > > > > > > dependency definitions in a particular order. It seems to
> be
> > > > > somewhat
> > > > > > > > > pay-as-you-go. If no inheritance, then almost no “goog”.
> > > > > > > > >
> > > > > > > > > -Alex
> > > > > > > > >
> > > > > > > > >
> > > > > > >
> > > > > > >
> > > > >
> > > > >
> > >
> > >
>
>
RE: [FalconJX] JXEmitter accessors
Posted by Frédéric THOMAS <we...@hotmail.com>.
> You mean if AS3 and ES6 inherit the same way correct? I wouldn't know 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 on 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 anonymous
> 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édéric 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édéric THOMAS <we...@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, if yes,
> > this function is re-usable IMO
> >
>
>
> You mean if AS3 and ES6 inherit the same way correct? I wouldn't know 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 on it.
>
> I guess one of the other questions is how it handles/outputs anonymous
> function call scope, you want to do a test with that? Like three or so
> levels nested.
>
> Mike
>
>
>
> >
> > Frédéric 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 the
> > > 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édéric THOMAS <
> > webdoublefx@hotmail.com>
> > > wrote:
> > >
> > > > I'm not a javascript guru either, but it was easy to create ES6 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 = value;
> > > > }
> > > >
> > > > For class B:
> > > >
> > > >
> > > > set: function (value) {
> > > > _set(Object.getPrototypeOf(B.prototype), "property", value,
> > > > this);
> > > > }
> > > >
> > > > Which calls:
> > > >
> > > > var _set = function set(object, property, value, receiver) {
> > > > var desc = Object.getOwnPropertyDescriptor(object, property); //
> > Get
> > > > the property on B
> > > > if (desc === undefined) { // If not overrided, will set the parent
> > > > recursively if the parent doesn't override the property either.
> > > > var parent = Object.getPrototypeOf(object);
> > > > if (parent !== null) {
> > > > set(parent, property, value, receiver);
> > > > }
> > > > } else if ("value" in desc && desc.writable) { // didn't get this
> > part
> > > > desc.value = value;
> > > > } else { // Else call the setterv of this Object
> > > > var setter = desc.set;
> > > > if (setter !== 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 check if the
> > > > property has been overriden, if Yes, get the value.
> > > >
> > > > var _get = function get(_x, _x2, _x3) {
> > > > var _again = true;
> > > > _function: while (_again) {
> > > > var object = _x, property = _x2, receiver = _x3;
> > > > desc = parent = getter = undefined;
> > > > _again = false;
> > > > var desc = Object.getOwnPropertyDescriptor(object, property);
> > > > if (desc === undefined) {
> > > > var parent = Object.getPrototypeOf(object);
> > > > if (parent === null) {
> > > > return undefined;
> > > > } else {
> > > > _x = parent;
> > > > _x2 = property;
> > > > _x3 = receiver;
> > > > _again = true;
> > > > continue _function;
> > > > }
> > > > } else if ("value" in desc) {
> > > > return desc.value;
> > > > } else {
> > > > var getter = desc.get;
> > > > if (getter === undefined) {
> > > > return undefined;
> > > > }
> > > > return getter.call(receiver);
> > > > }
> > > > }
> > > > };
> > > >
> > > > Does it do the trick ?
> > > >
> > > > Frédéric 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 to "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édéric THOMAS <
> > > > webdoublefx@hotmail.com>
> > > > > wrote:
> > > > >
> > > > > > I just tried in babel, see what it generates:
> > > > > >
> > > > > >
> > > > > >
> > > >
> > http://babeljs.io/repl/#?experimental=true&evaluate=true&loose=false&spec=false&code=class%20A%20{%0A%09constructor%28%29%20{%0A%09%20%20this._property%20%3D%20%22init%22%3B%0A%09}%0A%09get%20property%28%29%3Astring%20{%0A%09%09return%20this._property%3B%0A%09}%0A%09%0A%09set%20property%28value%3Astring%29%20{%0A%09%09this._property%20%3D%20value%3B%0A%09}%20%0A%09%0A%09showMyValue%28%29%20{%0A%09%09alert%28this._property%29%3B%0A%09}%0A%0A}%0A%0Aclass%20B%20extends%20A%20{%0A%09get%20property%28%29%3Astring%20{%0A%09%09return%20super.property%3B%0A%09}%0A%09%0A%09set%20property%28value%3Astring%29%20{%0A%09%09super.property%20%3D%20value%3B%0A%09}%0A}
> > > > > >
> > > > > > Frédéric 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’m still surprised that in 2015, TS hasn’t 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 get his
> > project
> > > > > > > working, Josh?
> > > > > > >
> > > > > > > Mike
> > > > > > >
> > > > > > >
> > > > > > > On Wed, May 27, 2015 at 7:51 PM, Alex Harui <ah...@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 OZ.
> > > > > > > > >
> > > > > > > > >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 !=
> > 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 actionscript could
> > be
> > > > cross
> > > > > > > > >compiled if you can't call super accessors.
> > > > > > > >
> > > > > > > > I’m still surprised that in 2015, TS hasn’t been forced to
> > handle
> > > > > > super.
> > > > > > > > Are people not using inheritance much in TS?
> > > > > > > >
> > > > > > > > >
> > > > > > > > >Alex, when you have time, can you explain what this is doing
> > so I
> > > > can
> > > > > > > > >implement it.
> > > > > > > >
> > > > > > > > I have not read the spec, but Object.defineProperties appears
> > to
> > > > > > associate
> > > > > > > > a data structure with a “class”. 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 ‘this’ pointer and scope. 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’s property map.
> > > > > > > >
> > > > > > > > In looking around the internet, the solutions seemed to:
> > > > > > > > 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 ‘this’ pointer.
> > > > > > > >
> > > > > > > > So that’s what is in the current JSFlexJSEmitter, 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, but steps
> > 2
> > > > > > through 4
> > > > > > > > can be the same.
> > > > > > > >
> > > > > > > > It is step 4 that re-introduces “re-writing” 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’ll bet there are still
> > bugs
> > > > in the
> > > > > > > > current JSFlexJSEmitter.
> > > > > > > >
> > > > > > > > And I think I still haven’t fixed the scenario where only a
> > getter
> > > > or
> > > > > > > > setter is overridden. The generated code must propagate a
> > “pass
> > > > > > through”
> > > > > > > > for the missing getter or setter to the subclass’s data
> > structure
> > > > > > > > otherwise the runtime will not find the setter or getter and
> > think
> > > > the
> > > > > > > > property is now read-only or write-only.
> > > > > > > >
> > > > > > > > >
> > > > > > > > >So correct me if I am wrong but, since there is really no
> > solution
> > > > > > without
> > > > > > > > >an external utility to call a super accessor, we can't really
> > say
> > > > that
> > > > > > > > >this
> > > > > > > > >transpiler is producing vanilla javascript. Chicken egg thing.
> > > > > > > >
> > > > > > > > Technically, you could inline everything in the utility
> > 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 and
> > loading
> > > > > > > > dependency definitions in a particular order. It seems to be
> > > > somewhat
> > > > > > > > pay-as-you-go. If no inheritance, then almost no “goog”.
> > > > > > > >
> > > > > > > > -Alex
> > > > > > > >
> > > > > > > >
> > > > > >
> > > > > >
> > > >
> > > >
> >
> >
Re: [FalconJX] JXEmitter accessors
Posted by Michael Schmalle <te...@gmail.com>.
On Thu, May 28, 2015 at 8:41 AM, Frédéric THOMAS <we...@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, if yes,
> this function is re-usable IMO
>
You mean if AS3 and ES6 inherit the same way correct? I wouldn't know 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 on it.
I guess one of the other questions is how it handles/outputs anonymous
function call scope, you want to do a test with that? Like three or so
levels nested.
Mike
>
> Frédéric 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 the
> > 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édéric THOMAS <
> webdoublefx@hotmail.com>
> > wrote:
> >
> > > I'm not a javascript guru either, but it was easy to create ES6 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 = value;
> > > }
> > >
> > > For class B:
> > >
> > >
> > > set: function (value) {
> > > _set(Object.getPrototypeOf(B.prototype), "property", value,
> > > this);
> > > }
> > >
> > > Which calls:
> > >
> > > var _set = function set(object, property, value, receiver) {
> > > var desc = Object.getOwnPropertyDescriptor(object, property); //
> Get
> > > the property on B
> > > if (desc === undefined) { // If not overrided, will set the parent
> > > recursively if the parent doesn't override the property either.
> > > var parent = Object.getPrototypeOf(object);
> > > if (parent !== null) {
> > > set(parent, property, value, receiver);
> > > }
> > > } else if ("value" in desc && desc.writable) { // didn't get this
> part
> > > desc.value = value;
> > > } else { // Else call the setterv of this Object
> > > var setter = desc.set;
> > > if (setter !== 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 check if the
> > > property has been overriden, if Yes, get the value.
> > >
> > > var _get = function get(_x, _x2, _x3) {
> > > var _again = true;
> > > _function: while (_again) {
> > > var object = _x, property = _x2, receiver = _x3;
> > > desc = parent = getter = undefined;
> > > _again = false;
> > > var desc = Object.getOwnPropertyDescriptor(object, property);
> > > if (desc === undefined) {
> > > var parent = Object.getPrototypeOf(object);
> > > if (parent === null) {
> > > return undefined;
> > > } else {
> > > _x = parent;
> > > _x2 = property;
> > > _x3 = receiver;
> > > _again = true;
> > > continue _function;
> > > }
> > > } else if ("value" in desc) {
> > > return desc.value;
> > > } else {
> > > var getter = desc.get;
> > > if (getter === undefined) {
> > > return undefined;
> > > }
> > > return getter.call(receiver);
> > > }
> > > }
> > > };
> > >
> > > Does it do the trick ?
> > >
> > > Frédéric 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 to "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édéric THOMAS <
> > > webdoublefx@hotmail.com>
> > > > wrote:
> > > >
> > > > > I just tried in babel, see what it generates:
> > > > >
> > > > >
> > > > >
> > >
> http://babeljs.io/repl/#?experimental=true&evaluate=true&loose=false&spec=false&code=class%20A%20{%0A%09constructor%28%29%20{%0A%09%20%20this._property%20%3D%20%22init%22%3B%0A%09}%0A%09get%20property%28%29%3Astring%20{%0A%09%09return%20this._property%3B%0A%09}%0A%09%0A%09set%20property%28value%3Astring%29%20{%0A%09%09this._property%20%3D%20value%3B%0A%09}%20%0A%09%0A%09showMyValue%28%29%20{%0A%09%09alert%28this._property%29%3B%0A%09}%0A%0A}%0A%0Aclass%20B%20extends%20A%20{%0A%09get%20property%28%29%3Astring%20{%0A%09%09return%20super.property%3B%0A%09}%0A%09%0A%09set%20property%28value%3Astring%29%20{%0A%09%09super.property%20%3D%20value%3B%0A%09}%0A}
> > > > >
> > > > > Frédéric 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’m still surprised that in 2015, TS hasn’t 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 get his
> project
> > > > > > working, Josh?
> > > > > >
> > > > > > Mike
> > > > > >
> > > > > >
> > > > > > On Wed, May 27, 2015 at 7:51 PM, Alex Harui <ah...@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 OZ.
> > > > > > > >
> > > > > > > >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 !=
> 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 actionscript could
> be
> > > cross
> > > > > > > >compiled if you can't call super accessors.
> > > > > > >
> > > > > > > I’m still surprised that in 2015, TS hasn’t been forced to
> handle
> > > > > super.
> > > > > > > Are people not using inheritance much in TS?
> > > > > > >
> > > > > > > >
> > > > > > > >Alex, when you have time, can you explain what this is doing
> so I
> > > can
> > > > > > > >implement it.
> > > > > > >
> > > > > > > I have not read the spec, but Object.defineProperties appears
> to
> > > > > associate
> > > > > > > a data structure with a “class”. 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 ‘this’ pointer and scope. 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’s property map.
> > > > > > >
> > > > > > > In looking around the internet, the solutions seemed to:
> > > > > > > 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 ‘this’ pointer.
> > > > > > >
> > > > > > > So that’s what is in the current JSFlexJSEmitter, 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, but steps
> 2
> > > > > through 4
> > > > > > > can be the same.
> > > > > > >
> > > > > > > It is step 4 that re-introduces “re-writing” 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’ll bet there are still
> bugs
> > > in the
> > > > > > > current JSFlexJSEmitter.
> > > > > > >
> > > > > > > And I think I still haven’t fixed the scenario where only a
> getter
> > > or
> > > > > > > setter is overridden. The generated code must propagate a
> “pass
> > > > > through”
> > > > > > > for the missing getter or setter to the subclass’s data
> structure
> > > > > > > otherwise the runtime will not find the setter or getter and
> think
> > > the
> > > > > > > property is now read-only or write-only.
> > > > > > >
> > > > > > > >
> > > > > > > >So correct me if I am wrong but, since there is really no
> solution
> > > > > without
> > > > > > > >an external utility to call a super accessor, we can't really
> say
> > > that
> > > > > > > >this
> > > > > > > >transpiler is producing vanilla javascript. Chicken egg thing.
> > > > > > >
> > > > > > > Technically, you could inline everything in the utility
> 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 and
> loading
> > > > > > > dependency definitions in a particular order. It seems to be
> > > somewhat
> > > > > > > pay-as-you-go. If no inheritance, then almost no “goog”.
> > > > > > >
> > > > > > > -Alex
> > > > > > >
> > > > > > >
> > > > >
> > > > >
> > >
> > >
>
>
RE: [FalconJX] JXEmitter accessors
Posted by Frédéric THOMAS <we...@hotmail.com>.
> 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, if yes, this function is re-usable IMO
Frédéric 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 the
> 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édéric THOMAS <we...@hotmail.com>
> wrote:
>
> > I'm not a javascript guru either, but it was easy to create ES6 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 = value;
> > }
> >
> > For class B:
> >
> >
> > set: function (value) {
> > _set(Object.getPrototypeOf(B.prototype), "property", value,
> > this);
> > }
> >
> > Which calls:
> >
> > var _set = function set(object, property, value, receiver) {
> > var desc = Object.getOwnPropertyDescriptor(object, property); // Get
> > the property on B
> > if (desc === undefined) { // If not overrided, will set the parent
> > recursively if the parent doesn't override the property either.
> > var parent = Object.getPrototypeOf(object);
> > if (parent !== null) {
> > set(parent, property, value, receiver);
> > }
> > } else if ("value" in desc && desc.writable) { // didn't get this part
> > desc.value = value;
> > } else { // Else call the setterv of this Object
> > var setter = desc.set;
> > if (setter !== 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 check if the
> > property has been overriden, if Yes, get the value.
> >
> > var _get = function get(_x, _x2, _x3) {
> > var _again = true;
> > _function: while (_again) {
> > var object = _x, property = _x2, receiver = _x3;
> > desc = parent = getter = undefined;
> > _again = false;
> > var desc = Object.getOwnPropertyDescriptor(object, property);
> > if (desc === undefined) {
> > var parent = Object.getPrototypeOf(object);
> > if (parent === null) {
> > return undefined;
> > } else {
> > _x = parent;
> > _x2 = property;
> > _x3 = receiver;
> > _again = true;
> > continue _function;
> > }
> > } else if ("value" in desc) {
> > return desc.value;
> > } else {
> > var getter = desc.get;
> > if (getter === undefined) {
> > return undefined;
> > }
> > return getter.call(receiver);
> > }
> > }
> > };
> >
> > Does it do the trick ?
> >
> > Frédéric 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 to "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édéric THOMAS <
> > webdoublefx@hotmail.com>
> > > wrote:
> > >
> > > > I just tried in babel, see what it generates:
> > > >
> > > >
> > > >
> > http://babeljs.io/repl/#?experimental=true&evaluate=true&loose=false&spec=false&code=class%20A%20{%0A%09constructor%28%29%20{%0A%09%20%20this._property%20%3D%20%22init%22%3B%0A%09}%0A%09get%20property%28%29%3Astring%20{%0A%09%09return%20this._property%3B%0A%09}%0A%09%0A%09set%20property%28value%3Astring%29%20{%0A%09%09this._property%20%3D%20value%3B%0A%09}%20%0A%09%0A%09showMyValue%28%29%20{%0A%09%09alert%28this._property%29%3B%0A%09}%0A%0A}%0A%0Aclass%20B%20extends%20A%20{%0A%09get%20property%28%29%3Astring%20{%0A%09%09return%20super.property%3B%0A%09}%0A%09%0A%09set%20property%28value%3Astring%29%20{%0A%09%09super.property%20%3D%20value%3B%0A%09}%0A}
> > > >
> > > > Frédéric 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’m still surprised that in 2015, TS hasn’t 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 get his project
> > > > > working, Josh?
> > > > >
> > > > > Mike
> > > > >
> > > > >
> > > > > On Wed, May 27, 2015 at 7:51 PM, Alex Harui <ah...@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 OZ.
> > > > > > >
> > > > > > >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 != 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 actionscript could be
> > cross
> > > > > > >compiled if you can't call super accessors.
> > > > > >
> > > > > > I’m still surprised that in 2015, TS hasn’t been forced to handle
> > > > super.
> > > > > > Are people not using inheritance much in TS?
> > > > > >
> > > > > > >
> > > > > > >Alex, when you have time, can you explain what this is doing so I
> > can
> > > > > > >implement it.
> > > > > >
> > > > > > I have not read the spec, but Object.defineProperties appears to
> > > > associate
> > > > > > a data structure with a “class”. 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 ‘this’ pointer and scope. 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’s property map.
> > > > > >
> > > > > > In looking around the internet, the solutions seemed to:
> > > > > > 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 ‘this’ pointer.
> > > > > >
> > > > > > So that’s what is in the current JSFlexJSEmitter, 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, but steps 2
> > > > through 4
> > > > > > can be the same.
> > > > > >
> > > > > > It is step 4 that re-introduces “re-writing” 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’ll bet there are still bugs
> > in the
> > > > > > current JSFlexJSEmitter.
> > > > > >
> > > > > > And I think I still haven’t fixed the scenario where only a getter
> > or
> > > > > > setter is overridden. The generated code must propagate a “pass
> > > > through”
> > > > > > for the missing getter or setter to the subclass’s data structure
> > > > > > otherwise the runtime will not find the setter or getter and think
> > the
> > > > > > property is now read-only or write-only.
> > > > > >
> > > > > > >
> > > > > > >So correct me if I am wrong but, since there is really no solution
> > > > without
> > > > > > >an external utility to call a super accessor, we can't really say
> > that
> > > > > > >this
> > > > > > >transpiler is producing vanilla javascript. Chicken egg thing.
> > > > > >
> > > > > > Technically, you could inline everything in the utility 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 and loading
> > > > > > dependency definitions in a particular order. It seems to be
> > somewhat
> > > > > > pay-as-you-go. If no inheritance, then almost no “goog”.
> > > > > >
> > > > > > -Alex
> > > > > >
> > > > > >
> > > >
> > > >
> >
> >
Re: [FalconJX] JXEmitter accessors
Posted by Michael Schmalle <te...@gmail.com>.
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 the
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édéric THOMAS <we...@hotmail.com>
wrote:
> I'm not a javascript guru either, but it was easy to create ES6 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 = value;
> }
>
> For class B:
>
>
> set: function (value) {
> _set(Object.getPrototypeOf(B.prototype), "property", value,
> this);
> }
>
> Which calls:
>
> var _set = function set(object, property, value, receiver) {
> var desc = Object.getOwnPropertyDescriptor(object, property); // Get
> the property on B
> if (desc === undefined) { // If not overrided, will set the parent
> recursively if the parent doesn't override the property either.
> var parent = Object.getPrototypeOf(object);
> if (parent !== null) {
> set(parent, property, value, receiver);
> }
> } else if ("value" in desc && desc.writable) { // didn't get this part
> desc.value = value;
> } else { // Else call the setterv of this Object
> var setter = desc.set;
> if (setter !== 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 check if the
> property has been overriden, if Yes, get the value.
>
> var _get = function get(_x, _x2, _x3) {
> var _again = true;
> _function: while (_again) {
> var object = _x, property = _x2, receiver = _x3;
> desc = parent = getter = undefined;
> _again = false;
> var desc = Object.getOwnPropertyDescriptor(object, property);
> if (desc === undefined) {
> var parent = Object.getPrototypeOf(object);
> if (parent === null) {
> return undefined;
> } else {
> _x = parent;
> _x2 = property;
> _x3 = receiver;
> _again = true;
> continue _function;
> }
> } else if ("value" in desc) {
> return desc.value;
> } else {
> var getter = desc.get;
> if (getter === undefined) {
> return undefined;
> }
> return getter.call(receiver);
> }
> }
> };
>
> Does it do the trick ?
>
> Frédéric 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 to "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édéric THOMAS <
> webdoublefx@hotmail.com>
> > wrote:
> >
> > > I just tried in babel, see what it generates:
> > >
> > >
> > >
> http://babeljs.io/repl/#?experimental=true&evaluate=true&loose=false&spec=false&code=class%20A%20{%0A%09constructor%28%29%20{%0A%09%20%20this._property%20%3D%20%22init%22%3B%0A%09}%0A%09get%20property%28%29%3Astring%20{%0A%09%09return%20this._property%3B%0A%09}%0A%09%0A%09set%20property%28value%3Astring%29%20{%0A%09%09this._property%20%3D%20value%3B%0A%09}%20%0A%09%0A%09showMyValue%28%29%20{%0A%09%09alert%28this._property%29%3B%0A%09}%0A%0A}%0A%0Aclass%20B%20extends%20A%20{%0A%09get%20property%28%29%3Astring%20{%0A%09%09return%20super.property%3B%0A%09}%0A%09%0A%09set%20property%28value%3Astring%29%20{%0A%09%09super.property%20%3D%20value%3B%0A%09}%0A}
> > >
> > > Frédéric 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’m still surprised that in 2015, TS hasn’t 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 get his project
> > > > working, Josh?
> > > >
> > > > Mike
> > > >
> > > >
> > > > On Wed, May 27, 2015 at 7:51 PM, Alex Harui <ah...@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 OZ.
> > > > > >
> > > > > >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 != 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 actionscript could be
> cross
> > > > > >compiled if you can't call super accessors.
> > > > >
> > > > > I’m still surprised that in 2015, TS hasn’t been forced to handle
> > > super.
> > > > > Are people not using inheritance much in TS?
> > > > >
> > > > > >
> > > > > >Alex, when you have time, can you explain what this is doing so I
> can
> > > > > >implement it.
> > > > >
> > > > > I have not read the spec, but Object.defineProperties appears to
> > > associate
> > > > > a data structure with a “class”. 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 ‘this’ pointer and scope. 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’s property map.
> > > > >
> > > > > In looking around the internet, the solutions seemed to:
> > > > > 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 ‘this’ pointer.
> > > > >
> > > > > So that’s what is in the current JSFlexJSEmitter, 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, but steps 2
> > > through 4
> > > > > can be the same.
> > > > >
> > > > > It is step 4 that re-introduces “re-writing” 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’ll bet there are still bugs
> in the
> > > > > current JSFlexJSEmitter.
> > > > >
> > > > > And I think I still haven’t fixed the scenario where only a getter
> or
> > > > > setter is overridden. The generated code must propagate a “pass
> > > through”
> > > > > for the missing getter or setter to the subclass’s data structure
> > > > > otherwise the runtime will not find the setter or getter and think
> the
> > > > > property is now read-only or write-only.
> > > > >
> > > > > >
> > > > > >So correct me if I am wrong but, since there is really no solution
> > > without
> > > > > >an external utility to call a super accessor, we can't really say
> that
> > > > > >this
> > > > > >transpiler is producing vanilla javascript. Chicken egg thing.
> > > > >
> > > > > Technically, you could inline everything in the utility 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 and loading
> > > > > dependency definitions in a particular order. It seems to be
> somewhat
> > > > > pay-as-you-go. If no inheritance, then almost no “goog”.
> > > > >
> > > > > -Alex
> > > > >
> > > > >
> > >
> > >
>
>
RE: [FalconJX] JXEmitter accessors
Posted by Frédéric THOMAS <we...@hotmail.com>.
I've got it:
else if ("value" in desc && desc.writable)
If the property is define and writable, set it, otherwise, will use the setter
Frédéric THOMAS
> From: webdoublefx@hotmail.com
> To: dev@flex.apache.org
> Subject: RE: [FalconJX] JXEmitter accessors
> Date: Thu, 28 May 2015 13:27:47 +0100
>
> I'm not a javascript guru either, but it was easy to create ES6 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 = value;
> }
>
> For class B:
>
>
> set: function (value) {
> _set(Object.getPrototypeOf(B.prototype), "property", value, this);
> }
>
> Which calls:
>
> var _set = function set(object, property, value, receiver) {
> var desc = Object.getOwnPropertyDescriptor(object, property); // Get the property on B
> if (desc === undefined) { // If not overrided, will set the parent recursively if the parent doesn't override the property either.
> var parent = Object.getPrototypeOf(object);
> if (parent !== null) {
> set(parent, property, value, receiver);
> }
> } else if ("value" in desc && desc.writable) { // didn't get this part
> desc.value = value;
> } else { // Else call the setterv of this Object
> var setter = desc.set;
> if (setter !== 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 check if the property has been overriden, if Yes, get the value.
>
> var _get = function get(_x, _x2, _x3) {
> var _again = true;
> _function: while (_again) {
> var object = _x, property = _x2, receiver = _x3;
> desc = parent = getter = undefined;
> _again = false;
> var desc = Object.getOwnPropertyDescriptor(object, property);
> if (desc === undefined) {
> var parent = Object.getPrototypeOf(object);
> if (parent === null) {
> return undefined;
> } else {
> _x = parent;
> _x2 = property;
> _x3 = receiver;
> _again = true;
> continue _function;
> }
> } else if ("value" in desc) {
> return desc.value;
> } else {
> var getter = desc.get;
> if (getter === undefined) {
> return undefined;
> }
> return getter.call(receiver);
> }
> }
> };
>
> Does it do the trick ?
>
> Frédéric 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 to "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édéric THOMAS <we...@hotmail.com>
> > wrote:
> >
> > > I just tried in babel, see what it generates:
> > >
> > >
> > > http://babeljs.io/repl/#?experimental=true&evaluate=true&loose=false&spec=false&code=class%20A%20{%0A%09constructor%28%29%20{%0A%09%20%20this._property%20%3D%20%22init%22%3B%0A%09}%0A%09get%20property%28%29%3Astring%20{%0A%09%09return%20this._property%3B%0A%09}%0A%09%0A%09set%20property%28value%3Astring%29%20{%0A%09%09this._property%20%3D%20value%3B%0A%09}%20%0A%09%0A%09showMyValue%28%29%20{%0A%09%09alert%28this._property%29%3B%0A%09}%0A%0A}%0A%0Aclass%20B%20extends%20A%20{%0A%09get%20property%28%29%3Astring%20{%0A%09%09return%20super.property%3B%0A%09}%0A%09%0A%09set%20property%28value%3Astring%29%20{%0A%09%09super.property%20%3D%20value%3B%0A%09}%0A}
> > >
> > > Frédéric 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’m still surprised that in 2015, TS hasn’t 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 get his project
> > > > working, Josh?
> > > >
> > > > Mike
> > > >
> > > >
> > > > On Wed, May 27, 2015 at 7:51 PM, Alex Harui <ah...@adobe.com> wrote:
> > > >
> > > > >
> > > > >
> > > > > On 5/27/15, 4:16 PM, "Michael Schmalle" <te...@gmail.com>
> > > wrote:
> > > > >
> > > > > >Ok, This needs to be clear to me before I go off to OZ.
> > > > > >
> > > > > >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 != 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 actionscript could be cross
> > > > > >compiled if you can't call super accessors.
> > > > >
> > > > > I’m still surprised that in 2015, TS hasn’t been forced to handle
> > > super.
> > > > > Are people not using inheritance much in TS?
> > > > >
> > > > > >
> > > > > >Alex, when you have time, can you explain what this is doing so I can
> > > > > >implement it.
> > > > >
> > > > > I have not read the spec, but Object.defineProperties appears to
> > > associate
> > > > > a data structure with a “class”. 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 ‘this’ pointer and scope. 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’s property map.
> > > > >
> > > > > In looking around the internet, the solutions seemed to:
> > > > > 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 ‘this’ pointer.
> > > > >
> > > > > So that’s what is in the current JSFlexJSEmitter, 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, but steps 2
> > > through 4
> > > > > can be the same.
> > > > >
> > > > > It is step 4 that re-introduces “re-writing” 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’ll bet there are still bugs in the
> > > > > current JSFlexJSEmitter.
> > > > >
> > > > > And I think I still haven’t fixed the scenario where only a getter or
> > > > > setter is overridden. The generated code must propagate a “pass
> > > through”
> > > > > for the missing getter or setter to the subclass’s data structure
> > > > > otherwise the runtime will not find the setter or getter and think the
> > > > > property is now read-only or write-only.
> > > > >
> > > > > >
> > > > > >So correct me if I am wrong but, since there is really no solution
> > > without
> > > > > >an external utility to call a super accessor, we can't really say that
> > > > > >this
> > > > > >transpiler is producing vanilla javascript. Chicken egg thing.
> > > > >
> > > > > Technically, you could inline everything in the utility 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 and loading
> > > > > dependency definitions in a particular order. It seems to be somewhat
> > > > > pay-as-you-go. If no inheritance, then almost no “goog”.
> > > > >
> > > > > -Alex
> > > > >
> > > > >
> > >
> > >
>
RE: [FalconJX] JXEmitter accessors
Posted by Frédéric THOMAS <we...@hotmail.com>.
I'm not a javascript guru either, but it was easy to create ES6 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 = value;
}
For class B:
set: function (value) {
_set(Object.getPrototypeOf(B.prototype), "property", value, this);
}
Which calls:
var _set = function set(object, property, value, receiver) {
var desc = Object.getOwnPropertyDescriptor(object, property); // Get the property on B
if (desc === undefined) { // If not overrided, will set the parent recursively if the parent doesn't override the property either.
var parent = Object.getPrototypeOf(object);
if (parent !== null) {
set(parent, property, value, receiver);
}
} else if ("value" in desc && desc.writable) { // didn't get this part
desc.value = value;
} else { // Else call the setterv of this Object
var setter = desc.set;
if (setter !== 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 check if the property has been overriden, if Yes, get the value.
var _get = function get(_x, _x2, _x3) {
var _again = true;
_function: while (_again) {
var object = _x, property = _x2, receiver = _x3;
desc = parent = getter = undefined;
_again = false;
var desc = Object.getOwnPropertyDescriptor(object, property);
if (desc === undefined) {
var parent = Object.getPrototypeOf(object);
if (parent === null) {
return undefined;
} else {
_x = parent;
_x2 = property;
_x3 = receiver;
_again = true;
continue _function;
}
} else if ("value" in desc) {
return desc.value;
} else {
var getter = desc.get;
if (getter === undefined) {
return undefined;
}
return getter.call(receiver);
}
}
};
Does it do the trick ?
Frédéric 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 to "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édéric THOMAS <we...@hotmail.com>
> wrote:
>
> > I just tried in babel, see what it generates:
> >
> >
> > http://babeljs.io/repl/#?experimental=true&evaluate=true&loose=false&spec=false&code=class%20A%20{%0A%09constructor%28%29%20{%0A%09%20%20this._property%20%3D%20%22init%22%3B%0A%09}%0A%09get%20property%28%29%3Astring%20{%0A%09%09return%20this._property%3B%0A%09}%0A%09%0A%09set%20property%28value%3Astring%29%20{%0A%09%09this._property%20%3D%20value%3B%0A%09}%20%0A%09%0A%09showMyValue%28%29%20{%0A%09%09alert%28this._property%29%3B%0A%09}%0A%0A}%0A%0Aclass%20B%20extends%20A%20{%0A%09get%20property%28%29%3Astring%20{%0A%09%09return%20super.property%3B%0A%09}%0A%09%0A%09set%20property%28value%3Astring%29%20{%0A%09%09super.property%20%3D%20value%3B%0A%09}%0A}
> >
> > Frédéric 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’m still surprised that in 2015, TS hasn’t 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 get his project
> > > working, Josh?
> > >
> > > Mike
> > >
> > >
> > > On Wed, May 27, 2015 at 7:51 PM, Alex Harui <ah...@adobe.com> wrote:
> > >
> > > >
> > > >
> > > > On 5/27/15, 4:16 PM, "Michael Schmalle" <te...@gmail.com>
> > wrote:
> > > >
> > > > >Ok, This needs to be clear to me before I go off to OZ.
> > > > >
> > > > >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 != 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 actionscript could be cross
> > > > >compiled if you can't call super accessors.
> > > >
> > > > I’m still surprised that in 2015, TS hasn’t been forced to handle
> > super.
> > > > Are people not using inheritance much in TS?
> > > >
> > > > >
> > > > >Alex, when you have time, can you explain what this is doing so I can
> > > > >implement it.
> > > >
> > > > I have not read the spec, but Object.defineProperties appears to
> > associate
> > > > a data structure with a “class”. 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 ‘this’ pointer and scope. 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’s property map.
> > > >
> > > > In looking around the internet, the solutions seemed to:
> > > > 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 ‘this’ pointer.
> > > >
> > > > So that’s what is in the current JSFlexJSEmitter, 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, but steps 2
> > through 4
> > > > can be the same.
> > > >
> > > > It is step 4 that re-introduces “re-writing” 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’ll bet there are still bugs in the
> > > > current JSFlexJSEmitter.
> > > >
> > > > And I think I still haven’t fixed the scenario where only a getter or
> > > > setter is overridden. The generated code must propagate a “pass
> > through”
> > > > for the missing getter or setter to the subclass’s data structure
> > > > otherwise the runtime will not find the setter or getter and think the
> > > > property is now read-only or write-only.
> > > >
> > > > >
> > > > >So correct me if I am wrong but, since there is really no solution
> > without
> > > > >an external utility to call a super accessor, we can't really say that
> > > > >this
> > > > >transpiler is producing vanilla javascript. Chicken egg thing.
> > > >
> > > > Technically, you could inline everything in the utility 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 and loading
> > > > dependency definitions in a particular order. It seems to be somewhat
> > > > pay-as-you-go. If no inheritance, then almost no “goog”.
> > > >
> > > > -Alex
> > > >
> > > >
> >
> >
Re: [FalconJX] JXEmitter accessors
Posted by Michael Schmalle <te...@gmail.com>.
Interesting Fred, I am no javascript guru so I need people to "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édéric THOMAS <we...@hotmail.com>
wrote:
> I just tried in babel, see what it generates:
>
>
> http://babeljs.io/repl/#?experimental=true&evaluate=true&loose=false&spec=false&code=class%20A%20{%0A%09constructor%28%29%20{%0A%09%20%20this._property%20%3D%20%22init%22%3B%0A%09}%0A%09get%20property%28%29%3Astring%20{%0A%09%09return%20this._property%3B%0A%09}%0A%09%0A%09set%20property%28value%3Astring%29%20{%0A%09%09this._property%20%3D%20value%3B%0A%09}%20%0A%09%0A%09showMyValue%28%29%20{%0A%09%09alert%28this._property%29%3B%0A%09}%0A%0A}%0A%0Aclass%20B%20extends%20A%20{%0A%09get%20property%28%29%3Astring%20{%0A%09%09return%20super.property%3B%0A%09}%0A%09%0A%09set%20property%28value%3Astring%29%20{%0A%09%09super.property%20%3D%20value%3B%0A%09}%0A}
>
> Frédéric 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’m still surprised that in 2015, TS hasn’t 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 get his project
> > working, Josh?
> >
> > Mike
> >
> >
> > On Wed, May 27, 2015 at 7:51 PM, Alex Harui <ah...@adobe.com> wrote:
> >
> > >
> > >
> > > On 5/27/15, 4:16 PM, "Michael Schmalle" <te...@gmail.com>
> wrote:
> > >
> > > >Ok, This needs to be clear to me before I go off to OZ.
> > > >
> > > >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 != 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 actionscript could be cross
> > > >compiled if you can't call super accessors.
> > >
> > > I’m still surprised that in 2015, TS hasn’t been forced to handle
> super.
> > > Are people not using inheritance much in TS?
> > >
> > > >
> > > >Alex, when you have time, can you explain what this is doing so I can
> > > >implement it.
> > >
> > > I have not read the spec, but Object.defineProperties appears to
> associate
> > > a data structure with a “class”. 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 ‘this’ pointer and scope. 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’s property map.
> > >
> > > In looking around the internet, the solutions seemed to:
> > > 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 ‘this’ pointer.
> > >
> > > So that’s what is in the current JSFlexJSEmitter, 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, but steps 2
> through 4
> > > can be the same.
> > >
> > > It is step 4 that re-introduces “re-writing” 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’ll bet there are still bugs in the
> > > current JSFlexJSEmitter.
> > >
> > > And I think I still haven’t fixed the scenario where only a getter or
> > > setter is overridden. The generated code must propagate a “pass
> through”
> > > for the missing getter or setter to the subclass’s data structure
> > > otherwise the runtime will not find the setter or getter and think the
> > > property is now read-only or write-only.
> > >
> > > >
> > > >So correct me if I am wrong but, since there is really no solution
> without
> > > >an external utility to call a super accessor, we can't really say that
> > > >this
> > > >transpiler is producing vanilla javascript. Chicken egg thing.
> > >
> > > Technically, you could inline everything in the utility 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 and loading
> > > dependency definitions in a particular order. It seems to be somewhat
> > > pay-as-you-go. If no inheritance, then almost no “goog”.
> > >
> > > -Alex
> > >
> > >
>
>
RE: [FalconJX] JXEmitter accessors
Posted by Frédéric THOMAS <we...@hotmail.com>.
I just tried in babel, see what it generates:
http://babeljs.io/repl/#?experimental=true&evaluate=true&loose=false&spec=false&code=class%20A%20{%0A%09constructor%28%29%20{%0A%09%20%20this._property%20%3D%20%22init%22%3B%0A%09}%0A%09get%20property%28%29%3Astring%20{%0A%09%09return%20this._property%3B%0A%09}%0A%09%0A%09set%20property%28value%3Astring%29%20{%0A%09%09this._property%20%3D%20value%3B%0A%09}%20%0A%09%0A%09showMyValue%28%29%20{%0A%09%09alert%28this._property%29%3B%0A%09}%0A%0A}%0A%0Aclass%20B%20extends%20A%20{%0A%09get%20property%28%29%3Astring%20{%0A%09%09return%20super.property%3B%0A%09}%0A%09%0A%09set%20property%28value%3Astring%29%20{%0A%09%09super.property%20%3D%20value%3B%0A%09}%0A}
Frédéric 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’m still surprised that in 2015, TS hasn’t 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 get his project
> working, Josh?
>
> Mike
>
>
> On Wed, May 27, 2015 at 7:51 PM, Alex Harui <ah...@adobe.com> wrote:
>
> >
> >
> > On 5/27/15, 4:16 PM, "Michael Schmalle" <te...@gmail.com> wrote:
> >
> > >Ok, This needs to be clear to me before I go off to OZ.
> > >
> > >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 != 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 actionscript could be cross
> > >compiled if you can't call super accessors.
> >
> > I’m still surprised that in 2015, TS hasn’t been forced to handle super.
> > Are people not using inheritance much in TS?
> >
> > >
> > >Alex, when you have time, can you explain what this is doing so I can
> > >implement it.
> >
> > I have not read the spec, but Object.defineProperties appears to associate
> > a data structure with a “class”. 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 ‘this’ pointer and scope. 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’s property map.
> >
> > In looking around the internet, the solutions seemed to:
> > 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 ‘this’ pointer.
> >
> > So that’s what is in the current JSFlexJSEmitter, 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, but steps 2 through 4
> > can be the same.
> >
> > It is step 4 that re-introduces “re-writing” 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’ll bet there are still bugs in the
> > current JSFlexJSEmitter.
> >
> > And I think I still haven’t fixed the scenario where only a getter or
> > setter is overridden. The generated code must propagate a “pass through”
> > for the missing getter or setter to the subclass’s data structure
> > otherwise the runtime will not find the setter or getter and think the
> > property is now read-only or write-only.
> >
> > >
> > >So correct me if I am wrong but, since there is really no solution without
> > >an external utility to call a super accessor, we can't really say that
> > >this
> > >transpiler is producing vanilla javascript. Chicken egg thing.
> >
> > Technically, you could inline everything in the utility 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 and loading
> > dependency definitions in a particular order. It seems to be somewhat
> > pay-as-you-go. If no inheritance, then almost no “goog”.
> >
> > -Alex
> >
> >
Re: [FalconJX] JXEmitter accessors
Posted by Josh Tynjala <jo...@gmail.com>.
I recall that I ran into the super getters and setters issue in TypeScript
pretty quickly. I would like to see them working in ActionScript.
- Josh
On May 28, 2015 3:54 AM, "Michael Schmalle" <te...@gmail.com>
wrote:
> > I’m still surprised that in 2015, TS hasn’t 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 get his project
> working, Josh?
>
> Mike
>
>
> On Wed, May 27, 2015 at 7:51 PM, Alex Harui <ah...@adobe.com> wrote:
>
> >
> >
> > On 5/27/15, 4:16 PM, "Michael Schmalle" <te...@gmail.com>
> wrote:
> >
> > >Ok, This needs to be clear to me before I go off to OZ.
> > >
> > >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 != 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 actionscript could be cross
> > >compiled if you can't call super accessors.
> >
> > I’m still surprised that in 2015, TS hasn’t been forced to handle super.
> > Are people not using inheritance much in TS?
> >
> > >
> > >Alex, when you have time, can you explain what this is doing so I can
> > >implement it.
> >
> > I have not read the spec, but Object.defineProperties appears to
> associate
> > a data structure with a “class”. 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 ‘this’ pointer and scope. 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’s property map.
> >
> > In looking around the internet, the solutions seemed to:
> > 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 ‘this’ pointer.
> >
> > So that’s what is in the current JSFlexJSEmitter, 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, but steps 2 through
> 4
> > can be the same.
> >
> > It is step 4 that re-introduces “re-writing” 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’ll bet there are still bugs in the
> > current JSFlexJSEmitter.
> >
> > And I think I still haven’t fixed the scenario where only a getter or
> > setter is overridden. The generated code must propagate a “pass through”
> > for the missing getter or setter to the subclass’s data structure
> > otherwise the runtime will not find the setter or getter and think the
> > property is now read-only or write-only.
> >
> > >
> > >So correct me if I am wrong but, since there is really no solution
> without
> > >an external utility to call a super accessor, we can't really say that
> > >this
> > >transpiler is producing vanilla javascript. Chicken egg thing.
> >
> > Technically, you could inline everything in the utility 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 and loading
> > dependency definitions in a particular order. It seems to be somewhat
> > pay-as-you-go. If no inheritance, then almost no “goog”.
> >
> > -Alex
> >
> >
>
Re: [FalconJX] JXEmitter accessors
Posted by Michael Schmalle <te...@gmail.com>.
> I’m still surprised that in 2015, TS hasn’t 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 get his project
working, Josh?
Mike
On Wed, May 27, 2015 at 7:51 PM, Alex Harui <ah...@adobe.com> wrote:
>
>
> On 5/27/15, 4:16 PM, "Michael Schmalle" <te...@gmail.com> wrote:
>
> >Ok, This needs to be clear to me before I go off to OZ.
> >
> >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 != 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 actionscript could be cross
> >compiled if you can't call super accessors.
>
> I’m still surprised that in 2015, TS hasn’t been forced to handle super.
> Are people not using inheritance much in TS?
>
> >
> >Alex, when you have time, can you explain what this is doing so I can
> >implement it.
>
> I have not read the spec, but Object.defineProperties appears to associate
> a data structure with a “class”. 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 ‘this’ pointer and scope. 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’s property map.
>
> In looking around the internet, the solutions seemed to:
> 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 ‘this’ pointer.
>
> So that’s what is in the current JSFlexJSEmitter, 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, but steps 2 through 4
> can be the same.
>
> It is step 4 that re-introduces “re-writing” 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’ll bet there are still bugs in the
> current JSFlexJSEmitter.
>
> And I think I still haven’t fixed the scenario where only a getter or
> setter is overridden. The generated code must propagate a “pass through”
> for the missing getter or setter to the subclass’s data structure
> otherwise the runtime will not find the setter or getter and think the
> property is now read-only or write-only.
>
> >
> >So correct me if I am wrong but, since there is really no solution without
> >an external utility to call a super accessor, we can't really say that
> >this
> >transpiler is producing vanilla javascript. Chicken egg thing.
>
> Technically, you could inline everything in the utility 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 and loading
> dependency definitions in a particular order. It seems to be somewhat
> pay-as-you-go. If no inheritance, then almost no “goog”.
>
> -Alex
>
>
Re: [FalconJX] JXEmitter accessors
Posted by Alex Harui <ah...@adobe.com>.
On 5/27/15, 4:16 PM, "Michael Schmalle" <te...@gmail.com> wrote:
>Ok, This needs to be clear to me before I go off to OZ.
>
>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 != 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 actionscript could be cross
>compiled if you can't call super accessors.
I’m still surprised that in 2015, TS hasn’t been forced to handle super.
Are people not using inheritance much in TS?
>
>Alex, when you have time, can you explain what this is doing so I can
>implement it.
I have not read the spec, but Object.defineProperties appears to associate
a data structure with a “class”. 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 ‘this’ pointer and scope. 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’s property map.
In looking around the internet, the solutions seemed to:
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 ‘this’ pointer.
So that’s what is in the current JSFlexJSEmitter, 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, but steps 2 through 4
can be the same.
It is step 4 that re-introduces “re-writing” 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’ll bet there are still bugs in the
current JSFlexJSEmitter.
And I think I still haven’t fixed the scenario where only a getter or
setter is overridden. The generated code must propagate a “pass through”
for the missing getter or setter to the subclass’s data structure
otherwise the runtime will not find the setter or getter and think the
property is now read-only or write-only.
>
>So correct me if I am wrong but, since there is really no solution without
>an external utility to call a super accessor, we can't really say that
>this
>transpiler is producing vanilla javascript. Chicken egg thing.
Technically, you could inline everything in the utility 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 and loading
dependency definitions in a particular order. It seems to be somewhat
pay-as-you-go. If no inheritance, then almost no “goog”.
-Alex
Re: [FalconJX] JXEmitter accessors
Posted by Michael Schmalle <te...@gmail.com>.
Also, this is what happens when you are away from something for 2 years.
You forget the major headaches that make this idea seem impossible(straight
transpiler).
It's all coming back to me now, grr...
Mike
On Wed, May 27, 2015 at 7:16 PM, Michael Schmalle <teotigraphixllc@gmail.com
> wrote:
> Ok, This needs to be clear to me before I go off to OZ.
>
> 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 != 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 actionscript could be cross
> compiled if you can't call super accessors.
>
> Alex, when you have time, can you explain what this is doing so I can
> implement it.
>
> Josh, you could chime into because your framework would use super
> accessors, so this has to be solved before any work is done.
>
> By solved I mean I need to know what the plan its. As stated, in Randori
> we uses get_, set_ rewriting.
>
> BTW, this new vanilla transpiler is just plain FalconJX with a JXEmitter
> and custom backend.
>
> So correct me if I am wrong but, since there is really no solution without
> an external utility to call a super accessor, we can't really say that this
> transpiler is producing vanilla javascript. Chicken egg thing.
>
> Mike
>
>
>