equivalent of Compojure resources in juxt/bidi
Hi I am trying to mimic the following Compojure behaviour, in juxt/bidi (defroutes routes (*resources* /) (GET /* req (io/resource index.html))) (def http-handler (reload/wrap-reload (api #'routes))) In Compojure, the 'resources' function seems to load all resources by default from /resources/public/. When I try set up the equivalent routes in bidi, I keep getting errors of resources not found. How would you do this in, juxt/bidi ? Thanks Clifford -- 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 email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: equivalent of Compojure resources in juxt/bidi
Hi Dan Thanks for that. I have read that section. My question is, how do I associate the / route with both a handler and the 'resources-maybe'? I would like the resources to pick up the Google Closure library sitting in 'resources/public/js/out' when navigating to '/index.html' On Monday, 12 January 2015 00:36:59 UTC+2, Dan Kersten wrote: Hi, Take a look at https://github.com/juxt/bidi#resources-and-resourcesmaybe Regards, Dan On 11 January 2015 at 19:27, cliff clifford...@gmail.com javascript: wrote: Hi I am trying to mimic the following Compojure behaviour, in juxt/bidi (defroutes routes (*resources* /) (GET /* req (io/resource index.html))) (def http-handler (reload/wrap-reload (api #'routes))) In Compojure, the 'resources' function seems to load all resources by default from /resources/public/. When I try set up the equivalent routes in bidi, I keep getting errors of resources not found. How would you do this in, juxt/bidi ? Thanks Clifford -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com javascript: Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com javascript: For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com javascript:. For more options, visit https://groups.google.com/d/optout. -- 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 email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: equivalent of Compojure resources in juxt/bidi
Would something like this be correct? (def routes [ { / {[ (br/resources-maybe {:prefix public})] :home-page-handler}}]) On Monday, 12 January 2015 08:39:19 UTC+2, cliff wrote: Hi Dan Thanks for that. I have read that section. My question is, how do I associate the / route with both a handler and the 'resources-maybe'? I would like the resources to pick up the Google Closure library sitting in 'resources/public/js/out' when navigating to '/index.html' On Monday, 12 January 2015 00:36:59 UTC+2, Dan Kersten wrote: Hi, Take a look at https://github.com/juxt/bidi#resources-and-resourcesmaybe Regards, Dan On 11 January 2015 at 19:27, cliff clifford...@gmail.com wrote: Hi I am trying to mimic the following Compojure behaviour, in juxt/bidi (defroutes routes (*resources* /) (GET /* req (io/resource index.html))) (def http-handler (reload/wrap-reload (api #'routes))) In Compojure, the 'resources' function seems to load all resources by default from /resources/public/. When I try set up the equivalent routes in bidi, I keep getting errors of resources not found. How would you do this in, juxt/bidi ? Thanks Clifford -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- 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 email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: test.check generating hierarchy with relations
Hi Nico Thanks for your advice. * The `size` param in `gen-hierarchy` is being passed as the first param to `run`, which limits the count of results returned by core.logic. What's the intention there? I think it's most common to grab one result from run, or all of them (to check if it always generates correct solutions, for example), but not something in the middle, nevertheless based on the size of the test.check iteration. Agreed. I should allow 'run' to return all results and rather let test.check reduce the returned set. * I think that your generator should generate a graph and a starting point. The traversal could be generated in the body of the `for-all`, and some relation between the graph, the starting point and the traversal should be asserted there. Here's a draft example: I was generating the starting point independently with a, (gen/not-empty (gen/int)) I'm not sure what the size means with regard to the graph and the starting point. This is important to think about so as to get a better shrinking when there's a failure. The graph generator should implement the shrinking strategy, I think... But all of that should not be strictly necessary to have something working. Worrying about shrinking may be a bit past my current skill level with test.check, maybe as the next stage. :-) I will refactor my solution to take into account some of your points above and see if I have any more success. Thanks again for your help Nico. On Wednesday, 10 December 2014 06:07:26 UTC+2, Nicolás Berger wrote: Hey Cliff, A couple comments: * The `size` param in `gen-hierarchy` is being passed as the first param to `run`, which limits the count of results returned by core.logic. What's the intention there? I think it's most common to grab one result from run, or all of them (to check if it always generates correct solutions, for example), but not something in the middle, nevertheless based on the size of the test.check iteration. * I think that your generator should generate a graph and a starting point. The traversal could be generated in the body of the `for-all`, and some relation between the graph, the starting point and the traversal should be asserted there. Here's a draft example: ``` (defn gen-graph Should return a real graph. Node count could be given by size [size] {1 [2 3 4] 2 [5 6 7] 6 [8 9] 10 [11 12 13]}) (defn traverse-graph [graph start] #{3 4 5 7 8 9}) (defn gen-graph-and-starting-point [size] (gen/bind gen-graph #(gen/tuple (gen/return %) (gen/elements (keys %) (defspec graph-traversal (prop/for-all [[graph start] gen-graph-and-starting-point] (let [traversal (traverse-graph graph start)] ; every element in traversal is a node in the graph (is (every? #(in-graph? graph %) traversal)) ; start is not part of traversal (is (not (traversal start))) ; some other property? (is (some-other-property? graph start traversal) ``` I'm not sure what the size means with regard to the graph and the starting point. This is important to think about so as to get a better shrinking when there's a failure. The graph generator should implement the shrinking strategy, I think... But all of that should not be strictly necessary to have something working. Hope it helps. Nico On Tue, Dec 9, 2014 at 3:50 AM, cliff clifford...@gmail.com javascript: wrote: Hi Gary I have tried your suggestion but I fear there is a deeper problem. Thanks Cliff On Monday, 8 December 2014 12:03:47 UTC+2, Gary Verhaegen wrote: I haven't touched test.check yet, si this might be completely off the mark, but based on my limited understanding, here's what I think happens. for-all probably removes one level of nesting from your generator, which means that bindings is bound to a seq with one element, which is a map. Then, keys in the (let [ks (into #{} (keys bindings))]... Form turns its argument into a seq, which is easy as it is already one, and then tries to map the key function on the result. The key function expects a Map.Entry, but here the elements of the seq are (or actually is, as there is only one) maps, so it blows up. Easiest way to test (I'm on my phone, emse I'd have done it) this hypothesis would be to turn the into for into (into #{} (keys (first bindings))). Once confirmed, I would suggest getting ris of that extra level of nesting earlier, for example inside your -maps fn (mapcat identity should do the trick). On Monday, 8 December 2014, cig clifford...@gmail.com wrote: Hi I would like to test a function which recursively traverses the nodes in a graph and collects them. For example, (def graph {1 [2 3 4] 2 [5 6 7] 6 [8 9] 10 [11 12 13]} my function is given a starting point say, 1 and should then traverse each node which is reachable
Re: test.check generating hierarchy with relations
Nico, what is the correct way to turn my function which generates the graph (using core.logic) into a generator? On Monday, 8 December 2014 09:04:14 UTC+2, cliff wrote: Hi I would like to test a function which recursively traverses the nodes in a graph and collects them. For example, (def graph {1 [2 3 4] 2 [5 6 7] 6 [8 9] 10 [11 12 13]} my function is given a starting point say, 1 and should then traverse each node which is reachable and return the set. In this case the result should be: #{3, 4, 5, 7, 8, 9} note: it does not return any elements reachable by 10. I would like to test this using test.check, but I would like to generate test data which will exercise the traversal of the graph. I found a similar thread here: https://groups.google.com/forum/#!topic/clojure/YWeT8BFc8k4 But, I don't think the proposed solution would suit this use case. So, I tried generating a graph with relations using core.logic (defn -maps take the output of run* and convert it into sequence of maps [q] (let [r (- q (partition 2) (map (fn [[k v]] {k (apply vector v)})) (apply merge))] r )) (defn gen-hierarchy generate a related hierarchy [size] (let [vars1 (- (repeatedly 7 lvar) (into [])) vars2 (- (repeatedly 7 lvar) (into [])) vars3 (- (repeatedly 7 lvar) (into []))] (- (run size [q] (fresh [?k1 ?k2 ?k3 ?v1 ?v2 ?v3 ?a] (fd/distinct vars1) (everyg #(fd/in % (fd/interval 1 9)) vars1) (fd/in ?k1 (fd/interval 1 9)) (rembero ?k1 vars1 ?v1) (membero ?k2 ?v1) (fd/distinct vars2) (everyg #(fd/in % (fd/interval 1 9)) vars2) (rembero ?k2 vars2 ?v2) (membero ?k3 ?v2) (fd/distinct vars3) (everyg #(fd/in % (fd/interval 1 9)) vars3) (rembero ?k3 vars3 ?v3) (appendo [?k1 ?v1] [?k2 ?v2] ?a) (appendo ?a [?k3 ?v3] q))) (map -maps Hooking this into test.check. I tried the following: (defn gen-port-hierarchy [] (gen/sized (fn [size] (gen/fmap #(gen-hierarchy %) (gen/return size) (gen/sample (gen/not-empty (gen-port-hierarchy)) 1) Which does produce more or less what I'm after: (({6 [2 3 4 5 7 1], 3 [6 7 1 2 4 5], 1 [3 2 4 5 6 7]}) ({5 [1 2 3 4 6 7], 7 [5 3 4 6 1 2], 1 [7 2 3 4 5 6]})) However, when I try use this in a spec: (prop/for-all [bindings (gen/not-empty (gen-port-hierarchy))] (let [ ks (into #{} (keys bindings))] ...) I seem to be getting back a LazySeq which then leads to a ClassCastException: java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.util.Map$Entry Am I on the completely wrong path here? Or have I incorrectly hooked this generator up with test.check? Any help would be very appreciated. -- 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 email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: test.check generating hierarchy with relations
Hi Gary I have tried your suggestion but I fear there is a deeper problem. Thanks Cliff On Monday, 8 December 2014 12:03:47 UTC+2, Gary Verhaegen wrote: I haven't touched test.check yet, si this might be completely off the mark, but based on my limited understanding, here's what I think happens. for-all probably removes one level of nesting from your generator, which means that bindings is bound to a seq with one element, which is a map. Then, keys in the (let [ks (into #{} (keys bindings))]... Form turns its argument into a seq, which is easy as it is already one, and then tries to map the key function on the result. The key function expects a Map.Entry, but here the elements of the seq are (or actually is, as there is only one) maps, so it blows up. Easiest way to test (I'm on my phone, emse I'd have done it) this hypothesis would be to turn the into for into (into #{} (keys (first bindings))). Once confirmed, I would suggest getting ris of that extra level of nesting earlier, for example inside your -maps fn (mapcat identity should do the trick). On Monday, 8 December 2014, cig clifford...@gmail.com javascript: wrote: Hi I would like to test a function which recursively traverses the nodes in a graph and collects them. For example, (def graph {1 [2 3 4] 2 [5 6 7] 6 [8 9] 10 [11 12 13]} my function is given a starting point say, 1 and should then traverse each node which is reachable and return the set. In this case the result should be: #{3, 4, 5, 7, 8, 9} note: it does not return any elements reachable by 10. I would like to test this using test.check, but I would like to generate test data which will exercise the traversal of the graph. I found a similar thread here: https://groups.google.com/forum/#!topic/clojure/YWeT8BFc8k4 But, I don't think the proposed solution would suit this use case. So, I tried generating a graph with relations using core.logic (defn -maps take the output of run* and convert it into sequence of maps [q] (let [r (- q (partition 2) (map (fn [[k v]] {k (apply vector v)})) (apply merge))] r )) (defn gen-hierarchy generate a related hierarchy [size] (let [vars1 (- (repeatedly 7 lvar) (into [])) vars2 (- (repeatedly 7 lvar) (into [])) vars3 (- (repeatedly 7 lvar) (into []))] (- (run size [q] (fresh [?k1 ?k2 ?k3 ?v1 ?v2 ?v3 ?a] (fd/distinct vars1) (everyg #(fd/in % (fd/interval 1 9)) vars1) (fd/in ?k1 (fd/interval 1 9)) (rembero ?k1 vars1 ?v1) (membero ?k2 ?v1) (fd/distinct vars2) (everyg #(fd/in % (fd/interval 1 9)) vars2) (rembero ?k2 vars2 ?v2) (membero ?k3 ?v2) (fd/distinct vars3) (everyg #(fd/in % (fd/interval 1 9)) vars3) (rembero ?k3 vars3 ?v3) (appendo [?k1 ?v1] [?k2 ?v2] ?a) (appendo ?a [?k3 ?v3] q))) (map -maps Hooking this into test.check. I tried the following: (defn gen-port-hierarchy [] (gen/sized (fn [size] (gen/fmap #(gen-hierarchy %) (gen/return size) (gen/sample (gen/not-empty (gen-port-hierarchy)) 1) Which does produce more or less what I'm after: (({6 [2 3 4 5 7 1], 3 [6 7 1 2 4 5], 1 [3 2 4 5 6 7]}) ({5 [1 2 3 4 6 7], 7 [5 3 4 6 1 2], 1 [7 2 3 4 5 6]})) However, when I try use this in a spec: (prop/for-all [bindings (gen/not-empty (gen-port-hierarchy))] (let [ ks (into #{} (keys bindings))] ...) I seem to be getting back a LazySeq which then leads to a ClassCastException: java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.util.Map$Entry Am I on the completely wrong path here? Or have I incorrectly hooked this generator up with test.check? Any help would be very appreciated. -- 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 email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- 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
Dealing with dynamic header in log file processing
Prefacing this with being a complete Clojure novice, my question is more about approach than the actual code required. Like many, I have a few tried and true examples that I like to work through in each language. In my case, I have a set of IIS log files that I want to generate usage statistics on. The hitch in my particular problem is that the log files may or may not have columns redefined within the file. As an example #Software: Microsoft Internet Information Services 6.0 #Version: 1.0 #Date: 2011-05-02 17:42:15 #Software: Microsoft Internet Information Services 6.0 #Version: 1.0 #Date: 2011-05-02 17:42:15 #Fields: date time c-ip cs-username s-ip s-port cs-method cs-uri-stem cs-uri-query sc-status cs(User-Agent) 2011-05-02 17:42:15 172.22.255.255 - 172.30.255.255 80 GET /images/picture2.jpg - 200 Mozilla/4.0+(compatible;MSIE+5.5;+Windows+2000+Server) 2011-05-02 17:43:15 172.22.255.255 - 172.30.255.255 80 GET /images/picture1.jpg - 200 Mozilla/4.0+(compatible;MSIE+5.5;+Windows+2000+Server) . . many more lines . . #Same file, s-ip is now removed so ordinal positions are changed #Fields: date time c-ip cs-username s-port cs-method cs-uri-stem cs-uri-query sc-status cs(User-Agent) 2011-05-02 17:48:15 172.22.255.255 - 80 GET /images/picture1.jpg - 200 Mozilla/4.0+(compatible;MSIE+5.5;+Windows+2000+Server) 2011-05-02 17:49:15 172.22.255.255 - 80 GET /images/picture3.jpg - 200 Mozilla/4.0+(compatible;MSIE+5.5;+Windows+2000+Server) So with the above data, I am trying to get the count of log file hits from a given cs(User-Agent). In other languages, I would just read in the #Fields row and continue processing merrily given the most recent order I encountered moving through the file sequentially. With Clojure, the immutability of the fields is throwing a wrench for me. If anyone could give me a nudge in the right direction, I would appreciate it. Cliff -- 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 email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Generalizing - -
On Sat, 2009-12-05 at 13:14 +0100, Konrad Hinsen wrote: On 4 Dec 2009, at 23:23, Cliff Wells wrote: What isn't clear to me is exactly what a piece of paper provides that an electronic form doesn't (aside from inconvenience). I don't see any A clear legal status all over the world. A signed statement on paper is recognized everywhere. The legal status of electronic messages, even if signed by some suitable technique, varies wildly from one country to the other. It would be nice if open software could somehow escape from the legal hassle surrounding copyright law, but I don't think this is a realistic idea. What I'm saying is that a signed document, whether digital or on paper, provides little in the way of forgery prevention. Therefore, without witnesses (e.g. a notary) or a sworn admission of signing, a signature is largely inconsequential. Since the Clojure CAS requires nothing of the sort, it is no better than a digital signature, regardless of jurisdiction. Clearly the decision is up to Rich (it's his project, anyone who doesn't like it could easily start a clojure-community project with relaxed requirements), but frankly the current requirements are rather pointless since they provide no real protections. Regards, Cliff -- 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 email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Generalizing - -
On Fri, 2009-12-04 at 11:49 -0800, Richard Newman wrote: The problem is that it is an unreasonably high barrier to entry. There MUST be an electronic-only way (and it must not require a cell phone, CC#, c.) if the full potential of this community is to be unleashed upon clojure-contrib. In particular, there should be a way to participate pseudonymously for those people that (unlike myself) value their privacy sufficiently not to want to even post here under their real names. Raising the barrier to entry stops people pseudonymously contributing code they don't own. If you're not even willing to stand behind it with your own name, and someone sues Rich, he has little recourse. Yeah, some dude named Gecko45 contributed this library. I don't know his real name or where he lives, sorry.. I'm sure Rich would be happy to avoid posting a contributor's name if they didn't want it public. Yes, this makes it more difficult for someone to just email a fix for a small bug. However, I quite understand Rich's reasons for doing it. I don't think it creates an unreasonably high barrier to entry, and I don't see why there MUST be an electronic-only way. If people don't want to submit a CA, they're welcome to put their libraries on GitHub like everyone else. What isn't clear to me is exactly what a piece of paper provides that an electronic form doesn't (aside from inconvenience). I don't see any requirement for notarization, registered mail, etc, so the paper is simply worth a bit less than it was before it was printed on. Any contributor in fear of culpability could resort to simple denial. I am unable to see why someone shouldn't be able to receive a signed PDF via email and achieve a similar level of confidence that the signor was legitimate. Regards, Cliff -- 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 email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Timing, JIT, Heisen-code
On Tue, 2009-09-29 at 22:54 -0700, Meikel Brandmeyer wrote: Hi, On Sep 30, 12:19 am, Cliff Wells cliff.we...@gmail.com wrote: In short, you've taken something that was originally CPU-bound and made it I/O-bound. I don't think so. The measured times do not include the println. The loop with the print will itself run longer, but the average time printed does not count the print. Ah, I missed that. Should have read closer. I would expect something like code elimination (the computed value is not used) or some other JIT-voodoo to happen in one case and for some reason not in the other. See Cliff Click's presentation on busted benchmarks. I don't have the link handy, but it should be in one of the more recent of the thousand timing threads. Sincerely Meikel -- http://www.google.com/search?q=vonage+sucks --~--~-~--~~~---~--~~ 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 email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Timing, JIT, Heisen-code
On Tue, 2009-09-29 at 09:08 -0700, Matt wrote: So, using mytime2 with the myavgtime macro gives average execution times for the expression (+ 1 2 3) of 2 to 3 times longer than when using mytime1. Why is this? Does the JIT optimize differently with all those println's when using mytime2? (Kind of quantum mechanics-y - observing what's going on changes it.) Output is painstakingly slow in all languages I've ever dealt with (I first noticed it in C). Most of the time it isn't noticed because there's a lot of other non-trivial stuff going on. Here's a comparison of a tight loop in C that does a printf vs one that doesn't (1,000,000 iterations of a simple calculation): With printf: real0m23.534s user0m0.396s sys 0m3.232s Without printf: real0m0.018s user0m0.012s sys 0m0.000s and for comparison, the same in Python: With print: real0m25.879s user0m2.172s sys 0m3.300s Without print: real0m0.596s user0m0.532s sys 0m0.052s Notice that with console output, the Python program is almost as fast (or as slow) as the C version =) In short, you've taken something that was originally CPU-bound and made it I/O-bound. Regards, Cliff --~--~-~--~~~---~--~~ 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 email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
dynamic :use
Hi, I'm new to Clojure (and Lisp-type languages in general) and I've never used Java... in short, I have a steep learning curve littered with rocks and nails. I also don't know whether it's a good thing that I have long experience with Python and C :-P In any case, as a first project, I'm trying to add PostgreSQL support to Clogger (http://github.com/Ejhfast/Clogger/tree/master) and I've managed to get it working. *But*, the number of changes involved suggest that I should put the existing MySQL code and the new PostgreSQL code into a separate files and pull in the correct one at runtime based on a configuration variable. This is where I'm choking. I've created a global variable *db-adapter* in setup.clj and would like change http://github.com/Ejhfast/Clogger/blob/dce291524ab76796c781f7200207070fefe26648/src/site/database.clj to selectively :use (or :import or whatever) mysql.clj or postgresql.clj based upon the value of *db-adapter*. In turn, mysql.clj and postgresql.clj will contain custom versions of the db and create-blog code from database.clj (this leads to a second issue, but I'll save that for later). What I've tried (no laughing!) is this bit of code: (ns site.database (:use [compojure]) (:use [clojure.contrib.sql]) (:use [site.setup]) (if (= *db-adapter* mysql) (:use [site.adapters.mysql :as adapter])) (if (= *db-adapter* postgresql) (:use [site.adapters.postgresql :as adapter]))) But this throws an error: java.lang.Exception: No such var: clojure.core/if (database.clj:1) In any case, this code smells funny, even if it were to work. It seems I should be able to somehow build a string such as (str site.adapters. *db-adapter*) and use that instead (or something else equally concise). And of course, this isn't my only problem. But I'll keep it to one issue at a time. Regards, Cliff --~--~-~--~~~---~--~~ 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 email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---