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

Macroify: nth #9

Closed
lilactown opened this issue Aug 14, 2022 · 2 comments
Closed

Macroify: nth #9

lilactown opened this issue Aug 14, 2022 · 2 comments

Comments

@lilactown
Copy link
Collaborator

nth should emit code the same as unchecked-get:

(nth [1 2 3] 2)
([1, 2, 3][2])
@lilactown
Copy link
Collaborator Author

This is actually a little trickier than I originally thought. The issue is that nth in Clojure supports nil, which we need for safe destructuring:

(let [[foo bar] nil]
  foo)

Is a perfectly valid bit of code, but would fail if we translated it to

(function () {
  let foo = null[0];
  let bar = null[1];
  return foo;
})()

@borkdude
Copy link
Member

Yeah, maybe this isn't worth the risk of breakage. I'll close this for now.

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