code-block-writer
code-block-writer copied to clipboard
Declaration and capturing of variables
Hi! Thank you for this library!
Is there any way to manage scopes of variables with it? For example, if I do some recursive code generation, at the moment I need to manage scope separately (mostly for capturing outer scope's variables).
Let's assume I generate some matrix processing code, and want to have some recursive function which generates the code. In that case I need to capture previous loop index somewhere, to then access it in the inner loop (and not use same i
variable name in the inner loop as well):
for (var i = 0; i < 10; i++) {
for (var i0 = 0; i < 10; i++) {
// access here both i and i0
}
}
It would be nice to have such feature in the library since it already is managing blocks and other scope-related things.
Sorry if expression of my thoughts is a bit messy, but I hope the issue is clear :D
@gobwas do you have any ideas for what the API might look like?