Not idiomatic. defn is always top level.

David

On Sat, Nov 15, 2014 at 11:31 AM, Udayakumar Rayala
<uday.ray...@gmail.com> wrote:
> <Cross posting from Clojurescript group. Sorry if you got this question
> twice>
>
> Hi,
>
> Is it idiomatic to have defn inside defn? eastwood throws def-in-def warning
> when I have the following code:
>
> (defn double-square [y]
>         (defn square [x] (* x x))
>         (+ (square y) (square y)))
>
> The above code is a simplified example to show the problem. In the above
> case, square is a function which is local and I dont want it to be shared
> outside the context of double-square.
>
> I can change it to use letfn like below:
>
> (defn double-square [y]
>         (letfn [(square [x] (* x x))]
>                 (+ (square y) (square y))))
>
> But when you have multiple local functions, it doesnt seem nice to read.
>
> - Uday.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> 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 clojure+unsubscr...@googlegroups.com.
> 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 clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
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 clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to