Re: Implementing multimethods in pure Clojure

2010-12-14 Thread Ken Wesson
On Tue, Dec 14, 2010 at 2:23 PM, javajosh wrote: > I wouldn't worry too much about your reputation. Your posts are top > notch, and you obviously know the language better than 90% of most > clojure users. Thank you. > Have confidence and laugh if you think someone is > disparaging: actions speak

Re: Implementing multimethods in pure Clojure

2010-12-14 Thread javajosh
I wouldn't worry too much about your reputation. Your posts are top notch, and you obviously know the language better than 90% of most clojure users. Have confidence and laugh if you think someone is disparaging: actions speak far louder than words. On Dec 14, 4:42 am, Ken Wesson wrote: > On Tu

Re: Implementing multimethods in pure Clojure

2010-12-14 Thread Ken Wesson
On Tue, Dec 14, 2010 at 4:52 AM, James Reeves wrote: > On 14 December 2010 09:22, Meikel Brandmeyer wrote: >> >> Am 13.12.2010 um 23:52 schrieb Ken Wesson: >> >>> That's not what I meant. I figure all of us have tabs permanently open >>> to there (I have two actually). What we don't have is the w

Re: Implementing multimethods in pure Clojure

2010-12-14 Thread James Reeves
On 14 December 2010 09:22, Meikel Brandmeyer wrote: > > Am 13.12.2010 um 23:52 schrieb Ken Wesson: > >> That's not what I meant. I figure all of us have tabs permanently open >> to there (I have two actually). What we don't have is the whole thing >> memorized, or the time to read it all rather th

Re: Implementing multimethods in pure Clojure

2010-12-14 Thread Meikel Brandmeyer
Hi, Am 13.12.2010 um 23:52 schrieb Ken Wesson: > That's not what I meant. I figure all of us have tabs permanently open > to there (I have two actually). What we don't have is the whole thing > memorized, or the time to read it all rather than use it for reference […] My solution to this problem

Re: Implementing multimethods in pure Clojure

2010-12-13 Thread Ken Wesson
On Mon, Dec 13, 2010 at 5:38 PM, Meikel Brandmeyer wrote: > Hi, > > Am 13.12.2010 um 21:42 schrieb Ken Wesson: > >> (Where did >> you find vary-meta? There seems to be a lot of stuff that's there, but >> hardly anyone knows about.) > > http://clojure.github.com/clojure/ > > Hope that helps. That'

Re: Implementing multimethods in pure Clojure

2010-12-13 Thread Meikel Brandmeyer
Hi, Am 13.12.2010 um 21:42 schrieb Ken Wesson: > (Where did > you find vary-meta? There seems to be a lot of stuff that's there, but > hardly anyone knows about.) http://clojure.github.com/clojure/ Hope that helps. Sincerely Meikel -- You received this message because you are subscribed to t

Re: Implementing multimethods in pure Clojure

2010-12-13 Thread Ken Wesson
On Mon, Dec 13, 2010 at 3:27 PM, Alan wrote: > That function is already written for you. > > user=> (def x (atom (with-meta [] {:foo 1}))) > #'user/x > user=> (meta @x) > {:foo 1} > user=> (swap! x vary-meta assoc :bar 2) > [] > user=> (meta @x) > {:bar 2, :foo 1} Not exactly. My swap-meta! is a

Re: Implementing multimethods in pure Clojure

2010-12-13 Thread Alan
See my reply to Ken. I recommend against writing swap-meta! in your own code, except maybe as a shorthand for (swap! foo vary-meta); certainly don't implement it from the ground up when the language already gives you the function you want. On Dec 12, 2:22 am, Alexander Yakushev wrote: > On Dec 12

Re: Implementing multimethods in pure Clojure

2010-12-13 Thread Alan
That function is already written for you. user=> (def x (atom (with-meta [] {:foo 1}))) #'user/x user=> (meta @x) {:foo 1} user=> (swap! x vary-meta assoc :bar 2) [] user=> (meta @x) {:bar 2, :foo 1} On Dec 11, 2:36 pm, Ken Wesson wrote: > On Sat, Dec 11, 2010 at 5:24 PM, Meikel Brandmeyer wrot

Re: Implementing multimethods in pure Clojure

2010-12-12 Thread Alexander Yakushev
On Dec 12, 12:36 am, Ken Wesson wrote: > > You can "change" the metadata on the object held by the atom (if that > object supports metadata) via (swap! a with-meta ...). > > One thing a bit annoying is if you want to alter the metadata in an > incremental way. To do that atomically requires a cl

Re: Implementing multimethods in pure Clojure

2010-12-12 Thread Alexander Yakushev
On Dec 12, 12:24 am, Meikel Brandmeyer wrote: > > I'm a bit confused. It just looks like a normal function call. > > (my-defmulti foo type) > > (my-defmethod foo String [x] (str "A String: " x)) > > (foo "Hello, World!") > > So it just looks like an ordinary function. Extracting the multi-call

Re: Implementing multimethods in pure Clojure

2010-12-11 Thread Ken Wesson
On Sat, Dec 11, 2010 at 5:24 PM, Meikel Brandmeyer wrote: > Am 11.12.2010 um 23:10 schrieb Alexander Yakushev: >> Oh, that's my fault, I tried with-meta function on the atom and it >> wouldn't work. Still, after I defined an atom with some metadata in >> it, how can I change it thereafter? > > I b

Re: Implementing multimethods in pure Clojure

2010-12-11 Thread Meikel Brandmeyer
Hi, Am 11.12.2010 um 23:10 schrieb Alexander Yakushev: > Thanks for your response! Your example is very useful, though I wanted > to implement the multimethods without that multi-call layer, so it > will look just like an ordinary function. Thanks to Ken Wesson I > already have an idea how to do

Re: Implementing multimethods in pure Clojure

2010-12-11 Thread Alexander Yakushev
On Dec 11, 6:56 pm, Meikel Brandmeyer wrote: > Hi, > > I suppose you are Unlogic from IRC. I don't whether you saw it, but I posted > some rough sketch:http://paste.pocoo.org/show/303462/ > > It just introduces the function binding, no other global objects are > introduced. The methods are store

Re: Implementing multimethods in pure Clojure

2010-12-11 Thread Alexander Yakushev
On Dec 11, 5:37 pm, Ken Wesson wrote: > On Sat, Dec 11, 2010 at 3:32 AM, Alexander Yakushev > > Making the thing work with (name args ...) is not too too difficult. > You'd have to have defmethod output both a def of an atom like above, > but with a gensym for a name, and a defn with the specifi

Re: Implementing multimethods in pure Clojure

2010-12-11 Thread Meikel Brandmeyer
Hi, I suppose you are Unlogic from IRC. I don't whether you saw it, but I posted some rough sketch: http://paste.pocoo.org/show/303462/ It just introduces the function binding, no other global objects are introduced. The methods are stored in a map in an atom in the metadata of the Var of the

Re: Implementing multimethods in pure Clojure

2010-12-11 Thread Ken Wesson
On Sat, Dec 11, 2010 at 3:32 AM, Alexander Yakushev wrote: > I am currently giving some lectures about Clojure to a group of > students. One of the Lisp features I promote to them is the ability to > write language in the language itself. So during the lecture when I > talked about multimethods on

Implementing multimethods in pure Clojure

2010-12-11 Thread Alexander Yakushev
I am currently giving some lectures about Clojure to a group of students. One of the Lisp features I promote to them is the ability to write language in the language itself. So during the lecture when I talked about multimethods one student asked if one could write own multimethods implementation i