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

Implement letfn* #257

Open
frenchy64 opened this issue Feb 11, 2025 · 3 comments · May be fixed by #259
Open

Implement letfn* #257

frenchy64 opened this issue Feb 11, 2025 · 3 comments · May be fixed by #259
Assignees

Comments

@frenchy64
Copy link
Contributor

frenchy64 commented Feb 11, 2025

Needed

  • Add a new letfn expression (follow let)
    • Needs new header
    • Needs to be added to the variant in expression.hpp
    • Will fail to compile until there are overloads for eval and gen (the next step)
  • Add eval and codegen support
    • For eval just wrap the expression and call it, like we do with let normally. This will require codegen by letfn by wrapping it in a fn and the evaluating that
  • Ensure letfn macro is added and working
  • Add tests under test/jank/form/letfn

References

@frenchy64
Copy link
Contributor Author

I can look into this.

@jeaye jeaye changed the title Implement letfn Implement letfn* Feb 11, 2025
@jeaye
Copy link
Member

jeaye commented Feb 11, 2025

Added some additional info.

@frenchy64 frenchy64 linked a pull request Feb 11, 2025 that will close this issue
@frenchy64
Copy link
Contributor Author

frenchy64 commented Feb 11, 2025

Thanks @jeaye! I started with the boilerplate and hit #260. I was hoping to get some pointers on how to implement recursion without vars but now I'm not sure if there is an existing example.

EDIT: I think I'm back on track, found an example to go off:

clojure.core=> ((fn a [] (when (< 0.5 (rand)) (println "iter") (a))))
iter
iter
iter
iter
nil

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

Successfully merging a pull request may close this issue.

2 participants