(constantly)

2012-04-02 Thread Jay Fields
I often tend to define the following in my apps (def no-op (fn [ _])) The other day I noticed constantly (http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/constantly), which is basically the same thing - except I would have to say (constantly nil). What do you all think about

Re: (constantly)

2012-04-02 Thread Jeff Weiss
I wish there was a built-in for this as well. I don't know that (constantly) is a good name for it though. I couldn't think of a good name, apparently a null function means the same as identity function so that doesn't work. On Monday, April 2, 2012 2:39:31 PM UTC-4, Jay Fields wrote: I

Re: .class files constantly going stale?

2012-02-15 Thread Timothy Washington
find myself doing *rm -rf classes/* during my development cycles. Tim Washington Interruptsoftware.ca 416.843.9060 On Sat, Feb 11, 2012 at 11:34 AM, Andrew Cholakian andre...@gmail.comwrote: I've noticed that when writing clojure code I constantly need to 'rm -rf classes' in my project

Re: .class files constantly going stale?

2012-02-15 Thread David Nolen
I've never have this problem. I'm assuming you're using AOT? David On Sat, Feb 11, 2012 at 11:34 AM, Andrew Cholakian andre...@gmail.comwrote: I've noticed that when writing clojure code I constantly need to 'rm -rf classes' in my project, otherwise anything related to (defrecord

Re: .class files constantly going stale?

2012-02-15 Thread Jay Fields
clojure code I constantly need to 'rm -rf classes' in my project, otherwise anything related to (defrecord) or (defprotocol) doesn't update. I've tried this on OSX Lion running both JDK 1.6 and 1.7. This isn't too hard to deal with in lein as I just run rm -rf classes lein run, but it makes

Re: .class files constantly going stale?

2012-02-15 Thread Stuart Halloway
I think this issue is related to using defrecord or defrecord defprotocol or defrecord, defprotocol, extend-protocol I've never bothered to look into the simplest case at which it fails. I have a namespace that has my defrecord, and another namespace that defines the protocol and

Re: .class files constantly going stale?

2012-02-15 Thread Jay Fields
again, I haven't felt much pain, so I'm not sure what I'm saying is entirely true, but... In the scenario I describe I have to :import the class created by defrecord to reference it as part of extend-protocol For example in foo/recs.clj (ns foo.recs) (defrecord ARecord [a b]) in

Re: .class files constantly going stale?

2012-02-15 Thread Chas Emerick
No; just add a (:require foo.recs) to the ns form of foo.prots, so the defrecord form(s) can be loaded; this will generate the classes at runtime, and avoid any ahead-of-time compilation. In general, AOT is rarely necessary, and almost always a hinderance. - Chas On Feb 15, 2012, at 11:13 AM,

Re: .class files constantly going stale?

2012-02-15 Thread Jay Fields
interesting, the trick is to use foo.recs.ARecord... (extend-protocol AProto   foo.recs.ARecord   (handle [o]     ;; do stuff )) Thanks for that. On Wed, Feb 15, 2012 at 11:31 AM, Chas Emerick c...@cemerick.com wrote: No; just add a (:require foo.recs) to the ns form of foo.prots, so the

Re: .class files constantly going stale?

2012-02-15 Thread Chas Emerick
The :import will work as well, as long as the :require comes first. - Chas On Feb 15, 2012, at 12:17 PM, Jay Fields wrote: interesting, the trick is to use foo.recs.ARecord... (extend-protocol AProto foo.recs.ARecord (handle [o] ;; do stuff )) Thanks for that. On Wed, Feb

.class files constantly going stale?

2012-02-13 Thread Andrew Cholakian
I've noticed that when writing clojure code I constantly need to 'rm -rf classes' in my project, otherwise anything related to (defrecord) or (defprotocol) doesn't update. I've tried this on OSX Lion running both JDK 1.6 and 1.7. This isn't too hard to deal with in lein as I just run rm -rf

Re: what's the typical usage of fn constantly

2009-01-26 Thread e
on. Thanks. On Sun, Jan 25, 2009 at 7:06 PM, rzeze...@gmail.com rzeze...@gmail.comwrote: Following James's description, I would image constantly's implementation to look something like the following. (defn constantly [value] #(identity value)) If you haven't seen the # macro before

what's the typical usage of fn constantly

2009-01-25 Thread wubbie
What's the typical usage of fn constantly ? thanks -sun --~--~-~--~~~---~--~~ 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

Re: what's the typical usage of fn constantly

2009-01-25 Thread James Reeves
On Jan 25, 5:34 pm, wubbie sunj...@gmail.com wrote: What's the typical usage of fn constantly ? When you need a function that constantly returns the same result :) That probably doesn't tell you any more than you know already, so I'll give you a real world use. My rnd-utils library has

Re: what's the typical usage of fn constantly

2009-01-25 Thread rzeze...@gmail.com
Following James's description, I would image constantly's implementation to look something like the following. (defn constantly [value] #(identity value)) If you haven't seen the # macro before, the form below is equivalent. (defn constantly [value] (fn [] (identity value))) Making use

Re: what's the typical usage of fn constantly

2009-01-25 Thread wubbie
thanks for the insight! On Jan 25, 7:06 pm, rzeze...@gmail.com rzeze...@gmail.com wrote: Following James's description, I would image constantly's implementation to look something like the following. (defn constantly [value] #(identity value)) If you haven't seen the # macro before