You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#798 and #1240 has discussed lots of thing about closure, but maybe there are some outdated information.
So I want to start to discuss it in some new page.
Project State
function object will be compiled as static object in data area.
function object store function index in table and null env.
High Level Requirement For Closure
Every function object from the same FunctionExpression will have different env.
When call function object, function can use (read / write) the variable in env and upper function env.
(Optional) If function is not a closure function, supporting closure has no or small influence this function in the perspective of code size and spend.
What should we do to support closure
For better code review, I think maybe we can support it step by step. I will post everything we need to implement closure. Please correct my mistakes and omissions.
letupper_function=()=>{letvariable_in_upper_function: i32=0;letcurrent_function=()=>{letvariable_in_current_function: i32=0;// used in lower function.variable_in_upper_function=1;// variable declared in upper function.letlower_function=()=>{variable_in_current_function=2;}})
I personally truly wish we had threads and closure support, I am looking at the AssemblyScript since a few years now, waiting for those features to land to be able to use it more often and I feel like I am not alone.
This project is super exciting and yet we are missing core features for the language to be more broadly used.
It need more work than I expected. Closure is a big challenge since it need lots of compiler internal feature to support. e.g. create a temporary object / class definition in local context as the definition of closure object.
Feature suggestion
#798 and #1240 has discussed lots of thing about closure, but maybe there are some outdated information.
So I want to start to discuss it in some new page.
Project State
High Level Requirement For Closure
What should we do to support closure
For better code review, I think maybe we can support it step by step. I will post everything we need to implement closure. Please correct my mistakes and omissions.
code gen
semantic
The text was updated successfully, but these errors were encountered: