Re: agent questions - DOS - asynchrony - protection
On Jun 10, 2009, at 11:23 PM, Robert Lehr wrote: >> As you noted, send-off uses a cached thread pool, so there is no >> protection from creating more threads than your system can handle > > OK - that's one person that agrees w/ me. I don't think anyone disagrees on that point. >> In general cached thread pools should be used only for short lived >> tasks. >> The DOS protection must come from somewhere else in your system. > > Right - as long as it *IS* solved elsewhere in the system. What on earth could constitute in-language DOS prevention? > The potential has to be recognized first which is impossible unless > it is > documented or one reads the source code. Some aspects of programming are best performed by programmers. If you want to call a thread pool a DOS threat, I'd like to introduce you to my friends automatic memory management, the call stack and I/O in general. :) > Yeah...I saw that. Except that the code assumes that the agent will > be modified by only the agent's callback mechanism. I think we all > will recognize that that is not the strongest protection. It is > perhaps satisfactory b/c it is idiomatic Clojure to modify an agent's > state ONLY via the callback. I don't think there are any other ways to modify an agent. I get a class cast exception or unable to alter root binding exception on all of these: user> (set! a 4) user> (dosync (set! a 4)) user> (alter a inc) user> (dosync (alter a inc)) user> (ref-set a 4) user> (dosync (ref-set a 4)) I don't know Java very well but reading the source code of Agent.java seems to indicate that the only way to change its state is by setting it directly or calling setState(), but neither of those options are public (I'm not aware of a way to set a property from Clojure anyway, and not sure it can be done in Java either, though I don't know). This fails because it can't find the method: user> (.setState a 5) The bean function doesn't even return the current value: user> (bean a) {:watches {}, :validator nil, :queueCount 0, :errors nil, :class clojure.lang.Agent} In other words, send and send-off are not merely idiomatic, they are the law. The only other thing you can do is to re-def the name of the agent with a new agent, but if you did this, any live references to the old agent such as closures or other threads created from this thread prior to the def would be unaffected and any actions pending for the old agent (targetted at that var or not) will continue to process for that var rather than being reassigned to the new one. You'd have to go through quite a bit of work to circumvent these effects, which are all consistent with pure FP. Let me illustrate: user> (defn increment-me-and-a-friend-slowly [n friend] (Thread/sleep 3000) (send-off friend inc) (inc n)) The idea here is to call this function with send-off and another agent, and it'll increment the friend agent and then itself after sleeping for 3 seconds. Now let's have some agents. They have the same value for illustrative purposes. user> (def a (agent 1)) #'user/a user> (def b (agent 1)) #'user/b For fun, let's make an alias to a called c. user> (def c a) #'user/c Same memory address, so it must be the same one: user> a # user> b # user> c # Now let's try it and see what happens: user> (send-off a increment-me-and-a-friend-slowly b) # user> a # user> b # user> c # Looks good to me. Now let's try it but redefine something right away after the send off before 3 seconds have elapsed: user> (do (send-off a increment-me-and-a-friend-slowly b) (def a (agent -5))) #'user/a user> a # user> b # user> c # user> (= a c) false To whit: if you screw around with def, you're going to have way more than the occasional hiccup. Your app will be dramatically and obviously wrong. Which leaves you with send and send-off. As an aside, I think your main problem is that you have an imperative conception of what a variable is. Variables in FP are just named values, not fixed pointers to raw hunks of memory that can be manipulated directly. In C++-ish jargon, think of every variable in Clojure as being a volatile pointer to a const piece of data of the appropriate type. A ref is an indirection on that, but it's more like an object with an API for changing the value which places certain demands on the caller, namely that a transaction be running. Agents are like that but their API consists of send and send-off. The language simply doesn't support getting the address of where these things really are in memory nor does it provide you with tools for manipulating them if you could get there. And a great deal of this is prevented not just by Clojure but by the JVM itself. There just isn't a lower level that you can get to from here like you're accustomed to in C++. — Daniel Lyons http://www.storytotell.org -- Tell It! --~--~-~--~~~---~--~~ Yo
Re: Reminder: Bay Area Clojure User Group meeting in SF during JavaOne (6/3) with Rich Hickey
On 11.06.2009, at 08:54, Alex wrote: > Just wanted to say I had a great time at the meetup. Really fun to > see people using Clojure in earnest and hear Rich talk about stuff. I > blogged it a bit here: > > http://tech.puredanger.com/2009/06/10/clojure-rich-hickey/ Thanks for the notes! There is lots of information there that I haven't seen on the list before. Konrad. --~--~-~--~~~---~--~~ 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 difficult would creating a collaborative multi-user online virtual world application be in Clojure?
One question that has been coming up at the back of my mind for the past several weeks has been how difficult would it be to create a collaborative multi-user online virtual world application in a semi-functional programming language, such as Clojure. More specifically, last August, I came across a very interesting application called Croquet (see http://www.opencroquet.org/index.php/Main_Page), which happens to be based on Squeak (see http://www.squeak.org/), a dialect of Smalltalk. Croquet, in turn, provides the basis for Cobalt (see http://www.duke.edu/~julian/Cobalt/Home.html), a "virtual workspace browser and construction toolkit for accessing, creating, and publishing hyperlinked multi-user virtual environments" (according to the home page for that project). What struck me as especially interesting was how Croquet allows multiple users to collaborate together in a multi-user online virtual world in software development and other collaborative projects. As one application, the video clip on the upper-right-hand corner of the above-mentioned Croquet home page illustrates how a user can, by writing code from inside the application, create on-the-fly additional virtual environments, which can then be entered by either the programmer or other programmers. Other applications (shown in other video clips on the "Screenshots/Videos" page (see http://www.opencroquet.org/index.php/Screenshots/Videos) show alternative applications that include text-based annotations, a 3D spreadsheet, and writing a conventional blog from within a virtual world. Unfortunately, Smalltalk is an object-oriented language. If possible, I would like to see something similar in a more functional programming language such as Clojure. Does anybody know whether duplicating this project in Clojure would be feasible? -- Benjamin L. Russell -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 "Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^ -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 "Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Updating a running app
HI, in his post "Macro design, by example" [1], Meikel Brandmeyer mentioned that it is possible to reload a function (in contrast to a macro) in a running application: "Now all you have to do is to just reload the single function in the running application. This can be easily done by environments like SLIME or VimClojure. Et voila. The next time the function is called you already get the benefit. Without recompilation of the whole app... " Is achieving this a general possibility for any app, or are there limitations to updating running applications? For example, is it necessary to start the app in a REPL to be able to update it while it's running? Or is it possible to open a REPL attached to a running application? I'm very curious about this (possibly compared to Erlang's hot code update possibilities) and would appreciate any pointer or example. Thanks! Raphael [1] http://groups.google.com/group/clojure/browse_thread/thread/5ff31c9d7fc58b0b# --~--~-~--~~~---~--~~ 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 difficult would creating a collaborative multi-user online virtual world application be in Clojure?
Hi, Take a look at project Wonderland -- https://lg3d-wonderland.dev.java.net/ -- Krešimir Šojat --~--~-~--~~~---~--~~ 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: (re)setting a function globally
Matt is signing the CA and I will be adding test-expect to contrib. Stu > > Can I help from the test-is side? Could test-expect be added to > clojure-contrib? > -Stuart > > > On Jun 10, 1:36 pm, Matt Clark wrote: >> Thanks for these ideas, I will give them a try tonight and update the >> adapter namespace with the changes. If anyone knows of a more >> idiomatic way I could have implemented the problem reporting >> functionality that would prevent the necessity of these "hacky" >> solutions, I'm all ears. > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Contributing to Clojure CLR.
Hi, How can one contribute to the development of Clojure on CLR? I was trying the following - (.ToString DateTime/Now) and was getting - "System.Exception: Unable to find static field: Now in System.DateTime". I added some code in Reflector.cs, Compiler.cs and StaticFieldExpr.cs and got it working, though I am not sure if the fixes are in the right place. Please let me know if you want to have a look at my changes. Thanks, Manoj. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Anyone planning on using Clojure for ICFP 2009?
So the 12th International Conference on Functional Programming is coming up soon. A few months before the event a programming contest is held, typically with very ambitious requirements in a short period of time (2-3 days). The 2009 contest will be held from Friday 26 to Monday 29 June and I would be surprised if they tightly restrict the acceptable languages. I submitted a fair/poor entry in Ruby last year (team Foognostic). I apologize if I've missed the obvious, but is anyone planning on using Clojure for the contest? Link to the ICFP 2009 contest site: http://www.ittc.ku.edu/icfp-contest/ Here is a copy of the task description from 2008: http://smlnj.org/icfp08-contest/task.html --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
do-asynch-periodically
Consider this public domain for copyright purposes. Try it at the repl with: (defn make-counter [] (let [i (atom 0)] #(do (swap! i + 1) @i))) (def *counter* (make-counter)) (do-asynch-periodically *xxx* 1 (println (*counter*))) (do-asynch-periodically *xxx* 1 (println (str "changed! " (*counter* After submitting the first do-asynch-periodically form, numbers should start counting up in the standard output stream. Wait a while, then submit the second. The numbers will keep counting up, with "changed! " prepended now to each one, indicating that the previous *xxx* thread was replaced by a new one rather than left orphaned but still running. So if you define a daemon job with this macro, and then during development keep reloading the file with the definition, you won't be creating a glut of threads all trying to do the same job, or worse, instead of replacing a buggy version with the fixed version, ending up with both running side-by-side. It took quite a bit of digging to figure out how to make with-global- if-exists work, actually the trickiest part of the whole thing. :) It might have other uses -- if *foo* exists and is bound, (with-global-if- exists *foo* bar (do-something-with bar)) will evaluate (do-something- with bar) with bar's value equal to *foo*s if *foo* exists and is bound, and do nothing otherwise. So, it's like (do-something-with *foo*) except it doesn't fail to compile if *foo* isn't defined, nor blow up at runtime if *foo* is a var but is unbound, but instead does nothing in both those cases. It also doesn't have side-effects -- the var won't be def'd, or bound, by the macro expansion, unless one of the provided arguments has such a side-effect when evaluated. The do-asynch-periodically macro takes a name, a number, and a body. The body will start executing asynchronously at an interval in seconds equal to the supplied number, with the first execution occurring that amount of time after the do-asynch-periodically form is evaluated. It will then loop endlessly, or until stopped with (. name (interrupt)) or restarted with a new body by evaluating another do-asynch- periodically form with the same name. The name is bound in the current namespace when the form is evaluated, to a Java Thread object admitting the usual manipulations, such as tweaking its priority, interrupting it, or whatever. The thread will die after the current body execution if interrupted, since it lets sleep throw an uncaught InterruptedException in that case. This could be very useful for implementing daemons to process job queues of various sorts. The example above used a closure that increments a counter, which is a nice demonstration but otherwise useless; more pragmatically, you'd use refs and transactions, atoms with something more interesting, or a BlockingQueue from the java.util.concurrent package. The thread macro, and the techniques in the other macros, could also be used to implement a periodically fn that creates jobs at runtime from passed-in functions, e.g. (periodically #(println (*counter*))) would return a thread that, when started, printed increasing numbers. (Being a macro, do-asynch-periodically is really only suitable for defining a fixed set of global job-daemons that will always be part of the background when your software is running.) On a side note, I've noticed a few issues with clojure that could use a bit of sprucing up, no disrespect intended: * If REPL code goes into infinite loop, only escape is to reset the REPL, which loses everything. Perhaps make ctrl-C interrupt and return to prompt? It could throw InterruptedException into the running code, or Error, or something. * No apparent way to change imports on-the-fly in REPL, have to recompile all dependencies, close REPL, and reopen REPL. Tedious. * Compiler diagnostics could use some improvement. Many are cryptic, not clearly indicating the nature of the original problem. Line number isn't always given if a REPL expression triggered the exception, even if the actual error is in a .clj file. Given many functions and expressions on some lines, column number would be useful too. * One especially cryptic error: undefined symbol clojure.core/unquote (or unquote-splicing). This looks like library misconfiguration but comes from forgetting the back-tick in some macro somewhere. * For some reason, at the clojure web site, the back button is noticeably slower than normal to operate and does not remember my position on the previous page -- if I am at the bottom of "vars and environment" for example, click one of the links there (such as to var-set on the API page), and hit back, it takes a couple of full seconds to be back at "vars and environment" and then I'm at the top and have to scroll all the way back down. This is strange, since other sites (e.g. Wikipedia) don't do this. I'm using Firefox 3.0.10 in case it matters. * Documentation of some useful things is still lacking there. For example, I d
Re: Clojure at LispNYC tonight 7pm
Stuart Sierra wrote: > On Jun 9, 10:32 am, Stuart Sierra wrote: >> Join us Tuesday, June 9 from 7:00-9:00 for Stuart Sierra's >> presentation: >> >> Implementing AltLaw.org in Clojure > > Slides and video here: http://lispnyc.org/wiki.clp?page=past-meetings > We'll try to get something lighter than a 3GB mpeg soon. Watched the video. Highly impressive! Thanks. BG -- Baishampayan Ghose oCricket.com signature.asc Description: OpenPGP digital signature
Re: Updating a running app
On Thu, Jun 11, 2009 at 5:06 AM, rb wrote: > > HI, > > in his post "Macro design, by example" [1], Meikel Brandmeyer > mentioned that it is possible to reload a function (in contrast to a > macro) in a running application: > > "Now all you have to do is to just reload the single function in the > running application. This can be easily done by environments like > SLIME or VimClojure. Et voila. The next time the function is called > you already get the benefit. Without recompilation of the whole app... > " > > Is achieving this a general possibility for any app, or are there > limitations to updating running applications? > For example, is it necessary to start the app in a REPL to be able to > update it while it's running? Or is it possible to open a REPL > attached to a running application? > Clojure loads code only when you tell it to via require, use, and load (or their equivalents in an ns definition), so you do need a way to tell it to reload. Currently that could happen via a REPL or Slime or any other I/O mechanism you could build into your app to take input and load code. It's pretty easy to launch an app and a REPL using the built-in command line arguments of clojure.main: java -cp clojure.jar --init myapp.clj --repl. Opening a slime connection in your init script is also pretty easy. > I'm very curious about this (possibly compared to Erlang's hot code > update possibilities) and would appreciate any pointer or example. > > Thanks! > > Raphael A big difference with Erlang's hot code loading is that in Erlang the runtime tracks multiple versions of code by module, and there's a well defined way for your code to indicate whether it always wants the latest version of a function it calls or whether only new Erlang processes see the new code. With Clojure it's more granular and forceful. As soon as a given function is loaded, the new version is visible globally to the program (except where a particular thread may have purposely set up a thread-local binding in its current context). If you're updating multiple functions with changes in their signatures or meaning, you have to be very careful. There was an interesting query on the group [1] about the possibility of supporting multiple versions of scripts by using dynamic classloaders, but it didn't generate discussion. Shawn [1] http://groups.google.com/group/clojure/browse_thread/thread/e05f73854549a25d/7c22e8472ff738a4 --~--~-~--~~~---~--~~ 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: agent questions - DOS - asynchrony - protection
On Wed, 2009-06-10 at 22:23 -0700, Robert Lehr wrote: > Given that this will only occur w/ the send-off function, we can guess > that the tasks may on-average longer than functions that could be sent > via "send". that is b/c send-off is recommended for functions that > could block. That could be a thread or I/O or a lock, etc. > > Also, I didn't see a recommendation in the docs (or anywhere else) > that agent callbacks be short-lived tasks. In fact, some of the > things that I have been pondering would not be short-lived. Well, in general thread pools don't go very well together with long running tasks. A fixed size thread pool could stop responding once all threads are blocked on I/O operations etc. Hence the cached thread pool which expands/contracts as needed. send-off uses the cached thread pool to stay responsive even if some individual threads block, but this does not mean that we should have lots and lots of long running threads in that pool. A brief notice can be found here: http://java.sun.com/javase/6/docs/api/java/util/concurrent/Executors.html#newCachedThreadPool() The highly recommended "Java Concurrency in Practice" from Brian Goetz also talks about this topic. > Yeah...I saw that. Except that the code assumes that the agent will > be modified by only the agent's callback mechanism. I think we all > will recognize that that is not the strongest protection. It is > perhaps satisfactory b/c it is idiomatic Clojure to modify an agent's > state ONLY via the callback. > > So - is that correct? That agents are protected by serializing the > mutator functions invoked via "send" and "send-off"? You have to differentiate between API and implementation. The agent API consists of a bunch of functions which allow agent creation, action dispatching (send, send-off) and some more functions related to validation, dereferencing etc. You will notice that none of these functions change the agent state, instead the result of an agent's action (a function of the current agent state plus maybe additional arguments) will become the next agent state. So this is not an assumption, it is a guarantee of the API. Now w.r.t the implementation you can easily verify that the agent's state is only changed by an executing Action (here I am referring to the Action class). If you would mess around with the implementation, e.g. creating another class in the clojure.lang package which invokes setState on an Agent you are on your own of course (and then we wouldn't talk about Clojure anymore). What you get when you download clojure_1.0.0.zip is safe both in terms of API and implementation, and yes, this safety is achieved by serializing the state changes of an Agent. Cheers, Toralf --~--~-~--~~~---~--~~ 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 performance and timings
Hello all! After reading this article: Clojure performance tips http://gnuvince.wordpress.com/2009/05/11/clojure-performance-tips/ I wrote a macro to better compare different timings of functions and expressions: (defmacro time-ms [n expr] `(let [start# (. System (nanoTime))] (dotimes [i# ~n] ~expr) (/ (double (- (. System (nanoTime)) start#)) 100.0))) (defmacro timings [n & expr] (let [expr-are-not-equal (cons 'not= expr) expr-times (cons 'vector (map #(list 'time-ms n %) expr))] `(if ~expr-are-not-equal (do (println "Expressions:\n") (dorun (map prn '~expr)) (println "\nare NOT equal!")) (let [~'ts ~expr-times ~'max-time (apply max ~'ts)] (dorun (map (fn [~'t ~'e] (printf "%8.2f ms %6.1f%% %5.1fx " ~'t (* 100.0 (/ ~'t ~'max-time)) (/ ~'max-time ~'t)) (prn ~'e)) ~'ts '~expr)) Here are the examples: (timings 1e6 (+ 2 4 5) (+ 2 (+ 4 5))) 787.96 ms 100.0% 1.0x (+ 2 4 5) 360.94 ms 45.8% 2.2x (+ 2 (+ 4 5)) ;;; (timings 1 (dotimes [i 1e6] (= i i)) (dotimes [i 1e6] (== i i))) 444.39 ms 100.0% 1.0x (dotimes [i 100.0] (= i i)) 237.29 ms 53.4% 1.9x (dotimes [i 100.0] (== i i)) (timings 1 (dotimes [i 1e6] (= i 10)) (dotimes [i 1e6] (== i 10))) 368.37 ms 100.0% 1.0x (dotimes [i 100.0] (= i 10)) 324.65 ms 88.1% 1.1x (dotimes [i 100.0] (== i 10)) ;;; (let [v [1 2 3]] (timings 1e6 (let [[a b c] v] a b c) (let [a (v 0) b (v 1) c (v 2)] a b c))) 920.15 ms 100.0% 1.0x (let [[a b c] v] a b c) 486.82 ms 52.9% 1.9x (let [a (v 0) b (v 1) c (v 2)] a b c) ;;; (def v 3) (let [l 3] (timings 1e6 v l)) 172.42 ms 100.0% 1.0x v 118.20 ms 68.6% 1.5x l ;;; (defn len [x] (.length x)) (defn len2 [#^String x] (.length x)) (def s "abcdef") (timings 1e5 (len s) (len2 s)) 1655.12 ms 100.0% 1.0x (len s) 32.82 ms2.0% 50.4x (len2 s) Interesting is that the speed difference is smaller than in the article. Bug reports and suggestions are welcome! Frantisek --~--~-~--~~~---~--~~ 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: Contributing to Clojure CLR.
I believe David Miller is the one who wrote the CLR code, and he is still hacking on it when he has time. In addition to what is checked into contrib there is also this: http://github.com/dmiller/ClojureCLR/tree/master I'm not sure if they are in sync or which is the most current (github may be it was last updated May 31). I suppose one possible workflow is to fork, improve, and set a pull request. Paul On Wed, Jun 10, 2009 at 10:25 PM, mmwaikar wrote: > > Hi, > > How can one contribute to the development of Clojure on CLR? > > I was trying the following - (.ToString DateTime/Now) and was getting > - "System.Exception: Unable to find static field: Now in > System.DateTime". > > I added some code in Reflector.cs, Compiler.cs and StaticFieldExpr.cs > and got it working, though I am not sure if the fixes are in the right > place. Please let me know if you want to have a look at my changes. > > Thanks, > Manoj. > > > > --~--~-~--~~~---~--~~ 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: Contributing to Clojure CLR.
On Jun 11, 9:57 am, Paul Stadig wrote: > I believe David Miller is the one who wrote the CLR code, and he is still > hacking on it when he has time. > > In addition to what is checked into contrib there is also this: > > http://github.com/dmiller/ClojureCLR/tree/master > > I'm not sure if they are in sync or which is the most current (github may be > it was last updated May 31). I suppose one possible workflow is to fork, > improve, and set a pull request. > > Paul > > On Wed, Jun 10, 2009 at 10:25 PM, mmwaikar wrote: > > > Hi, > > > How can one contribute to the development of Clojure on CLR? > > > I was trying the following - (.ToString DateTime/Now) and was getting > > - "System.Exception: Unable to find static field: Now in > > System.DateTime". > > > I added some code in Reflector.cs, Compiler.cs and StaticFieldExpr.cs > > and got it working, though I am not sure if the fixes are in the right > > place. Please let me know if you want to have a look at my changes. > > > Thanks, > > Manoj. You will need a CA as well. Rich --~--~-~--~~~---~--~~ 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: Anyone planning on using Clojure for ICFP 2009?
I'm going to do what I did last year: 1. Learn a functional language (Clojure this year; OCaml last year). 2. Try to do the the problem in said new language. 3. Give up and switch to Python. :) On Jun 11, 1:54 am, Seth wrote: > So the 12th International Conference on Functional Programming is > coming up soon. A few months before the event a programming contest is > held, typically with very ambitious requirements in a short period of > time (2-3 days). The 2009 contest will be held from Friday 26 to > Monday 29 June and I would be surprised if they tightly restrict the > acceptable languages. I submitted a fair/poor entry in Ruby last year > (team Foognostic). > > I apologize if I've missed the obvious, but is anyone planning on > using Clojure for the contest? > > Link to the ICFP 2009 contest site:http://www.ittc.ku.edu/icfp-contest/ > > Here is a copy of the task description from > 2008:http://smlnj.org/icfp08-contest/task.html --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Simple idiom in clojure, mutate a value
I do this a lot but can't figure out to change the UPDATEABLE_VALUE, I am using some pseudo code because I don't have a clojure solution yet. SET UPDATEABLE_VALUE = 0 (loop [line (.readLine reader)] (if (or (empty? line) (> line-num max-num)) SET UPDATEABLE_VALUE = UPDATEABLE_VALUE + (SOME_FUNC) (recur (.readLine reader -- basically I want to have access to some value UPDATEABLE_VALUE outside of the loop but also have the ability to update the value. --~--~-~--~~~---~--~~ 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: Simple idiom in clojure, mutate a value
Not totally clear what you are trying to accomplish, but would something like the following work? (defn get-value [start-value] (loop [updateable start-value line (.readline reader)] (if (or (empty? line) (> line-num max-num)) (+ updateable (somefunc)) (recur (.readLine reader) (defn do-something [] (let [updated-value (get-value 0)] ...)) On Thu, Jun 11, 2009 at 11:25 AM, BerlinBrown wrote: > > I do this a lot but can't figure out to change the UPDATEABLE_VALUE, I > am using some pseudo code because I don't have a clojure solution yet. > > SET UPDATEABLE_VALUE = 0 > (loop [line (.readLine reader)] > (if (or (empty? line) (> line-num max-num)) > SET UPDATEABLE_VALUE = UPDATEABLE_VALUE + (SOME_FUNC) >(recur (.readLine reader > > -- > > basically I want to have access to some value UPDATEABLE_VALUE outside > of the loop but also have the ability to update the > value. > > > --~--~-~--~~~---~--~~ 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: Anyone planning on using Clojure for ICFP 2009?
On Jun 10, 2009, at 6:54 PM, Seth wrote: > > So the 12th International Conference on Functional Programming is > coming up soon. A few months before the event a programming contest is > held, typically with very ambitious requirements in a short period of > time (2-3 days). The 2009 contest will be held from Friday 26 to > Monday 29 June and I would be surprised if they tightly restrict the > acceptable languages. I submitted a fair/poor entry in Ruby last year > (team Foognostic). > > I apologize if I've missed the obvious, but is anyone planning on > using Clojure for the contest? My story is pretty similar to Matt's except usually I'm the only one in my group of friends who tries to learn the language and we default back to Ruby. Sad, I know. :) I'm hoping this year with Clojure they can fall back on JRuby or Jython and I can press on in Clojure. I wish there were some details up on the contest site. I think 2006 ("Cult of the Bound Variable") was probably the best year. — Daniel Lyons http://www.storytotell.org -- Tell It! --~--~-~--~~~---~--~~ 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: Simple idiom in clojure, mutate a value
On Jun 11, 2009, at 9:25 AM, BerlinBrown wrote: > > I do this a lot but can't figure out to change the UPDATEABLE_VALUE, I > am using some pseudo code because I don't have a clojure solution yet. > > SET UPDATEABLE_VALUE = 0 > (loop [line (.readLine reader)] > (if (or (empty? line) (> line-num max-num)) > SET UPDATEABLE_VALUE = UPDATEABLE_VALUE + (SOME_FUNC) >(recur (.readLine reader In general it's going to be something like this: (loop [line (.readLine reader) UPDATEABLE_VALUE 0] (if (or (empty? line) (> line-num max-num)) (recur (.readLine reader) (+ UPDATEABLE_VALUE (SOME_FUNC) Whenever you would have modified a local variable before, in FP you establish a new binding instead. — Daniel Lyons http://www.storytotell.org -- Tell It! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
PermGen OutOfMemory error
Hi all, I'm using Clojure for web apps inside Tomcat. If I don't compile my .clj files ahead of time, I will eventually get one of these OutOfMemory errors, after a number of redeployments. Is there something I can do about this? Is this a bug somewhere, in my code, or in Clojure, or in Tomcat; or a limitation of the JVM? thanks, Rob Here is the entire barfage from my Tomcat log: Jun 11, 2009 12:01:57 PM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet ClojureServlet threw exception java.lang.NullPointerException at clojure.lang.Var.popThreadBindings(Var.java:289) at biz.encodia.webapps.webdispatch $make_dispatcher__3759$fn__3761.invoke(webdispatch.clj:90) at clojure.lang.Var.invoke(Var.java:350) at biz.encodia.webapps.ClojureServlet.processRequest (ClojureServlet.java:70) at biz.encodia.webapps.ClojureServlet.doGet (ClojureServlet.java:99) at javax.servlet.http.HttpServlet.service(HttpServlet.java: 617) at javax.servlet.http.HttpServlet.service(HttpServlet.java: 717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke (StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke (StandardContextValve.java:191) at org.apache.catalina.authenticator.AuthenticatorBase.invoke (AuthenticatorBase.java:433) at org.apache.catalina.core.StandardHostValve.invoke (StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke (StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service (CoyoteAdapter.java:286) at org.apache.coyote.http11.Http11Processor.process (Http11Processor.java:845) at org.apache.coyote.http11.Http11Protocol $Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run (JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:613) Jun 11, 2009 12:04:23 PM org.apache.catalina.core.ApplicationContext log SEVERE: StandardWrapper.Throwable java.lang.ExceptionInInitializerError at biz.encodia.webapps.ClojureServlet.loadDispatchCode (ClojureServlet.java:32) at biz.encodia.webapps.ClojureServlet.init(ClojureServlet.java: 49) at org.apache.catalina.core.StandardWrapper.loadServlet (StandardWrapper.java:1172) at org.apache.catalina.core.StandardWrapper.allocate (StandardWrapper.java:808) at org.apache.catalina.core.StandardWrapperValve.invoke (StandardWrapperValve.java:129) at org.apache.catalina.core.StandardContextValve.invoke (StandardContextValve.java:191) at org.apache.catalina.authenticator.AuthenticatorBase.invoke (AuthenticatorBase.java:433) at org.apache.catalina.core.StandardHostValve.invoke (StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke (StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service (CoyoteAdapter.java:286) at org.apache.coyote.http11.Http11Processor.process (Http11Processor.java:845) at org.apache.coyote.http11.Http11Protocol $Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run (JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:613) Caused by: java.lang.RuntimeException: java.lang.OutOfMemoryError: PermGen space (core.clj:2151) at clojure.lang.RT.(RT.java:294) ... 15 more Caused by: java.lang.OutOfMemoryError: PermGen space (core.clj:2151) at clojure.lang.Compiler.eval(Compiler.java:4617) at clojure.lang.Compiler.eval(Compiler.java:4593) at clojure.lang.Compiler.load(Compiler.java:4931) at clojure.lang.RT.loadResourceScript(RT.java:329) at clojure.lang.RT.loadResourceScript(RT.java:320) at clojure.lang.RT.load(RT.java:398) at clojure.lang.RT.load(RT.java:370) at clojure.lang.RT.doInit(RT.java:405) at clojure.lang.RT.(RT.java:291) ... 15 more Caused by: java.lang.OutOfMemoryError: PermGen space at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:675) at java.lang.ClassLoader.defineClass(ClassLoader.java:520) at clojure.lang.DynamicClassLoader.defineClass (DynamicClassLoader.java:42) at clojure.lang.Compiler$FnExpr.getCompiledClass(Compiler.java: 3465) at clojure.lang.Compiler$FnExpr.eval(Compiler.java:3476) at clojure.lang.Compiler.eval(Compiler.java:4
catching exception error
Hi clojurians, I was happily clojure-coding whent I tried to catch a exception in a thrown deeply in a function. After looking for the fact that the IllegalArgumentException wasn't catch, I added a catch RuntimeException to my catch list ... and that worked of course. Here is the simplified case: (defn throw-error [arg] (throw (IllegalArgumentException. (str arg (try (let [ test (into {} (map (fn[x] (if (= 5 x) (throw-error x) [x x])) [1 2 3 4 5])) ] (str "NO PB " name)) (catch IllegalArgumentException e (.getMessage e)) (catch RuntimeException e (str "RT" (.getMessage e))) ) If you comment the RuntimeException catch, the exception is not catched. I don't understand why IllegalArgumentException is not catched ... Somebody could tell me ? Thanks Phil --~--~-~--~~~---~--~~ 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: Simple idiom in clojure, mutate a value
On Jun 11, 12:16 pm, Daniel Lyons wrote: > On Jun 11, 2009, at 9:25 AM, BerlinBrown wrote: > > > > > I do this a lot but can't figure out to change the UPDATEABLE_VALUE, I > > am using some pseudo code because I don't have a clojure solution yet. > > > SET UPDATEABLE_VALUE = 0 > > (loop [line (.readLine reader)] > > (if (or (empty? line) (> line-num max-num)) > > SET UPDATEABLE_VALUE = UPDATEABLE_VALUE + (SOME_FUNC) > >(recur (.readLine reader > > In general it's going to be something like this: > > (loop [line (.readLine reader) UPDATEABLE_VALUE 0] > (if (or (empty? line) (> line-num max-num)) > (recur (.readLine reader) (+ UPDATEABLE_VALUE (SOME_FUNC) > > Whenever you would have modified a local variable before, in FP you > establish a new binding instead. > > — > Daniel Lyonshttp://www.storytotell.org-- Tell It! I can modify the value within the loop, but what is a good approach for accessing the value outside of the loop. For example (pseudo code with a mix of procedural logic). ;; Init updateable value outside of 'loop' SET UPDATEABLE_VALUE = 0 (loop [line (.readLine reader)] (if (or (empty? line) (> line-num max-num)) SET UPDATEABLE_VALUE = UPDATEABLE_VALUE + (SOME_FUNC) (recur (.readLine reader ;; Now outside of the loop, use UPDATEABLE_VALUE with the mutated value (println UPDATEABLE_VALUE) --~--~-~--~~~---~--~~ 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: PermGen OutOfMemory error
On Jun 11, 11:38 am, Rob wrote: > Hi all, > > I'm using Clojure for web apps inside Tomcat. If I don't compile > my .clj files ahead of time, I will eventually get one of these > OutOfMemory errors, after a number of redeployments. Is there > something I can do about this? Is this a bug somewhere, in my code, > or in Clojure, or in Tomcat; or a limitation of the JVM? > PermGen space is where Sun's VM keeps class bytes. It's not garbage collected, so if you keep adding classes to a running VM you will eventally run out. We can only deploy a couple of times on our non- clojure webapp, in Jboss + Tomcat. It's not unique to Clojure, but it's true that generating classes on the fly can burn up permGen space faster. Try increasng your PermGen space as a workaround. This arg your jvm: -XX:MaxPermGen=128m or so might help. Hugh > thanks, > Rob > > Here is the entire barfage from my Tomcat log: > > Jun 11, 2009 12:01:57 PM org.apache.catalina.core.StandardWrapperValve > invoke > SEVERE: Servlet.service() for servlet ClojureServlet threw exception > java.lang.NullPointerException > at clojure.lang.Var.popThreadBindings(Var.java:289) > at biz.encodia.webapps.webdispatch > $make_dispatcher__3759$fn__3761.invoke(webdispatch.clj:90) > at clojure.lang.Var.invoke(Var.java:350) > at biz.encodia.webapps.ClojureServlet.processRequest > (ClojureServlet.java:70) > at biz.encodia.webapps.ClojureServlet.doGet > (ClojureServlet.java:99) > at javax.servlet.http.HttpServlet.service(HttpServlet.java: > 617) > at javax.servlet.http.HttpServlet.service(HttpServlet.java: > 717) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter > (ApplicationFilterChain.java:290) > at org.apache.catalina.core.ApplicationFilterChain.doFilter > (ApplicationFilterChain.java:206) > at org.apache.catalina.core.StandardWrapperValve.invoke > (StandardWrapperValve.java:233) > at org.apache.catalina.core.StandardContextValve.invoke > (StandardContextValve.java:191) > at org.apache.catalina.authenticator.AuthenticatorBase.invoke > (AuthenticatorBase.java:433) > at org.apache.catalina.core.StandardHostValve.invoke > (StandardHostValve.java:128) > at org.apache.catalina.valves.ErrorReportValve.invoke > (ErrorReportValve.java:102) > at org.apache.catalina.core.StandardEngineValve.invoke > (StandardEngineValve.java:109) > at org.apache.catalina.connector.CoyoteAdapter.service > (CoyoteAdapter.java:286) > at org.apache.coyote.http11.Http11Processor.process > (Http11Processor.java:845) > at org.apache.coyote.http11.Http11Protocol > $Http11ConnectionHandler.process(Http11Protocol.java:583) > at org.apache.tomcat.util.net.JIoEndpoint$Worker.run > (JIoEndpoint.java:447) > at java.lang.Thread.run(Thread.java:613) > Jun 11, 2009 12:04:23 PM org.apache.catalina.core.ApplicationContext > log > SEVERE: StandardWrapper.Throwable > java.lang.ExceptionInInitializerError > at biz.encodia.webapps.ClojureServlet.loadDispatchCode > (ClojureServlet.java:32) > at biz.encodia.webapps.ClojureServlet.init(ClojureServlet.java: > 49) > at org.apache.catalina.core.StandardWrapper.loadServlet > (StandardWrapper.java:1172) > at org.apache.catalina.core.StandardWrapper.allocate > (StandardWrapper.java:808) > at org.apache.catalina.core.StandardWrapperValve.invoke > (StandardWrapperValve.java:129) > at org.apache.catalina.core.StandardContextValve.invoke > (StandardContextValve.java:191) > at org.apache.catalina.authenticator.AuthenticatorBase.invoke > (AuthenticatorBase.java:433) > at org.apache.catalina.core.StandardHostValve.invoke > (StandardHostValve.java:128) > at org.apache.catalina.valves.ErrorReportValve.invoke > (ErrorReportValve.java:102) > at org.apache.catalina.core.StandardEngineValve.invoke > (StandardEngineValve.java:109) > at org.apache.catalina.connector.CoyoteAdapter.service > (CoyoteAdapter.java:286) > at org.apache.coyote.http11.Http11Processor.process > (Http11Processor.java:845) > at org.apache.coyote.http11.Http11Protocol > $Http11ConnectionHandler.process(Http11Protocol.java:583) > at org.apache.tomcat.util.net.JIoEndpoint$Worker.run > (JIoEndpoint.java:447) > at java.lang.Thread.run(Thread.java:613) > Caused by: java.lang.RuntimeException: java.lang.OutOfMemoryError: > PermGen space (core.clj:2151) > at clojure.lang.RT.(RT.java:294) > ... 15 more > Caused by: java.lang.OutOfMemoryError: PermGen space (core.clj:2151) > at clojure.lang.Compiler.eval(Compiler.java:4617) > at clojure.lang.Compiler.eval(Compiler.java:4593) > at clojure.lang.Compiler.load(Compiler.java:4931) > at clojure.lang.RT.loadResourceScript(RT.java:329) > at clojure.lang.RT.loadResourceScript(RT.java:320) > at clojure.lang.RT.loa
Re: Simple idiom in clojure, mutate a value
Why isn't the following satisfactory for your needs? get-value takes a value returns a new value based on it. do-something can 'do something' to/with this new value. (defn get-value [start-value] (loop [updateable start-value line (.readline reader)] (if (or (empty? line) (> line-num max-num)) (+ updateable (somefunc)) (recur (.readLine reader) (defn do-something [] (let [updated-value (get-value 0)] (println updated-value)) On Thu, Jun 11, 2009 at 2:21 PM, Berlin Brown wrote: > > > > On Jun 11, 12:16 pm, Daniel Lyons wrote: > > On Jun 11, 2009, at 9:25 AM, BerlinBrown wrote: > > > > > > > > > I do this a lot but can't figure out to change the UPDATEABLE_VALUE, I > > > am using some pseudo code because I don't have a clojure solution yet. > > > > > SET UPDATEABLE_VALUE = 0 > > > (loop [line (.readLine reader)] > > > (if (or (empty? line) (> line-num max-num)) > > > SET UPDATEABLE_VALUE = UPDATEABLE_VALUE + (SOME_FUNC) > > >(recur (.readLine reader > > > > In general it's going to be something like this: > > > > (loop [line (.readLine reader) UPDATEABLE_VALUE 0] > > (if (or (empty? line) (> line-num max-num)) > > (recur (.readLine reader) (+ UPDATEABLE_VALUE (SOME_FUNC) > > > > Whenever you would have modified a local variable before, in FP you > > establish a new binding instead. > > > > — > > Daniel Lyonshttp://www.storytotell.org-- Tell It! > > I can modify the value within the loop, but what is a good approach > for accessing the value outside of the loop. For example (pseudo code > with a mix of procedural logic). > > ;; Init updateable value outside of 'loop' > SET UPDATEABLE_VALUE = 0 > (loop [line (.readLine reader)] > (if (or (empty? line) (> line-num max-num)) > SET UPDATEABLE_VALUE = UPDATEABLE_VALUE + (SOME_FUNC) >(recur (.readLine reader > ;; Now outside of the loop, use UPDATEABLE_VALUE with the mutated > value > (println UPDATEABLE_VALUE) > > > > > > --~--~-~--~~~---~--~~ 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: Simple idiom in clojure, mutate a value
You could do something like; (let [updated-val (loop [updateable start-value line (.readline reader)] (if (or (empty? line) (> line-num max-num)) (+ updateable (somefunc)) (recur (.readLine reader)] (do-something with updated-val)) Rgds, Adrian. On Thu, Jun 11, 2009 at 8:34 PM, David Nolen wrote: > Why isn't the following satisfactory for your needs? get-value takes a value > returns a new value based on it. do-something can 'do something' to/with > this new value. > (defn get-value [start-value] > (loop [updateable start-value line (.readline reader)] > (if (or (empty? line) (> line-num max-num)) > (+ updateable (somefunc)) > (recur (.readLine reader) > (defn do-something [] > (let [updated-value (get-value 0)] > (println updated-value)) > On Thu, Jun 11, 2009 at 2:21 PM, Berlin Brown > wrote: >> >> >> >> On Jun 11, 12:16 pm, Daniel Lyons wrote: >> > On Jun 11, 2009, at 9:25 AM, BerlinBrown wrote: >> > >> > >> > >> > > I do this a lot but can't figure out to change the UPDATEABLE_VALUE, I >> > > am using some pseudo code because I don't have a clojure solution yet. >> > >> > > SET UPDATEABLE_VALUE = 0 >> > > (loop [line (.readLine reader)] >> > > (if (or (empty? line) (> line-num max-num)) >> > > SET UPDATEABLE_VALUE = UPDATEABLE_VALUE + (SOME_FUNC) >> > > (recur (.readLine reader >> > >> > In general it's going to be something like this: >> > >> > (loop [line (.readLine reader) UPDATEABLE_VALUE 0] >> > (if (or (empty? line) (> line-num max-num)) >> > (recur (.readLine reader) (+ UPDATEABLE_VALUE (SOME_FUNC) >> > >> > Whenever you would have modified a local variable before, in FP you >> > establish a new binding instead. >> > >> > — >> > Daniel Lyonshttp://www.storytotell.org-- Tell It! >> >> I can modify the value within the loop, but what is a good approach >> for accessing the value outside of the loop. For example (pseudo code >> with a mix of procedural logic). >> >> ;; Init updateable value outside of 'loop' >> SET UPDATEABLE_VALUE = 0 >> (loop [line (.readLine reader)] >> (if (or (empty? line) (> line-num max-num)) >> SET UPDATEABLE_VALUE = UPDATEABLE_VALUE + (SOME_FUNC) >> (recur (.readLine reader >> ;; Now outside of the loop, use UPDATEABLE_VALUE with the mutated >> value >> (println UPDATEABLE_VALUE) >> >> >> >> > > > > > --~--~-~--~~~---~--~~ 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: Simple idiom in clojure, mutate a value
Re-read your example - that should have been; (let [updated-val (loop [updateable 0 line (.readline reader)] (if (or (empty? line) (> line-num max-num)) (+ updateable (somefunc)) (recur (.readLine reader)] (do-something-with updated-val)) I.e initialising updateable to 0. On Thu, Jun 11, 2009 at 8:38 PM, Adrian Cuthbertson wrote: > You could do something like; > > (let [updated-val (loop [updateable start-value line (.readline reader)] > (if (or (empty? line) (> line-num max-num)) > (+ updateable (somefunc)) > (recur (.readLine reader)] > (do-something with updated-val)) > > Rgds, Adrian. > > On Thu, Jun 11, 2009 at 8:34 PM, David Nolen wrote: >> Why isn't the following satisfactory for your needs? get-value takes a value >> returns a new value based on it. do-something can 'do something' to/with >> this new value. >> (defn get-value [start-value] >> (loop [updateable start-value line (.readline reader)] >> (if (or (empty? line) (> line-num max-num)) >> (+ updateable (somefunc)) >> (recur (.readLine reader) >> (defn do-something [] >> (let [updated-value (get-value 0)] >> (println updated-value)) >> On Thu, Jun 11, 2009 at 2:21 PM, Berlin Brown >> wrote: >>> >>> >>> >>> On Jun 11, 12:16 pm, Daniel Lyons wrote: >>> > On Jun 11, 2009, at 9:25 AM, BerlinBrown wrote: >>> > >>> > >>> > >>> > > I do this a lot but can't figure out to change the UPDATEABLE_VALUE, I >>> > > am using some pseudo code because I don't have a clojure solution yet. >>> > >>> > > SET UPDATEABLE_VALUE = 0 >>> > > (loop [line (.readLine reader)] >>> > > (if (or (empty? line) (> line-num max-num)) >>> > > SET UPDATEABLE_VALUE = UPDATEABLE_VALUE + (SOME_FUNC) >>> > > (recur (.readLine reader >>> > >>> > In general it's going to be something like this: >>> > >>> > (loop [line (.readLine reader) UPDATEABLE_VALUE 0] >>> > (if (or (empty? line) (> line-num max-num)) >>> > (recur (.readLine reader) (+ UPDATEABLE_VALUE (SOME_FUNC) >>> > >>> > Whenever you would have modified a local variable before, in FP you >>> > establish a new binding instead. >>> > >>> > — >>> > Daniel Lyonshttp://www.storytotell.org-- Tell It! >>> >>> I can modify the value within the loop, but what is a good approach >>> for accessing the value outside of the loop. For example (pseudo code >>> with a mix of procedural logic). >>> >>> ;; Init updateable value outside of 'loop' >>> SET UPDATEABLE_VALUE = 0 >>> (loop [line (.readLine reader)] >>> (if (or (empty? line) (> line-num max-num)) >>> SET UPDATEABLE_VALUE = UPDATEABLE_VALUE + (SOME_FUNC) >>> (recur (.readLine reader >>> ;; Now outside of the loop, use UPDATEABLE_VALUE with the mutated >>> value >>> (println UPDATEABLE_VALUE) >>> >>> >>> >>> >> >> >> >> >> > --~--~-~--~~~---~--~~ 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: catching exception error
The Clojure run time throws IllegalArgumentException in a lot of different places. It does also throw RuntimeException in several places. It traps exceptions generically (catch (Exception e), catch (Throwable t) ) and may have thrown a RuntimeException back to upper layers instead of the original\ IllegalArgumentException. Did you print the RuntimeException ? There might a be a text messages there that can tell us where it came from within the Clojure run time. Luc On Thu, 2009-06-11 at 10:12 -0700, peg wrote: > Hi clojurians, > > I was happily clojure-coding whent I tried to catch a exception in a > thrown deeply in a function. > > After looking for the fact that the IllegalArgumentException wasn't > catch, I added a catch RuntimeException to my catch list ... and that > worked of course. > > Here is the simplified case: > > (defn throw-error [arg] > (throw (IllegalArgumentException. (str arg > > (try > (let [ test > (into {} > (map (fn[x] (if (= 5 x) (throw-error x) [x x])) > [1 2 3 4 5])) ] >(str "NO PB " name)) > (catch IllegalArgumentException e (.getMessage e)) > (catch RuntimeException e (str "RT" (.getMessage e))) > ) > > If you comment the RuntimeException catch, the exception is not > catched. > > I don't understand why IllegalArgumentException is not catched ... > > Somebody could tell me ? > > Thanks > Phil > > > > > > Luc Préfontaine Armageddon was yesterday, today we have a real problem... --~--~-~--~~~---~--~~ 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: Simple idiom in clojure, mutate a value
Here's a fuller example of similar techniques extracted from a working program. It reads a file of lines and applies some transformations and accumulates a vector of records which it finally returns; (defn some-fn "Read a file and return a vector of its records." [fpath] (let [r (BufferedReader. (FileReader. (File. fpath)))] (try (let [line (.readLine r)] ; discard line 1 (loop [line (.readLine r) recs []] (if-not line recs (let [rec (do-something-with line) newrecs (conj recs rec)] (recur (.readLine r) newrec) (finally (.close r) On Thu, Jun 11, 2009 at 8:48 PM, Adrian Cuthbertson wrote: > Re-read your example - that should have been; > > (let [updated-val (loop [updateable 0 line (.readline reader)] > (if (or (empty? line) (> line-num max-num)) > (+ updateable (somefunc)) > (recur (.readLine reader)] > (do-something-with updated-val)) > > I.e initialising updateable to 0. > > > On Thu, Jun 11, 2009 at 8:38 PM, Adrian > Cuthbertson wrote: >> You could do something like; >> >> (let [updated-val (loop [updateable start-value line (.readline reader)] >> (if (or (empty? line) (> line-num max-num)) >> (+ updateable (somefunc)) >> (recur (.readLine reader)] >> (do-something with updated-val)) >> >> Rgds, Adrian. >> >> On Thu, Jun 11, 2009 at 8:34 PM, David Nolen wrote: >>> Why isn't the following satisfactory for your needs? get-value takes a value >>> returns a new value based on it. do-something can 'do something' to/with >>> this new value. >>> (defn get-value [start-value] >>> (loop [updateable start-value line (.readline reader)] >>> (if (or (empty? line) (> line-num max-num)) >>> (+ updateable (somefunc)) >>> (recur (.readLine reader) >>> (defn do-something [] >>> (let [updated-value (get-value 0)] >>> (println updated-value)) >>> On Thu, Jun 11, 2009 at 2:21 PM, Berlin Brown >>> wrote: On Jun 11, 12:16 pm, Daniel Lyons wrote: > On Jun 11, 2009, at 9:25 AM, BerlinBrown wrote: > > > > > I do this a lot but can't figure out to change the UPDATEABLE_VALUE, I > > am using some pseudo code because I don't have a clojure solution yet. > > > SET UPDATEABLE_VALUE = 0 > > (loop [line (.readLine reader)] > > (if (or (empty? line) (> line-num max-num)) > > SET UPDATEABLE_VALUE = UPDATEABLE_VALUE + (SOME_FUNC) > > (recur (.readLine reader > > In general it's going to be something like this: > > (loop [line (.readLine reader) UPDATEABLE_VALUE 0] > (if (or (empty? line) (> line-num max-num)) > (recur (.readLine reader) (+ UPDATEABLE_VALUE (SOME_FUNC) > > Whenever you would have modified a local variable before, in FP you > establish a new binding instead. > > — > Daniel Lyonshttp://www.storytotell.org-- Tell It! I can modify the value within the loop, but what is a good approach for accessing the value outside of the loop. For example (pseudo code with a mix of procedural logic). ;; Init updateable value outside of 'loop' SET UPDATEABLE_VALUE = 0 (loop [line (.readLine reader)] (if (or (empty? line) (> line-num max-num)) SET UPDATEABLE_VALUE = UPDATEABLE_VALUE + (SOME_FUNC) (recur (.readLine reader ;; Now outside of the loop, use UPDATEABLE_VALUE with the mutated value (println UPDATEABLE_VALUE) >>> >>> >>> >>> >>> >> > --~--~-~--~~~---~--~~ 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: Contributing to Clojure CLR.
Yes to all of the above. Github will always be the most current version. I'm rolling changes out to contrib on a less frequent basis. for, improve, post a pull on github is way to go. And CA definitely required. On Jun 11, 10:14 am, Rich Hickey wrote: > On Jun 11, 9:57 am, Paul Stadig wrote: > > > > > I believe David Miller is the one who wrote the CLR code, and he is still > > hacking on it when he has time. > > > In addition to what is checked into contrib there is also this: > > >http://github.com/dmiller/ClojureCLR/tree/master > > > I'm not sure if they are in sync or which is the most current (github may be > > it was last updated May 31). I suppose one possible workflow is to fork, > > improve, and set a pull request. > > > Paul > > > On Wed, Jun 10, 2009 at 10:25 PM, mmwaikar wrote: > > > > Hi, > > > > How can one contribute to the development of Clojure on CLR? > > > > I was trying the following - (.ToString DateTime/Now) and was getting > > > - "System.Exception: Unable to find static field: Now in > > > System.DateTime". > > > > I added some code in Reflector.cs, Compiler.cs and StaticFieldExpr.cs > > > and got it working, though I am not sure if the fixes are in the right > > > place. Please let me know if you want to have a look at my changes. > > > > Thanks, > > > Manoj. > > You will need a CA as well. > > Rich --~--~-~--~~~---~--~~ 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: Status of Clojure on .NET?
On Jun 11, 12:11 am, David Miller wrote: > Improving the performance of ClojureCLR is in the top two development > goals. (Porting to Mono is the other.) Are you familiar with Mono and the recent attempts from the Mono developers to make the VM more functional programming language friendly, e.g. coroutines? Miguel discusses it on his blog. I'd love to help you, but have my own projects on table right now. At best I might submit a patch as I comb over the source code. Also, I'll do my best to raise awareness of your project, hopefully nudging developers to the cause, and help out in that way for now. --~--~-~--~~~---~--~~ 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: Simple idiom in clojure, mutate a value
Adrian and David are suggesting how to work functionally, which is best when appropriate. Berlin, if you really need state modified over time, Clojure does this differently from most languages. Values never change, only references to values and only in controlled ways. Maybe what you want is a ref, see http://clojure.org/refs Something like this: (def x (ref 0)) (dosync ... (alter x inc)) (println @x) -Mike On Thu, Jun 11, 2009 at 11:21 AM, Berlin Brown wrote: > > > > On Jun 11, 12:16 pm, Daniel Lyons wrote: > > On Jun 11, 2009, at 9:25 AM, BerlinBrown wrote: > > > > > > > > > I do this a lot but can't figure out to change the UPDATEABLE_VALUE, I > > > am using some pseudo code because I don't have a clojure solution yet. > > > > > SET UPDATEABLE_VALUE = 0 > > > (loop [line (.readLine reader)] > > > (if (or (empty? line) (> line-num max-num)) > > > SET UPDATEABLE_VALUE = UPDATEABLE_VALUE + (SOME_FUNC) > > >(recur (.readLine reader > > > > In general it's going to be something like this: > > > > (loop [line (.readLine reader) UPDATEABLE_VALUE 0] > > (if (or (empty? line) (> line-num max-num)) > > (recur (.readLine reader) (+ UPDATEABLE_VALUE (SOME_FUNC) > > > > Whenever you would have modified a local variable before, in FP you > > establish a new binding instead. > > > > — > > Daniel Lyonshttp://www.storytotell.org-- Tell It! > > I can modify the value within the loop, but what is a good approach > for accessing the value outside of the loop. For example (pseudo code > with a mix of procedural logic). > > ;; Init updateable value outside of 'loop' > SET UPDATEABLE_VALUE = 0 > (loop [line (.readLine reader)] > (if (or (empty? line) (> line-num max-num)) > SET UPDATEABLE_VALUE = UPDATEABLE_VALUE + (SOME_FUNC) >(recur (.readLine reader > ;; Now outside of the loop, use UPDATEABLE_VALUE with the mutated > value > (println UPDATEABLE_VALUE) > > > > > > --~--~-~--~~~---~--~~ 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: Simple idiom in clojure, mutate a value
On Thu, Jun 11, 2009 at 3:03 PM, Adrian Cuthbertson wrote: > > Here's a fuller example of similar techniques extracted from a working > program. It reads a file of lines and applies some transformations and > accumulates a vector of records which it finally returns; > > (defn some-fn > "Read a file and return a vector of its records." > [fpath] > (let > [r (BufferedReader. (FileReader. (File. fpath)))] > (try > (let [line (.readLine r)] ; discard line 1 > (loop [line (.readLine r) recs []] > (if-not line recs > (let [rec (do-something-with line) > newrecs (conj recs rec)] > (recur (.readLine r) newrec) > (finally > (.close r) To test this I'm using: (import '(java.io File FileReader BufferedReader)) (defn do-something-with [line] (.toUpperCase line)) Note that (let [r ...] (try ... (finally (.close r is already packaged up in the with-open macro: (defn some-fn "Read a file and return a vector of its records." [fpath] (with-open [r (BufferedReader. (FileReader. (File. fpath)))] (.readLine r) ; discard line 1 (loop [line (.readLine r) recs []] (if-not line recs (let [rec (do-something-with line) newrecs (conj recs rec)] (recur (.readLine r) newrecs)) Also note that this is a great candidate for line-seq: (defn some-fn "Read a file and return a vector of its records." [fpath] (with-open [r (BufferedReader. (FileReader. (File. fpath)))] (vec (map do-something-with (next ; discard first line (line-seq r)) --Chouser --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
LWN article on clojure and vala
here: http://lwn.net/Articles/335966/ enjoy, Ray --~--~-~--~~~---~--~~ 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: Simple idiom in clojure, mutate a value
On Jun 11, 3:42 pm, Chouser wrote: > On Thu, Jun 11, 2009 at 3:03 PM, Adrian > > > > Cuthbertson wrote: > > > Here's a fuller example of similar techniques extracted from a working > > program. It reads a file of lines and applies some transformations and > > accumulates a vector of records which it finally returns; > > > (defn some-fn > > "Read a file and return a vector of its records." > > [fpath] > > (let > > [r (BufferedReader. (FileReader. (File. fpath)))] > > (try > > (let [line (.readLine r)] ; discard line 1 > > (loop [line (.readLine r) recs []] > > (if-not line recs > > (let [rec (do-something-with line) > > newrecs (conj recs rec)] > > (recur (.readLine r) newrec) > > (finally > > (.close r) > > To test this I'm using: > > (import '(java.io File FileReader BufferedReader)) > (defn do-something-with [line] (.toUpperCase line)) > > Note that (let [r ...] (try ... (finally (.close r is > already packaged up in the with-open macro: > > (defn some-fn > "Read a file and return a vector of its records." > [fpath] > (with-open [r (BufferedReader. (FileReader. (File. fpath)))] > (.readLine r) ; discard line 1 > (loop [line (.readLine r) recs []] > (if-not line > recs > (let [rec (do-something-with line) > newrecs (conj recs rec)] > (recur (.readLine r) newrecs)) > > Also note that this is a great candidate for line-seq: > > (defn some-fn > "Read a file and return a vector of its records." > [fpath] > (with-open [r (BufferedReader. (FileReader. (File. fpath)))] > (vec (map do-something-with > (next ; discard first line > (line-seq r)) > > --Chouser Yea, I think conj was what I was looking for. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Lazy load of imports
I have a Clojure applications with different files, different namespaces and I have imports of classes within those files/ namespaces. lets say (import java.io File) (import thepackage SomeClass) Is it possible to lazy load the imports of the class. For example, if I start my app, I will get an error if thepackage.SomeClass is unavailable. Even though I haven't instantiated an Object of SomeClass type. Is it possible to dynamically set a referance to SomeClass and then do the import. E.g. 1. Launch Clojure application 2. Do: Class.forName("thepackage.SomeClass") ... ... 3. and then do the lazy import of (import thepackage SomeClass) --~--~-~--~~~---~--~~ 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: PermGen OutOfMemory error
I haven't hit the permgen issue, but it sounds like I have a similar setup to you. Out of curiosity, how do you redeploy while compiling your .clj files? I typically connect via Slime and use slime-load- file, which I assume calls (load filename) Allen On Jun 11, 1:23 pm, hughw wrote: > On Jun 11, 11:38 am, Rob wrote: > > > Hi all, > > > I'm using Clojure for web apps inside Tomcat. If I don't compile > > my .clj files ahead of time, I will eventually get one of these > > OutOfMemory errors, after a number of redeployments. Is there > > something I can do about this? Is this a bug somewhere, in my code, > > or in Clojure, or in Tomcat; or a limitation of the JVM? > > PermGen space is where Sun's VM keeps class bytes. It's not garbage > collected, so if you keep adding classes to a running VM you will > eventally run out. We can only deploy a couple of times on our non- > clojure webapp, in Jboss + Tomcat. It's not unique to Clojure, but > it's true that generating classes on the fly can burn up permGen space > faster. Try increasng your PermGen space as a workaround. This arg > your jvm: > -XX:MaxPermGen=128m or so might help. > > Hugh > > > > > thanks, > > Rob > > > Here is the entire barfage from my Tomcat log: > > > Jun 11, 2009 12:01:57 PM org.apache.catalina.core.StandardWrapperValve > > invoke > > SEVERE: Servlet.service() for servlet ClojureServlet threw exception > > java.lang.NullPointerException > > at clojure.lang.Var.popThreadBindings(Var.java:289) > > at biz.encodia.webapps.webdispatch > > $make_dispatcher__3759$fn__3761.invoke(webdispatch.clj:90) > > at clojure.lang.Var.invoke(Var.java:350) > > at biz.encodia.webapps.ClojureServlet.processRequest > > (ClojureServlet.java:70) > > at biz.encodia.webapps.ClojureServlet.doGet > > (ClojureServlet.java:99) > > at javax.servlet.http.HttpServlet.service(HttpServlet.java: > > 617) > > at javax.servlet.http.HttpServlet.service(HttpServlet.java: > > 717) > > at > > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter > > (ApplicationFilterChain.java:290) > > at org.apache.catalina.core.ApplicationFilterChain.doFilter > > (ApplicationFilterChain.java:206) > > at org.apache.catalina.core.StandardWrapperValve.invoke > > (StandardWrapperValve.java:233) > > at org.apache.catalina.core.StandardContextValve.invoke > > (StandardContextValve.java:191) > > at org.apache.catalina.authenticator.AuthenticatorBase.invoke > > (AuthenticatorBase.java:433) > > at org.apache.catalina.core.StandardHostValve.invoke > > (StandardHostValve.java:128) > > at org.apache.catalina.valves.ErrorReportValve.invoke > > (ErrorReportValve.java:102) > > at org.apache.catalina.core.StandardEngineValve.invoke > > (StandardEngineValve.java:109) > > at org.apache.catalina.connector.CoyoteAdapter.service > > (CoyoteAdapter.java:286) > > at org.apache.coyote.http11.Http11Processor.process > > (Http11Processor.java:845) > > at org.apache.coyote.http11.Http11Protocol > > $Http11ConnectionHandler.process(Http11Protocol.java:583) > > at org.apache.tomcat.util.net.JIoEndpoint$Worker.run > > (JIoEndpoint.java:447) > > at java.lang.Thread.run(Thread.java:613) > > Jun 11, 2009 12:04:23 PM org.apache.catalina.core.ApplicationContext > > log > > SEVERE: StandardWrapper.Throwable > > java.lang.ExceptionInInitializerError > > at biz.encodia.webapps.ClojureServlet.loadDispatchCode > > (ClojureServlet.java:32) > > at biz.encodia.webapps.ClojureServlet.init(ClojureServlet.java: > > 49) > > at org.apache.catalina.core.StandardWrapper.loadServlet > > (StandardWrapper.java:1172) > > at org.apache.catalina.core.StandardWrapper.allocate > > (StandardWrapper.java:808) > > at org.apache.catalina.core.StandardWrapperValve.invoke > > (StandardWrapperValve.java:129) > > at org.apache.catalina.core.StandardContextValve.invoke > > (StandardContextValve.java:191) > > at org.apache.catalina.authenticator.AuthenticatorBase.invoke > > (AuthenticatorBase.java:433) > > at org.apache.catalina.core.StandardHostValve.invoke > > (StandardHostValve.java:128) > > at org.apache.catalina.valves.ErrorReportValve.invoke > > (ErrorReportValve.java:102) > > at org.apache.catalina.core.StandardEngineValve.invoke > > (StandardEngineValve.java:109) > > at org.apache.catalina.connector.CoyoteAdapter.service > > (CoyoteAdapter.java:286) > > at org.apache.coyote.http11.Http11Processor.process > > (Http11Processor.java:845) > > at org.apache.coyote.http11.Http11Protocol > > $Http11ConnectionHandler.process(Http11Protocol.java:583) > > at org.apache.tomcat.util.net.JIoEndpoint$Worker.run > > (JIoEndpoint.java:447) > > at java.lang.Thread.run(Thread.java:613) > > Caused by: java.lang.RuntimeException: java.lang.OutOfMemoryError: > > PermGen space (co
Re: Lazy load of imports
On Jun 11, 2009, at 2:30 PM, BerlinBrown wrote: I have a Clojure applications with different files, different namespaces and I have imports of classes within those files/ namespaces. I don't think the following is exactly what you're asking for, but you can use "clojure.contrib.core/new-by-name" to do something like what you described. Here's an example from clojure.contrib.miglayout.internal: (def MigLayout "net.miginfocom.swing.MigLayout") [...] (.setLayout (new-by-name MigLayout layout column row)) [...] Using this technique I was able to change clojure.contrib.miglayout's dependence on the miglayout jar from compile time to runtime. --Steve smime.p7s Description: S/MIME cryptographic signature
Re: How is Clojure API reference generated?
Rich posted the code he uses here: http://paste.lisp.org/display/77339 But note that he's building it in wiki markup and not html. HTH, Tom On Jun 9, 4:13 pm, Nicolas Buduroi wrote: > Hi, I'm wondering how Clojure API reference page is generated? I'd > like to adapt it for the future Compojure website if possible. On > another note, how is Clojure website built and what language/framework > does it use? > > Thanks > > - budu --~--~-~--~~~---~--~~ 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: Lazy load of imports
On Jun 11, 6:51 pm, "Stephen C. Gilardi" wrote: > On Jun 11, 2009, at 2:30 PM, BerlinBrown wrote: > > > I have a Clojure applications with different files, different > > namespaces and I have imports of classes within those files/ > > namespaces. > > I don't think the following is exactly what you're asking for, but you > can use "clojure.contrib.core/new-by-name" to do something like what > you described. > > Here's an example from clojure.contrib.miglayout.internal: > > (def MigLayout "net.miginfocom.swing.MigLayout") > > [...] > > (.setLayout (new-by-name MigLayout layout column row)) > > [...] > > Using this technique I was able to change clojure.contrib.miglayout's > dependence on the miglayout jar from compile time to runtime. > > --Steve > > smime.p7s > 3KViewDownload Now, that is close, not entirely but close enough. Do you think there will be any performance hits. --~--~-~--~~~---~--~~ 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: Lazy load of imports
On Jun 11, 2009, at 5:20 PM, Berlin Brown wrote: Now, that is close, not entirely but close enough. Cool. Do you think there will be any performance hits. I haven't run any tools on it. In looking around the reflection- related code in clojure.lang, it looks to me like the performance of new-by-name should be similar to that of other Clojure code that uses reflection rather than direct calls. --Steve smime.p7s Description: S/MIME cryptographic signature
Clojure Decompiled
I was looking for a way to make my understanding of Clojure's code generation more concrete. What actually does execute when you run a Clojure function? These are notes based on my talk at the Bay Area Clojure meetup last week: http://georgejahad.com/clojure/clojureDecompiled.html --~--~-~--~~~---~--~~ 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: (re)setting a function globally
The agreement is signed and in the (snail) mail. Also, I think I found a solution to the original problem that spurred this thread. In the test-is-adapter namespace I have added an expect macro that wraps the standard expect macro with a binding for the test- is specific report-problem function. So now when you want to use test- expect and test-is together, just :use all of test-expect excluding the expect macro, :use the expect macro from the test-is-adapter, :use test-is and you should be good to go. This way you should get the best of both worlds with no destructive global function changes. Go figure I come up with this after reading the entire "clojure modules" thread and starting a solution using deftemplate :) - Matt On Jun 11, 8:36 am, Stuart Halloway wrote: > Matt is signing the CA and I will be adding test-expect to contrib. > > Stu > > > > > > > Can I help from the test-is side? Could test-expect be added to > > clojure-contrib? > > -Stuart > > > On Jun 10, 1:36 pm, Matt Clark wrote: > >> Thanks for these ideas, I will give them a try tonight and update the > >> adapter namespace with the changes. If anyone knows of a more > >> idiomatic way I could have implemented the problem reporting > >> functionality that would prevent the necessity of these "hacky" > >> solutions, I'm all ears. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Date Adapter Utility
Hey everyone, I'm looking for feedback on a date utility library I'm writing. It's still early in it's design, and I want to see if other people see anything. It's designed to create various forms of date objects. It's available on github here: http://github.com/francoisdevlin/devlinsf-clojure-utils/tree/master Here is an except from docs/date-utils.markdown: namespace: lib.devlinsf.date-utils This library is designed to add a standard way to construct & wrap date objects in Clojure. It is intended to be a very broad purpose adapter. It depends on clojure.contrib.str-utils (defn date[& params] ...) This function is designed to create a java.util.Date object. ;This code was executed on June 11, 2009, near 7PM user=> (date) # The date method can also take a list of keywords followed by values user=> (date :year 1982) # Notice that the "unset" values default to the current time and date. user=> (date :year 1982 :month 2 :day 4) # Passing a map works just a easily: user=> (date {:year 1982 :month :2 :day 4}) # * Setting the Month * In the example above, notice that month 2 corresponds to March, not February. This is done to match the Java api. However, that's a PITA. The month field can also take a keyword. user=> (date :year 1982 :month :march :day 4) # Or, use the three letter shorthand: user=> (date :year 1982 :month :mar :day 4) # Much better! The complete list of month keywords: *Date Parsing* (Note: This parser currently only works for dates, not times.) How about creating a date from a string? user=> (date "3/4/1982") # user=> (date "3-4-1982") # Hmmm, this is good for Americans, but the rest of the world might prefer something else. No problem. (date "4/3/1982" :order [:day :month :year]) => Perfect! *nil behavior* This function returns nil if passed nil user=> (date nil) nil * Wrapping other time formats * This function can also accept other time formats and return them as java.util.Date objects. This method can take: *java.lang.Long user=> (date (. (date :year 1970) getTime)) # *java.util.Calendar user=> (date (java.util.GregorianCalendar. )) # *java.sql.Timestamp user=> (date (java.sql.Timestamp. (. (java.util.Date. ) getTime))) # *java.util.Date user=> (date (java.util.Date. )) # Each of the above functions "drills down" to the Long value, and builds a new Date object. This way changing the original object won't affect the new date record. *** The Awesome Part *** There are also four other methods in this library long-time (returns java.lang.Long) greg-cal(returns java.util.GregorianCalendar) sql-ts(returns java.sql.Timestamp) time-map (returns clojure.lang.PersistentHashMap) Each of these has the exact same signature as date. Every use of date shown above will work with these methods. For example, each of the following is valid: user=> (long-time) 1244764606423 user=> (greg-cal (date)) # user=> (sql-ts :year 1982 :month :march :day 4) # user=> (time-map "3/4/1982") {:minute 57, :hour-of-day 19, :day-of-week 5, :year 1982, :month 2, :day 4, :second 44, :ms 375} Each of these methods also drills down to the Long, so that there is no object linking. This also makes each of the methods a very versatile adapters. --~--~-~--~~~---~--~~ 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 is Clojure API reference generated?
Great, exactly what we needed! On Jun 11, 7:51 pm, Tom Faulhaber wrote: > Rich posted the code he uses here:http://paste.lisp.org/display/77339 > > But note that he's building it in wiki markup and not html. > > HTH, > > Tom > > On Jun 9, 4:13 pm, Nicolas Buduroi wrote: > > > Hi, I'm wondering how Clojure API reference page is generated? I'd > > like to adapt it for the future Compojure website if possible. On > > another note, how is Clojure website built and what language/framework > > does it use? > > > Thanks > > > - budu --~--~-~--~~~---~--~~ 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: Contributing to Clojure CLR.
What is CA? I've never used GitHub too so any help is greatly appreciated. On Jun 11, 3:24 pm, David Miller wrote: > Yes to all of the above. > > Github will always be the most current version. I'm rolling changes > out to contrib on a less frequent basis. > > for, improve, post a pull on github is way to go. > > And CA definitely required. > > On Jun 11, 10:14 am, Rich Hickey wrote: > > > On Jun 11, 9:57 am, Paul Stadig wrote: > > > > I believe David Miller is the one who wrote the CLR code, and he is still > > > hacking on it when he has time. > > > > In addition to what is checked into contrib there is also this: > > > >http://github.com/dmiller/ClojureCLR/tree/master > > > > I'm not sure if they are in sync or which is the most current (github may > > > be > > > it was last updated May 31). I suppose one possible workflow is to fork, > > > improve, and set a pull request. > > > > Paul > > > > On Wed, Jun 10, 2009 at 10:25 PM, mmwaikar wrote: > > > > > Hi, > > > > > How can one contribute to the development of Clojure on CLR? > > > > > I was trying the following - (.ToString DateTime/Now) and was getting > > > > - "System.Exception: Unable to find static field: Now in > > > > System.DateTime". > > > > > I added some code in Reflector.cs, Compiler.cs and StaticFieldExpr.cs > > > > and got it working, though I am not sure if the fixes are in the right > > > > place. Please let me know if you want to have a look at my changes. > > > > > Thanks, > > > > Manoj. > > > You will need a CA as well. > > > Rich --~--~-~--~~~---~--~~ 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: Contributing to Clojure CLR.
CA = Contributor Agreement. See http://clojure.org/contributing Github help is fairly extensive: http://github.com/guides/home On Jun 11, 8:28 pm, mmwaikar wrote: > What is CA? I've never used GitHub too so any help is greatly > appreciated. > > On Jun 11, 3:24 pm, David Miller wrote: > > > Yes to all of the above. > > > Github will always be the most current version. I'm rolling changes > > out to contrib on a less frequent basis. > > > for, improve, post a pull on github is way to go. > > > And CA definitely required. > > > On Jun 11, 10:14 am, Rich Hickey wrote: > > > > On Jun 11, 9:57 am, Paul Stadig wrote: > > > > > I believe David Miller is the one who wrote the CLR code, and he is > > > > still > > > > hacking on it when he has time. > > > > > In addition to what is checked into contrib there is also this: > > > > >http://github.com/dmiller/ClojureCLR/tree/master > > > > > I'm not sure if they are in sync or which is the most current (github > > > > may be > > > > it was last updated May 31). I suppose one possible workflow is to fork, > > > > improve, and set a pull request. > > > > > Paul > > > > > On Wed, Jun 10, 2009 at 10:25 PM, mmwaikar wrote: > > > > > > Hi, > > > > > > How can one contribute to the development of Clojure on CLR? > > > > > > I was trying the following - (.ToString DateTime/Now) and was getting > > > > > - "System.Exception: Unable to find static field: Now in > > > > > System.DateTime". > > > > > > I added some code in Reflector.cs, Compiler.cs and StaticFieldExpr.cs > > > > > and got it working, though I am not sure if the fixes are in the right > > > > > place. Please let me know if you want to have a look at my changes. > > > > > > Thanks, > > > > > Manoj. > > > > You will need a CA as well. > > > > Rich --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---