Re: generating a static method
.Bill Smith a écrit : > The genclass documentation says, "Static methods can be specified with > #^{:static true} in the signature's metadata." I thought that would > mean this: > > (ns tango.test.unit.StaticTest > (:gen-class > :methods [[f [] #^{:static true} void ]])) > > Try: (ns tango.test.unit.StaticTest (:gen-class :methods [#^{:static true} [f [] void ]])) (untested but that's where gen-class expects the metadata to be/) HTH Christophe -- Professional: http://cgrand.net/ (fr) On Clojure: http://clj-me.blogspot.com/ (en) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: generating a static method
Hi Christophe, It works as per your example, but not with arguments to the method... ns gncls.MyStatic (:gen-class :methods [#^{:static true} [f [String] void ]])) (defn -f [s] ; also [this s] doesn't work (prn "Hi from " s )) (gncls.MyStatic/f "me") java.lang.Exception: No such var: gncls.MyStatic/f (NO_SOURCE_FILE:2) On Tue, Mar 10, 2009 at 9:18 AM, Christophe Grand wrote: > > .Bill Smith a écrit : >> The genclass documentation says, "Static methods can be specified with >> #^{:static true} in the signature's metadata." I thought that would >> mean this: >> >> (ns tango.test.unit.StaticTest >> (:gen-class >> :methods [[f [] #^{:static true} void ]])) >> >> > > Try: > > (ns tango.test.unit.StaticTest > (:gen-class > :methods [#^{:static true} [f [] void ]])) > > > (untested but that's where gen-class expects the metadata to be/) > > HTH > > Christophe > > > -- > Professional: http://cgrand.net/ (fr) > On Clojure: http://clj-me.blogspot.com/ (en) > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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: version of -> short-circuiting on nil
Hello, 2009/3/10 Jason Wolfe > > > (let [person (get-the-person)] > > (when-not (nil? person) > > (let [address (.getAddress person)] > > (when-not (nil? address) > > (let [street (.getStreet address)] > > (when-not (nil? street) > >(do-something-finally-with-street street) > > > > > ?-> sounds potentially useful to me, but let me also point out that > you could simplify the above to: > > (when-let [person (get-the-person)] > (when-let [address (.getAddress person)] >(when-let [street (.getStreet address)] > (do-something-finally-with-street street > No, because here, you could also short-circuit on the value false , and not only nil. And it's definitely what I had in a first attempt, and wanted to avoid : having to think about variable names and add several nested levels of lets. > > Not quite > > (?-> (get-the-person) #(.getAddress %) #(.getStreet %) do-something) > > but it's halfway there at least. > > Info on contributing is here: > > http://clojure.org/contributing > > The first step is to get your CA signed and in the mail. > Yes you're right, I already have sent my CA, and will re-read this page. But I thought that before proposing something (even for clojure-contrib), it would be interesting to see if what I would like to propose sounds interesting to more than one person :-) and if somebody having commit rights on clojure-contrib informally accepts the contrib, before creating an issue with the patch attached ? > > Thanks, > Jason > > > > > --~--~-~--~~~---~--~~ 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 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: Question about instance?
On Mon, Mar 9, 2009 at 11:10 PM, Laurent PETIT wrote: > Hello, > > I have the use case for calling instance? where, once instance? returns > true, I want to do something with the successful instance, such as binding > it, or directly calling something on it. > > For instance, I have in my code : > > (let [console (.getConsole v)] > (when (instance? org.eclipse.debug.ui.console.IConsole console) > ... ...) > > Where I would like to really use when-let : > (when-let [console (instance? org.eclipse.debug.ui.console.IConsole > (.getConsole v))] > ... ...) > > For this to work, instance? would have to return logical true instead of > real true. > > Do you think it could be an interesting idea to change instance? in such a > way ? Or maybe there's already something similar in clojure-contrib I > haven't seen ? What about this case: (when-let [x (instance? java.lang.Boolean false)] (println x)) I think that should print 'true', and therefor I am against this proposal. > > Thanks in advance, > > -- > Laurent > > > > > -- Venlig hilsen / Kind regards, Christian Vest Hansen. --~--~-~--~~~---~--~~ 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 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: generating a static method
Adrian Cuthbertson a écrit : > Hi Christophe, > > It works as per your example, but not with arguments to the method... > > ns gncls.MyStatic > (:gen-class > :methods [#^{:static true} [f [String] void ]])) > > (defn -f > [s] ; also [this s] doesn't work > (prn "Hi from " s )) > > (gncls.MyStatic/f "me") > java.lang.Exception: No such var: gncls.MyStatic/f (NO_SOURCE_FILE:2 Hmm, the exception says it is looking for gncls.MyStatic/f, not for gncls.MyStatic/-f, it hints me that you are not going through the static method at all but directly to the function through the namespace gncls.MyStatix. Try and contrast: (ns gncls.MyStatic (:gen-class :methods [#^{:static true} [f [String] void ]])) (defn -f [s] (prn "Hi " s "from -f")) (defn f [s] (prn "Hi " s "from f")) (gncls.MyStatic/f "me") ; should print "Hi me from f" (. gncls.MyStatic f "me") ; should print "Hi me from -f" a/b both means function b in ns a and static method b in class a, when you have both a ns and a class going by the same name the ns wins. Christophe -- Professional: http://cgrand.net/ (fr) On Clojure: http://clj-me.blogspot.com/ (en) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Is proxy the right tool for this job ? Cyclic vector ? Proxy bug ?
> I really don't know why you are trying to dissuade Paul in all this. I was (stupidly) wrong. Sorry Paul for the misinformation. --~--~-~--~~~---~--~~ 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 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: Question about instance?
How about a cast variant that doesn't throw an exception but returns nil? user=> (cast java.lang.Boolean false) false user=> (cast java.lang.Integer false) java.lang.ClassCastException (NO_SOURCE_FILE:0) user=> (defn instance [c i] (try (cast c i) (catch Exception e))) #'user/instance user=> (instance java.lang.Boolean false) false user=> (instance java.lang.Integer false) nil Regards, Tim. On Mar 10, 7:15 pm, Christian Vest Hansen wrote: > On Mon, Mar 9, 2009 at 11:10 PM, Laurent PETIT > wrote: > > Hello, > > > I have the use case for calling instance? where, once instance? returns > > true, I want to do something with the successful instance, such as binding > > it, or directly calling something on it. > > > For instance, I have in my code : > > > (let [console (.getConsole v)] > > (when (instance? org.eclipse.debug.ui.console.IConsole console) > > ... ...) > > > Where I would like to really use when-let : > > (when-let [console (instance? org.eclipse.debug.ui.console.IConsole > > (.getConsole v))] > > ... ...) > > > For this to work, instance? would have to return logical true instead of > > real true. > > > Do you think it could be an interesting idea to change instance? in such a > > way ? Or maybe there's already something similar in clojure-contrib I > > haven't seen ? > > What about this case: > > (when-let [x (instance? java.lang.Boolean false)] (println x)) > > I think that should print 'true', and therefor I am against this proposal. > > > > > Thanks in advance, > > > -- > > Laurent > > -- > Venlig hilsen / Kind regards, > Christian Vest Hansen. --~--~-~--~~~---~--~~ 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 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: What is Clojure NOT good for?
On Tue, Mar 10, 2009 at 12:17 AM, bOR_ wrote: > > I'm not from the software engineers field, but how difficult is it for > some non-lisp, but java-savvy software writer to pick up a 600-line > clojure program and learn to understand it? I think the majority of Java programmers will be able to pull that off, but it will take a good deal longer than the equivalent 2000-line Java program. Also, how do you think this increase in required effort grows? What if we are talking about a +10.000-line Clojure program? Now add schedule pressure, deadlines and the cost of missed oppotunities and you will find that many companies sees the introduction of a new programming language - especially if it is uncontrolled or happens without their knowledge - as a significant risk. > I mean, everyone in this > forum managed to learn clojure to some degree without too much > trouble.. including me. If there is a function the poor software > engineer doesn't know about, there is excellent documentation > available (unlike, for example for K, where your documentation is the > source code in Q), there's this google group, and there is irc. > > I am a scientist, and I seem to manage fine. Someone who programs for > a living should be able to fix a program that is broken in whatever > language relatively easy. "Relative" as in opposed to someone who does not program at all? ;) You may find it hard to pursuade an off-the-street VB hacker to fix bugs in your K code :) > > On Mar 9, 6:08 pm, Jay Fields wrote: >> I've lived through this discussion for the past 3 years while writing web >> applications using Ruby and Rails. Here's what I've learned: >> >> - Using a language that the average stupid programmer can't understand >> virtually guarantees that you'll increase your success chances, since you >> and your team-mates will be of a higher caliber. > > > > -- Venlig hilsen / Kind regards, Christian Vest Hansen. --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
How to find lazy discards
How to implement a check for: (my-fun [] (map x y) 5) Visually you can see that map is probably the wrong thing in this case (I can't think of a valid scenario where it would be right)... just by virtue that the lazy is not returned or passed to a function. Regards, Tim. --~--~-~--~~~---~--~~ 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 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: Question about instance?
On Tue, Mar 10, 2009 at 9:40 AM, Timothy Pratley wrote: > > How about a cast variant that doesn't throw an exception but returns > nil? > > user=> (cast java.lang.Boolean false) > false > user=> (cast java.lang.Integer false) > java.lang.ClassCastException (NO_SOURCE_FILE:0) > user=> (defn instance [c i] (try (cast c i) (catch Exception e))) > #'user/instance > user=> (instance java.lang.Boolean false) > false > user=> (instance java.lang.Integer false) > nil That's a better idea. You might want to consider calling it 'coerce' instead of 'instance' - I think that name is clearer and fits the intent better. > > > Regards, > Tim. > > > On Mar 10, 7:15 pm, Christian Vest Hansen > wrote: >> On Mon, Mar 9, 2009 at 11:10 PM, Laurent PETIT >> wrote: >> > Hello, >> >> > I have the use case for calling instance? where, once instance? returns >> > true, I want to do something with the successful instance, such as binding >> > it, or directly calling something on it. >> >> > For instance, I have in my code : >> >> > (let [console (.getConsole v)] >> > (when (instance? org.eclipse.debug.ui.console.IConsole console) >> > ... ...) >> >> > Where I would like to really use when-let : >> > (when-let [console (instance? org.eclipse.debug.ui.console.IConsole >> > (.getConsole v))] >> > ... ...) >> >> > For this to work, instance? would have to return logical true instead of >> > real true. >> >> > Do you think it could be an interesting idea to change instance? in such a >> > way ? Or maybe there's already something similar in clojure-contrib I >> > haven't seen ? >> >> What about this case: >> >> (when-let [x (instance? java.lang.Boolean false)] (println x)) >> >> I think that should print 'true', and therefor I am against this proposal. >> >> >> >> > Thanks in advance, >> >> > -- >> > Laurent >> >> -- >> Venlig hilsen / Kind regards, >> Christian Vest Hansen. > > > -- Venlig hilsen / Kind regards, Christian Vest Hansen. --~--~-~--~~~---~--~~ 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 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: What is Clojure NOT good for?
> Also, how do you think this increase in required effort grows? What if > we are talking about a +10.000-line Clojure program? Now add schedule > pressure, deadlines and the cost of missed oppotunities and you will > find that many companies sees the introduction of a new programming > language - especially if it is uncontrolled or happens without their > knowledge - as a significant risk. > Haven't written anything larger in clojure than 600 lines yet, and I'm tempted to clean that one up to reduce it back to 400'ish. Isn't 10.000 lines in a clojure program an indication that something is going wrong and you might need to look for a better way of solving your problem? K is a disaster :), but I just looked at it as something fun to toy with.. not much unlike a new computer game or something. --~--~-~--~~~---~--~~ 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 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: Question about instance?
Laurent PETIT writes: Hi Laurent, > For this to work, instance? would have to return logical true instead > of real true. I'm new to clojure, so please forgive any stupid questions. But you mean that (instance? java.lang.Integer 17) should return 17 instead of true, right? Seems plausible, but there's this corner case: (instance? java.lang.Boolean false) If it returned false, then instance? would be broken. So I guess the current behavior is correct. Maybe this can act as a workaround: --8<---cut here---start->8--- user> (defn maybe-print-int [n] (when-let [i (and (instance? java.lang.Integer n) n)] (println "Foo" i))) #'user/maybe-print-int user> (maybe-print-int 17) Foo 17 nil user> (maybe-print-int "A String") nil --8<---cut here---end--->8--- Bye, Tassilo --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
New in the group and question about Java interaction
Hello, I'd like to thank you for providing us Clojure. This is fantastic. My background in Lisp if for several years now, just for fun, and using Common Lisp, mainly. I have some programs in Java, and would like to use Clojure to test/develop them. My question is: Is it easy to test/load Java code in real time in Clojure while developing it? For example, I have a bunch of classes I want to continue developing in Java, while other parts are made in Clojure. Is it possible to test my modifications of the Java part in Clojure in real time? I'm using Netbeans. --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
Two quick questions on functions...
I'm relatively new to Clojure, and I just want to make sure I understand things correctly. There are two issues that I'm struggling with. Neither is major, but if there is a good solution, I'd like to find out. 1) You must define a method before you call it from another function. Stylistically, I prefer to define helper functions after the main function, but that seems to cause errors. If I move them in front of the main function, the errors go away. I don't know if there's some way to declare the methods before you define them (like C header files). 2) To have two or more functions with the same name and a different arity, you must define them in a single (defn...). For example, the following code: (defn good ([a] (println (str "argument: " a))) ([a, b] (println (str "arguments: " a ", " b (defn bad [a] (str "argument: " a)) (defn bad [a b] (str "arguments:" a ", " b)) (good "foo") (good "foo" "bar") (bad "foo") (bad "foo" "bar") Generates the following output: argument: foo arguments: foo, bar Exception in thread "main" java.lang.IllegalArgumentException: Wrong number of args passed to: core$bad (SandBox.clj:0) This crops up when I have a function that was created using a function- building macro, and I wanted to define a wrapper with the same name that allowed me to enter the arguments in a simpler manner. Also, it just feels odd. You don't get an error when defining the same- named function--but suddenly neither version works. That's a pretty serious side-effect. So maybe this is just a bug? Thanks, -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 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: Two quick questions on functions...
Hi Rich, for your first issue "declare" does exactly what you want. => (doc declare) - clojure.core/declare ([& names]) Macro defs the supplied var names with no bindings, useful for making forward declarations. nil Cheers, Paul. 2009/3/10 Rich : > > I'm relatively new to Clojure, and I just want to make sure I > understand things correctly. There are two issues that I'm struggling > with. Neither is major, but if there is a good solution, I'd like to > find out. > > 1) You must define a method before you call it from another function. > Stylistically, I prefer to define helper functions after the main > function, but that seems to cause errors. If I move them in front of > the main function, the errors go away. I don't know if there's some > way to declare the methods before you define them (like C header > files). > > 2) To have two or more functions with the same name and a different > arity, you must define them in a single (defn...). > > For example, the following code: > > (defn good > ([a] (println (str "argument: " a))) > ([a, b] (println (str "arguments: " a ", " b > > (defn bad [a] (str "argument: " a)) > (defn bad [a b] (str "arguments:" a ", " b)) > > > (good "foo") > (good "foo" "bar") > (bad "foo") > (bad "foo" "bar") > > Generates the following output: > > argument: foo > arguments: foo, bar > Exception in thread "main" java.lang.IllegalArgumentException: Wrong > number of args passed to: core$bad (SandBox.clj:0) > > This crops up when I have a function that was created using a function- > building macro, and I wanted to define a wrapper with the same name > that allowed me to enter the arguments in a simpler manner. > > Also, it just feels odd. You don't get an error when defining the same- > named function--but suddenly neither version works. That's a pretty > serious side-effect. So maybe this is just a bug? > > Thanks, > > -Rich- > > > > > -- Iode Software Ltd, registered in England No. 6299803. Registered Office Address: 12 Sancroft Drive, Houghton-le-Spring, Tyne & Wear, DH5 8NE. This message is intended only for the use of the person(s) ("the intended recipient(s)") to whom it is addressed. It may contain information which is privileged and confidential within the meaning of applicable law. If you are not the intended recipient, please contact the sender as soon as possible. The views expressed in this communication may not necessarily be the views held by The Company. --~--~-~--~~~---~--~~ 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 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: Question about instance?
Thank you both, those are indeed good points. I'm not sure if I prefer coerce over cast, because (but I may be wrong), coerce implies to me some conversion. And, indeed, cast already exists in clojure, which I hadn't seen. Is there a strong requirement for cast throwing an exception rather than just returning nil ? -- Laurent 2009/3/10 Christian Vest Hansen > > On Tue, Mar 10, 2009 at 9:40 AM, Timothy Pratley > wrote: > > > > How about a cast variant that doesn't throw an exception but returns > > nil? > > > > user=> (cast java.lang.Boolean false) > > false > > user=> (cast java.lang.Integer false) > > java.lang.ClassCastException (NO_SOURCE_FILE:0) > > user=> (defn instance [c i] (try (cast c i) (catch Exception e))) > > #'user/instance > > user=> (instance java.lang.Boolean false) > > false > > user=> (instance java.lang.Integer false) > > nil > > That's a better idea. You might want to consider calling it 'coerce' > instead of 'instance' - I think that name is clearer and fits the > intent better. > > > > > > > Regards, > > Tim. > > > > > > On Mar 10, 7:15 pm, Christian Vest Hansen > > wrote: > >> On Mon, Mar 9, 2009 at 11:10 PM, Laurent PETIT > wrote: > >> > Hello, > >> > >> > I have the use case for calling instance? where, once instance? > returns > >> > true, I want to do something with the successful instance, such as > binding > >> > it, or directly calling something on it. > >> > >> > For instance, I have in my code : > >> > >> > (let [console (.getConsole v)] > >> > (when (instance? org.eclipse.debug.ui.console.IConsole console) > >> >... ...) > >> > >> > Where I would like to really use when-let : > >> > (when-let [console (instance? org.eclipse.debug.ui.console.IConsole > >> > (.getConsole v))] > >> > ... ...) > >> > >> > For this to work, instance? would have to return logical true instead > of > >> > real true. > >> > >> > Do you think it could be an interesting idea to change instance? in > such a > >> > way ? Or maybe there's already something similar in clojure-contrib I > >> > haven't seen ? > >> > >> What about this case: > >> > >> (when-let [x (instance? java.lang.Boolean false)] (println x)) > >> > >> I think that should print 'true', and therefor I am against this > proposal. > >> > >> > >> > >> > Thanks in advance, > >> > >> > -- > >> > Laurent > >> > >> -- > >> Venlig hilsen / Kind regards, > >> Christian Vest Hansen. > > > > > > > > > -- > Venlig hilsen / Kind regards, > Christian Vest Hansen. > > > > --~--~-~--~~~---~--~~ 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 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: Two quick questions on functions...
On Mar 9, 2009, at 11:11 PM, Rich wrote: > 1) You must define a method before you call it from another function. > Stylistically, I prefer to define helper functions after the main > function, but that seems to cause errors. If I move them in front of > the main function, the errors go away. I don't know if there's some > way to declare the methods before you define them (like C header > files). > Don't know about this one. It's been bugging me too. > 2) To have two or more functions with the same name and a different > arity, you must define them in a single (defn...). > Correct. > For example, the following code: > > (defn good > ([a] (println (str "argument: " a))) > ([a, b] (println (str "arguments: " a ", " b > > (defn bad [a] (str "argument: " a)) > (defn bad [a b] (str "arguments:" a ", " b)) > > > (good "foo") > (good "foo" "bar") > (bad "foo") > (bad "foo" "bar") > > Generates the following output: > > argument: foo > arguments: foo, bar > Exception in thread "main" java.lang.IllegalArgumentException: Wrong > number of args passed to: core$bad (SandBox.clj:0) > > This crops up when I have a function that was created using a > function- > building macro, and I wanted to define a wrapper with the same name > that allowed me to enter the arguments in a simpler manner. > > Also, it just feels odd. You don't get an error when defining the > same- > named function--but suddenly neither version works. That's a pretty > serious side-effect. So maybe this is just a bug? > What happens if you flip you 2 tests of "bad". (I'll bet it's exactly what you expect to happen.) Aloha, David Sletten --~--~-~--~~~---~--~~ 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 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: Question about instance?
Hello, yes, you are right, for the change to be correct, instance? should not return false, but nil if it is not an instance. (nil is a logical false too). But maybe, as was suggested by others, just having a variant of cast returning nil instead of throwing an exception (or making returning nil the new behavior of cast) could serve the purpose as well, and maybe even better. 2009/3/10 Tassilo Horn > > Laurent PETIT writes: > > Hi Laurent, > > > For this to work, instance? would have to return logical true instead > > of real true. > > I'm new to clojure, so please forgive any stupid questions. But you > mean that (instance? java.lang.Integer 17) should return 17 instead of > true, right? Seems plausible, but there's this corner case: > > (instance? java.lang.Boolean false) > > If it returned false, then instance? would be broken. So I guess the > current behavior is correct. Maybe this can act as a workaround: > > --8<---cut here---start->8--- > user> (defn maybe-print-int [n] > (when-let [i (and (instance? java.lang.Integer n) n)] > (println "Foo" i))) > #'user/maybe-print-int > user> (maybe-print-int 17) > Foo 17 > nil > user> (maybe-print-int "A String") > nil > --8<---cut here---end--->8--- > > Bye, > Tassilo > > > > --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
contrib api documentation?
Hi, is there a place where I can find the documentation of clojure.contrib in the same vein as clojure.core is documented at http://clojure.org/API ? Thanks Raphaël --~--~-~--~~~---~--~~ 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 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: letfn - mutually recursive local functions
On Feb 28, 2009, at 2:38 PM, Rich Hickey wrote: > > I've added letfn, which lets you define mutually recursive local > functions a la CL's labels. > > (defn ring [n] > (letfn [(a [n] (if (zero? n) n (b (dec n > (b [n] (if (zero? n) n (c (dec n > (c [n] (if (zero? n) n (a (dec n] > (c n))) > > (ring 1000) > > Note this is still subject to stack limits, i.e. no TCO, so please > don't report your StackOverflowErrors. Useful for bounded data only. > Do you advocate usage of 'letfn' and 'let' similar to the distinction between LABELS and FLET in CL? In other words, FLET implies non- recursive local function definition whereas LABELS suggests (mutually) recursive function(s). So, (letfn [(f [x] (+ x 2))] (f 8)) ; LABELS should ideally be: (let [f (fn [x] (+ x 2))] (f 8)) ; FLET Aloha, David Sletten --~--~-~--~~~---~--~~ 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 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: New in the group and question about Java interaction
In general, no -- in a typical project setup, any changes to Java code precipitate a rebuild and a restart of your application. There are plenty of ways to avoid this, but currently, they're only used in the major IDEs when debugging (e.g. while debugging an application, you can usually make various changes to java code, and then load those changes into the running application without restarting). This is accomplished by bootstrapping the application with a custom classloader (or, more likely, many, many classloaders) that allows the IDE to replace bytecode at various levels of granularity (class, method, etc). In my experience, eclipse is much better at this than netbeans, although the latter should approach parity with the 6.7 release if I've read the tea leaves properly. I know of people who have used JavaRebel (http://www.zeroturnaround.com/javarebel/ ) to implement this kind of hot code reloading in a production environment; apparently, it works quite well. You could try using it yourself -- it appears to be free for personal and open-source development. How it will interact with clojure and the details of its classloader-related implementation is anyone's guess. - Chas On Mar 10, 2009, at 2:01 AM, Javier wrote: > > Hello, I'd like to thank you for providing us Clojure. This is > fantastic. > > My background in Lisp if for several years now, just for fun, and > using > Common Lisp, mainly. > I have some programs in Java, and would like to use Clojure to > test/develop them. My question is: > > Is it easy to test/load Java code in real time in Clojure while > developing it? For example, I have a bunch of classes I want to > continue > developing in Java, while other parts are made in Clojure. Is it > possible to test my modifications of the Java part in Clojure in > real time? > > I'm using Netbeans. > > > > --~--~-~--~~~---~--~~ 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 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: contrib api documentation?
This is a pretty nice reference: http://clj-doc.s3.amazonaws.com/tmp/doc-1116/index.html A little old now, though. The tool that generated it is open-source (on github, I think), so refreshing it for yourself shouldn't be too difficult. - Chas On Mar 10, 2009, at 6:16 AM, rb wrote: > > Hi, > > is there a place where I can find the documentation of clojure.contrib > in the same vein as clojure.core is documented at http://clojure.org/API > ? > > Thanks > > Raphaël > > --~--~-~--~~~---~--~~ 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 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: Two quick questions on functions...
Rich wrote: > I'm relatively new to Clojure, and I just want to make sure I > understand things correctly. There are two issues that I'm struggling > with. Neither is major, but if there is a good solution, I'd like to > find out. > > 1) You must define a method before you call it from another function. > Stylistically, I prefer to define helper functions after the main > function, but that seems to cause errors. If I move them in front of > the main function, the errors go away. I don't know if there's some > way to declare the methods before you define them (like C header > files). > The two strategies I've seen before are either to use (declare foo), or to put your helpers into another file/namespace, and then :use that namespace when you open the primary namespace that will use them. > 2) To have two or more functions with the same name and a different > arity, you must define them in a single (defn...). > > This crops up when I have a function that was created using a function- > building macro, and I wanted to define a wrapper with the same name > that allowed me to enter the arguments in a simpler manner. > > Also, it just feels odd. You don't get an error when defining the same- > named function--but suddenly neither version works. That's a pretty > serious side-effect. So maybe this is just a bug? > This might make more sense if you understand how namespaces, vars and functions work in Clojure. If you haven't read about those in the documentation and/or watched the videos on http://clojure.blip.tv, those are good places to start. In short: (defn foo [a] (println "argument a: " a)) is equivalent to: (def foo (fn [a] (println "argument a: " a))) So it has to do with the way things are organized. When you use (def ...) it will assign a value to a var in the current namespace. (Which, FYI, you can always find by looking at *ns*.) So you can always assign a var using def. Try it on the repl. You can (def foo 1) and then (def foo 2). This is why you don't have problems when you (defn foo) multiple times. That at least explains why it works that way. In general, I think rather than trying to adapt a new language and its associated culture to your old habits, it is more enjoyable and educational to adapt yourself to the new culture. Try looking through core.clj in the clojure source and reading over stuff in clojure-contrib. When I'm wondering how to do something or what is typical in Clojure land the first thing I do is grep around in those two places, then google, then ask on IRC or the mailing list. It seems to work. Cheers, Jeff --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
swank-clojure-extra-classpaths troubles
Hi all, to get started with Clojure I've bought the PDF version of "Programming Clojure". But I don't get how I have to setup swank-clojure in order to make the examples work. I tried both --8<---cut here---start->8--- (swank-clojure-config (add-to-list 'swank-clojure-extra-classpaths "/home/horn/repos/programming-clojure/")) --8<---cut here---end--->8--- and --8<---cut here---start->8--- (swank-clojure-config (add-to-list 'swank-clojure-extra-classpaths "/home/horn/repos/programming-clojure/examples/")) --8<---cut here---end--->8--- in my .emacs where the examples lay as *.clj files in /home/horn/repos/programming-clojure/examples/ Now when I do user> (require 'examples.introduction) I get this exception: , | java.io.FileNotFoundException: Could not locate \ | examples/introduction__init.class or \ | examples/introduction.clj on classpath: (NO_SOURCE_FILE:0) | [Thrown class clojure.lang.Compiler$CompilerException] ` When I use the repl.sh script that comes with the examples and start it from /home/horn/repos/programming-clojure/ it works (. is in the -cp argument), but I guess that's exactly what those extra classpaths of clojure-swank are meant for. Is this a bug in swank-clojure? (And if so, is that the right place to ask for help with clojure tool support anyway?) Bye and thanks for any pointers, Tassilo --~--~-~--~~~---~--~~ 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 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 can I make the smallest structure possible?
Arrays also have some overhead though so if your "objects" are all of equal size you could use just one array (of ints?) for all of them and create functions for indexing correctly in your array. A bit brittle but very space efficient. Of course this throws all of the benefits of Clojure or even Java out the window, it's like plain old address arithmetic in C ;) On Mar 9, 9:17 pm, Stuart Sierra wrote: > Java doesn't have a C-like structure type, so Java objects still have > overhead. If you want the absolute minimum number of bytes in memory, > you can create Java primitive arrays in Clojure: > > (make-array Integer/TYPE 100) > > Then access them with the "aset..." and "aget" functions. > > -Stuart Sierra > > On Mar 9, 1:04 pm, Bradbev wrote: > > > I'm writing a program that will have millions of small structures in > > it. If I were writing in C (or Java I guess), I estimate the object > > size to be about 40 bytes. In Clojure, using a struct map I've made a > > rough measure & I think that the objects are weighing in at about > > 200bytes. > > > 1) I know that my measurement methods suck (cons up a big list, look > > at the total usage count & try to adjust for list overhead) - is there > > a good way that I can measure the size in memory of my structmap? > > 2) Is there a good way to optimize the size of these objects in > > Clojure? I'd prefer to stay within Clojure, but my current plan to > > squeeze the smallest size out is to move to a Java object. > > > I also know the types of the struct members, and most of them are > > 32bit numbers. Eliminating dynamic types from the struct is probably > > important for overall size. > > > Any thoughts? > > > Cheers, > > Brad --~--~-~--~~~---~--~~ 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 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: (ancestors ClassName) does not include tag ancestors of ClassName's superclasses
FWIW, a version of ancestors that exhibits proper (IMO) behaviour: (defn ancestors ([tag] (ancestors global-hierarchy tag)) ([h tag] (not-empty (let [ta (get (:ancestors h) tag)] (if (class? tag) (let [superclasses (set (supers tag))] (apply clojure.set/union ta superclasses (map #(get (:ancestors h) %) superclasses))) ta) - Chas --~--~-~--~~~---~--~~ 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 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: New in the group and question about Java interaction
Thank you for your response. I'm actually using BeanShell for doing most of this stuff, as it provides reloadClasses(), wich allows a very fast reloading of every change (anyway, changes in code which is actually in use are not propagated, but this is an expected issue). I'll have a glance to the link you provide. One more question: is there a way to call a function similar to reloadClasses in Clojure? If so, it would be my solution. On 10 mar, 11:44, Chas Emerick wrote: > In general, no -- in a typical project setup, any changes to Java code > precipitate a rebuild and a restart of your application. > > There are plenty of ways to avoid this, but currently, they're only > used in the major IDEs when debugging (e.g. while debugging an > application, you can usually make various changes to java code, and > then load those changes into the running application without > restarting). This is accomplished by bootstrapping the application > with a custom classloader (or, more likely, many, many classloaders) > that allows the IDE to replace bytecode at various levels of > granularity (class, method, etc). In my experience, eclipse is much > better at this than netbeans, although the latter should approach > parity with the 6.7 release if I've read the tea leaves properly. > > I know of people who have used JavaRebel > (http://www.zeroturnaround.com/javarebel/ > ) to implement this kind of hot code reloading in a production > environment; apparently, it works quite well. You could try using it > yourself -- it appears to be free for personal and open-source > development. How it will interact with clojure and the details of its > classloader-related implementation is anyone's guess. > > - Chas > > On Mar 10, 2009, at 2:01 AM, Javier wrote: > > > > > Hello, I'd like to thank you for providing us Clojure. This is > > fantastic. > > > My background in Lisp if for several years now, just for fun, and > > using > > Common Lisp, mainly. > > I have some programs in Java, and would like to use Clojure to > > test/develop them. My question is: > > > Is it easy to test/load Java code in real time in Clojure while > > developing it? For example, I have a bunch of classes I want to > > continue > > developing in Java, while other parts are made in Clojure. Is it > > possible to test my modifications of the Java part in Clojure in > > real time? > > > I'm using Netbeans. --~--~-~--~~~---~--~~ 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 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: Static type guy trying to convert
Timothy Pratley wrote: > Jump on in! Just like with swimming the cold soon goes away. [...] Bad analogy. In swimming, the cold returns about half an hour later :) Gavin --~--~-~--~~~---~--~~ 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 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: generating a static method
That worked. Thank you for your help, Christophe. Bill Smith, Austin, TX --~--~-~--~~~---~--~~ 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 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: Static type guy trying to convert
Here's my feeling on it (note that I am talking about languages from the C family, not Haskell or ML). 1. Like Jason Wolfe said, the interactive REPL means that you can manually test a function as soon as you're done writing it, so it's easy to get feedback and know if something breaks. 2. The whole thing does not need to be complete or even functional for you to start unit testing. 3. The type systems of Java, C and C++ do not protect you against errors like NullPointerExceptions. (I am pretty sure C# has nullable types now, and of course Haskell has Maybe t.) 4. Not having the static type system means that if it's ever needed, it will be possible for you to do what you know is right instead of what the compiler wants. Try it, test a lot, use the REPL and you'll probably find that the problem is not as bad as one may think. Nevertheless, I'd like to mention that I'm also a fan of static typing and that to this day, I still don't know whether I prefer the freedom and flexibility of dynamic typing or the constraint and safety of static typing. Be safe, Vincent. On Mar 10, 1:16 am, zoltar wrote: > Hey everyone. I've been keeping up with developments in Clojure for a > few months now and have a question for all you long-time static typers > out there (I know you're there :) > > I really like what I read about Clojure and LISP in general and can > see the potential for great power and flexibility. I know the > advantages/disadvantages of static vs dynamic languages but I can't > help feeling like I'm losing something whenever I try Clojure. I am > admittedly brainwashed after years of C, C++ and Java but I miss the > warm fuzzies when I know the compiler has checked all the types for me > and I don't have to worry about a whole class of run-time errors. I'm > willing to give that up for the advantages Clojure gives me but I was > wondering how others have dealt with the loss of these static warm > fuzzies. I always feel a bit lost in Clojure, not knowing what types a > function expects or what it will return. I suppose this goes away in > time but any advice is appreciated. > > Curtis --~--~-~--~~~---~--~~ 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 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: contrib api documentation?
On Mar 10, 11:47 am, Chas Emerick wrote: > This is a pretty nice reference: > > http://clj-doc.s3.amazonaws.com/tmp/doc-1116/index.html Nice, especially after you update the css to have #doc-items position set to fixed :-) > > A little old now, though. The tool that generated it is open-source > (on github, I think), so refreshing it for yourself shouldn't be too > difficult. Didn't find the link rapidly, I'll look further later. Thanks for your help! Raph > > - Chas > > On Mar 10, 2009, at 6:16 AM, rb wrote: > > > > > Hi, > > > is there a place where I can find the documentation of clojure.contrib > > in the same vein as clojure.core is documented athttp://clojure.org/API > > ? > > > Thanks > > > Raphaël --~--~-~--~~~---~--~~ 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 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: New in the group and question about Java interaction
> One more question: is there a way to call a function similar to > reloadClasses in Clojure? If so, it would be my solution. Yep, I work with a multi-tab console with a rlwrap repl window and another window for builds (ant) and other general stuff, then I use the clojure load function to reload any classes and/or clj sources that have changed, for example; from the repl... (use 'twlib.jty)(start-jty 8080) which loads and starts my jetty instance. The twlib.jty module (clj) uses (ns :use/:import etc, to load all the dependencies. Then during the session, I might say change twlib/xxx.clj, and I then just use (load "twlib/xxx") to reload the new version. It's not totally reloadable as you have to restart if you add new functions or other structural changes. With rlwrap I have the up-arrow/down-arrows set to incremental command history recall, so you can just type one or 2 characters of a previous repl line, hit the up arrow to recall and press Enter to execute. Tabbing between console tabs and with a good recall setup, it's little more than a couple of key strokes to almost instantaneously do a build, reload or restart. And of course you have full interactivity with the executing environmnent (jetty and other java libs, etc) directly through the repl. I also typically have one or more other console tabs open with ssh sessions to (linux) servers where I have similar setups. It sounds messy but it's the most efficient jvm platform dev environment I've worked with. I have the identical setup on my mac laptop and linux servers. I'm not sure how the equivalent would work on Windows though. Rgds, Adrian. On Tue, Mar 10, 2009 at 2:40 PM, Javier wrote: > > Thank you for your response. I'm actually using BeanShell for doing > most of this stuff, as it provides reloadClasses(), wich allows a very > fast reloading of every change (anyway, changes in code which is > actually in use are not propagated, but this is an expected issue). > I'll have a glance to the link you provide. > > One more question: is there a way to call a function similar to > reloadClasses in Clojure? If so, it would be my solution. > > > > > On 10 mar, 11:44, Chas Emerick wrote: >> In general, no -- in a typical project setup, any changes to Java code >> precipitate a rebuild and a restart of your application. >> >> There are plenty of ways to avoid this, but currently, they're only >> used in the major IDEs when debugging (e.g. while debugging an >> application, you can usually make various changes to java code, and >> then load those changes into the running application without >> restarting). This is accomplished by bootstrapping the application >> with a custom classloader (or, more likely, many, many classloaders) >> that allows the IDE to replace bytecode at various levels of >> granularity (class, method, etc). In my experience, eclipse is much >> better at this than netbeans, although the latter should approach >> parity with the 6.7 release if I've read the tea leaves properly. >> >> I know of people who have used JavaRebel >> (http://www.zeroturnaround.com/javarebel/ >> ) to implement this kind of hot code reloading in a production >> environment; apparently, it works quite well. You could try using it >> yourself -- it appears to be free for personal and open-source >> development. How it will interact with clojure and the details of its >> classloader-related implementation is anyone's guess. >> >> - Chas >> >> On Mar 10, 2009, at 2:01 AM, Javier wrote: >> >> >> >> > Hello, I'd like to thank you for providing us Clojure. This is >> > fantastic. >> >> > My background in Lisp if for several years now, just for fun, and >> > using >> > Common Lisp, mainly. >> > I have some programs in Java, and would like to use Clojure to >> > test/develop them. My question is: >> >> > Is it easy to test/load Java code in real time in Clojure while >> > developing it? For example, I have a bunch of classes I want to >> > continue >> > developing in Java, while other parts are made in Clojure. Is it >> > possible to test my modifications of the Java part in Clojure in >> > real time? >> >> > I'm using Netbeans. > > > --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
transposing a small java class in clojure
Hi, I'm experimenting with http://mina.apache.org/ftpserver I have written a small java class that gets used by the ftp server, and am trying to transpose it to clojure, but unsuccessfully until now The class generated with clojure is detected and used by the server, but the code of the method implemented is not run, and even worse, the ftp server isn't functional anymore (though I don't see any exception raised). Does anyone have an idea about what I'm doing wrong? Thanks Raphaël Here's the java code: package com.raphinou; import java.io.IOException; import org.apache.ftpserver.*; import org.apache.ftpserver.ftplet.*; public class Ftplet extends DefaultFtplet { public FtpletResult onLogin(FtpSession session, FtpRequest request) throws FtpException, IOException { java.util.logging.Logger logger= java.util.logging.Logger.getLogger("com.raphinou"); logger.addHandler( new java.util.logging.FileHandler("/tmp/ ftp.log")); logger.severe("Logging in!!"); return FtpletResult.DEFAULT; } } and here's the clojure code: (ns com.raphinou.ftplet (:gen-class :name com.raphinou.Ftplet :extends org.apache.ftpserver.ftplet.DefaultFtplet) (:import [org.apache.ftpserver.ftplet DefaultFtpReply FtpletResult])) (def logger (java.util.logging.Logger/getLogger "com.raphinou")) (.addHandler logger (java.util.logging.FileHandler. "/tmp/ftp.log")) (defn -onLogin [session request] (.severe logger "Logging in, clj") FtpletResult/DEFAULT) --~--~-~--~~~---~--~~ 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 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: generating a static method
On Mon, Mar 9, 2009 at 9:52 PM, .Bill Smith wrote: > > Would someone mind showing me a brief example of how to define a > static method (using gen-class)? Look for "static" under http://www.ociweb.com/mark/clojure/article.html#Compiling. -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
List comprehension examples for Wikibook
I translated some examples from the book "The Haskell Road" (http:// homepages.cwi.nl/~jve/HR/): (defn naturals [] (iterate inc 0)) (def evens1 (for [n (naturals) :when (even? n)] n)) (def odds1 (for [n (naturals) :when (odd? n)] n)) (def evens2 (for [n (naturals)] (* 2 n))) (def small-squares1 (for [n (range 0 1000)] (* n n))) (def small-squares2 (for [n (naturals) :when (< n 1000)] (* n n))) ; Maybe should use :while instead? Are these appropriate for inclusion on the Wikibook API page (http:// en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples) since they are derived from a copyrighted book? Aloha, David Sletten --~--~-~--~~~---~--~~ 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 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: Static type guy trying to convert
On Mar 10, 8:26 am, Vincent Foley wrote: [...snip...] > I'd like to > mention that I'm also a fan of static typing and that to this day, I > still don't know whether I prefer the freedom and flexibility of > dynamic typing or the constraint and safety of static typing. That dichotomy seems to be the one that most people like to discuss when weighing the advantages of different programming languages, but I confess that it seems sort of irrelevant to me. I don't mean that no one should care about it; just that I can't work up much enthusiasm about it. I've thought of Lisp as my native language in programming for around twenty years now, but I'm comfortable in other languages. I like ML a lot, and I like Haskell more. I like their type systems, but the alleged safety they provide has never been part of the appeal; rather, I like how easy and natural it is to describe types, even complicated ones. It's expressiveness I like, rather than magical protection against bugs (no disrespect intended to anyone who likes ML and Haskell for their safety). Maybe I have a skewed perspective, having done my first serious programming in 6502 assembly language. I remember that C seemed like a very high-level language to me at one time (albeit one with an annoying number of gotchas). FORTH was more comfortable. Lisp, when I got my hands on it pretty much kicked everything else out of the house. I didn't intend to like it (it looked rather unappealing in books) but in no time at all I was thinking in 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 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: contrib api documentation?
The GitHub project is here: http://github.com/mmcgrana/clj-doc/tree/master You can find recently generated docs for clojure and clojure contrib in the examples directory of that project, or you can use the provided script to generate your own. You mentioned adding a position fixed property; did you mean like: #doc-items { margin-left: 17.5em; position: fixed; } What does this change for you? Is it an IE rendering fix (I haven't tested clj-doc at all in IE)? - Mark McGranaghan On Tue, Mar 10, 2009 at 9:26 AM, rb wrote: > > > > On Mar 10, 11:47 am, Chas Emerick wrote: >> This is a pretty nice reference: >> >> http://clj-doc.s3.amazonaws.com/tmp/doc-1116/index.html > > Nice, especially after you update the css to have #doc-items position > set to fixed :-) > >> >> A little old now, though. The tool that generated it is open-source >> (on github, I think), so refreshing it for yourself shouldn't be too >> difficult. > > Didn't find the link rapidly, I'll look further later. > > Thanks for your help! > > Raph > >> >> - Chas >> >> On Mar 10, 2009, at 6:16 AM, rb wrote: >> >> >> >> > Hi, >> >> > is there a place where I can find the documentation of clojure.contrib >> > in the same vein as clojure.core is documented athttp://clojure.org/API >> > ? >> >> > Thanks >> >> > Raphaël > > > --~--~-~--~~~---~--~~ 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 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: categorizing forms
> What form would you suggest? XML, something else ... Just a regular Clojure map is what I was thinking: http://groups.google.com/group/clojure/web/categories.clj Obviously having the categories as metadata would be neat, but the advantage of having a separate regular map is that no change to core is required. It can just be in contrib and used for interactive help (better syntax required): user=> (cat/categories :bindings) #{"def" "binding" "defonce" "declare" "if-let" "with-local-vars" "let"} Or generating your html: user=> (cat/write-html) http://groups.google.com/group/clojure/web/cat.html As you can see I've suggested some super-categories... but my html formatting is not so hot :P Regards, Tim. --~--~-~--~~~---~--~~ 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 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: categorizing forms
On Tue, Mar 10, 2009 at 9:40 AM, Timothy Pratley wrote: > >> What form would you suggest? XML, something else ... > > Just a regular Clojure map is what I was thinking: > http://groups.google.com/group/clojure/web/categories.clj Looks great! > Obviously having the categories as metadata would be neat, but the > advantage of having a separate regular map is that no change to core > is required. It can just be in contrib and used for interactive help > (better syntax required): > user=> (cat/categories :bindings) > #{"def" "binding" "defonce" "declare" "if-let" "with-local-vars" > "let"} > > Or generating your html: > user=> (cat/write-html) > http://groups.google.com/group/clojure/web/cat.html > > As you can see I've suggested some super-categories... but my html > formatting is not so hot :P It's a good start! Do you want to support any number of nested categories or just two deep? -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~~---~--~~ 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 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: Static type guy trying to convert
I just jumped on Clojure five months ago, and I was a little lost without types at first also. Then I've come to realize that types is not as essential to bug-less software as I previously thought it was. For the following reasons: 1) There's less "types" to begin with. I was a Java programmer, and libraries are literally filled with classes with names like "ActionListener, MouseClickHandler, Tester, DummyTester" etc... I call these "behavior" classes. Classes that represent "behavior" instead of "data". These classes were designed to take advantage of the limited polymorphism that Java offers. In Clojure, there's no need to represent this functionality in this fashion. Usually you just pass functions around, and it's much more natural, and there's no need for these "behavior" classes. 2) There's less repetitive code. In Java, whenever I changed something, the changes would have to be propagated down almost the entire project. And I relied upon the compile-time errors to keep track of the changes that I need to update. In Clojure, I find there's a lot less repetitive code, so usually I only need to change the code in one small part. This is highly dependent on your programming style though, so this won't apply to everyone. 3) "Open" types make reusing code easier. So again there's less types to deal with. In Java, classes are final. You cannot add methods or fields to classes. Instead, you're supposed to use inheritance to accomplish that. So in Java, you have a lot of extraneous classes such as "String", "QString", "KString", "MyString", etc.. or "Window", "AWTWindow", "SpringWindow", "JWindow", etc... Clojure prefers to use many functions that operate on a limited number of types. So this situation doesn't arise very often. 4) Testing is much much easier. I was a relatively experienced Java programmer. I very rarely got compile-time errors anymore. All of my bugs were RuntimeErrors. Which you can only catch by testing. And yet Java's type system makes testing so tedious and difficult. So giving up a little compile-time safety for the ease of testing that Clojure offers is a big big win in my books. Hope that puts you at ease a bit, and I hope you enjoy learning Clojure -Patrick --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure plugin for IntelliJ IDEA published
Liking it so far. Can you get jline style functionality into the REPL, I really miss it. Cheers Tom 2009/2/27 AndrewC. > > > > On Feb 26, 7:08 pm, CuppoJava wrote: > > Hello Ilya, > > Thanks for the workaround. > > > > I'm glad to hear you're working on a "surround with" feature. Some > > other parenthesis commands that I most commonly use is: > > 1) Delete next Sexp. > > 2) Splice Sexp. (Remove the parenthesis around the current sexp). > > 3) Move cursor to next/previous sexp. > > Don't forget Barf and Slurp! > > Barf - eject an Sexp from this Sexp (front and back): > > (a b c) -> (a b) c > (a b c) -> a (b c) > > Slurp - incorporate an Sexp into this Sexp (front and back): > > (a b) c -> (a b c) > a (b c) -> (a b c) > > Also copy this sexp, cut this sexp. > > All vital! > > > > > > --~--~-~--~~~---~--~~ 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 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: Static type guy trying to convert
Thanks everyone! That gives me a lot more confidence in trying Clojure. There is a certain freedom in not worrying about types. I spend a lot of time in Java trying to get types and type hierarchies right (especially generics). I haven't been doing a lot of unit testing but I can see how that would help you feel more confident about your code. Now the other thing I have to get used to being without is object orientation. It's amazing how a programming style can create neuronal paths in your brain and it's hard to think any other way. I sure like what FP gives you though, especially for concurrency. Now if I could just understand monads :) The best thing about Clojure is its friendly and helpful community. Thanks again. I'm definitely going to start using Clojure where possible. Curtis --~--~-~--~~~---~--~~ 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 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: Static type guy trying to convert
With Clojure you don't need to understand Monads. And I don't think they're hard to understand, I think they're hard to come to grips with because of what they are capable of. Anyway, I hope you enjoy Clojure :) On Mar 10, 11:30 am, zoltar wrote: > Thanks everyone! That gives me a lot more confidence in trying > Clojure. There is a certain freedom in not worrying about types. I > spend a lot of time in Java trying to get types and type hierarchies > right (especially generics). I haven't been doing a lot of unit > testing but I can see how that would help you feel more confident > about your code. > > Now the other thing I have to get used to being without is object > orientation. It's amazing how a programming style can create neuronal > paths in your brain and it's hard to think any other way. I sure like > what FP gives you though, especially for concurrency. Now if I could > just understand monads :) > > The best thing about Clojure is its friendly and helpful community. > Thanks again. I'm definitely going to start using Clojure where > possible. > > Curtis --~--~-~--~~~---~--~~ 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 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: Static type guy trying to convert
On Mar 10, 10:03 am, Vincent Foley wrote: > With Clojure you don't need to understand Monads. And I don't think > they're hard to understand, I think they're hard to come to grips with > because of what they are capable of. > > Anyway, I hope you enjoy Clojure :) Yes, I know, but I'd like to understand them anyway. Looks like a good way to avoid mutable state in my programs (along with other things). --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure plugin for IntelliJ IDEA published
Is there any kind of debugger support (now, or coming?). On Tue, Mar 10, 2009 at 8:10 AM, Tom Ayerst wrote: > Liking it so far. Can you get jline style functionality into the REPL, I > really miss it. > > Cheers > > Tom > > 2009/2/27 AndrewC. >> >> >> >> On Feb 26, 7:08 pm, CuppoJava wrote: >> > Hello Ilya, >> > Thanks for the workaround. >> > >> > I'm glad to hear you're working on a "surround with" feature. Some >> > other parenthesis commands that I most commonly use is: >> > 1) Delete next Sexp. >> > 2) Splice Sexp. (Remove the parenthesis around the current sexp). >> > 3) Move cursor to next/previous sexp. >> >> Don't forget Barf and Slurp! >> >> Barf - eject an Sexp from this Sexp (front and back): >> >> (a b c) -> (a b) c >> (a b c) -> a (b c) >> >> Slurp - incorporate an Sexp into this Sexp (front and back): >> >> (a b) c -> (a b c) >> a (b c) -> (a b c) >> >> Also copy this sexp, cut this sexp. >> >> All vital! >> >> >> >> > > > > > -- Howard M. Lewis Ship Creator Apache Tapestry and Apache HiveMind --~--~-~--~~~---~--~~ 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 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: transposing a small java class in clojure
I can see one possible difference, depending on how you are loading the code into the ftp server. In your clojure example you are accessing the logger through a top- level define. I believe this will run *during the file loading process* as static code. In your working java example, you aren't accessing the logger until the actual onLogin function is called. If the logger is in an odd state (like null) or god forbid the runtime sets up the logger just before it calls into your function then you may get different results. I would recommend calling the getlogger call in the function perhaps; change the 'def logger' to 'defn logger []' and work out the resulting details. This would make the clojure example a little closer to your java example and at least eliminate one possible problem. Chris On Mar 10, 7:35 am, rb wrote: > Hi, > > I'm experimenting withhttp://mina.apache.org/ftpserver > I have written a small java class that gets used by the ftp server, > and am trying to transpose it to clojure, but unsuccessfully until > now > > The class generated with clojure is detected and used by the server, > but the code of the method implemented is not run, and even worse, the > ftp server isn't functional anymore (though I don't see any exception > raised). > > Does anyone have an idea about what I'm doing wrong? > > Thanks > > Raphaël > > Here's the java code: > > package com.raphinou; > > import java.io.IOException; > import org.apache.ftpserver.*; > import org.apache.ftpserver.ftplet.*; > > public class Ftplet extends DefaultFtplet { > public FtpletResult onLogin(FtpSession session, FtpRequest > request) > throws FtpException, IOException { > java.util.logging.Logger logger= > java.util.logging.Logger.getLogger("com.raphinou"); > logger.addHandler( new java.util.logging.FileHandler("/tmp/ > ftp.log")); > logger.severe("Logging in!!"); > return FtpletResult.DEFAULT; > } > > } > > and here's the clojure code: > > (ns com.raphinou.ftplet > (:gen-class :name com.raphinou.Ftplet > :extends org.apache.ftpserver.ftplet.DefaultFtplet) > (:import [org.apache.ftpserver.ftplet DefaultFtpReply > FtpletResult])) > > (def logger (java.util.logging.Logger/getLogger "com.raphinou")) > (.addHandler logger (java.util.logging.FileHandler. "/tmp/ftp.log")) > > (defn -onLogin [session request] > (.severe logger "Logging in, clj") > FtpletResult/DEFAULT) --~--~-~--~~~---~--~~ 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 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: Static type guy trying to convert
http://www.mindview.net/WebLog/log-0025 I am not actually as in favor of untyped programming as this article is, but I can see the points and I agree with most of them. Chris On Mar 10, 10:34 am, zoltar wrote: > On Mar 10, 10:03 am, Vincent Foley wrote: > > > With Clojure you don't need to understand Monads. And I don't think > > they're hard to understand, I think they're hard to come to grips with > > because of what they are capable of. > > > Anyway, I hope you enjoy Clojure :) > > Yes, I know, but I'd like to understand them anyway. Looks like a good > way to avoid mutable state in my programs (along with other things). --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
Macros problem
I'm trying to build something using macros ... my long goal is a simple embedded DSL. Here's a simplified version: (defmacro to-fn "Converts a collection of forms into an anonymous function of no arguments." [forms] `(fn [] ~...@forms)) (defn run-example [fn] (printf "BEFORE\n") (fn) (printf "AFTER\n")) (defmacro example [& code] `(let [fn# (to-fn ~code)] (run-example fn#))) (example (printf "EXAMPLE1\n") (printf "EXAMPLE2\n")) This gives the expected output: BEFORE EXAMPLE1 EXAMPLE2 AFTER Now, the problem is, I want to manipulate the list of forms passed to the example macro before turning it into (to-fn) (the real DSL will split the forms into groups and create multiple functions, and this is all about the side-effects). Changing the macro as so: (defmacro example [& code] `(let [rcode# ~(reverse code) fn# (to-fn rcode#)] (run-example fn#))) Give me an exception: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: Symbol (p0-01.clj:42) at clojure.lang.Compiler.analyze(Compiler.java:4032) at clojure.lang.Compiler.analyzeSeq(Compiler.java:4176) at clojure.lang.Compiler.analyze(Compiler.java:4017) at clojure.lang.Compiler.access$100(Compiler.java:38) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:3790) at clojure.lang.Compiler.analyzeSeq(Compiler.java:4188) at clojure.lang.Compiler.analyze(Compiler.java:4017) at clojure.lang.Compiler.analyzeSeq(Compiler.java:4176) at clojure.lang.Compiler.analyze(Compiler.java:4017) at clojure.lang.Compiler.analyzeSeq(Compiler.java:4176) at clojure.lang.Compiler.analyze(Compiler.java:4017) at clojure.lang.Compiler.analyze(Compiler.java:3978) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:3678) at clojure.lang.Compiler$FnMethod.parse(Compiler.java:3513) at clojure.lang.Compiler$FnMethod.access$1100(Compiler.java:3390) at clojure.lang.Compiler$FnExpr.parse(Compiler.java:2952) at clojure.lang.Compiler.analyzeSeq(Compiler.java:4186) at clojure.lang.Compiler.analyze(Compiler.java:4017) at clojure.lang.Compiler.eval(Compiler.java:4222) at clojure.lang.Compiler.load(Compiler.java:4548) at clojure.lang.Compiler.loadFile(Compiler.java:4515) at clojure.main$load_script__5665.invoke(main.clj:206) at clojure.main$script_opt__5696.invoke(main.clj:258) at clojure.main$main__5720$fn__5722.invoke(main.clj:333) at clojure.main$main__5720.doInvoke(main.clj:328) at clojure.lang.RestFn.invoke(RestFn.java:413) at clojure.lang.Var.invoke(Var.java:340) at clojure.lang.AFn.applyToHelper(AFn.java:173) at clojure.lang.Var.applyTo(Var.java:457) at clojure.main.main(main.java:39) Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: Symbol at clojure.lang.LazySeq.seq(LazySeq.java:40) at clojure.lang.Cons.next(Cons.java:37) at clojure.lang.RT.count(RT.java:522) at clojure.lang.Cons.count(Cons.java:47) at clojure.lang.Compiler.analyze(Compiler.java:4008) ... 29 more Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: Symbol at clojure.lang.LazySeq.seq(LazySeq.java:40) at clojure.lang.RT.seqFrom(RT.java:481) at clojure.lang.RT.seq(RT.java:451) at clojure.lang.LazySeq.seq(LazySeq.java:36) ... 33 more Caused by: java.lang.IllegalArgumentException: Don't know how to create ISeq from: Symbol at clojure.lang.RT.seqFrom(RT.java:494) at clojure.lang.RT.seq(RT.java:451) at clojure.core$seq__3046.invoke(core.clj:107) at clojure.core$concat__3174$cat__3188$fn__3189.invoke(core.clj:443) at clojure.lang.LazySeq.seq(LazySeq.java:36) ... 36 more I've thrashed on a number of variations, none of which do much better. I feel I'm missing something subtle here. What is the right approach? -- Howard M. Lewis Ship Creator Apache Tapestry and Apache HiveMind --~--~-~--~~~---~--~~ 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 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: transposing a small java class in clojure
HI Chris, thanks for your response, and I'll update the code as you suggest. However, I actually have problems even when the -onLogin function is empty, returns nil, or returns FtpletResult/DEFAULT. It seems it causes trouble once it's defined. I'll post an update tomorrow Raphaël On Mar 10, 6:50 pm, chris wrote: > I can see one possible difference, depending on how you are loading > the code into the ftp server. > > In your clojure example you are accessing the logger through a top- > level define. I believe this will run *during the file loading > process* as static code. > > In your working java example, you aren't accessing the logger until > the actual onLogin function is called. > > If the logger is in an odd state (like null) or god forbid the runtime > sets up the logger just before it calls into your function then you > may get different results. I would recommend calling the getlogger > call in the function perhaps; change the 'def logger' to 'defn logger > []' and work out the resulting details. This would make the clojure > example a little closer to your java example and at least eliminate > one possible problem. > > Chris > > On Mar 10, 7:35 am, rb wrote: > > > Hi, > > > I'm experimenting withhttp://mina.apache.org/ftpserver > > I have written a small java class that gets used by the ftp server, > > and am trying to transpose it to clojure, but unsuccessfully until > > now > > > The class generated with clojure is detected and used by the server, > > but the code of the method implemented is not run, and even worse, the > > ftp server isn't functional anymore (though I don't see any exception > > raised). > > > Does anyone have an idea about what I'm doing wrong? > > > Thanks > > > Raphaël > > > Here's the java code: > > > package com.raphinou; > > > import java.io.IOException; > > import org.apache.ftpserver.*; > > import org.apache.ftpserver.ftplet.*; > > > public class Ftplet extends DefaultFtplet { > > public FtpletResult onLogin(FtpSession session, FtpRequest > > request) > > throws FtpException, IOException { > > java.util.logging.Logger logger= > > java.util.logging.Logger.getLogger("com.raphinou"); > > logger.addHandler( new java.util.logging.FileHandler("/tmp/ > > ftp.log")); > > logger.severe("Logging in!!"); > > return FtpletResult.DEFAULT; > > } > > > } > > > and here's the clojure code: > > > (ns com.raphinou.ftplet > > (:gen-class :name com.raphinou.Ftplet > > :extends org.apache.ftpserver.ftplet.DefaultFtplet) > > (:import [org.apache.ftpserver.ftplet DefaultFtpReply > > FtpletResult])) > > > (def logger (java.util.logging.Logger/getLogger "com.raphinou")) > > (.addHandler logger (java.util.logging.FileHandler. "/tmp/ftp.log")) > > > (defn -onLogin [session request] > > (.severe logger "Logging in, clj") > > FtpletResult/DEFAULT) --~--~-~--~~~---~--~~ 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 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: transposing a small java class in clojure
I don't know how many arguments the method you are overriding with onLogin takes, but the function you define should take one more argument then the method you are overiding, the first argument being an explicit reference to an instance On Tue, Mar 10, 2009 at 12:16 PM, rb wrote: > > HI Chris, > > thanks for your response, and I'll update the code as you suggest. > However, I actually have problems even when the -onLogin function is > empty, returns nil, or returns FtpletResult/DEFAULT. It seems it > causes trouble once it's defined. > > I'll post an update tomorrow > > Raphaël > > On Mar 10, 6:50 pm, chris wrote: >> I can see one possible difference, depending on how you are loading >> the code into the ftp server. >> >> In your clojure example you are accessing the logger through a top- >> level define. I believe this will run *during the file loading >> process* as static code. >> >> In your working java example, you aren't accessing the logger until >> the actual onLogin function is called. >> >> If the logger is in an odd state (like null) or god forbid the runtime >> sets up the logger just before it calls into your function then you >> may get different results. I would recommend calling the getlogger >> call in the function perhaps; change the 'def logger' to 'defn logger >> []' and work out the resulting details. This would make the clojure >> example a little closer to your java example and at least eliminate >> one possible problem. >> >> Chris >> >> On Mar 10, 7:35 am, rb wrote: >> >> > Hi, >> >> > I'm experimenting withhttp://mina.apache.org/ftpserver >> > I have written a small java class that gets used by the ftp server, >> > and am trying to transpose it to clojure, but unsuccessfully until >> > now >> >> > The class generated with clojure is detected and used by the server, >> > but the code of the method implemented is not run, and even worse, the >> > ftp server isn't functional anymore (though I don't see any exception >> > raised). >> >> > Does anyone have an idea about what I'm doing wrong? >> >> > Thanks >> >> > Raphaël >> >> > Here's the java code: >> >> > package com.raphinou; >> >> > import java.io.IOException; >> > import org.apache.ftpserver.*; >> > import org.apache.ftpserver.ftplet.*; >> >> > public class Ftplet extends DefaultFtplet { >> > public FtpletResult onLogin(FtpSession session, FtpRequest >> > request) >> > throws FtpException, IOException { >> > java.util.logging.Logger logger= >> > java.util.logging.Logger.getLogger("com.raphinou"); >> > logger.addHandler( new java.util.logging.FileHandler("/tmp/ >> > ftp.log")); >> > logger.severe("Logging in!!"); >> > return FtpletResult.DEFAULT; >> > } >> >> > } >> >> > and here's the clojure code: >> >> > (ns com.raphinou.ftplet >> > (:gen-class :name com.raphinou.Ftplet >> > :extends org.apache.ftpserver.ftplet.DefaultFtplet) >> > (:import [org.apache.ftpserver.ftplet DefaultFtpReply >> > FtpletResult])) >> >> > (def logger (java.util.logging.Logger/getLogger "com.raphinou")) >> > (.addHandler logger (java.util.logging.FileHandler. "/tmp/ftp.log")) >> >> > (defn -onLogin [session request] >> > (.severe logger "Logging in, clj") >> > FtpletResult/DEFAULT) > > > -- And what is good, Phaedrus, And what is not good— Need we ask anyone to tell us these things? --~--~-~--~~~---~--~~ 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 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: Macros problem
On Tue, Mar 10, 2009 at 2:45 PM, Howard Lewis Ship wrote: > > (defmacro example > [& code] > `(let [rcode# ~(reverse code) > fn# (to-fn rcode#)] > (run-example fn#))) Thanks for the complete example, it really helps. Macroexpand might help you see at least one of the problems: (clojure.core/let [rcode__614__auto__ ((printf "EXAMPLE2\n") (printf "EXAMPLE1\n")) fn__615__auto__ (user/to-fn rcode__614__auto__)] (user/run-example fn__615__auto__)) Since (printf ...) returns nil, it looks like you'll be trying to bind rcode# to the value of (nil nil), that is 'nil' called with a single argument of 'nil'. It actually errors out before it gets that far, but anyway... Try completing as much of your manipulation as is possible outside the syntax-quote: (defmacro example [& code] (let [rcode (reverse code)] `(let [func# (to-fn ~rcode)] (run-example func# Also, try to avoid using builtin names like 'fn' for your own locals. It only leads to more pain in the long run. --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 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: The Application Context Pattern
> Does anyone have similar example using one of the cells > implementations? > What would be pros/cons between this and cells approach? Sorry for a late reply but some of the code didn't exist when you asked your question. This example can be done using neman cells and swing wrapper like this: http://is.gd/mKRT This shows that swing wrapper can 'erase' lexical scope so you can use widgets before they are declared and 'bind' macro, part of cells lib, that will sync text property of label with value of user-input cell. Libs are very experimental, so this is more a feature preview for now, not something you would use just yet. -- 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 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: Static type guy trying to convert
I am in the same boat. However, even more than type safety, I miss my IDE giving me the most appropriate options. I often have objects with many call-backs, it's nice to be able to ctrl+space (in eclipse) and quickly get a list available methods, pressing enter gives you some skeleton code. Clojure's brevity mitigates some of the hassle of not having types though. --~--~-~--~~~---~--~~ 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 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: Macros problem
Hi, Am 10.03.2009 um 19:45 schrieb Howard Lewis Ship: (defmacro example [& code] `(let [rcode# ~(reverse code) fn# (to-fn rcode#)] (run-example fn#))) Your problem is, to-fn is a macro. So when you expand the macro, the expansion calls to-fn with the symbol generated by rcode#. Then in to-fn you try to use it as a list => *BOOM*. You have to reverse the code in the macro an itself and then make sure, that the to-fn in the expansion sees the code. (defmacro example [& code] (let [rcode (reverse code)] `(let [fn# (to-fn ~rcode)] (run-example fn# Hope this helps. Sincerely Meikel smime.p7s Description: S/MIME cryptographic signature
Re: Macros problem
Thanks! That got me back on track. I'm off and running on my DSL: (defmacro sketch [title & code] (let [code-map (assemble-map #{:setup :draw} :draw code) setup-slice (:setup code-map) draw-slice (:draw code-map)] `(let [setup-fn# (to-fn ~setup-slice) draw-fn# (to-fn ~draw-slice)] (run-sketch ~title setup-fn# draw-fn# It's a bit challenging at first; I was very concerned with symbol name collisions ... it takes a bit to realize that symbols you use in a macro body (that are not part of the back quoted template) can't conflict with symbols in forms passed to the macro; by the time those passed forms are ever evaluated, the (let) in the macro is long gone and the namespaces are clean. On Tue, Mar 10, 2009 at 12:30 PM, Chouser wrote: > > On Tue, Mar 10, 2009 at 2:45 PM, Howard Lewis Ship wrote: >> >> (defmacro example >> [& code] >> `(let [rcode# ~(reverse code) >> fn# (to-fn rcode#)] >> (run-example fn#))) > > Thanks for the complete example, it really helps. > > Macroexpand might help you see at least one of the problems: > > (clojure.core/let [rcode__614__auto__ ((printf "EXAMPLE2\n") (printf > "EXAMPLE1\n")) > fn__615__auto__ (user/to-fn rcode__614__auto__)] > (user/run-example fn__615__auto__)) > > Since (printf ...) returns nil, it looks like you'll be trying to bind > rcode# to the value of (nil nil), that is 'nil' called with a single > argument of 'nil'. It actually errors out before it gets that far, > but anyway... > > Try completing as much of your manipulation as is possible outside the > syntax-quote: > > (defmacro example [& code] > (let [rcode (reverse code)] > `(let [func# (to-fn ~rcode)] > (run-example func# > > Also, try to avoid using builtin names like 'fn' for your own locals. > It only leads to more pain in the long run. > > --Chouser > > > > -- Howard M. Lewis Ship Creator Apache Tapestry and Apache HiveMind --~--~-~--~~~---~--~~ 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 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: Static type guy trying to convert
> IDE giving me the most appropriate options. i'm under the updated impression that some Smalltalk IDEs can and do look at the current AST of the system to give you proper completion, rather than giving up because there aren't explicit types. so maybe some such could be done some day for Clojure? --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure plugin for IntelliJ IDEA published
Hi, Tom. >Can you get jline style functionality into the REPL Sure, we're working on it now. With best regards, Ilya On Mar 10, 4:10 pm, Tom Ayerst wrote: > Liking it so far. Can you get jline style functionality into the REPL, I > really miss it. > > Cheers > > Tom > > 2009/2/27 AndrewC. > > > > > On Feb 26, 7:08 pm, CuppoJava wrote: > > > Hello Ilya, > > > Thanks for the workaround. > > > > I'm glad to hear you're working on a "surround with" feature. Some > > > other parenthesis commands that I most commonly use is: > > > 1) Delete next Sexp. > > > 2) Splice Sexp. (Remove the parenthesis around the current sexp). > > > 3) Move cursor to next/previous sexp. > > > Don't forget Barf and Slurp! > > > Barf - eject an Sexp from this Sexp (front and back): > > > (a b c) -> (a b) c > > (a b c) -> a (b c) > > > Slurp - incorporate an Sexp into this Sexp (front and back): > > > (a b) c -> (a b c) > > a (b c) -> (a b c) > > > Also copy this sexp, cut this sexp. > > > All vital! > > --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure plugin for IntelliJ IDEA published
Hi, Howard Yes, we support debugging for Clojure scripts (even from libary). To launch debugger, create run configuration (for this you may just press Ctrl-Shift-F10 on appropriate script to be run) and launch it in debug mode (Shift-f9 in Linux/Windows keymap). You may set breakpoints and navigate through call stack. "Evaluate expression" in Clojure-style is not supported now, but it is coming soon. With best regards, Ilya On Mar 10, 6:44 pm, Howard Lewis Ship wrote: > Is there any kind of debugger support (now, or coming?). > > > > On Tue, Mar 10, 2009 at 8:10 AM, Tom Ayerst wrote: > > Liking it so far. Can you get jline style functionality into the REPL, I > > really miss it. > > > Cheers > > > Tom > > > 2009/2/27 AndrewC. > > >> On Feb 26, 7:08 pm, CuppoJava wrote: > >> > Hello Ilya, > >> > Thanks for the workaround. > > >> > I'm glad to hear you're working on a "surround with" feature. Some > >> > other parenthesis commands that I most commonly use is: > >> > 1) Delete next Sexp. > >> > 2) Splice Sexp. (Remove the parenthesis around the current sexp). > >> > 3) Move cursor to next/previous sexp. > > >> Don't forget Barf and Slurp! > > >> Barf - eject an Sexp from this Sexp (front and back): > > >> (a b c) -> (a b) c > >> (a b c) -> a (b c) > > >> Slurp - incorporate an Sexp into this Sexp (front and back): > > >> (a b) c -> (a b c) > >> a (b c) -> (a b c) > > >> Also copy this sexp, cut this sexp. > > >> All vital! > > -- > Howard M. Lewis Ship > > Creator Apache Tapestry and Apache HiveMind --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
Debugging support for clojure?
Hi all, is there any debugging support for clojure which lets one step though a function? If not, is there better way than inserting gazillions of printlns to check why and where a function doesn't do the right thing? Bye, Tassilo --~--~-~--~~~---~--~~ 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 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: Static type guy trying to convert
I think the key to feeling confident in dynamically typed code is to go ahead and write out the "contract" for the function in your comments. You should always state what the "domain" and the "range" of the function are, so that you and other people can use the function appropriately. A static type system also documents these properties, but you're restricted to certain concepts that the computer can understand and prove things about. You'll start to realize that there are concepts that are difficult or impossible to easily capture with a static type system (e.g., this function takes positive even integers, and returns a number from 0 to 9). I'm finding Clojure is a bit trickier to write contracts for than other dynamically-typed languages I've used, because many of the concepts are somewhat nebulous and don't have good terminology yet (e.g., this function takes anything that doesn't return an error when you apply seq to it), but I'd still choose dynamic typing over static typing any day. --~--~-~--~~~---~--~~ 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 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: Debugging support for clojure?
Tassilo Horn writes: > If not, is there better way than inserting gazillions of printlns to > check why and where a function doesn't do the right thing? Most definitely! Break your functions up into smaller pieces, then write tests for them using test-is. If your functions are hard to test, it's probably because they need to be broken out differently. -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 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: Debugging support for clojure?
The IntelliJ plugin supports debugging. And using JSwat is also possible, but a little less streamlined. -Patrick --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
macros
Does the Clojure book contain much conceptual material on macros? I keep finding places where I think a macro might be useful, and then the macro doesn't work and it's hard to understand why. Bill Smith Austin, TX --~--~-~--~~~---~--~~ 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 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: macros
It does. Also Practical Common Lisp and On Lisp cover this in depth as well, though you'll need to convert commas into tildes as well as use ~' for each level of backquote depth that you don't want Clojure to namespace free symbols. On Tue, Mar 10, 2009 at 6:05 PM, .Bill Smith wrote: > > Does the Clojure book contain much conceptual material on macros? I > keep finding places where I think a macro might be useful, and then > the macro doesn't work and it's hard to understand why. > > Bill Smith > Austin, TX > > > --~--~-~--~~~---~--~~ 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 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: macros
Practical Common Lisp and On Lisp are available online and free. On Tue, Mar 10, 2009 at 6:16 PM, David Nolen wrote: > It does. Also Practical Common Lisp and On Lisp cover this in depth as > well, though you'll need to convert commas into tildes as well as use ~' for > each level of backquote depth that you don't want Clojure to namespace free > symbols. > > > On Tue, Mar 10, 2009 at 6:05 PM, .Bill Smith wrote: > >> >> Does the Clojure book contain much conceptual material on macros? I >> keep finding places where I think a macro might be useful, and then >> the macro doesn't work and it's hard to understand why. >> >> Bill Smith >> Austin, TX >> >> >> > --~--~-~--~~~---~--~~ 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 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: filter1 interesting?
Doesn't (some pred coll) do the same thing as (first (filter pred coll))? On Mar 9, 11:34 am, Stuart Sierra wrote: > I do use this pattern, but if I were naming it I think I'd call it > "find-first". But that's scarcely shorter than "(first (filter ...)", > which is why I've never actually defined it. > -Stuart Sierra > > On Mar 8, 3:20 pm, André Thieme wrote: > > > I regularily stumble upon the (first (filter predicate coll)) pattern. > > Maybe we can add a filter1 for that? > > In the Clojure project itself I found this two times, in core.clj for > > the ns macro, > > and in genclass.clj in find-field. > > Also in the clojure-contrib project it shows up two times (again in > > the core.clj > > of Clojure for CLR, and in clojurescript.clj). --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
z/OS and codepage issues?
I'm having difficulty running Clojure under z/OS. If I download a current Clojure onto my Gentoo Linux system and build it so: svn checkout http://clojure.googlecode.com/svn/trunk/ clojure-read- only cd clojure-read-only ant Then I can treat myself to a delicious REPL: ~/clojure-read-only $ java -cp clojure.jar clojure.lang.Repl Clojure user=> (+ 1 1) 2 So I move this write-once-read-anywhere bundle to z/OS: I tar the clojure-read-only directory, binary-ftp it to my z/OS system, ssh in to *that* and untar the archive, ending up with an identical clojure- read-only directory on the z/OS filesystem. But now I have serious code page issues. The best I can get out of Clojure here is: $ java -Dfile.encoding=ISO8859-1 -Dconsole.encoding=IBM-1047 -cp clojure.jar clojure.lang.Repl Clojure user=> (+ 1 1) java.lang.Exception: Unable to resolve symbol: MN in this context (NO_SOURCE_FILE:0) java.lang.Exception: Unable to resolve symbol: ��� in this context (NO_SOURCE_FILE:0) One person suggested to me that "The code is probably doing something odd with how it reads input, making bad assumptions about the codepage being "ASCII". Running with ISO8859-1 as the file encoding usually fixes this, but apparently not in this case." I'm well out of my depth here, and wonder if anyone has a suggestion on how I can proceed? --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
Importing classes with an anonymous package
Hello all, I needed to import a class (that I didn't write) today into Clojure. The problem is that the class has no explicit package declaration. The solution that I found out (thanks to Chouser on #clojure) is this: (.importClass *ns* 'Foo (clojure.lang.RT/classForName "Foo")) This tip might be useful for others. On the other hand, would it make sense to augment 'import' to allow for this case? Perhaps something like (import '(nil Foo)) Duncan. --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
z/OS and codepage issues?
I'm having difficulty running Clojure under z/OS. If I download a current Clojure onto my Gentoo Linux system and build it so: svn checkout http://clojure.googlecode.com/svn/trunk/ clojure-read- only cd clojure-read-only ant Then I can treat myself to a delicious REPL: ~/clojure-read-only $ java -cp clojure.jar clojure.lang.Repl Clojure user=> (+ 1 1) 2 So I move this write-once-read-anywhere bundle to z/OS: I tar the clojure-read-only directory, binary-ftp it to my z/OS system, ssh in to *that* and untar the archive, ending up with an identical clojure- read-only directory on the z/OS filesystem. But now I have serious code page issues. The best I can get out of Clojure here is: $ java -Dfile.encoding=ISO8859-1 -Dconsole.encoding=IBM-1047 -cp clojure.jar clojure.lang.Repl Clojure user=> (+ 1 1) java.lang.Exception: Unable to resolve symbol: MN in this context (NO_SOURCE_FILE:0) java.lang.Exception: Unable to resolve symbol: ��� in this context (NO_SOURCE_FILE:0) One person suggested to me that "The code is probably doing something odd with how it reads input, making bad assumptions about the codepage being "ASCII". Running with ISO8859-1 as the file encoding usually fixes this, but apparently not in this case." I'm well out of my depth here, and wonder if anyone has a suggestion on how I can proceed? --~--~-~--~~~---~--~~ 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 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: Debugging support for clojure?
The eclipse plugin also provides some debugging support. Joshua On Mar 10, 5:33 pm, Tassilo Horn wrote: > Hi all, > > is there any debugging support for clojure which lets one step though a > function? If not, is there better way than inserting gazillions of > printlns to check why and where a function doesn't do the right thing? > > Bye, > Tassilo --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
VimClojure 2.0.0 released (merged with Gorilla)
Dear vimming Clojurians, I'm proud to announce VimClojure 2.0! I want to thank durka42 on #clojure for being a patient guinea pig - eh - beta tester, finding the bugs within minutes. :) Updates and Fixes: * Updated higlighting to SVN 1327 * Fixed completion bug on Windows (thanks to jb) Gorilla was merged into VimClojure. To use the interactive features, set the variable "clj_want_gorilla" in your .vimrc. If you do so, you must start the Nailgun server before editing clojure files with vim. More information on the installation can be found in the README.txt. Interactive features are: * docstring lookup * javadoc lookup * evaluation of code * buffer repl * omni completion with fuzzy logic (eg. r-s => read-string, resultset-seq, ...) Note: Ruby is *not* needed anymore! Windows support: I'm loosing complete interest in supporting Windows. No matter how much time you invest, there will be another moronic special case which breaks everything again. Adding to the difficulty is that I cannot test on Windows. So I will release as is. In case there are problems on Windows I'm open for fixes but I will not invest much time myself. Anyway, I hope you find this plugin useful and that it helps you in your work. http://www.vim.org/scripts/script.php?script_id=2501 Sincerely Meikel smime.p7s Description: S/MIME cryptographic signature
Re: Debugging support for clojure?
On Tue, Mar 10, 2009 at 2:44 PM, CuppoJava wrote: > > The IntelliJ plugin supports debugging. > I must have missed this; the UI didn't seem to allow for setting of breakpoints. > And using JSwat is also possible, but a little less streamlined. > -Patrick > > > -- Howard M. Lewis Ship Creator Apache Tapestry and Apache HiveMind --~--~-~--~~~---~--~~ 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 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: Debugging support for clojure?
Have you updated to the latest version? If it's setup properly, you should be able to set breakpoints by clicking on the grey column on the left side of your code. Also, not every line can be breakpointed. Try breakpointing some different lines if you're having problems there. -Patrick --~--~-~--~~~---~--~~ 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 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: filter1 interesting?
That's what I was going to say. (some pred col) is what I use so far. --~--~-~--~~~---~--~~ 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 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: VimClojure 2.0.0 released (merged with Gorilla)
Awesome! This is really sweet. I've got it up and running, and this is really getting good now. I've got a couple quick questions: * Is there a smart way to install it? I've been copying each .vim file into its place inside my $HOME/.vim directory, but this gets repetitive and annoying fast. How about an ant task or something that does it for you? * How about starting the nailgun server automatically if it isn't already started? * How about connecting a repl to a running process? My guess is that by connecting to your back-end and starting a listening socket this could be done... * I've got the clojure.txt file inside $HOME/.vim/doc, but if I :h clojure it says no help for clojure... Thanks a lot for doing this. I use it daily, and I think it will help a lot of people get into Clojure as the language grows. -Jeff Meikel Brandmeyer wrote: > Dear vimming Clojurians, > > I'm proud to announce VimClojure 2.0! > > I want to thank durka42 on #clojure for being a > patient guinea pig - eh - beta tester, finding the > bugs within minutes. :) > > Updates and Fixes: > * Updated higlighting to SVN 1327 > * Fixed completion bug on Windows (thanks to jb) > > Gorilla was merged into VimClojure. To > use the interactive features, set the variable > "clj_want_gorilla" in your .vimrc. If you do so, > you must start the Nailgun server before > editing clojure files with vim. > > More information on the installation can be > found in the README.txt. > > Interactive features are: > * docstring lookup > * javadoc lookup > * evaluation of code > * buffer repl > * omni completion with fuzzy logic >(eg. r-s >=> read-string, resultset-seq, ...) > > Note: Ruby is *not* needed anymore! > > Windows support: > I'm loosing complete interest in supporting > Windows. No matter how much time you > invest, there will be another moronic special > case which breaks everything again. > > Adding to the difficulty is that I cannot test > on Windows. So I will release as is. In case > there are problems on Windows I'm open > for fixes but I will not invest much time myself. > > Anyway, I hope you find this plugin useful > and that it helps you in your work. > > http://www.vim.org/scripts/script.php?script_id=2501 > > Sincerely > Meikel > --~--~-~--~~~---~--~~ 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 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: Static type guy trying to convert
this is an interesting question to me. Seems like there are at least two parts: a) do you like compilation and static code analysis, b) do you like a strong type system? Some has already been said about (a) and more about (b). For me, it's still bizarre in python that I can be running a program that actually has *syntax errors". I can do things like, "how do I exit the program again when I accidentally end up down this branch? . . .oh, who knows, just put some nonsense there, and the program will crash" No, I don't really do that on purpose. The reality is that a program that compiles is not necessarily a correct program, but there is something to be said about learning the techniques that force the errors to occur at compilation time . . . .for example, saying: "if (3 = a)" is caught at compile time because it should have been "if (3 == a)", but "if (a = 3)" would happily work in C++. Likewise, a program that appears to run correctly on a non-exhaustive case isn't necessarily right, in general. But in it's defense, the running a program is all that counts. That's what the program is for! Test driven development can be seen, then, as a better mode for the developer to spend the majority of time. I just think, like some others, that it's most effective to have smart IDE's that pretend to run the code ... or pretend to compile the code as you go. It's true that testing as you go is the more disciplined thing to do, but it can also be kind of tedious when you're just trying to have fun. On Tue, Mar 10, 2009 at 1:16 AM, zoltar wrote: > > Hey everyone. I've been keeping up with developments in Clojure for a > few months now and have a question for all you long-time static typers > out there (I know you're there :) > > I really like what I read about Clojure and LISP in general and can > see the potential for great power and flexibility. I know the > advantages/disadvantages of static vs dynamic languages but I can't > help feeling like I'm losing something whenever I try Clojure. I am > admittedly brainwashed after years of C, C++ and Java but I miss the > warm fuzzies when I know the compiler has checked all the types for me > and I don't have to worry about a whole class of run-time errors. I'm > willing to give that up for the advantages Clojure gives me but I was > wondering how others have dealt with the loss of these static warm > fuzzies. I always feel a bit lost in Clojure, not knowing what types a > function expects or what it will return. I suppose this goes away in > time but any advice is appreciated. > > Curtis > > > > > --~--~-~--~~~---~--~~ 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 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: filter1 interesting?
On Mar 10, 2:45 pm, "gray...@gmail.com" wrote: > Doesn't (some pred coll) do the same thing as (first (filter pred > coll))? Not quite, because ... (some even? [1 2 3]) --> true (first (filter even? [1 2 3])) --> 2 `some' only works like that when the "predicate" returns it's argument instead of true. Rob --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure plugin for IntelliJ IDEA published
Hi Ilya, I would like to use the IntelliJ IDEA to create a GUI in the forms designer and then code the rest of the app in Clojure. I would like both Java and Clojure code to be registered in a single project and compiled together. If you can do that, you've got yourself another sale. Can you tell me the current capabilities / future plans with this? Thanks. Mike On Mar 10, 2:30 pm, Ilya Sergey wrote: > Hi, Howard > > Yes, we support debugging for Clojure scripts (even from libary). To > launch debugger, create run configuration (for this you may just press > Ctrl-Shift-F10 on appropriate script to be run) and launch it in debug > mode (Shift-f9 in Linux/Windows keymap). > You may set breakpoints and navigate through call stack. "Evaluate > expression" in Clojure-style is not supported now, but it is coming > soon. > > With best regards, > Ilya > > On Mar 10, 6:44 pm, Howard Lewis Ship wrote: > > > Is there any kind of debugger support (now, or coming?). > > > On Tue, Mar 10, 2009 at 8:10 AM, Tom Ayerst wrote: > > > Liking it so far. Can you get jline style functionality into the REPL, I > > > really miss it. > > > > Cheers > > > > Tom > > > > 2009/2/27 AndrewC. > > > >> On Feb 26, 7:08 pm, CuppoJava wrote: > > >> > Hello Ilya, > > >> > Thanks for the workaround. > > > >> > I'm glad to hear you're working on a "surround with" feature. Some > > >> > other parenthesis commands that I most commonly use is: > > >> > 1) Delete next Sexp. > > >> > 2) Splice Sexp. (Remove the parenthesis around the current sexp). > > >> > 3) Move cursor to next/previous sexp. > > > >> Don't forget Barf and Slurp! > > > >> Barf - eject an Sexp from this Sexp (front and back): > > > >> (a b c) -> (a b) c > > >> (a b c) -> a (b c) > > > >> Slurp - incorporate an Sexp into this Sexp (front and back): > > > >> (a b) c -> (a b c) > > >> a (b c) -> (a b c) > > > >> Also copy this sexp, cut this sexp. > > > >> All vital! > > > -- > > Howard M. Lewis Ship > > > Creator Apache Tapestry and Apache HiveMind --~--~-~--~~~---~--~~ 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 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 in Atlanta, Meetup event on
http://leafhopper.github.com/clojure.html 1. Step through the Programming Clojure book. 2. Reinforce above by creating a draft of an online course mimicking the style of Ruby Learning. * read material * review a list of important points * do (create) a few exercises related to the material and discuss in a forum * take (create) a multiple choice test RubyLearning.com online courses provide a fun & simple way to learn something new. So the next best thing to taking a fun & simple course for clojure would be to create one. Please note that I have little experience in Clojure and am using this method to learn it. You are welcome to join in. I got the following email today, related to a Clojure group in Atlanta. I guess this is only relevant for those that are close to Atlanta. But Clojure groups by locale are always a good thing. There is a very strong J2EE/Ruby community in Atlanta. Hopefully that can also include some Clojure. --~--~-~--~~~---~--~~ 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 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: What is Clojure NOT good for?
- You aren't going to find a job in your favorite city using your favorite > language in your favorite domain. Decide what you value the most and go from > there. nice post! but only the cities and domains are fairly well enumerated. I guess 2 out of 3 ain't bad. --~--~-~--~~~---~--~~ 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 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: filter1 interesting?
seems like a good reason all predicates should be required to return their argument, contractually. So this is a good lesson for me. Even if I'm wrong about all predicates, how would one do such a thing in a functional language? That is, I'm not even sure what "all predicates" means. In OO, it would mean they somehow subclass "predicate" . . . or in static, generic programming, you'd get a compile error it the wrong type were returned from the predicate template param. Anyway, if all preds don't return their argument, you can't trust any to. ... seems to me. On Tue, Mar 10, 2009 at 8:31 PM, Rob wrote: > > > On Mar 10, 2:45 pm, "gray...@gmail.com" wrote: > > Doesn't (some pred coll) do the same thing as (first (filter pred > > coll))? > > Not quite, because ... > > (some even? [1 2 3]) --> true > (first (filter even? [1 2 3])) --> 2 > > `some' only works like that when the "predicate" returns it's argument > instead of true. > > Rob > > > --~--~-~--~~~---~--~~ 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 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: filter1 interesting?
On Tue, Mar 10, 2009 at 9:03 PM, e wrote: > seems like a good reason all predicates should be required to return their > argument, contractually. You'd have some trouble with 'nil?' and 'false?' at the very least. --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 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: Static type guy trying to convert
On Tuesday 10 March 2009 21:33:38 Mark Engelberg wrote: > A static type system also documents these properties, but you're > restricted to certain concepts that the computer can understand and > prove things about. You'll start to realize that there are concepts > that are difficult or impossible to easily capture with a static type > system (e.g., this function takes positive even integers, and returns > a number from 0 to 9). While your point is valid your example is not. Specifically, you can easily imagine a function signature: uint seq -> digit -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e --~--~-~--~~~---~--~~ 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 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: VimClojure 2.0.0 released (merged with Gorilla)
*cheer* thanks Meikel! --~--~-~--~~~---~--~~ 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 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: VimClojure 2.0.0 released (merged with Gorilla)
I've got it up and running on Windows and it looks great. Thanks Meikel! On Mar 10, 7:36 pm, Meikel Brandmeyer wrote: > Dear vimming Clojurians, > > I'm proud to announce VimClojure 2.0! > > I want to thank durka42 on #clojure for being a > patient guinea pig - eh - beta tester, finding the > bugs within minutes. :) > > Updates and Fixes: > * Updated higlighting to SVN 1327 > * Fixed completion bug on Windows (thanks to jb) > > Gorilla was merged into VimClojure. To > use the interactive features, set the variable > "clj_want_gorilla" in your .vimrc. If you do so, > you must start the Nailgun server before > editing clojure files with vim. > > More information on the installation can be > found in the README.txt. > > Interactive features are: > * docstring lookup > * javadoc lookup > * evaluation of code > * buffer repl > * omni completion with fuzzy logic > (eg. r-s > => read-string, resultset-seq, ...) > > Note: Ruby is *not* needed anymore! > > Windows support: > I'm loosing complete interest in supporting > Windows. No matter how much time you > invest, there will be another moronic special > case which breaks everything again. > > Adding to the difficulty is that I cannot test > on Windows. So I will release as is. In case > there are problems on Windows I'm open > for fixes but I will not invest much time myself. > > Anyway, I hope you find this plugin useful > and that it helps you in your work. > > http://www.vim.org/scripts/script.php?script_id=2501 > > Sincerely > Meikel > > smime.p7s > 5KViewDownload --~--~-~--~~~---~--~~ 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 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: Static type guy trying to convert
On Tuesday 10 March 2009 13:26:32 Vincent Foley wrote: > Here's my feeling on it (note that I am talking about languages from > the C family, not Haskell or ML). Then the feelings you are describing are specifically about C and are not related to static typing in general. > 1. Like Jason Wolfe said, the interactive REPL means that you can > manually test a function as soon as you're done writing it, so it's > easy to get feedback and know if something breaks. Even C# has a REPL now. > 2. The whole thing does not need to be complete or even functional for > you to start unit testing. Apples and oranges: unit tests are not the same between dynamic and static code bases because dynamic code bases rely upon a huge number of additional unit tests to serve as a poor man's substitute for static type checking. > 3. The type systems of Java, C and C++ do not protect you against > errors like NullPointerExceptions. (I am pretty sure C# has nullable > types now, and of course Haskell has Maybe t.) Actually Haskell's Maybe monad is a counter example because its sole purpose is to protect you from the equivalent of null pointer exceptions by forcing you to be explicit about them. > 4. Not having the static type system means that if it's ever needed, > it will be possible for you to do what you know is right instead of > what the compiler wants. You are assuming that what you know is right and what the compiler wants are different. IME, that is virtually unheard of in real code. Most of the reasons given in this thread were red herrings and many of static typing's real issues were not even touched upon: . Implementing modern static type systems correctly is really hard. Consequently, the vast majority of new languages are dynamically typed because that is much easier to implement. . Interface code between dissimilar parts of a program is often incapable of conveying static type information so static type checking is useless here. This includes everything from remote procedure calls through to database transactions and down to the foreign function interface. Haskell's Darcs project was almost killed by an FFI-related bug. . Static typing is hard to appreciate and hard to learn. People with no experience of developing complex software correctly cannot appreciate the benefit of proving any kind of correctness because everything they have done is obvious. Concepts like parametric polymorphism are just mathematics so a math background helps. -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e --~--~-~--~~~---~--~~ 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 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: What is Clojure NOT good for?
That's the whole idea, if your current "coding" habits are not efficient well changing them involves taking a risk... otherwise everyone would do it. Humans have a tendency to stay within their comfort zone. Stretching that bubble takes time. No change however = stagnation and eventually obsolescence. I have never believed in the single hammer approach to all problems in a single project. However most customer projects I dealt with had this disease, the main reason being that was the "comfort" zone issue showing up in most of the technical decisions taken in the project. The day managers will stop looking at their developer's skills as something fixed and "immutable", projects will deliver with better quality and faster because there will be a choice of tools available for different parts of the same project and more flexibility resource wise. When my shop was working solely on custom components for our customers, I used to change people from one project to other according to the workload state at a couple of hours notice. New project, new technology... It's like moving a plant from one spot to a different one. It might be hard at first but at some point the plant gets stronger. This approach beats the hell out of people at first but as they are moved from one project to the other they see the light. They understand how to adapt and shift because of the constraints (time line, learning curve, ) One big advantage of my employees versus plants: they were able to speak when they did needed some guidance. I must say that what I did was not a benefit for most that left for other companies since we stopped the custom software business. They found most of the time that their liberty was severely restricted in their new job compared to what they could do in my shop... Today, we can choose the appropriate technology for the task to do since we are now working on our own products. Our approach has not changed except that we have greater latitude in what we decide to use (and of course greater potential to hang ourselves). Luc On Tue, 2009-03-10 at 09:53 +0100, Christian Vest Hansen wrote: > Also, how do you think this increase in required effort grows? What if > we are talking about a +10.000-line Clojure program? Now add schedule > pressure, deadlines and the cost of missed oppotunities and you will > find that many companies sees the introduction of a new programming > language - especially if it is uncontrolled or happens without their > knowledge - as a significant risk. -- Luc Préfontaine Off.:(514) 993-0320 Fax.:(514) 993-0325 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 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: What profilers are you using?
On Feb 7, 9:16 am, David Powell wrote: > Newer versions of JDK 1.6, eg Update 11, have an application called > 'jvisualvm' in the bin directory. It lets you attach to any running > Java process and it has aprofilerthat you can switch on at runtime. > > It seems quite good. It does profiling via instrumentation, and yet > doesn't slow the app down to much. I tried it with a clojure module > that is run from a Java appserver, and it worked well. > > -- > Dave Can you go into more detail about how you used visualvm? I'm trying to run it (visualvm 1.1.1), and it seems to have a race condition with the clojure classloader. Sometimes it won't find all of the compiled clojure source, and sometimes it will correctly profile methods until I reload a file, at which point the profiler no longer tracks calls to the clojure fn. Any advice? Allen --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
Identifying maps.
Hi, I've just read the "On the importance of recognizing and using maps" post and it made wonder about the best way for identifying maps. Obviously, when the situation permit it, we better use some kind of label to identify them. But sometimes, it's preferable to test for multiple keys and I'm not sure what's the best way to do this. We can use contains? but it takes only one key. I've made a modification to contains? so that it can take many keys as shown in the patch below. P.S.: I've still not mailed a contributor agreement, tried to send it two months ago, but it came back. I had totally forgotten about postage stamps! It's astonishing how the web can make you used to get stuff for free ;-) I'll try again this week with stamps this time! --- src/clj/clojure/core.clj(revision 1301) +++ src/clj/clojure/core.clj(working copy) @@ -900,7 +900,16 @@ vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or logarithmic time; it will not perform a linear search for a value. See also 'some'." - [coll key] (. clojure.lang.RT (contains coll key))) + ([coll key] (. clojure.lang.RT (contains coll key))) + ([coll key & keys] + (loop [keys (cons key keys) acc true] + (if keys + (let [key (first keys) + res (and acc (. clojure.lang.RT (contains coll key)))] + (if (and res (seq? keys)) + (recur (next keys) res) + res)) + acc (defn get "Returns the value mapped to key, not-found or nil if key not present." --~--~-~--~~~---~--~~ 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 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: What profilers are you using?
> Can you go into more detail about how you used visualvm? I'm trying to > run it (visualvm 1.1.1), and it seems to have a race condition with > the clojure classloader. Sometimes it won't find all of the compiled > clojure source, and sometimes it will correctly profile methods until > I reload a file, at which point theprofilerno longer tracks calls to > the clojure fn. > Replying to my own question because I figured it out. On the profiler tab, before you hit "start profiling", click the settings checkbox. Edit the "start from class" field. Mine was set to jline.**. After changing it to the appropriate namespace for my app, hit the "start profiling" button. Visualvm starting working reliably for me after that. Allen --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
Resurrecting request for infinity
http://groups.google.com/group/clojure/browse_frm/thread/5e665ce7a318f44a/3ddb49bd3ca34709?lnk=gst&q=infinite+inc+0#3ddb49bd3ca34709 I would have replied to the above post, but google groups doesn't seem to want to let me. In it, Stephen Gilardi makes the case for a fn equivalent to "(iterate inc 0)" be built into the language. I ran into needing to do this again tonight, and forgot the idiom for (iterate inc 0). Allen --~--~-~--~~~---~--~~ 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 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: filter1 interesting?
> You'd have some trouble with 'nil?' and 'false?' at the very least. > wouldn't be the first time :) ... I mean, oh, ok. --~--~-~--~~~---~--~~ 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 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: Static type guy trying to convert
Some of you may not know of Jon's behvior on comp.lang.lisp so some background will be useful here. He runs a business selling ocaml and f# consulting and training services and materials. He routinely posts insulting and inflammatory remarks about lispers and lisp in comp.lang.lisp. He admits his principal purpose there is to drum up business for his ocaml/f# consulting. These both being statically typed languages, and Jon's livelihood flowing from their use, he will naturally defend static typing and criticize dynamic typing. His posts must be considered as being highly biased because of his admitted economic interests and purposes. If past behavior is any guide he will seek to belittle clojure and present f# as a superior alternative. Don't be fooled by his attempts to prey on those unfamiliar with his mode of operation and get them to buy his training materials/journals and consulting services by presenting their language of choice, clojure, as somehow lacking with respect to those he sells services 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 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: Static type guy trying to convert
On Wed, Mar 11, 2009 at 12:26 AM, Raffael Cavallaro < raffaelcavall...@gmail.com> wrote: > > Some of you may not know of Jon's behvior on comp.lang.lisp so some > background will be useful here. > > He runs a business selling ocaml and f# consulting and training > services and materials. He routinely posts insulting and inflammatory > remarks about lispers and lisp in comp.lang.lisp. > > He admits his principal purpose there is to drum up business for his > ocaml/f# consulting. These both being statically typed languages, and > Jon's livelihood flowing from their use, he will naturally defend > static typing and criticize dynamic typing. > > His posts must be considered as being highly biased because of his > admitted economic interests and purposes. If past behavior is any > guide he will seek to belittle clojure and present f# as a superior > alternative. > > Don't be fooled by his attempts to prey on those unfamiliar with his > mode of operation and get them to buy his training materials/journals > and consulting services by presenting their language of choice, > clojure, as somehow lacking with respect to those he sells services > for. > > > h, that could sound like more of an endorsement than anything he could have said, himself! Afterall he could have chosen a dynamically typed language for his business if he had wanted to. That really says something about OCaml and f#. At any rate, either he makes a good point or he doesn't. If his arguments have flaws, point them out. My interest right now in following clojure is to learn ALL the arguments, including his. --~--~-~--~~~---~--~~ 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 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: Static type guy trying to convert
On Mar 11, 12:44 am, e wrote: > h, that could sound like more of an endorsement than anything he could > have said, himself! Afterall he could have chosen a dynamically typed > language for his business if he had wanted to. You have to be an expert in something to run a business selling training and consulting in it. There is no evidence that he has ever written a single line of lisp. Read that again; he has posted to comp.lang.lisp dozens of times and not to my knowledge ever posted a single line of lisp. His business is what it is because that's what he knows, not because he had a choice between that and lisp. You have to know lisp for it to be a choice. --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
Enjoying test-is
I just wanted to say thanks to Stuart Sierra for test-is. When I start using some new compiler, there always comes a point, if I keep it up long enough, that I get annoyed with my little ad hoc tests and want some sort of testing framework to make things easier. test-is does the job. Thanks, Stuart! --~--~-~--~~~---~--~~ 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 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: Debugging support for clojure?
Joshua writes: Hi Joshua, > The eclipse plugin also provides some debugging support. Ok, so Eclipse & IntelliJ support debugging. Does SLIME do, too? Bye, Tassilo --~--~-~--~~~---~--~~ 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 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: Static type guy trying to convert
On Mar 10, 11:44 pm, e wrote: > On Wed, Mar 11, 2009 at 12:26 AM, Raffael Cavallaro < > > > > > > raffaelcavall...@gmail.com> wrote: > [...comments on Harrop's marketing tactics...] > h, that could sound like more of an endorsement than anything he could > have said, himself! Afterall he could have chosen a dynamically typed > language for his business if he had wanted to. That really says something > about OCaml and f#. > > At any rate, either he makes a good point or he doesn't. If his arguments > have flaws, point them out. > > My interest right now in following clojure is to learn ALL the arguments, > including his. Saying that something sucks and suggesting that people who like it are fools isn't an argument, it's just yanking people's chains to get attention. --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---