proxy with dynamic

2011-12-25 Thread Razvan Rotaru
Hi, Is it possible to give the class as value at runtime to proxy? (defn create-proxy [clazz] (proxy [clazz] )) I know this can be done with a macro, but my question is whether it can be done as function. Thanks, Razvan -- You received this message because you are subscribed to the G

Re: proxy with dynamic

2011-12-25 Thread Alan Malloy
On Dec 25, 12:45 am, Razvan Rotaru wrote: > Hi, > > Is it possible to give the class as value at runtime to proxy? > > (defn create-proxy [clazz] >     (proxy [clazz] )) > > I know this can be done with a macro, but my question is whether it > can be done as function. Presumably you just trie

weird quote/unquote usage

2011-12-25 Thread Razvan Rotaru
Hi, Consider following code: (defprotocol WithOptions (getOptions [this] "All options") (getOption [this option] "One option")) (defn- gen-proxy [klass opts] `(proxy [~klass WithOptions] [] (getOptions [~'_] ~opts) (getOption [~'thi

Re: proxy with dynamic

2011-12-25 Thread Razvan Rotaru
On Dec 25, 12:01 pm, Alan Malloy wrote: > > Presumably you just tried it and found it doesn't work, so I'm not > sure what more you're looking for here. How would you even fill in the > body of the proxy? "I don't know what class this is, but I know > exactly what methods I need to override"? Prob

Re: weird quote/unquote usage

2011-12-25 Thread Meikel Brandmeyer
Hi, Am 25.12.2011 um 11:37 schrieb Razvan Rotaru: > Consider following code: > > (defprotocol WithOptions > (getOptions [this] "All options") > (getOption [this option] "One option")) > > > (defn- gen-proxy [klass opts] > `(proxy [~klass WithOptions] [] >

Re: proxy with dynamic

2011-12-25 Thread Meikel Brandmeyer
Hi, Am 25.12.2011 um 11:46 schrieb Razvan Rotaru: > Macros work fine, but I want to try to have it as a function. Wiring to classes happens in the bytecode and hence have to be known at compile time. You either have to use eval or refrain from doing things at runtime. Is the class transferred

Re: proxy with dynamic

2011-12-25 Thread Razvan Rotaru
On Dec 25, 1:17 pm, Meikel Brandmeyer wrote: > Hi, > > Wiring to classes happens in the bytecode and hence have to be known at > compile time. You either have to use eval or refrain from doing things at > runtime. Is the class transferred into your program at runtime without > knowing it up-fro

Re: weird quote/unquote usage

2011-12-25 Thread Razvan Rotaru
Thanks. Razvan -- 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send

Re: Matching core.match's syntactic keywords

2011-12-25 Thread Herwig Hochleitner
Thanks! Am 23.12.2011 16:10 schrieb "Steve Miner" : > > On Dec 22, 2011, at 10:54 PM, Herwig Hochleitner wrote: > > I want to match vectors of the form [(some expr) :as :label], but #(match > [%] [[expr :as (label :when keyword)]] {:expr expr :label label}) throws a > compiler exception: Unable t

Re: proxy with dynamic

2011-12-25 Thread Meikel Brandmeyer
Hi, Am 25.12.2011 um 13:03 schrieb Razvan Rotaru: > I'm not sure I understand your question. The class is known, but it's > transfered as an instance of java.lang.Class. > I also don't quite understand your argument. Clojure creates classes > dynamically (e.g. deftype), so why not create a proxy

Merging maps based on custom priority logic

2011-12-25 Thread Shoeb Bhinderwala
I want to merge lists of maps. Each map entry has an :id and :code key. The code associated to :id from one map should have higher precedence than the same :id entry from another map. I have an implementation. The problem and solution is best described using example: ;priority 1 map (def p1 [{:i

Re: Merging maps based on custom priority logic

2011-12-25 Thread Bill Caputo
On Sun, Dec 25, 2011 at 10:25 AM, Shoeb Bhinderwala wrote: > I want to merge lists of maps. Each map entry > I have written the > implementation. > [...] > Is there a more efficient, cleaner > and idiomatic way to do this. Am I missing out on any core library > functions that already provide this

Re: Merging maps based on custom priority logic

2011-12-25 Thread Baishampayan Ghose
>> Is there a more efficient, cleaner >> and idiomatic way to do this. Am I missing out on any core library >> functions that already provide this behavior? > > I believe the core function "merge-with" may give you what you are > looking for: > http://clojure.github.com/clojure/clojure.core-api.ht

Re: Merging maps based on custom priority logic

2011-12-25 Thread Bill Caputo
On Sun, Dec 25, 2011 at 10:37 AM, Baishampayan Ghose wrote: > Shoeb wants to merge sequences of maps and not the maps themselves, so > merge/merge-with won't help him much. Sorry, I may have misunderstood, I was thinking something like this (where select-code implements his selecting codes from t

Re: Merging maps based on custom priority logic

2011-12-25 Thread Meikel Brandmeyer
Hi, maybe using group-by works? (defn custom-merge [maps] (->> maps (apply concat) (group-by :id) (sort-by key) (map (comp first val I'm not sure about the efficiency, though. If you don't need the result sorted by :id you might replace the sort and the map by “vals (map