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
Some solutions have been proposed to reduce the string concatenation (#11, #12). I'd like to pitch another alternative: code generation from a dynamically generated AST using escodegen.
esprima or acorn can also be used to generate the AST for the static portions of the code:
// from view.pickletvars=acorn.parse('var a = [], b = [], c = this.offset;').body[0].expression;FunctionDecl('pick',range(n).map((i)=>'x'+i),[vars,//...Return(BinOp('a','+','b'))]// <-- not accurate, just an example
This would allow for runtime generation of the classes and retention of efficiency, but in a more controlled and maintainable way. It also reads somewhat intuitively (I've been playing around with escodegen, the above are working examples).
Let me know what you think. You can see updates in my fork patgrasso/ndarray (check out the escodegen branch).
The text was updated successfully, but these errors were encountered:
Unfortunately I foolishly did not push any of my experimental changes and had a disk error. To reduce the build size, astring can be used instead of escodegen, which is ~16kb minified and supposedly much faster. Runtime performance should be unaffected barring constructor compilation. Additionally, it might be possible to move most of the code generation into the build process rather than occurring at runtime. I'll do some investigation to that end if the additional 16kb would still be too costly.
Some solutions have been proposed to reduce the string concatenation (#11, #12). I'd like to pitch another alternative: code generation from a dynamically generated AST using escodegen.
You could have something like this:
esprima or acorn can also be used to generate the AST for the static portions of the code:
This would allow for runtime generation of the classes and retention of efficiency, but in a more controlled and maintainable way. It also reads somewhat intuitively (I've been playing around with escodegen, the above are working examples).
Let me know what you think. You can see updates in my fork patgrasso/ndarray (check out the escodegen branch).
The text was updated successfully, but these errors were encountered: