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
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
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
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
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
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
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
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,
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
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
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
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 ?
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
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
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
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
16 matches
Mail list logo