Re: why the def of run-jetty looks like defn #^Server run-jetty

2010-08-10 Thread ngocdaothanh
The main usage (at least for me) is avoiding reflection in the context of direct call to a Java method. if you write: (defn foo [x]   (.clone x)) Thank you for the insightful explanation. -- You received this message because you are subscribed to the Google Groups Clojure group. To post

why the def of run-jetty looks like defn #^Server run-jetty

2010-08-09 Thread limux
The follow is the ring's source, and I am a newbie in Clojure. what the defn of run-jetty looks like this form, what's the meaning of #^Server in the defn and let? Thanks in advance. Limux. (defn #^Server run-jetty Serve the given handler according to the options. Options: :configurator

Re: why the def of run-jetty looks like defn #^Server run-jetty

2010-08-09 Thread j-g-faustus
On Aug 9, 8:25 am, limux liumengji...@gmail.com wrote: what's the meaning of #^Server in the defn and let? (defn #^Server run-jetty ...   (let [#^Server s (create-server (dissoc options :configurator))] It's a type hint. In the defn it specifies the type of the return value, in the let it

Re: why the def of run-jetty looks like defn #^Server run-jetty

2010-08-09 Thread limux
I see, heartly thanks, and there is no any words about it in API doc of clojure.org yet! Regards limux. On 8月9日, 下午3时04分, j-g-faustus johannes.fries...@gmail.com wrote: On Aug 9, 8:25 am, limux liumengji...@gmail.com wrote: what's the meaning of #^Server in the defn and let? (defn

Re: why the def of run-jetty looks like defn #^Server run-jetty

2010-08-09 Thread limux
The type hint can be placed on function parameters, let-bound names, var names, and expressions. And it can be placed behind or ahead of them. Isn't it? On 8月9日, 下午3时31分, limux liumengji...@gmail.com wrote: I see, heartly thanks, and there is no any words about it in API doc of clojure.org

Re: why the def of run-jetty looks like defn #^Server run-jetty

2010-08-09 Thread Nicolas Oury
I am not 100% sure, but it seems they are always ahead. (defn ^Bar foo ...) tells that function foo returns something of class Bar. (f ^Bar expr) says that expr is of type Bar. (let [ ^Bar e expr] ... says that e is of type Bar. (Bar can be a class or an interface.) The main usage (at least