When in practice should I use letfn vs. let for defining local functions?
What about cases where I want both local functions and local non-functions?
When in practice should I use letfn vs. let for defining local functions? What
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If all I need is one or a few local functions, I
letfnthem. If I need to define a mix of functions and non-functions, I’ll just use a normallet.letfning andleting would be a very verbose way to do this.However, if you need mutual recursion through your local functions, you’ll have to
letfnthem either way.Short version: use them when you think it looks better, and when it’s convenient. There are no hard and fast rules for using either. They are just tools in the Clojure toolbox.
Have fun!