Using letfn allows the local functions to reference each other arbitrarily. In your example, f2 can call f1 but not vice versa.
On Thu, Nov 20, 2014 at 11:08 AM, Alex Baranosky < [email protected]> wrote: > letfn has no value imo. It is an unwritten stylistic rule I have to never > use it. Why introduce a new macro syntax for something that could just as > easily be written as?: > > (let [f1 (fn [] ...) > f2 (fn [] ...)] > (+ (f1) (f2))) > > > On Thu, Nov 20, 2014 at 12:41 PM, henry w <[email protected]> wrote: > >> I never heard of letfn before. that looks like a clear way to do what i >> need. >> >> just found this stackoverflow thread which is relevant: >> http://stackoverflow.com/questions/23255798/clojure-style-defn-vs-letfn >> >> On Thu, Nov 20, 2014 at 3:34 PM, Alex Baranosky < >> [email protected]> wrote: >> >>> I'd structure my app like this. >>> >>> Say there's one "pages" ns with code for different webpages >>> >>> pages/index is a pretty short function >>> pages/dashboard is a more elaborate function and has two subcomponents: >>> ->analytics, and ->user-info >>> pages.analytics/->analytics >>> pages.user-info/->user-info >>> >>> On Thu, Nov 20, 2014 at 9:23 AM, Tassilo Horn <[email protected]> wrote: >>> >>>> henry w <[email protected]> writes: >>>> >>>> > you have understood my arguments pretty much. again the thing that >>>> > bothers me is that f and g are logically part of x only, but are >>>> > visible from y and z (even if and and y are declared higher up, the >>>> > same problem applies to their own related, private fns and x). >>>> >>>> Then declare f and g inside of x using `let' or `letfn'. >>>> >>>> Bye, >>>> Tassilo >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Clojure" group. >>>> To post to this group, send email to [email protected] >>>> Note that posts from new members are moderated - please be patient with >>>> your first post. >>>> To unsubscribe from this group, send email to >>>> [email protected] >>>> For more options, visit this group at >>>> http://groups.google.com/group/clojure?hl=en >>>> --- >>>> You received this message because you are subscribed to the Google >>>> Groups "Clojure" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> >> > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to [email protected] > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
