scheme's define is scoped inside a function. clojure is not scheme.
clojure's def (which defn uses) is not lexical or scoped in anyway, it
always operates on global names. if you want lexical scope please use
one of clojure's lexical scoping constructs, let or letfn.

On Wed, Feb 10, 2010 at 1:28 PM, Hozumi <fat...@googlemail.com> wrote:
> Hi all.
> Is it not recommended to use defn within defn?
>
> Normal function is faster than the function which has inner function
> which actually doesn't run.
> ------------------------------------------------------------------------------
> (defn aaa1 []
>  (defn bbb [] 1)
>  1)
>
> (defn aaa2 [] 1)
>
> user> (time (dotimes [_ 10000000] (aaa1)))
> "Elapsed time: 4083.291 msecs"
> nil
> user> (time (dotimes [_ 10000000] (aaa2)))
> "Elapsed time: 58.34 msecs"
> nil
> ------------------------------------------------------------------------------
> In scheme's case both code have been excuted in the same time.
>
> None of clojure code I have seen have inner function.
> I like inner function because it doesn't consume a name from namespace
> and make it clear that inner function is only used by outer function.
> Thanks.
>
> --
> 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



-- 
And what is good, Phaedrus,
And what is not good—
Need we ask anyone to tell us these things?

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

Reply via email to