avoiding duplication using multi-methods

2008-08-31 Thread Parth Malwankar
Hello, I have a situation in which different multi-methods need similar behavior with different arguments. So they call the same function (one-or-two below) with the arguments. E.g. (defmulti what-num (fn [x] x)) (defn one-or-two [x] (println "saw one or two: " x)) (defmethod what

Re: remove-ns before loading lib?

2008-08-31 Thread Stephen C. Gilardi
On Aug 31, 2008, at 10:11 PM, Rich Hickey wrote: > On Aug 31, 8:12 pm, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote: >> There may still be situations where other code can hold onto an old >> definition across a reload but this change will cover the vast >> majority of cases easily and reliably.

Re: remove-ns before loading lib?

2008-08-31 Thread Rich Hickey
On Aug 31, 8:12 pm, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote: > One of the downsides of interactive development and testing using the > REPL is the fact that an old definitions in a lib's namespace can > linger in memory after its source code has been deleted from the lib. > One can relaun

Re: Discrepancies between boot.clj and API Docs

2008-08-31 Thread Rich Hickey
On Aug 31, 6:05 pm, Meikel Brandmeyer <[EMAIL PROTECTED]> wrote: > Hello Rich, > > I noticed a difference between boot.clj and the API Docs. I know that > there are internal definitions, which are not supposed to be used by the > user. New functions might also take some time, before they show up

remove-ns before loading lib?

2008-08-31 Thread Stephen C. Gilardi
One of the downsides of interactive development and testing using the REPL is the fact that an old definitions in a lib's namespace can linger in memory after its source code has been deleted from the lib. One can relaunch Clojure to be sure of clearing that situation, but that often loses

Discrepancies between boot.clj and API Docs

2008-08-31 Thread Meikel Brandmeyer
Hello Rich, I noticed a difference between boot.clj and the API Docs. I know that there are internal definitions, which are not supposed to be used by the user. New functions might also take some time, before they show up in the docs. But I'm missing for example delay and force. I found myself i

Re: New Release of VimClojure: v1.2.0

2008-08-31 Thread Meikel Brandmeyer
Hello, Am 30.08.2008 um 14:53 schrieb Parth Malwankar: Just found one minor issue. defmulti formatting is like: (defmulti foo :abc [n] (println n)) With (pr.. being aligned with foo instead of ^(d. I disagree. The format of defmulti is: (defmulti name dispatch-fn [default-dispatc

Re: debugging, logging, ... and code sections

2008-08-31 Thread Stephen C. Gilardi
On Aug 31, 2008, at 4:34 AM, Frantisek Sodomka wrote: > To extend this idea little further, lets define "code sections": I like the idea a lot. I believe the "Aspect oriented programming" folks call these kinds of "outside the main flow" items "aspects". I think it would be good to have aspe

Re: debugging, logging, ... and code sections

2008-08-31 Thread Frantisek Sodomka
I found that Rich wrote a simple tracing facility: http://groups.google.com/group/clojure/browse_frm/thread/fd315d9dfdb8c32c/7479682cdf3a1b97 What I had in mind is to literally turn on and off parts of code. This way I can play with design by contract: (def *section-tags* {:require true}) (de

Instrumenting functions (was: Re: debugging, logging, ... and code sections)

2008-08-31 Thread Meikel Brandmeyer
Hello Parth, (defn print-decorate [f] (fn [& args] (println (:name (meta (var f))) "called with" args) (apply f args))) f is not a toplevel binding, but only a local variable. This is the issue here, I think. Please try the following. (defn print-decorate [f] (fn [& args] (pri

Re: with-meta usage

2008-08-31 Thread Meikel Brandmeyer
Hello, I was wondering why the first scenario didn't work but couldn't find details on this. Can someone please explain? I also stumbled over this issue. Please read this sentence from the "Metadata" section on clojure.org (http://clojure.org/metadata) "Symbols and collections support metadat

Re: debugging, logging, ... and code sections

2008-08-31 Thread Parth Malwankar
Frantisek Sodomka wrote: > Hello! > It is very common pattern to include parts of code which are used for > specific purposes - for example debugging, logging, etc. While these parts > can be used when developing code, they can be removed from finished > application. One way is to comment these

with-meta usage

2008-08-31 Thread Apurva
Hi Clojure experts, I am newbie to Clojure and was exploring metadata. The following didn't work: user=> (def v 10) #'user/v user=> (with-meta v {:info 1}) java.lang.IncompatibleClassChangeError java.lang.IncompatibleClassChangeError at clojure.with_meta__47.invoke(boot.clj:159)

Re: executing shell command

2008-08-31 Thread Albert Cardona
John wrote: > I did this: > > (import '(java.io BufferedReader InputStreamReader)) > > (defn cmd [p] (.. Runtime getRuntime (exec (str p > > (defn cmdout [o] > (let [r (BufferedReader. > (.InputStreamReader. >(.getInputStream o)))] > (dorun (map println (line

debugging, logging, ... and code sections

2008-08-31 Thread Frantisek Sodomka
Hello! It is very common pattern to include parts of code which are used for specific purposes - for example debugging, logging, etc. While these parts can be used when developing code, they can be removed from finished application. One way is to comment these parts out, when we are done.