Re: Teaching Clojure to students (how ?)
Hi, If I were a programming teacher, I would have students re-realize what one can achieve with programing in general at the start because people's action always come from their inner motivation. To enumerate concrete benefits and success story like TV shopping may be effective. Without motivation, all interesting knowledge will vaporize. Immutable? It must be something great! but I don't care. Cheers, Takahiro 2013/10/6 bernardH un.compte.pour.tes...@gmail.com Hi all, I intend to (ab)use my authority as a teacher to enlighten unsuspecting students about Clojure. On the plus side, I may give them insights that they did not even know they needed. On the minus side, I cannot expect (all of) them to be curious about Clojure. Hence, I want to make a demand driven introduction. My goal is to : 1. identify what novelties Clojure brings to the table to Java developers - homoiconicity : macros - syntaxing sugar (e.g -, cond) - programming paradigms as libraries - core.logic - core.async - dynamic typing - simple concurrency handling : - immutable data structures - ref - atoms - STM - open-ended dynamic dispatching (protocols, namespaced vs. monkey patching) - multiple dispatching (multimethods) - maps instead of classes (no privacy accessors needed thx to dynamic typing and immutable data) and composable libraries instead of frameworks. 2. For as many of those features as possible, I'd like to find a minimal use case that will be : - genuinely interesting (so that they find it beliveable that they might actually want to solve a similar problem) - complex (if possible hard!) / tedious to solve in Java (I will provide the Java code) - simple (if possible easy) to solve in Clojure. The idea being that they would conclude from : 1. that the want to solve these problems 2. that Java won't help them much but Clojure would help them a lot (+ 1. 2.) → 3. They want to learn Clojure ! ☺ I'd be most grateful for any help, either to complete/amend my list in 1., or to provide ideas for 2. Best Regards, B. -- -- 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/groups/opt_out. -- -- 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/groups/opt_out.
Re: Can we please deprecate the :use directive ?
Hi Ye, or at least *Do Not Use *those standard names*.* The following guide suggests the opposite. http://dev.clojure.org/display/community/Library+Coding+Standards Use good names, and don't be afraid to collide with names in other namespaces. That's what the flexible namespace support is there for. Takahiro On Sunday, August 4, 2013 11:25:34 AM UTC+9, Ye He wrote: Yesterday, I spent hours trying to figure out why some code didn't work. The code is like so: (defn replace-symbol-in-ast-node [old new ast] (tree-replace (symbol old) (symbol new) ast)) I use tree-replace directly like this: (ast/tree-replace (symbol 'a) (symbol 'c) (ast/sexp-parsley '(+ a b))) I thought the result would the the same but I was wrong. After hours of thinking, I finally figured it out. Guess what? The 'symbol' function in the first code snippet is not the standard 'symbol'. It actually is: (defn symbol [sym] (make-node :atom (core/vector (name sym It's defined in another library. But I stupidly thought it was the standard 'symbol'. Part of this was my fault, I guess. I shouldn't have taken it for granted and guessed its meaning. But who know? In my opinion if we use less :use, it would easier for others to read our code and less likely to misunderstand the meaning, or at least *Do Not Use *those standard names*.* On Wednesday, July 24, 2013 1:50:50 AM UTC+10, Greg wrote: I think I read somewhere that :use is no longer encouraged, but I could be mistaken. From what I've read, it seems like most people agree that Clojure has too many ways of including/importing/referencing/requiring/using things: http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html The above gives a very nice explanation of all the various difference, but it also acknowledges their complexity. Since :use uses :require, and since :require can do everything that :use can, can we simplify Clojure programming a bit for newcomers by deprecating the use of :use? The situation in ClojureScript is even worse because it adds :require-macros on top of all the other ways of including files. Ideally, it would be awesome if there was just a single directive for everything, but perhaps there's some complicated low-level reason why that's not possible. :-\ Thoughts? Thanks, Greg P.S. If this has already been brought up you have my sincere apologies. -- Please do not email me anything that you are not comfortable also sharing with the NSA. -- -- 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/groups/opt_out.
Re: Does this abstraction have any existing name?
I think clojure.walk is suited to this purpose. https://github.com/clojure/clojure/blob/master/src/clj/clojure/walk.clj See keywordize-keys as an example. On Saturday, July 27, 2013 2:31:21 AM UTC+9, Yoshinori Kohyama wrote: Thank you Gary. There's no reason why this need to be a macro. It has rewritten as a function. And I'd still like to hear any response about the same three questions. (require '[clojure.test :refer (with-test is run-tests)]) (with-test (defn mapf [f m args] ((fn g [n] (if (map? n) (into {} (map (fn [[k v]] [k (g v)]) n)) (apply f n args))) m)) (is (= (mapf #(* % %) {:a {:b 3 :c 4} :d 5}) {:a {:b 9 :c 16} :d 25})) (is (= (mapf #(+ (* %1 %1) %2) {:a {:b 3 :c 4} :d 5} 1) {:a {:b 10 :c 17} :d 26}))) -- -- 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/groups/opt_out.
Re: Can we please deprecate the :use directive ?
I hate it mainly in blogs, where they explain some new API. They :use like 3 namespaces and you have to guess which fn is from which ns :) Agree. Code is read much more often than it is written, so omitting a few character is not effective time-saving. I also don't like :refer :all. I think it should be considered hack rather than official feature. On Wednesday, July 24, 2013 3:17:02 AM UTC+9, Jozef Wagner wrote: +1, :use is IMO an antipattern. I hate it mainly in blogs, where they explain some new API. They :use like 3 namespaces and you have to guess which fn is from which ns :) JW On Tuesday, July 23, 2013 5:50:50 PM UTC+2, Greg Slepak wrote: I think I read somewhere that :use is no longer encouraged, but I could be mistaken. From what I've read, it seems like most people agree that Clojure has too many ways of including/importing/referencing/requiring/using things: http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html The above gives a very nice explanation of all the various difference, but it also acknowledges their complexity. Since :use uses :require, and since :require can do everything that :use can, can we simplify Clojure programming a bit for newcomers by deprecating the use of :use? The situation in ClojureScript is even worse because it adds :require-macros on top of all the other ways of including files. Ideally, it would be awesome if there was just a single directive for everything, but perhaps there's some complicated low-level reason why that's not possible. :-\ Thoughts? Thanks, Greg P.S. If this has already been brought up you have my sincere apologies. -- Please do not email me anything that you are not comfortable also sharing with the NSA. -- -- 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/groups/opt_out.
Re: [ANN] http-kit 2.1.1. Bug fix release, please upgrade if using the WebSocket
Shen, Thank you for your announcement. 2013/5/6 Shen, Feng shen...@gmail.com Hi, It's a bug fix release. *If using the WebSocket support, please upgrade. All older version has this bug.* The bug is Large websocket requests get corrupted. Detail: https://github.com/http-kit/http-kit/issues/47. And thanks Gal Dolber for reporting it. Condition this bug will be triggered: 1. A large message sent to server, server may received this message segmented, will likely to unmark the message wrongly 2. Small message ( 1k - 30k kilobytes, is less likely to have this problem) The fixed version is already push to clojars: [http-kit 2.1.1] -- -- 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/groups/opt_out. -- -- 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/groups/opt_out.
Re: Prismatic Plumbing and Graph Open-Source Release
Thanks for amazing work! I want to know how typical CRUD application is implemented. Do you use single gigantic graph with lazy-compile or separated graph for each operation? How do you handle validation and error? Will almost all x-y function disappear? On Jan 30, 3:46 am, Aria Haghighi m...@aria42.com wrote: Hey all, Prismatic has open-sourced our Plumbing and Graph library on githubhttps://github.com/prismatic/plumbing. Jason Wolfe gave a talkhttp://blog.getprismatic.com/blog/2012/10/1/prismatics-graph-at-stran...about how we use graph for systems composition at Strange loop last year. Please give the library a whirl and let us know if you're using it and if you find any issues or feature requests. We use this library very heavily throughout our code and hope others find it useful as well. Best, Aria -- -- 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/groups/opt_out.
Re: Efficient idioms to handle large lists?
Hi Bruce, Try `into` instead of `concat`. Applying concat to growing data is like Schlemiel the Painter's algorithm. Cheers. On 2月1日, 午後4:19, bruce li leilmy...@gmail.com wrote: Hello, everyone. I'm experience some performance issue when using clojure. The scenario is as follows: I have a huge list of xls files to process. I used the org.clojars.boechat107/cloxls to read the files which for each file generates a list(approximately 65,000 elements). Now I need to concatenate all of them. I used (mapcat read-worksheet files) to get the final list, but it soon reports out of heap space. Then I tried to use mutable structures: (doseq [f files] (swap! sheet concat (read-worksheet f))) where sheet is defined as (def sheet (atom []))) But the concat seems to slow down a lot when the list grows larger. I'm wondering if in clojure there is some efficient idiom to handle such situation such as efficient concatenation? Thanks, Bruce Li -- -- 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/groups/opt_out.
*read-eval* vulnerability
As more and more projects are using edn format for config, communication and etc, I think that default value of *read-eval*, which is true, is source of vulnerability such as recently reported ring issue [1]. And I don't understand why read-string depends on *read-eval* instead of argument. I believe optional argument is more preferable. What do you think? [1] Ring 1.0.3 / 1.1.7 released to fix security flaw https://groups.google.com/group/clojure/browse_thread/thread/7b0fe662867b9124 -- -- 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/groups/opt_out.
Re: Where did the idea of metadata come from?
Paul, Raoul, David, Mimmo, JvJ, Thanks for use cases. I have better understanding now. Cheers, - Takahiro On Nov 14, 12:56 am, Paul deGrandis paul.degran...@gmail.com wrote: Here's one use case: Let's say you want to develop a library that monitors system behavior and resources while functions are executed (or while collections are processed). You might have a collection of monitoring functions (we'll call them sensors) that check various things, like disk I/O activity. We now need a way to annotate our other functions and collections (maps, vectors, etc) with the sensors that concern them. For example, maybe we want to ensure a given function doesn't run off with exponential disk writing (commonly called a 'log explosion') - this defect caused one of the Mars Rovers to crash. One way is to attach the sensors directly to the functions in the form of metadata. You could then run the functions in a special context that executed sensors from any piece of metadata. - - - Another example might be that you want to attached additional specification information to functions, so you can run some sort of analysis/verification against your code - - - It's difficult to spot the best time to apply metadata, since we've become accustomed to working in languages without support for it. Anytime you want to convey programmatic meaning about entities themselves, metadata is an elegant solution. I hope this helps a little. Paul -- 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 did the idea of metadata come from?
Metadata is a really useful feature, and it's been helping me a lot. Could you show me concrete example? I still don't understand the value of metadata and rarely use it except type hint. I saw active using metadata on some project(e.g. postal[1]), but I think regular hashmap instead of metadata is also good enough for the purpose. [1] https://github.com/drewr/postal Cheers, -Takahiro On Nov 13, 6:01 am, JvJ kfjwhee...@gmail.com wrote: Metadata is a really useful feature, and it's been helping me a lot. It seems like a flash of genius on the part of Mr. Hickey. I'm wondering if similar concepts exist in other programming languages that inspired it, or if it's unique to Clojure. Just a matter of curiosity, really. -- 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: Coding Standard - ns usage
:require :as is always good and generally preferred over :refer or :use :only. I think we all agree with this, but in reality :use with/without :only is very widely used in a number of real project I've seen on github. :use (especially without :only) makes code reading painful and usually reading time including other's is much longer than writing time. I hope :use is used only for popular library such as clojure.test, etc. On Friday, November 9, 2012 3:54:38 AM UTC+9, Justin Kramer wrote: Sorry, yes, to clarify -- :require :as is always good and generally preferred over :refer or :use :only. Justin On Thursday, November 8, 2012 1:42:26 PM UTC-5, Luc wrote: I am pragmatic and quite lazy, I use require with an alias and use mostly with stuff like clojure.tools.trace, clojure.pprint where selecting explicit vars brings no or little value (in my opinion). You either need most of the public vars or the potential name conflict is a remote possibility a few light-years away. I almost never select explicit vars from external name spaces. I find this cumbersome to manage. With (short) aliases, I get auto expansion of all public vars as soon as I type the / in CCW (Eclipse plugin). With a little consistency in choosing aliases, it's then very easy to find out while reading the code where a reference comes from. I am also older than most of you guys so the less stuff resides in my working memory, the easier I can cheat with the slowly eroding aging process :) I leave most of the work to the computer. Mmmh, maybe I should create a pocket guide for elderly Clojure coders someday... Luc P. Current best practice in my view: For Clojure 1.4+, do not use :use at all. Use :require :refer (judiciously). :refer :all is almost never a good idea. For Clojure 1.3 and below, :use :only is strongly encouraged. Bare :use is almost never good. Justin On Thursday, November 8, 2012 11:57:21 AM UTC-5, David McNeil wrote: I notice the following item at http://dev.clojure.org/display/design/Library+Coding+Standards Be explicit and minimalist about dependencies on other packages. (Prefer the :only option to use and require). The page was last edited on Mar 29, 2011 and ns usage has been discussed a fair bit since then... this leads to the question: Is the item quoted above still the standard for Clojure Libraries? Thanks. -David -- 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 -- Softaddictslprefo...@softaddicts.ca sent by ibisMail from my ipad! -- 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 : a good start for non-programmers?
Hi Gregorius, I recommend for you to watch Brian Will channel on youtube. http://www.youtube.com/user/briantwill/videos?flow=gridview=1 There are several introduction of programming language: Clojure, Java, Python, JavaScript, C etc.. After watching all part.1 of each introduction, then you may have some preference. Cheers, - Takahiro On Monday, September 24, 2012 3:11:23 PM UTC+9, Gregorius R. wrote: Hello Clojurists! I'm a person in middle age (you know, too old to rock'n'roll, to young to die) and would like to programm but starting with functional programming. Regarding this i have some questions: is clojure a good start to learn programming? which (prerfer free online) is a good tut to start? am i to old for this stuff? thnx in advance for all responses 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
[ANN] Ducttape.cljs 0.1.0: A ClojureScript micro MVC framework
Hi, Ducttape.cljs is a ClojureScript micro MVC framework/library. https://github.com/hozumi/ducttape.cljs Here's a list of benefits: * Clear structure * Super thin * No original event system * Use functions and atoms as building blocks * Don't force to use specific library Check it out. Cheers, - Takahiro -- 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: ClojureScript and development workflow
Hi, I guess that at least the following require a restart. Please correct / explain as needed : - change in CSS file on disk ? - change in template file (either enfocus / hiccup-on-the-browser -don't remember the name) ? and also when doing certain changes to the ClojureScript code itself : - when I add a new namespace ? - same problem with multimethods as JVM Clojure ? - ... ? You need to refresh the browser every time you update cljs/css/js file on disk as with normal javascript webapp development. Personally I don't use browser-repl frequently because I refresh the browser in a short time interval. - same problem with multimethods as JVM Clojure ? Sorry, I don't understand what this means. Anyway I don't recommend using multimethods in cljs because it is not fast. Cheers, - Takahiro On Sep 11, 4:52 pm, Laurent PETIT laurent.pe...@gmail.com wrote: 2012/9/10 Takahiro Hozumi fat...@googlemail.com Hi, I refresh browser every time I change cljs files. Using the REPL as the main way to deliver code to the browser means never having to refresh the page. One could theoretically build an entire application without a single page refresh. If you find yourself refreshing the page after every change you make, you're doing it wrong. What is this, 2009? I think this is somewhat exaggeration. REPL isn't good enough to push the all changes into browser. Hello, While I could learn the long and hard way where when it is necessary to restart the ClojureScript application (refresh the browser), I'd be interesting in feedback in this area. I guess that at least the following require a restart. Please correct / explain as needed : - change in CSS file on disk ? - change in template file (either enfocus / hiccup-on-the-browser -don't remember the name) ? and also when doing certain changes to the ClojureScript code itself : - when I add a new namespace ? - same problem with multimethods as JVM Clojure ? - ... ? Thanks in advance, -- Laurent -- 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: Immutant 0.3.0 released
Hi, Forgive my ignorance, although I think the project must be useful, but I still don't understand what is the benefit of using application server. What is the difference between using a particular library(e.g. HornetQ) with JBoss AS7 and using the same one without JBoss AS7? Cheers, - Takahiro On Sep 12, 4:30 am, Jim Crossley jcrossl...@gmail.com wrote: We released our third official version of Immutant today! With this release we now publish the Immutant namespaces to Clojars. They are of limited use when run outside of Immutant, of course, but they'll at least compile so you can mock/stub/redefine them in your unit tests. You can render some of them mostly functional by adding the relevant jars to your project.clj, e.g. Infinispan, HornetQ, etc, and we expect to add more container-less functionality in future releases. Obviously, they're completely functional *inside* an Immutant container, so we've published a library to facilitate integration testing, and continued to improve our nrepl/swank support so you can now add dependencies to your project on the fly without having to redeploy it. Here's the announcement:http://bit.ly/immutant030 Enjoy and thanks, Jim -- 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: Immutant 0.3.0 released
Hi Jim, Thank you for comprehensible explanation. I understand. Thanks, - Takahiro On Sep 12, 10:45 am, Jim Crossley jcrossl...@gmail.com wrote: Hi Takahiro, When considering a specific library in isolation, e.g. HornetQ, there is little difference between using it within or without an app server. Benefits of an app server include uniform deployment, centralized configuration, monitoring, and control, clustering capabilities to support scaling and high availability, multi-resource transactions, and in-process services like caching, messaging, and scheduling. Things that matter to larger organizations in which different groups produce applications that need to coordinate, often deployed to environments controlled by still other groups. For certain applications, I would recommend using libraries to access external processes like Memcached, RabbitMQ, or cron, for example. And for others, I would recommend an app server. As always, it depends on the requirements of the application and the capabilities of the organization to support it. Thanks, Jim On Tuesday, September 11, 2012 7:26:21 PM UTC-4, Takahiro Hozumi wrote: Hi, Forgive my ignorance, although I think the project must be useful, but I still don't understand what is the benefit of using application server. What is the difference between using a particular library(e.g. HornetQ) with JBoss AS7 and using the same one without JBoss AS7? Cheers, - Takahiro On Sep 12, 4:30 am, Jim Crossley jcrossl...@gmail.com wrote: We released our third official version of Immutant today! With this release we now publish the Immutant namespaces to Clojars. They are of limited use when run outside of Immutant, of course, but they'll at least compile so you can mock/stub/redefine them in your unit tests. You can render some of them mostly functional by adding the relevant jars to your project.clj, e.g. Infinispan, HornetQ, etc, and we expect to add more container-less functionality in future releases. Obviously, they're completely functional *inside* an Immutant container, so we've published a library to facilitate integration testing, and continued to improve our nrepl/swank support so you can now add dependencies to your project on the fly without having to redeploy it. Here's the announcement:http://bit.ly/immutant030 Enjoy and thanks, Jim -- 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: ClojureScript and development workflow
Hi, I refresh browser every time I change cljs files. Using the REPL as the main way to deliver code to the browser means never having to refresh the page. One could theoretically build an entire application without a single page refresh. If you find yourself refreshing the page after every change you make, you're doing it wrong. What is this, 2009? I think this is somewhat exaggeration. REPL isn't good enough to push the all changes into browser. Cheers, - Takahiro On Tuesday, September 11, 2012 1:28:44 AM UTC+9, lpetit wrote: Hello, A ClojureScript workflow newbie question. People seem to be using a lot lein-cljsbuild to work with their ClojureScript project. From what I understand, this means they have a watcher which recompiles javascript in the background whenever they save changes to clojurescript files to the disk. Thus, this means that whenever they make a change, they have to restart the application (e.g. refresh the browser). Is that the end of the story with lein-cljs ? (wrt development workflow ?) On the other end, when looking at the wiki page for ClojureScript One, one can see : Using the REPL as the main way to deliver code to the browser means never having to refresh the page. One could theoretically build an entire application without a single page refresh. If you find yourself refreshing the page after every change you make, you're doing it wrong. What is this, 2009? So before digging into ClojureScript for the first time, I'd like to know what to thing about all this, so that I don't waste my time following wrong paths. What would be my expected default workflow when starting to write a single page application with ClojureScript, in September 2012 ? Cheers, -- Laurent -- 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
Pattern of Succinctness
Hi, I would like to know common technics that make code succinct. For example: (or (:b {:a 1}) 0) (:b {:a 1} 0) (if-not x 1 2) (if x 2 1) (filter #(not (nil? %)) coll) (filter identity coll) ;; nearly equal Please let me know any tips you found. Cheers, Takahiro. -- 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: Pattern of Succinctness
(filter (partial not nil?) coll) You mean (filter (comp not nil?) coll). I'm not sure which is more readable, but thanks for Meikel and Alex, I now prefer (remove nil? coll). Thanks. On Monday, August 13, 2012 2:38:23 AM UTC+9, Tamreen Khan (Scriptor) wrote: Is the last one considered generally more readable? I think the following is clearer while still not having as much noise as the first filter example: (filter (partial not nil?) coll) On Sun, Aug 12, 2012 at 1:35 PM, Takahiro Hozumi fat...@googlemail.comjavascript: wrote: Hi, I would like to know common technics that make code succinct. For example: (or (:b {:a 1}) 0) (:b {:a 1} 0) (if-not x 1 2) (if x 2 1) (filter #(not (nil? %)) coll) (filter identity coll) ;; nearly equal Please let me know any tips you found. Cheers, Takahiro. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: 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 On Monday, August 13, 2012 2:38:23 AM UTC+9, Tamreen Khan (Scriptor) wrote: Is the last one considered generally more readable? I think the following is clearer while still not having as much noise as the first filter example: (filter (partial not nil?) coll) On Sun, Aug 12, 2012 at 1:35 PM, Takahiro Hozumi fat...@googlemail.comjavascript: wrote: Hi, I would like to know common technics that make code succinct. For example: (or (:b {:a 1}) 0) (:b {:a 1} 0) (if-not x 1 2) (if x 2 1) (filter #(not (nil? %)) coll) (filter identity coll) ;; nearly equal Please let me know any tips you found. Cheers, Takahiro. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: 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 On Monday, August 13, 2012 2:38:23 AM UTC+9, Tamreen Khan (Scriptor) wrote: Is the last one considered generally more readable? I think the following is clearer while still not having as much noise as the first filter example: (filter (partial not nil?) coll) On Sun, Aug 12, 2012 at 1:35 PM, Takahiro Hozumi fat...@googlemail.comjavascript: wrote: Hi, I would like to know common technics that make code succinct. For example: (or (:b {:a 1}) 0) (:b {:a 1} 0) (if-not x 1 2) (if x 2 1) (filter #(not (nil? %)) coll) (filter identity coll) ;; nearly equal Please let me know any tips you found. Cheers, Takahiro. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: 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 On Monday, August 13, 2012 2:38:23 AM UTC+9, Tamreen Khan (Scriptor) wrote: Is the last one considered generally more readable? I think the following is clearer while still not having as much noise as the first filter example: (filter (partial not nil?) coll) On Sun, Aug 12, 2012 at 1:35 PM, Takahiro Hozumi fat...@googlemail.comjavascript: wrote: Hi, I would like to know common technics that make code succinct. For example: (or (:b {:a 1}) 0) (:b {:a 1} 0) (if-not x 1 2) (if x 2 1) (filter #(not (nil? %)) coll) (filter identity coll) ;; nearly equal Please let me know any tips you found. Cheers, Takahiro. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: 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 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: Experiences developing a crowdfunding site for open source projects in Clojure (from a Python background)
Hi Aaron, Thank you for the interesting post. I guess we all here have quite similar experience as code size shrink. I found myself digging around in github repos to actual read code instead of documentation a lot more than I ever did with Python. Agreed. In fact, for emacs/swank-clojure users this is one key-stroke(M-.) task. Cheers, Takahiro. On Friday, July 27, 2012 4:59:46 AM UTC+9, Aaron Lebo wrote: Hello! Sometime around 2 and a half months ago, I started to work on a new project using Clojure. I've been using Python heavily for about 6 six years working for a small direct mail company and before that started programming with Ruby on Rails. This new project was something out of left field, so I had different options on what technology to use. I ended up choosing Clojure, and my work on the site has been my first real experience using a lisp, Clojure, and the JVM. I'd like to share my experiences and how that has differed with my previous Python work. Before that, I'd like to make a little plug for my site. It is called kodefund http://www.kodefund.com (www.kodefund.com). The basic idea is to take the familiar Kickstarter model but to really focus on applying that to open source development. I feel that previous crowdfunding efforts have shown that there is an interest by developers to fund projects that they are enthusiastic about. When this works, everyone wins: the developer working on the project can devote their full time and effort on the actual project and still make a living and others get the benefits of the open source software. I feel like it is preferable over selling licenses to proprietary software or other efforts. So, every project on kodefund is required to be open source. This differentiates it from other crowdfunding sites, and helps to apply a filter: you know what you are getting when you go there instead of seeing dozens of projects for unrelated stuff. One other difference is that you can also start a project which is more or less a reverse Kickstarter. This allows you to take an idea for a project or issue you want fixed, raise funding, and find someone who will actually implement the project. Other users get to submit applications and you choose from them to find the most capable candidate. Once you chose an application, that person takes over the project. Finally, one other push I want to make is to open up proprietary software. Maybe your company has written some software in-house, but there's no real incentive to release it. What if you could crowdfund the software, get paid to release it, and the open source community as a whole could benefit from that? I feel like crowdfunding and open source software are an ideal fit. I'm getting off track here. I'll shift to my actual experiences using Clojure. I was more than a little nervous about using the JVM. It always seemed like some huge, scary thing, and digging into Java libraries was not something I wanted to do. Something which resolved this was leiningen. I feel like it is absolutely brilliant, and it really makes adding libraries to your project a non-issue. Things have slowly changed in Python, but it used to be that downloading dependencies was a global process and you ended up with a site-packages that was full of dozens of old libraries that you used for other projects. Being able to specify in my project.clj file exactly which libraries I need and those getting downloaded automatically is a really nice feature that I will look for similar functionality in other languages from now on. I was also pleasantly surprised by the library availability. The vast majority of things that I needed such as oauth2 support and such already have decent Clojure wrappers. When I did drop down into Java, I found that to be painless. The JVM really does have a wide swath of functionality already available. Some of the things that I ended up using were email libraries, date formatting libraries, and an rss feed generator. There never was a point where I felt like I was going to have to just roll things by hand. Most of the hard work has been done. Considering the language itself, one of the first things I noticed (or didn't) was the parentheses. I don't remember when, but they simply are a non-issue after a short amount of time. One slight thing I did have a problem with was that inserting a parenthesis at the wrong place could completely alter the flow of code and it was not immediately obvious. This is not an issue when you are closing off a line or two of expressions, but when you are halfway down the page, insert a paren and everything breaks, it could get frustrating. This is probably resolved through better editor usage. I unfortunately could never get emacs with clojure-mode and goodies working properly on my Windows machine, so I ended up using the counterclockwise Eclipse plugin. It was not a
Re: is their a Clojure framework for handling form validation?
Instead of calling the ExceptionInfo ctor .getData directly, it's better to use ex-info ex-data instead. Baishampayan Thank you for the information. I agree with you. On Friday, July 27, 2012 6:39:29 PM UTC+9, Baishampayan Ghose wrote: On Thu, Jul 26, 2012 at 10:19 PM, Takahiro Hozumi fat...@googlemail.com wrote: (when-let [m (validate params)] (throw (clojure.lang.ExceptionInfo. validation error m))) (defn wrap-validation-exception [handler] (fn [req] (try (handler req) (catch clojure.lang.ExceptionInfo e {:status 400 :headers {Content-Type application/json} :body (some-json-generator (.getData e))} Instead of calling the ExceptionInfo ctor .getData directly, it's better to use ex-info ex-data instead. Regards, BG -- Baishampayan Ghose b.ghose at gmail.com -- 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: is their a Clojure framework for handling form validation?
If you build simple json API, combining validation function which return validation error as a map and clojure.lang.ExceptionInfo can reduce intermediate error handling code. (when-let [m (validate params)] (throw (clojure.lang.ExceptionInfo. validation error m))) (defn wrap-validation-exception [handler] (fn [req] (try (handler req) (catch clojure.lang.ExceptionInfo e {:status 400 :headers {Content-Type application/json} :body (some-json-generator (.getData e))} On Monday, July 23, 2012 8:46:52 AM UTC+9, larry google groups wrote: Since 2000 I've been doing web development, first with PHP and then with Ruby On Rails. In the world of PHP, there are some frameworks, such as Symfony, that have classes for managing forms, both generating the HTML for the forms, and also handling the validation of the forms. In the world of Python, the Django framework also has facilities for generating and validating forms. These frameworks offer certain time saving conveniences. For instance, with the Symfony framework, if you have a database table that has a foreign key, then you can get that other table (the target of the foreign key) to appear in a form as a pre-populated select box, automatically (after filling out some config files). I'm now trying to make Clojure my primary development language for everything, including web development. I'm curious, are there any libraries in the land of Clojure that offer similar conveniences for forms? -- 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: Any downside of record compared to map
I think defrecord has 5 downsides compared to regular map. 1. The literal of regular map is eye-friendly and portable. However I still don't know how helpful instant literals added in clojure 1.4 is for records. 2. The construction of record depends on an order of arguments. Sometimes, I feel that a lack of construction with key-value style is not convenient. 3. Replacing all regular maps to records simply make code volume increase. 4. Records easily loose their type. (merge {:c 3 :d 4} (Foo. 1 2)) ;= {:a 1, :b 2, :c 3, :d 4} 5. Regular map is a persistent data structure, which has internally efficient tree data structure, but record is compiled into class with fields as something like POJO. I suspect efficiency of record when repeated assoc/dissoc. But I could be wrong. Regards, Takahiro. On Monday, July 23, 2012 12:54:03 PM UTC+9, Warren Lynn wrote: I don't think you're in the minority. I prefer regular maps to records in general. struct-map was deprecated a long time ago (in Clojure 1.2). clojure.java.jdbc stopped using struct-map a while back - at the recommendation of Clojure/core - in favor of regular maps. Chas Emerick's flowchart is very helpful here I think: http://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/ Could you elaborate a little bit more? I know there is a chart, but the chart does not tell you why. Again, if record provides everything a map can provide, why would you prefer regular map? I thought at most you would say it does not make much difference, and that would mean no harm to me. -- 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: Any downside of record compared to map
Baishampayan I didn't know `map-Foo`. Thank you for the infomation! On Monday, July 23, 2012 2:11:45 PM UTC+9, Baishampayan Ghose wrote: On Mon, Jul 23, 2012 at 10:37 AM, Takahiro Hozumi fat...@googlemail.com wrote: 2. The construction of record depends on an order of arguments. Sometimes, I feel that a lack of construction with key-value style is not convenient. (defrecord Foo ... will give you `-Foo` `map-Foo` for free. The second one accepts a map as input. Regards, BG -- Baishampayan Ghose b.ghose at gmail.com On Monday, July 23, 2012 2:11:45 PM UTC+9, Baishampayan Ghose wrote: On Mon, Jul 23, 2012 at 10:37 AM, Takahiro Hozumi fat...@googlemail.com wrote: 2. The construction of record depends on an order of arguments. Sometimes, I feel that a lack of construction with key-value style is not convenient. (defrecord Foo ... will give you `-Foo` `map-Foo` for free. The second one accepts a map as input. Regards, BG -- Baishampayan Ghose b.ghose at gmail.com -- 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
ClojureScript assoc performance
Hi, I found that assoc can be slow in ClojureScript. This is my app profile. http://twitpic.com/8kbupv/full I think the cause is that entire clone happen when assoc is called. https://github.com/clojure/clojurescript/blob/master/src/cljs/cljs/core.cljs#L2284 Is this design choice intended for some reason? 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
How to convert string into sequence with replacing matched text.
Hi, I want to make a sequence from string as follows. input: hello 1 world 2 output: (hello [1] world [2]) What is efficient way to achieve this in ClojureScript? 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: WebSockets with Clojure
If you need scalability, two phase connect might be necessary. 1. Resolve a server name which client should be connected to. If a client need to be connected to specific resource (chat room etc) consistent hashing is useful. http://nakkaya.com/2010/05/05/consistent-hashing-with-clojure/ 2. Connect. On 2月2日, 午前7:05, blais goo...@furius.ca wrote: Hi Clojurians, Does anyone have experience with serving WebSockets from Clojure, in particular w.r.t. scalability? I'm evaluating server-side options for handling a large number of simultaneous web clients (100) and wondering how well this scales. I already hooked up Clojure to Netty and built a simple test application. I think I'll write some stress tests, but any feedback regarding how well this could scale, possible roadblocks, or experience reports would be appreciated and informative. 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: Multimethods performance in ClojureScript.
Thank you for your response. The reasons why I didn't use protocols are following. 1. Currently ClojureScript doesn't have `extend`, which makes inheritance easy. http://david-mcneil.com/post/1475458103/implementation-inheritance-in-clojure 2. I think an entity which is created by deftype or defrecord should represent a value rather than an identity, after reading this article. http://clojure.org/state The methods I implemented need to update an entity value itself. So in order to follow immutable manner, the methods should return a return value and an updated entity itself. This programming style is difficult when a method needs to call another method or makes callback which need to update an entity itself. I suspect that to include atoms as fields of record make the entity an identity. Is this wrong? Thanks. On Jan 19, 8:57 am, Dave Sann daves...@gmail.com wrote: If you are only dispatching on a single type - I think protocols will always be much faster than multimethods. I think that you only really want to use multimethods if you need to dispatch on more than one type or on something that is not a type at all. D -- 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
::keyword are not resolved properly in ClojureScript.
Hi, I found that ::keyword doesn't have correct namespace in ClojureScript. If this is not only my environemnt problem, I will create an issue. (.log js/console ::mykeyword) Evaluate this in file, not repl. 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
Multimethods performance in ClojureScript.
I've experienced rewriting my ClojureScript code into multimethods base. I'd share my results. Initially I implemented polymorphism behavior as simple hashmap like this: (def parent {:foo (fn [x] ...) :bar (fn [x] ...)}) (def child (merge parent {:foo (fn [x] ...)})) For some reason, I didn't choose protocols. Then I found multimethods support hierarchy system and rewrote the code into 42 defmulti and 64 defmethod. After rewriting, I noticed that rewritten code is too slow as I can see a displaying delay without measurement. Profiles in Chrome (Ignore first (program) line.) Simple hashmap approach: http://twitpic.com/88wvyl Multimethods approach:http://twitpic.com/88wwd8 So I put the code back. -- 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
Cannot access variables without namespace in ClojureScript repl.
Hi, In my browser repl, which follows the ClojureScript wiki[1], I must specify variables with namespace even if `in-ns` is used, but I noticed that I don't have to do in the repl of ClojureScript One[2]. Am I the only one who cannot access variables without namespace? What makes the diffirence? log: ClojureScript:cljs.user (in-ns 'myns) ClojureScript:myns myns/mydiv ;;with a namespace #[object HTMLDivElement] ClojureScript:myns mydiv ;;without a namespace Error evaluating: mydiv :as .mydiv;\n #SyntaxError: Unexpected token . SyntaxError: Unexpected token . at http://localhost:8080/cljs/clojure/browser/repl.js:21:158 [1] https://github.com/clojure/clojurescript/wiki/Emacs-%26-inferior-lisp-mode [2] https://github.com/brentonashworth/one/wiki/Development 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
Emulating inheritance on protocols in ClojureScript.
Hi, I want to set a default behavior on a protocol. The following article describes how to implement inheritance in Clojure by using `extend`, but `extend` doesn't exist in ClojureScript. Is there a way to set a default behavior on a protocol in ClojureScript? (david-mcneil.com :blog), Implementation inheritance in Clojure http://david-mcneil.com/post/1475458103/implementation-inheritance-in-clojure 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: My implementation of ISeqable for NodeList doesn't work on Opera.
I've created an issue about this. http://dev.clojure.org/jira/browse/CLJS-120 Thanks. On Jan 10, 5:31 am, Stuart Sierra the.stuart.sie...@gmail.com wrote: I would like to have NodeList be seqable. Please file a ticket with a patch. Perhaps someone else can shed light on why Opera doesn't work. -S -- 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
[ClojureScript] My implementation of ISeqable for NodeList doesn't work on Opera.
Hi, Following code cause an error, because NodeList doesn't extend ISeqable. (doseq [u (goog.dom/getElementsByClass myclass)] ...) Uncaught Error: No protocol method ISeqable.-seq defined for type object: [object NodeList] So I implemented ISeqable for NodeList. (extend-type js/NodeList ISeqable (-seq [array] (array-seq array 0))) I used an implementation of ISeqable for array as reference. https://github.com/clojure/clojurescript/blob/master/src/cljs/cljs/core.cljs#L338 This works well on Chrome, Safari and Firefox, and doesn't on Opera. Is special consideration needed for Opera? 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: Do you use Monads in your real clojure applications
In MVC pattern, Model should take responsibility for business logic. Therefore I write validate function for creating in the model. If creating a instance of the model should be safe, I must validate a parameter in the create function. My problem is that a controller have to validate a parameter twice in the validate function and the create function. Ring handler example (defn handler [{:keys [params] :as req}] (if (person/valid? params) {:status 200 :body (json/generate-string (person/create params))} {:status 400})) I think this might be suited to monads, which I don't fully understand. On Jan 4, 4:35 am, Mark Engelberg mark.engelb...@gmail.com wrote: Some of the most common uses for monads have pre-existing mechanisms with Clojure to handle them, e.g.: sequence monad (for) state monad (Clojure has many stateful mechansisms) maybe monad (Clojure programmers usually just return nil for failure, and use something like when-let to process it) In terms of higher-level DSLs constructed out of monads, the most useful monadic frameworks I've seen are monads for parsing, and monads for representing probability distributions. If I needed to do one of those things in Clojure, I'd look closely at monad options. But since I haven't needed to do those things, and the common uses for monads are already covered, I haven't found a need to do any monadic style programming in my own code. --Mark -- 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
[ClojureScript] Wrapping all def into a load event handler
Hi, In order to manipulate dom, I often want to bind elements into variable through def, but we cannot manipulate it until load event. So I wrapped all def into a load event handler in the following way. https://gist.github.com/1521051 I don't use let, because many elements cause deep nested let, and I don't use atom to store elements, because reset! and deref are not necessary by binding element directly. Is this bad way in ClojureScript? Is there a downside? 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
core.match feature request: supporting java.util.HashMap
Hi, I'd like to use core.match with java.util.HashMap without converting into {}. The core.match doesn't support it as below. (let [m (java.util.HashMap. {a 1})] (match m {a 1} true)) ;= nil Is it difficult? 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
Must PersistentQueue be stored in ref not atom?
Hi, To avoid peeking same element of a queue, I think PersistentQueue must be stored in ref not atom. Is this correct? ;;Ref: safe (dosync (let [item (peek @r)] (alter r pop) item)) ;Atom: unsafe (let [item (peek @a)] (swap! a pop) item)) 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: Thoughts on CUDA + Clojure
C in S-expression approach might be helpful, if you just want to write C in Clojure syntax. The advantage of this pure translator approach is you can fully recognize what you do. Such implementation already exist in Scheme. http://practical-scheme.net/gauche/man/gauche-refe_76.html I think translating Clojure source into PTX directly is more powerful and less trouble, because PTX has less syntax than C. http://www.nvidia.com/content/CUDA-ptx_isa_1.4.pdf Clojure - C - PTX Clojure - PTX The disadvantage of this is you cannot port it to OpenCL. I guess to create a compiler like ClojureScript is much harder than just translator. On 9月9日, 午前3:43, Timothy Baldridge tbaldri...@gmail.com wrote: I've been kicking around an idea for some time, of starting a Clojure-CUDA compiler. I would like to start a discussion about this to figure out what some possible solutions are. First of all let me start a simple fact list: CUDA (for those who don't know) is NVIDIA's technology for writing general use code for modern GPUs. The current system uses a subset of C++ as it's input. The code looks like small functions/classes that are executed for each thread of the GPU. These threads can number in the thousands, and the GPU commonly executes hundreds of these at one time. So, basically we're talking of running pmap on a system will 512+ cores. CUDA 4.0 supports some very advanced C++ features. As of 4.0 CUDA supports virtual functions, and new/deleteyes...your GPU code can allocate memory on the fly (if you have a GeForce 4xx or greater). My idea is to make a subset of Clojure translatable to CUDA. So you would create input data in native memory, the the Clojure functions would be translated to CUDA C++, then to CUDA binaries where they would be executed in the CPU. A very simple approach would be to take the view that may Clojure-SQL frameworks do, and simply do a translation. In this method all CUDA Clojure functions would take only arrays and scalar values as inputs, and the functions would read data from arrays, and output them to arrays. No sequences, on-the-fly allocation, or any such thing would be allowed. On top of that, all input and output data must be of the same type, so no mixing doubles and floats, or ints and longs. All data must be resolved to staticlly defined types, and mutating the variable's type on the fly is not allowed. The more complex approach would be to use something like ClojureScript to compile core.clj to CUDA, and actually run a subset of Clojure on the GPU. In this case we would have to come up with a simple type system, and then rewrite the ClojureScript compiler to output C++ code instead of JS. In addition, some sort of simple GC (reference counting?) would have to be developed. The result would be slower than my first approach, but would be much more flexible. So in the first version we have a simple to create system, but we can't use many of the functions we are familiar with in CUDA. In the second method, we have a slower, but much more powerful system that would integrate much more tightly with existing code. Any thoughts? Besides that I'm crazy... Timothy -- 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
Your favorite utility function or macro.
Hi, I'm interested in useful utility which you create. Please show me your favorite utility. For example, _- is that for me. _- is like -, but it can insert expression in arbitrary place by marking underscore. (_- :a (assoc {} _ 1)) ;= {:a 1} Therefore It can unify - and - behavior. https://gist.github.com/886748 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
Should destructure emit not nthnext, but nthrest?
Hi, I think destructure should not produce nthnext, because it realize an element of sequence more than needed. For example: (defn inc-seq [i] (iterate #(let [x (inc %)] (println realize: x) x) i)) ;= #'user/inc-seq (take 1 (inc-seq 0)) ;= (0) (take 1 (let [[x xs] (inc-seq 0)] (cons x xs))) ; realize: 1 ;= (0) (macroexpand '(let [[x xs] (inc-seq 0)] (cons x xs))) ;= (let* [vec__2630 (inc-seq 0) x (clojure.core/nth vec__2630 0 nil) xs (clojure.core/nthnext vec__2630 1)] (cons x xs)) Although nthrest isn't in clojure, why not to use nthrest instead of nthnext in destructure? What do you think? -- 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: Should destructure emit not nthnext, but nthrest?
If you don't plan to use the rest arguments, and in fact don't care about them at all, why are you binding them to something? I omitted code for sake of simplicity. There are situations which require rest arguments. Using rest would cause the xs part to always be true You're right. I see to use nthrest instead of nthnext can break code, so unfortunately this is unwelcome change. Thanks! On 3月24日, 午前11:28, Alan a...@malloys.org wrote: If you don't plan to use the rest arguments, and in fact don't care about them at all, why are you binding them to something? More importantly, it would make the following idiom a lot more clumsy: (defn sum [list] (let [[x xs] list] (+ x (if xs (sum xs) 0 Using rest would cause the xs part to always be true, because to determine whether the sequence is empty you would have to call seq on it. On Mar 23, 6:23 pm, Takahiro Hozumi fat...@googlemail.com wrote: Hi, I think destructure should not produce nthnext, because it realize an element of sequence more than needed. For example: (defn inc-seq [i] (iterate #(let [x (inc %)] (println realize: x) x) i)) ;= #'user/inc-seq (take 1 (inc-seq 0)) ;= (0) (take 1 (let [[x xs] (inc-seq 0)] (cons x xs))) ; realize: 1 ;= (0) (macroexpand '(let [[x xs] (inc-seq 0)] (cons x xs))) ;= (let* [vec__2630 (inc-seq 0) x (clojure.core/nth vec__2630 0 nil) xs (clojure.core/nthnext vec__2630 1)] (cons x xs)) Although nthrest isn't in clojure, why not to use nthrest instead of nthnext in destructure? What do you think? -- 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.string/replace-first return nil when not matched
Hi, I have two questions about clojure.string/replace-first. 1. Is this expected behavior of replace-first? (require '[clojure.string :as str]) (str/replace-first abc def #ghi (fn [a] (str a a))) = nil I don't think so, because string / string argument version returns original string when mismatched. (str/replace-first abc def ghi jkl) = abc def 2. Is it difficult that replace-first support argument of string / function besides regex / function (i.e. without using Pattern/quote)? (str/replace-first abc def def (fn [a] (str a a))) = abc defdef The reason why I'd like to avoid using Pattern/quote is that ,I think, to replace string with string should be more lightweight than with regex. 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: slime warn-on-reflection?
I had same problem. Add following line in your project.cjj. :warn-on-reflection true On Feb 26, 9:11 am, Seth wbu...@gmail.com wrote: Has any gotten the warn-on-reflection to work in slime when compiling a buffer? Warning occur when i paste a function into the repl, but no reflections occur when i compile a buffer or when i load the file. -- 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: http.async.client v0.2.2 released
Hi, Thank you for the introduction. Here is my little feed back: 1. I want to see a example using callbacks. 2. Is RequestBuilderWrapper.java necessary? Why not simply use RequestBuilder? 3. I prefer reify or defrecord to proxy for performance reason, when implement interface. 4. I think hash-map is more suitable rather than cond in convert- method function. Thanks. On 2月8日, 午前3:30, Hubert Iwaniuk neo...@kungfoo.pl wrote: Hi All, Just released v0.2.2 of HTTP Asynchronous Client. Featuring following changeloghttp://bit.ly/hc9dxt - get-encoding helper works w/o Content-Type header - upgrade async-http-client to v1.5.0 - exposed more configuration options - zero byte copy mode - allow providing your own poll - allow Asynchronous Connect - fix seq streaming API - lots of performance improvements from async-http-client to v1.5.0 Uploaded to clojarshttp://bit.ly/hVAY8z Documentation is here:http://bit.ly/epmcMw Enjoy fresh release, Hubert. -- 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
dosync style
Hi, This is trivial question. Which style do you like? (def *counts* (ref {})) (defn dec-or-dissoc! [key] (dosync (let [n (@*counts* key)] (if ( 1 n) (alter *counts* assoc key (dec n)) (alter *counts* dissoc key) (defn dec-or-dissoc! [key] (dosync (alter *counts* (fn [m] (let [n (m key)] (if ( 1 n) (assoc m key (dec n)) (dissoc m key))) I think former style is normal, but latter is easy to replace ref with atom. Thanks. -- Takahiro Hozumi -- 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