Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement for Supporting Template Literals in Parser and Addressing Variable Updates #84

Closed
K1NZ54 opened this issue Sep 29, 2023 · 1 comment

Comments

@K1NZ54
Copy link

K1NZ54 commented Sep 29, 2023

Hello,

Following the recent suggestion by @prevwong regarding supporting template literals for parsing JavaScript:

Reka.create({
  externals: {
    functions: (self) => {
       return [
         t.externalFunc({ name: "js", func: (args) => {
              const fn = new Function(`return ${args.expr}`);
              return fn();
         }})
       ]
    }
  }
});
val str = "hello world";
$js(`console.log(${str})`);

I appreciate that this approach can potentially resolve certain awkward aspects of our current setup. However, I have concerns about updating internal variables with this mechanism. While we can execute a return statement, how can we update internal values?

Moreover, I'd like to highlight that with the recent update, accessing array elements like table[0] is now feasible. However, updating a value in the array gives us a typeError: Validation.... This needs to be addressed alongside the template literal enhancement.

Would appreciate insights on these two matters.

Thank you.

@prevwong
Copy link
Owner

Can we split this to 2 separate issues please? I don't see a correlation between the template literals and updating the value of a member expression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants