<div dir="auto">Whatever the implementation, I'd be surprised to learn that the browser *does* have the information automatically and wouldn't need to store additional memory similar to .bind().<div dir="auto"><br></div><div dir="auto">But I'm also not a browser engine expert, so there's that.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le lun. 11 mars 2019 11 h 55, john larson <<a href="mailto:johnlarsondev1@gmail.com">johnlarsondev1@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><p class="MsoNormal" style="margin:0pt 0pt 0.0001pt;font-family:Calibri"><span style="font-family:Arial;letter-spacing:0pt;font-size:12pt;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial">Well, actually this is the same discussion we had with</span><span style="font-family:Arial;letter-spacing:0pt;font-size:12pt;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"> </span><b><span style="font-family:Arial;letter-spacing:0pt;font-size:12pt">@Jordan Harband. </span></b><span style="font-family:Arial;letter-spacing:0pt;font-size:12pt;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial">I think the js run-time already has that information at hand, so as long as we don't implement this as pure syntactical sugar, there would not be a need to keep an extra reference to anything, because it </span><span style="font-family:Arial;letter-spacing:0pt;font-size:12pt;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial">would be</span><span style="font-family:Arial;letter-spacing:0pt;font-size:12pt;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"> already there. </span><span style="font-family:Arial;letter-spacing:0pt;font-size:12pt;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial">The run-time will know which instance the invoked method belongs to. But as I said, it would be insightful to get a js engine expert opinion on this. Having said that, I believe it is just an implementation detail and can be handled one way or the other. I guess the “</span><span style="font-family:Arial;letter-spacing:0pt;font-size:12pt;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial">class property arrow methods</span><span style="font-family:Arial;letter-spacing:0pt;font-size:12pt;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"> in React</span><span style="font-family:Arial;letter-spacing:0pt;font-size:12pt;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial">"</span><span style="font-family:Arial;letter-spacing:0pt;font-size:12pt;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"> example you just provided also supports this notion.</span></p></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 11, 2019 at 6:23 PM Ben Wiley <<a href="mailto:therealbenwiley@gmail.com" target="_blank" rel="noreferrer">therealbenwiley@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div>The main issue here is that you're sort of asking for something too late.<div dir="auto"><br></div><div dir="auto">If you reference the "notThis" keyword inside a callback method that has been separated from "its own" class instance, you're now saying "could you please do this all in the context of your instance", but your method doesn't know what its instance is because it never saved a reference.</div><div dir="auto"><br></div><div dir="auto">Alternatively the compiler would notice that the "notThis" keyword is invoked inside a method, and automatically make a bound property on construction. The problem is that you're eagerly making a copy of every method using "notThis" for every instance that exists - eating up a whole bunch of extra memory for large collections - without knowing necessarily that those bound copies will be used. Granted, we're triggering the same problem when folks are using "class property arrow methods" for all their methods in React classes.</div><div dir="auto"><br></div>Ben<br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le lun. 11 mars 2019 11 h 04, john larson <<a href="mailto:johnlarsondev1@gmail.com" target="_blank" rel="noreferrer">johnlarsondev1@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><b>@Rob:</b> Thanks for pointing out "proposal-bind-operator". I examined the proposal and as far as I understand, it is just another way to create a bound enclosing function. What I am proposing is just the opposite, no binding should take place in the enclosing function. A method call or usage of a property should already have its lexical scope pointing to the class instance and should not need any binding of its enclosing environment to function correctly.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 11, 2019 at 4:57 PM Rob Ede <<a href="mailto:robjtede@icloud.com" rel="noreferrer noreferrer" target="_blank">robjtede@icloud.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>I would imagine that this can be achieved with bind operator proposal, which already has Babel support, despite no examples showing usage inside a class.<div><br></div><div>Something like:</div><div>`oReq.addEventListener("load", ::this.responseHandler);`</div><div>seems to be the syntax that will de-sugar to</div><div>`oReq.addEventListener("load", this.responseHandler.bind(this));`</div><div>to get you the desired this binding.</div><div><br></div><div>I’m surprised this idea hasn't been mentioned yet although things have been moving slowly on that proposal and it seems to need some community support to move along.</div><div><br></div><div>Regards,</div><div>Rob</div><div><br></div><div><br></div><div>References:</div><div>1: Bind Syntax Proposal (<a href="https://github.com/tc39/proposal-bind-operator" rel="noreferrer noreferrer" target="_blank">https://github.com/tc39/proposal-bind-operator</a>)</div><div>2: Babel Plugin (<a href="https://babeljs.io/docs/en/next/babel-plugin-proposal-function-bind" rel="noreferrer noreferrer" target="_blank">https://babeljs.io/docs/en/next/babel-plugin-proposal-function-bind</a>)</div><div><br></div></div></blockquote></div>
_______________________________________________<br>
es-discuss mailing list<br>
<a href="mailto:es-discuss@mozilla.org" rel="noreferrer noreferrer" target="_blank">es-discuss@mozilla.org</a><br>
<a href="https://mail.mozilla.org/listinfo/es-discuss" rel="noreferrer noreferrer noreferrer" target="_blank">https://mail.mozilla.org/listinfo/es-discuss</a><br>
</blockquote></div></div></div>
</blockquote></div>
</blockquote></div>