On Sep 11, 11:33 am, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote:
> On Sep 11, 2008, at 8:12 AM, Rich Hickey wrote:
>
> > Using the latest syntax is good, although the idiom for static calls
> > is (Classname/method args). For instance:
>
> > (clojure.lang.Namespace/find sym)
>
> > instead of:
>
> > (.find clojure.lang.Namespace sym)
>
> > because static methods really aren't functions taking classes, but
> > functions in a class namespace.
>
> I see now, cool.
>
> > I think it's close. The other tip I have is that by type-hinting the-
> > ns you can avoid the hint in every let:
>
> > (defn #^{:private true :tag clojure.lang.Namespace}
> >  the-ns ...)
>
> > (defn ns-name
> >  "Returns the name of the namespace, a symbol."
> >  [ns]
> >  (let [ns (the-ns ns)]
> >    (.getName ns)))
>
> > getName is a non-reflective call.
>
> I made that change and then removed the let altogether when ns was
> used only once. I also remove the call to the-ns in the one case (ns-
> imports) where ns was only being passed along to another ns- function.
>
> I tried to verify that removing the let wouldn't interfere with making
> it a non-reflective call, but I wasn't able to get any calls to these
> functions to give me a reflection warning even if I removed the ":tag"
> from 'the-ns. Was this the right way to test that:
>
>         user=> (binding [*warn-on-reflection* true] (ns-name 'clojure))
>

In the Repl, you need to:

(set! *warn-on-reflection* true)

then recompile or reload the code. The check is made during
compilation, not at runtime.


> > If you could make these changes I'll incorporate the patch, thanks!
>
> You're quite welcome. Thanks for all the tips. If it needs further
> refinement, please let me know.


Looks good. I added an exception if the symbol arg to the-ns doesn't
name a namespace.

Patch applied (rev 1022) - thanks!

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