-
Notifications
You must be signed in to change notification settings - Fork 842
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
feat: Add support for destructuring locals #452
Conversation
This is pretty great. :) Couple of issues:
Otherwise awesome. This looks like a really useful path forward to avoid verbosity without having to resort to using |
This is because locals are passed at execution time, whereas the locals to destructure are specified at compile time. Because of this, it’s impossible to know what exactly locals will have at execution time, so you have to specify variables to destructure at compile time. And if you’re only compiling, immediately executing and discarding code, you can always just do |
Oh, duh, sorry. I tend to overlook the precompile use-case. This makes good sense. If you could beef up the tests a bit, and update the README, I'll be happy to merge this, and then plug the same documentation into the EJS site. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for this!
Supersedes and closes #450.
Destructured locals have to be specified at compile time. All other locals need to be accessed via
locals
(or whateverejs.localsName
is set to).This works for KumaScript, where the only locals are API namespaces and macro arguments
$$
(all arguments array) and$0
-$9
, which don’t change between macros or API invocations.review?(@mde)