Re: [FalconJX] Scope when calling member function from a reference

2015-07-16 Thread Alex Harui
Isn’t it that any FunctionDefinition that isn’t local and isn’t being used in a call needs to be turned into a closure and cached so that same closure gets re-used the next time? You could be building an array of callbacks: Var foo:Array = new Array(10); foo[1] = someFunction;

Re: [FalconJX] Scope when calling member function from a reference

2015-07-16 Thread Michael Schmalle
Yeah, it can be. The more I look at this the more I remember doing it all for variables, function/method arguments for Randori as well. I mean some type of function binding. I am still rusty when looking at this and just doing a high level browse right at the moment. So is there any other place I

Re: [FalconJX] Scope when calling member function from a reference

2015-07-16 Thread Josh Tynjala
Yeah, that looks like the function in use. The comment specifically mentions being on the right side of an equals sign. Would the same code be used when passed as a function argument, or would that need to happen elsewhere? Maybe in the emitArgumentIdentifier() function above that? I don't know if

Re: [FalconJX] Scope when calling member function from a reference

2015-07-16 Thread Michael Schmalle
HA, I just looked at the code I wrote 2+ years ago for the AMD emitter, looks like I already did this. :) If you look at JSAMDEmitter.java at line 845. :) That AS3.bind() call IS that function in javascript you just listed out. So I guess that answers that, my comment was; // AS3.bi

Re: [FalconJX] Scope when calling member function from a reference

2015-07-16 Thread Josh Tynjala
This little snippet from that wiki page looks like it should be helpful. function bind(object, boundMethodName) { if (object.hasOwnProperty(boundMethodName)) { return object[boundMethodName]; } var boundMethod = object[boundMethodName].bind(object); Object.defineProperty(object, boundM

Re: [FalconJX] Scope when calling member function from a reference

2015-07-16 Thread Alex Harui
Hi Frank, Thanks for the reminder. I’ll wait a few days to see if there is any other input before trying to implement this. The main output is using Google Closure Library which uses goog.bind and may also write a named property for @export, so it would be good to make sure other’s can’t think o

Re: [FalconJX] Scope when calling member function from a reference

2015-07-16 Thread Frank Wienberg
Hi guys, honestly I didn't read through the whole thread, but just wanted to remind you of what we collected about binding methods in the Apache Flex Wiki: https://cwiki.apache.org/confluence/display/FLEX/Simulating+AS3+language+features+in+JavaScript+using+AMD+and+ES5#SimulatingAS3languagefeatures

Re: [FalconJX] Scope when calling member function from a reference

2015-07-15 Thread Michael Schmalle
On Tue, Jul 14, 2015 at 7:11 PM, Alex Harui wrote: > Bummer. > > Did you try: > > this.addEventListener("mousedown", simpleButton_mousedownHandler); > > The “this.” might be creating a pattern that isn’t handled. I’m sort of > hoping Mike will finish his mother-in-law’s bathroom and find time

Re: [FalconJX] Scope when calling member function from a reference

2015-07-14 Thread Alex Harui
Good point. We’ll have to create a mechanism that saves closures so you don’t have to do it yourself. Maybe Mike already did this once. -Alex On 7/14/15, 4:55 PM, "Josh Tynjala" wrote: >Darn. Now I ran into the issue where removing an event listener doesn't >work because goog.bind() returns a

Re: [FalconJX] Scope when calling member function from a reference

2015-07-14 Thread Josh Tynjala
Darn. Now I ran into the issue where removing an event listener doesn't work because goog.bind() returns a different function every time that it is called. Looks like I will need to go with my original workaround for now. I can put this in the constructor to make it work the way that I expect: th

Re: [FalconJX] Scope when calling member function from a reference

2015-07-14 Thread Alex Harui
Yeah, the current state of the compiler is that we are checking for specific AST patterns. We handle the common case here for passing a method from an implied ‘this’ pointer which is a different tree than if you actually type “this.”. We need a more general mechanism. -Alex On 7/14/15, 4:33 PM,

Re: [FalconJX] Scope when calling member function from a reference

2015-07-14 Thread Josh Tynjala
That worked! I thought I had tried that. I don't usually use "this." when adding event listeners in ActionScript. I guess I was thinking too much about how it would be converted to JavaScript or something. I must have thought it would help the compiler. Haha! - Josh On Tue, Jul 14, 2015 at 4:11 P

Re: [FalconJX] Scope when calling member function from a reference

2015-07-14 Thread Alex Harui
Bummer. Did you try: this.addEventListener("mousedown", simpleButton_mousedownHandler); The “this.” might be creating a pattern that isn’t handled. I’m sort of hoping Mike will finish his mother-in-law’s bathroom and find time to start in on some way to pass context so we don’t have to one-of

Re: [FalconJX] Scope when calling member function from a reference

2015-07-14 Thread Josh Tynjala
Alex, The change you made worked for the case where the function is assigned to a variable, but it doesn't account for the function being passed as an argument to a function. This still doesn't work for me: this.addEventListener("mousedown", this.simpleButton_mousedownHandler); However, as a wo

Re: [FalconJX] Scope when calling member function from a reference

2015-06-30 Thread Michael Schmalle
On Tue, Jun 30, 2015 at 10:35 AM, Alex Harui wrote: > > > On 6/30/15, 3:08 AM, "Michael Schmalle" wrote: > > >On Tue, Jun 30, 2015 at 1:25 AM, Alex Harui wrote: > > > >> 100% agree, but I think we have to do it soon because I keep adding in > >> these parent walks and I think it slows things do

Re: [FalconJX] Scope when calling member function from a reference

2015-06-30 Thread Alex Harui
On 6/30/15, 3:08 AM, "Michael Schmalle" wrote: >On Tue, Jun 30, 2015 at 1:25 AM, Alex Harui wrote: > >> 100% agree, but I think we have to do it soon because I keep adding in >> these parent walks and I think it slows things down. I’d like to know >> more about the model. >> > >I can't say fo

Re: [FalconJX] Scope when calling member function from a reference

2015-06-30 Thread Michael Schmalle
On Tue, Jun 30, 2015 at 1:25 AM, Alex Harui wrote: > > > On 6/29/15, 2:27 PM, "Michael Schmalle" wrote: > > >We just really need to be careful about how we change stuff like this and > >I > >agree coming back to the point, accessing parents is not a good idea. > > > >Why? Because there are so ma

Re: [FalconJX] Scope when calling member function from a reference

2015-06-29 Thread Alex Harui
On 6/29/15, 2:27 PM, "Michael Schmalle" wrote: >Alex I know it's late(I am doing major renovations this week so I am slow) >but; > >I ended up keeping a model in Randori for this type of stuff and knew I >was >in expressions so I could test right side and left appropriately etc. > >It's just th

Re: [FalconJX] Scope when calling member function from a reference

2015-06-29 Thread Michael Schmalle
Alex I know it's late(I am doing major renovations this week so I am slow) but; I ended up keeping a model in Randori for this type of stuff and knew I was in expressions so I could test right side and left appropriately etc. It's just there is a lot of code underneath these changes that might no

Re: [FalconJX] Scope when calling member function from a reference

2015-06-29 Thread Alex Harui
OK. I will work on it. I looked already and want to get your thoughts: there are several places in the emitter where we stop and look up the parent nodes to try to find the context. Is that a normal thing to do in a compiler or should we be passing some sort of context down? In this case, there

Re: [FalconJX] Scope when calling member function from a reference

2015-06-29 Thread Michael Schmalle
Oh yeah, I did remember the goog bind() for even listeners but it was raining last night so I didn't put 2 and 2 together, blame it on the rain... Mike On Mon, Jun 29, 2015 at 5:13 AM, Michael Schmalle wrote: > Well, I was only trying to be nice but, if you know how to fix this sooner > than la

Re: [FalconJX] Scope when calling member function from a reference

2015-06-29 Thread Michael Schmalle
Well, I was only trying to be nice but, if you know how to fix this sooner than later, do it. I have this next week or two left with very little time, more like just enough to send emails. Mike On Mon, Jun 29, 2015 at 1:13 AM, Alex Harui wrote: > > > On 6/28/15, 2:21 PM, "Michael Schmalle" wro

Re: [FalconJX] Scope when calling member function from a reference

2015-06-28 Thread Alex Harui
On 6/28/15, 2:21 PM, "Michael Schmalle" wrote: >On Sun, Jun 28, 2015 at 5:17 PM, Josh Tynjala >wrote: > >> Yes, that is correct. >> >> In case it wasn't obvious, event listeners are the typical use case >>where >> you'd pass a reference to a member function somewhere else where a >> reference

Re: [FalconJX] Scope when calling member function from a reference

2015-06-28 Thread Josh Tynjala
Here's the JIRA ticket: https://issues.apache.org/jira/browse/FLEX-34897 - Josh On Sun, Jun 28, 2015 at 2:21 PM, Michael Schmalle wrote: > On Sun, Jun 28, 2015 at 5:17 PM, Josh Tynjala > wrote: > > > Yes, that is correct. > > > > In case it wasn't obvious, event listeners are the typical use

Re: [FalconJX] Scope when calling member function from a reference

2015-06-28 Thread Michael Schmalle
On Sun, Jun 28, 2015 at 5:17 PM, Josh Tynjala wrote: > Yes, that is correct. > > In case it wasn't obvious, event listeners are the typical use case where > you'd pass a reference to a member function somewhere else where a > reference needs to be saved in a variable. AS3 made this easy by > auto

Re: [FalconJX] Scope when calling member function from a reference

2015-06-28 Thread Josh Tynjala
Yes, that is correct. In case it wasn't obvious, event listeners are the typical use case where you'd pass a reference to a member function somewhere else where a reference needs to be saved in a variable. AS3 made this easy by automatically binding member functions. JavaScript usually requires so

Re: [FalconJX] Scope when calling member function from a reference

2015-06-28 Thread Michael Schmalle
So this only happens in javascript when you pass an object function to a variable? SO what I am saying is that not using this.func() is what looses the connection to the instance scope and then this becaomes window, correct? Mike On Sun, Jun 28, 2015 at 4:48 PM, Josh Tynjala wrote: > In Flash P