Re: How Clojure protocols are implemented internally?
On May 7, 11:28 pm, Dmitry Kakurin dmitry.kaku...@gmail.com wrote: Let me rephrase my question to avoid unfortunate confusion with standard count function: Suppose I have extended my own IMyCountable protocol with a single mycount method to String class. What happens when I call (mycount some string)? [snip..] This is my (i.e. non authoritative) guess. defprotocol generates an interface and dispatch functions for each of your protocol functions. The dispatch function is a level of indirection between your (mycount some string) and the actual call of your implementation. When you extend the protocol to reach a type there are two cases 1) if you are simultaneously defining a new type and extending the protocol, the underlying new class of the type can directly implement the interface. The dispatch function simply calls the appropriate interface method directly on the object (first argument of the protocol function). 2) (your case) you are extending an existing type. This dispatch function is changed to take account if this new case (I believe the dispatch is a switch on the class of the first argument to the protocol function). I could be wrong, but I don't think it is that far. Kind Regards, - Karl -- 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: Testing functions that access a database
On May 8, 8:37 am, Tim McIver tmci...@verizon.net wrote: I'm looking for some input as to the best way to test functions that interact with a database. I've just started writing some tests for functions that read/write to a mysql database (using clojure.contrib.sql) but my problem is that I'd like the tests to begin with either an empty database or one that has been initialized with some known data. Some of my functions add/remove data from the You may like to consider Clj-Liquibase for some of these jobs: https://bitbucket.org/kumarshantanu/clj-liquibase/src http://www.liquibase.org/manual/home (most of the Change types are supported by Clj-Liquibase) You can load seed data using Liquibase and have the schema dropped/re- created/migrated as required before every test case. Coupling this with your own setup functions for various test scenarios may be a good compromise. Of course, every test needs to call the appropriate setup function to prepare the DB. database and so some of these tests will fail if run again on the changed database. I was thinking I'd have a fixture that loaded a mysql dump file before running the tests but I haven't found any way to do this in Clojure. Any suggestions? Loading SQL statements from the dump file and replaying them can be done using JDBC, but setting up the DB for every test case and cleaning up afterwards will still need to be handled. JDBC distinguishes between queries (SELECT) and updates (DML, DDL) in the API, which is something you will need to take care of. Regards, Shantanu -- 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: Where's incanter chrono?
I think the code has been under development and is now here: https://github.com/getwoven/clj-time as clj-time. On 8 May 2011, at 05:53, Andreas Kostler wrote: Hello all, Has incanter.chrono disappeared? (use '(incanter core chrono)) results in Could not locate incanter/chrono__init.class or incanter/chrono.clj on classpath: [Thrown class java.io.FileNotFoundException] For both incanter 1.2.3 and incanter 1.2.2 Cheers Andreas -- 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 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: Where's incanter chrono?
Cheers :) On 08/05/2011, at 8:17 PM, Edmund Jackson wrote: I think the code has been under development and is now here: https://github.com/getwoven/clj-time as clj-time. On 8 May 2011, at 05:53, Andreas Kostler wrote: Hello all, Has incanter.chrono disappeared? (use '(incanter core chrono)) results in Could not locate incanter/chrono__init.class or incanter/chrono.clj on classpath: [Thrown class java.io.FileNotFoundException] For both incanter 1.2.3 and incanter 1.2.2 Cheers Andreas -- 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 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 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: Closures in macros
Hello Ken, thanks for your explanations. It seems that you basically outlined a strategy that can be used to implement that feature. Very good! :-) Am 05.05.2011 02:21, schrieb Ken Wesson: As for concerns that this kind of extension might mask common macro errors, adding some *warn-on-foo* option to generate warnings when unusual kinds of object literal were encountered by eval/the compiler would hopefully address such. Yes, that’s what I thought too, when I read about Chris Perkins’ concerns. Let the default behaviour be an error message as it now is, but perhaps a more useful one, and let us have an option in defmacros attr-map or in a global switch to tell the compiler, or macroexpander here: “yes, I really want to embed a literal object in the code”. -- 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: Testing functions that access a database
@Ken: I looked into mocking a (very little) bit. I don't have any experience with it but I'm worried about the need to sync the 'real' database with my mocked functions. Using the real schema is appealing because I don't have to worry about synchronization issues. @Shantanu: This looks great! I've also recently started thinking about the best way to migrate changes (I've been doing it by hand, but they've been small changes). I'll look into this more. Thanks for the input. Tim On May 8, 4:33 am, Shantanu Kumar kumar.shant...@gmail.com wrote: On May 8, 8:37 am, Tim McIver tmci...@verizon.net wrote: I'm looking for some input as to the best way to test functions that interact with a database. I've just started writing some tests for functions that read/write to a mysql database (using clojure.contrib.sql) but my problem is that I'd like the tests to begin with either an empty database or one that has been initialized with some known data. Some of my functions add/remove data from the You may like to consider Clj-Liquibase for some of these jobs:https://bitbucket.org/kumarshantanu/clj-liquibase/srchttp://www.liquibase.org/manual/home(most of the Change types are supported by Clj-Liquibase) You can load seed data using Liquibase and have the schema dropped/re- created/migrated as required before every test case. Coupling this with your own setup functions for various test scenarios may be a good compromise. Of course, every test needs to call the appropriate setup function to prepare the DB. database and so some of these tests will fail if run again on the changed database. I was thinking I'd have a fixture that loaded a mysql dump file before running the tests but I haven't found any way to do this in Clojure. Any suggestions? Loading SQL statements from the dump file and replaying them can be done using JDBC, but setting up the DB for every test case and cleaning up afterwards will still need to be handled. JDBC distinguishes between queries (SELECT) and updates (DML, DDL) in the API, which is something you will need to take care of. Regards, Shantanu -- 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
Clojure test framework
Hi, I need to write tests for my Clojure application. Which Clojure test framework would you recommend? I also need posibility to intergrate a framework with Maven. Thanks -- 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: Clojure test framework
Standard clojure.test works fine with maven On Sun, May 8, 2011 at 4:29 PM, Zlatko Josic zlatko.jo...@gmail.com wrote: Hi, I need to write tests for my Clojure application. Which Clojure test framework would you recommend? I also need posibility to intergrate a framework with Maven. -- With best wishes, Alex Ott http://alexott.net/ Tiwtter: alexott_en (English), alexott (Russian) Skype: alex.ott -- 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: Clojure test framework
Midje also works well with Maven. Just wrap them in clojure.test/deftest and you're good to go. Some examples: https://github.com/pallet/stevedore/blob/feature%2Fbatch-impl/test/pallet/stevedore/batch_test.clj And here are almost identical tests, but with clojure.test/is instead of Midje. https://github.com/pallet/stevedore/blob/feature%2Fbatch-impl/test/pallet/stevedore/bash_test.clj I prefer Midje but clojure.test is sufficient also. Ambrose On Sun, May 8, 2011 at 10:29 PM, Zlatko Josic zlatko.jo...@gmail.comwrote: Hi, I need to write tests for my Clojure application. Which Clojure test framework would you recommend? I also need posibility to intergrate a framework with Maven. Thanks -- 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 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: Closures in macros
Am 05.05.2011 02:01, schrieb Ken Wesson: (There's an ugly workaround involving explicitly calling intern; you create a dummy namespace with a var holding the object, and then eval code that refers to that var by fully-qualified name in order to retrieve the object.) Yes, this is what I currently do. In the macro I do (let [f (gensym logger)] (intern 'my.ns f @*logger*) `(~f ~level ...))) which pollutes the ns of my lib, but for now this works. Much better would be of course if the core team of Clojure would implement what you outlined. Greetings, André -- 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: Testing functions that access a database
On May 8, 6:57 pm, Tim McIver tmci...@verizon.net wrote: @Ken: I looked into mocking a (very little) bit. I don't have any experience with it but I'm worried about the need to sync the 'real' database with my mocked functions. Using the real schema is appealing because I don't have to worry about synchronization issues. Yes. Mocking can help test an individual layer (e.g. the business layer without worrying about the underlying database layer), but you also need tests for the database layer anyway, which cannot be done without a real database. At best, probably testing can be done on an in-memory database (e.g. H2) and deployment on MySQL as long as the SQL is portable. @Shantanu: This looks great! I've also recently started thinking about the best way to migrate changes (I've been doing it by hand, but they've been small changes). I'll look into this more. For offline migrations, you may also find this Leiningen plugin useful: https://bitbucket.org/kumarshantanu/lein-lb/src/ Regards, Shantanu -- 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
How Clojure protocols are implemented internally?
On Sat, May 7, 2011 at 5:28 PM, Dmitry Kakurin dmitry.kaku...@gmail.com wrote: Let me rephrase my question to avoid unfortunate confusion with standard count function: Suppose I have extended my own IMyCountable protocol with a single mycount method to String class. What happens when I call (mycount some string)? - Dmitry If you want to understand how it works you'll need to look at src/clj/clojure/core_deftype.clj and src/jvm/clojure/lang/MethodImplCache.java and src/jvm/clojure/lang/AFunction.java. David -- 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: How Clojure protocols are implemented internally?
Very well, something along these lines would be my guess too. But that would mean that in case 2 protocols are no faster than multimethods. And I've got an impression that protocols are described to be as fast as interface dispatch (callvirt). So either my impression is wrong (which is totally possible) or there is some clever trick available on JVM to do case 2 below faster. That's why I'm asking. Also for case 1 your description implies that even for your own types there is a performance penalty for extending interfaces *after* type definition. I'm curious if that's the case as well. - Dmitry On Saturday, May 7, 2011 11:29:16 PM UTC-7, Krukow wrote: When you extend the protocol to reach a type there are two cases 1) if you are simultaneously defining a new type and extending the protocol, the underlying new class of the type can directly implement the interface. The dispatch function simply calls the appropriate interface method directly on the object (first argument of the protocol function). 2) (your case) you are extending an existing type. This dispatch function is changed to take account if this new case (I believe the dispatch is a switch on the class of the first argument to the protocol function). -- 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: Testing functions that access a database
On Sun, May 8, 2011 at 12:14 PM, Shantanu Kumar kumar.shant...@gmail.com wrote: On May 8, 6:57 pm, Tim McIver tmci...@verizon.net wrote: @Ken: I looked into mocking a (very little) bit. I don't have any experience with it but I'm worried about the need to sync the 'real' database with my mocked functions. Using the real schema is appealing because I don't have to worry about synchronization issues. Yes. Mocking can help test an individual layer (e.g. the business layer without worrying about the underlying database layer), but you also need tests for the database layer anyway, which cannot be done without a real database. At best, probably testing can be done on an in-memory database (e.g. H2) and deployment on MySQL as long as the SQL is portable. That's basically what I was thinking: use something like H2 to essentially mock the db itself, rather than the whole db layer. -- 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
If any of you have to code Objective-C...
I came up with something that might make your life a bit easier (after Clojure exposure): http://www.taoeffect.com/blog/2011/05/better-objective-c-through-clojure-philosophy/ - Greg -- 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
Request for feedback: Tradui
Hi all, I've started development on tradui, a translator for the Creole markup language. It is not finished or in any deployable shape or form yet, however it's progressed enough to gather some feedback on the approach taken. Please feel free to clone https://github.com/AndreasKostler/tradui.git and comment away. Kind Regards Andreas -- 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: How Clojure protocols are implemented internally?
On Sun, May 8, 2011 at 4:43 PM, Dmitry Kakurin dmitry.kaku...@gmail.comwrote: Very well, something along these lines would be my guess too. But that would mean that in case 2 protocols are no faster than multimethods. Not true. And I've got an impression that protocols are described to be as fast as interface dispatch (callvirt). So either my impression is wrong (which is totally possible) or there is some clever trick available on JVM to do case 2 below faster. That's why I'm asking. They are not as fast, but they are quite fast. Look at the implementation. David -- 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
Hi, simple problem from a newbie
Hi everybody :) I am an experienced C++ programmer. Recently I decided to try out clojure(I have some java experience). I read some tutorials of the basics clojure. Now I want to implement some simple algorithms. Starting with Insertion sort. But, when I have tried to start, I find myself lost. It feels like I have to write a big line to solve it. Can anyone help me to have a head start! Thanks :) -- 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: Hi, simple problem from a newbie
On Sun, May 8, 2011 at 4:59 PM, iamcreasy quazir...@gmail.com wrote: Hi everybody :) Welcome! I am an experienced C++ programmer. Recently I decided to try out clojure(I have some java experience). My background was C++ for most of the 90's then Java for quite a bit of the 00's so I expect you're finding the hardest part of learning Clojure is adjusting to a functional approach with immutable data? I read some tutorials of the basics clojure. Now I want to implement some simple algorithms. Starting with Insertion sort. There are two parts to the problem: * given an item and a sorted list, return a new list with the item inserted in the correct place * given a list of unsorted items, repeatedly perform the first part For the sorted insert: * if the sorted list is empty, return a new list with just the new item * else if the new item is less than the first item in the sorted list, return a new list: (cons new-item sorted-list) * else return a new list: (cons (first sorted-list) (sorted-insert new-item (rest list))) To repeatedly perform the insertion, try a loop with three variables: next item to insert, remaining items to insert, sorted list so far... Hope that helps you get started? -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Railo Technologies, Inc. -- http://www.getrailo.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- 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
clojure.java.jdbc 0.0.1 released
The library formerly known as clojure.contrib.sql has had it's first non-snapshot release. Features added: * returns generated keys for single record inserts * supports naming strategies to allow to override the conversion of keywords to/from SQL entity names * exposes resultset-seq that respects naming strategies * exposes print-* functions to print SQL exceptions (and no longer prints to *err* on an exception) More on naming strategies: https://github.com/clojure/java.jdbc/blob/master/doc/clojure/java/jdbc/NameMapping.md If you start using this with Clojure 1.3.0 and find bugs or think of enhancements, please enter them here: http://dev.clojure.org/jira/browse/JDBC -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Railo Technologies, Inc. -- http://www.getrailo.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- 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
Order a sequence of maps with {:type :before [types]}
I want to order a sequence of maps with keys: obligatory :type optional :before [types]; which means the types should occur before this element in the sequence. I tried to use a custom java.util.Comparator but it only compares adjacent elements. This is my example: (defn- comes-after? checks if o1 comes after o2 if o1 has an :after seq of types; [o1 o2] (some #{(:type o2)} (:after o1))) ; Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as ; the first argument is less than, equal to, or greater than the second. (def mycomparator (reify java.util.Comparator (compare [this o1 o2] (println comparing o1: o1 , and o2: o2) (cond (comes-after? o1 o2) 1 (comes-after? o2 o1) -1 :else 0 ; Dieser algorithmus funzt net da immer nur die adjazenten elemente verglichen werden, :a und :o werden nur verglichen wenn nebeneinander (def data [{:type :a :after [:o]} {:type :b} {:type :z} {:type :e} {:type :m} {:type :o}]) (sort mycomparator data) Which leads to the following printlns: comparing o1: {:type :a, :after [:o]} , and o2: {:type :b} comparing o1: {:type :b} , and o2: {:type :z} comparing o1: {:type :z} , and o2: {:type :e} comparing o1: {:type :e} , and o2: {:type :m} comparing o1: {:type :m} , and o2: {:type :o} -- 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: Order a sequence of maps with {:type :before [types]}
On Sun, May 8, 2011 at 10:56 PM, msappler damnedmar...@web.de wrote: I want to order a sequence of maps with keys: obligatory :type optional :before [types]; which means the types should occur before this element in the sequence. That's a quite complex and somewhat difficult problem. First of all, what if you have A: {:type :foo :before [:bar]} B: {:type :bar :before [:foo]} ? Which comes first then? Probably you should throw an Exception or an Error then because the constraints are unsatisfiable. More generally, the :before values create directed outbound edges of a directed graph and this needs to be acyclic. If it's cyclic you have a problem. Otherwise, you can order the nodes such that any node is left of any node it has an outbound edge to -- nodes with no outbound edges are at far right, nodes with outbound edges to them are one step to the left, nodes with outbound edges to those are two steps to the left, and so forth. This determines a partial order on the nodes by how-far-left, and you want to sort by this, and sort on :type as the tiebreaker within the nodes that are a particular distance left. Something like this: (defn subset? [a-seq a-set] (if a-seq (if (contains? a-set (first a-seq)) (recur (next a-seq) a-set)) true)) (defn presort [node-seq] (loop [out nil nodes node-seq] (if (empty? nodes) out (let [toright (set (map :type (apply concat out))) nextnode? #(subset? (seq (:before %)) toright) nextnodes (filter nextnode? nodes)] (if (empty? nextnodes) (throw (Error. circularity))) (recur (cons nextnodes out) (remove nextnode? nodes)) (defn sort [node-seq] (mapcat #(sort-by :type %) (presort node-seq))) user= (sort [{:type 1 :before [2 5]} {:type 2} {:type 3 :before [4]} {:type 4 :before []} {:type 5 :before [4]}]) ({:type 1, :before [2 5]} {:type 3, :before [4]} {:type 5, :before [4]} {:type 2} {:type 4, :before []}) user= -- 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
Equivalent of Cyclic barrier
Is the java.util.concurrent.CyclicBarrier implemented in Clojure using a promise and agents ? I came across some examples like this and I think all threads can use the barrier once using this method. Is there a way to create a reusable Cyclic barrier ? The barrier is called cyclic because it can be re-used after the waiting threads are released. Thanks, Mohan -- 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: Equivalent of Cyclic barrier
None of Clojure's concurrency primitives really support this mode of thinking, as far as I know. If you want a CyclicBarrier (which I doubt you often will, in Clojure), use the perfectly-good, well-tested one in java.util.concurrent. On May 8, 10:13 pm, MohanR radhakrishnan.mo...@gmail.com wrote: Is the java.util.concurrent.CyclicBarrier implemented in Clojure using a promise and agents ? I came across some examples like this and I think all threads can use the barrier once using this method. Is there a way to create a reusable Cyclic barrier ? The barrier is called cyclic because it can be re-used after the waiting threads are released. Thanks, Mohan -- 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