Mark Engelberg <[email protected]> writes:

> This is a total nonsense function, just to show formatting (will it
> even show up in googlegroups with the proper formatting?):
>
> (defn test-letfn [n]
>   (letfn
>       [(function1 [a b]
>                   (+ (function2 a) sqr-n))
>        (function2 [a]
>                   (* 2 3))]
>     (function1 8 10)))
>
> The bracket under the letfn is indented a couple spaces more than I'd
> probably prefer, but that's not really what bothers me.  The bodies of
> the functions are indented WAY too much.

I see. The way I usually see let-forms is having the argument list start
on the same line as the "let" itself, which would look like:

> (defn test-letfn [n]
>   (letfn [(function1 [a b]
>                      (+ (function2 a) sqr-n))
>           (function2 [a]
>                      (* 2 3))]
>    (function1 8 10)))

The problem with the function bodies is that the fact that "function1"
starts a new function is impossible to determine without looking at the
greater context, that being the fact that it's within the binding vector
of a letfn. I'm sure it's possible to solve this, but it's rather beyond
me.

It's unclear (to me at least) what letfn offers you over regular let,
since functions are just values anyway:

> (let [f2 (fn [a]
>            (* 2 3))
>       f1 (fn [a b]
>            (+ (f2 a) 99))]
>     (f1 8 10))

Sure this is a contrived example, but the indentation works fine here
since it knows that "fn" means function. Is the only advantage the fact
that you can put f1 before f2?

-Phil

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to