Re: idiomatic list-ify
Not sure what kind of input you can get, but apply-ing list only on strings would decompose them, so your function can be written as: (defn ls [x] (cond (string? x) (apply list (list x)) :else (apply list x as '(apply list nil)' will yield '(). Or, you can write it more lispy: (defn ls [x] (apply list (if (string? x) (list x) x))) On Thursday, March 8, 2012 7:28:12 PM UTC+1, Brandon Harvey wrote: > > Hi, > > I'm seeking a small & idiomatic function that will take input and ensure > it's wrapped in a list. If nil, I'd like the list to be empty. If the > input is already a list, I don't want to wrap it in another list layer. So: > > "hi" => ("hi") > nil=> () > ("hi") => ("hi") > > (list '("hi")) => (("hi")) ; bad > (apply list "hi") => (\h \i) ; bad > > So I've ended up writing the function with a conditional, like so. Is > there a tidier way? > > (defn ls [x] (cond (list? x) (apply list x) >(nil? x) '() >:else (list x))) > > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
using Clojail dynamically
I've just been trying out Clojail, and ran into a difficulty. Suppose you make a sandbox: (def sb (sandbox secure-tester)) and you want to dynamically assemble function calls to run inside the sandbox. Well, the sandbox takes a quoted expression, so you do something like this: (defn function-sandbox [func inputs] (map (fn [inp] (sb `(~func ~inp))) inputs)) and try: (function-sandbox inc [1 2 3]) but: RuntimeException EvalReader not allowed when *read-eval* is false. clojure.lang.Util.runtimeException Naturally, eval is disallowed by the sandbox. All the examples in the docs show using the sandbox with a literal quoted expression; how do you use it with expressions assembled at runtime? Thanks, Nick. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: using Clojail dynamically
Hi, without being too deep in clojail and the like... Try quoting the func and input values to your function-sandbox function. 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Leiningen 2.0.0-preview1
Another problem. I have a ":repl-init myproj.something" in project.clj . Using "lein repl", that namespace gets pulled in just fine, but not when I do a "lein2 repl". Any idea why? Looks like it does not even try to load the namespace until I pull it in inside the repl manually. Thanks, Marius K. On Mar 9, 5:41 am, Phil Hagelberg wrote: > Phil Hagelberg writes: > > Just found a bug that only manifests when you don't have any profiles > > and are running outside a project. > > I released a 2.0.0-preview2 version with this fix. If you are running > the old preview, running "lein2 upgrade" should take care of it. > > thanks, > Phil -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Can Clojure be as readable as Python or Ruby ?
On Thursday, March 8, 2012 9:33:04 PM UTC-5, puzzler wrote: > > I love these ideas. I think your final comment is especially insightful. > I have no problem writing Clojure code, I just find it unnecessarily taxing > to read it. The idea of separating the two, and possibly having a > read-mode is an absolutely fascinating idea. In some sense, Marginalia is > already a good positive step in this direction. The first time I ran > Marginalia on my code I was astonished at how much more readable it was to > have the comments in a separate column alongside the code, rather than > interrupting the code itself. It makes me wonder how many other things > could have such a positive, dramatic effect. > I think you struck it there, especially wrt marginalia. I've been wanting for a long time for some kind of code editor where ancillary things like comments/tests/contracts/examples may be displayed in a more appropriate manner, so that our code may be the star of our screen, while still being appropriately accompanied on demand by those comments/tests/contracts/examples. You're right that putting comments in a different column (which is scrolled synchronously) helps. Wouldn't be nice if that column could be replaced anytime with tests/contracts/examples/etc.? And with a larger monitor, multiple synced columns could be displayed. That said, to me, it's important that all of this is still editable at all times. I don't often read my own code in marginalia for this reason. Of course, you may just as well tell me that's what emacs allows with its buffers and swank-clojure & slime. But anyway, emacs' way of doing it is much more an *on demand* thing, and much less pervasive for now. I feel we could do quite a bit more with those tools. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: idiomatic list-ify
On Thursday, March 8, 2012 2:19:37 PM UTC-8, mefesto wrote: > > If `x` is a list then is the call to `(apply list x)` necessary? > Yes, meant to take that out. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Can Clojure be as readable as Python or Ruby ?
This has been a fascinating discussion, thanks to everyone involved. I do kind of feel like complaining about indentation in Clojure is like complaining that Ruby has too many parentheses ( shut up, they're optional!). I still feel like a big part of 'readability' comes down to personal preference. Python is often the canonical example of a readable language, but I find significant whitespace offensive, and other 'features' just terribly limiting. I spend most of my time coding in Ruby, which is very readable (for me), but I enjoy reading and writing Clojure equally well, if not more. One side-effect of Clojure's 'difficulty', for me at least, is being forced to think harder. This is a good thing. Homoiconicity was never a feature geared toward easiness, but rather power and simplicity. Anyhow, thanks for this discussion. I've enjoyed it. Jason On Mar 9, 2012 2:48 AM, "Tassilo Horn" wrote: > > Mark Engelberg writes: > > Hi Mark, > > > In the meantime, just to get a feel for whether this is unique to my code > > or universal, I decided that I was going to carefully scrutinize the > > nesting level of the next public Clojure code I encountered. Completely > > randomly, the next Clojure code I encountered was this blog post: > > http://blog.japila.pl/2012/03/block-scanner-from-let-over-lambda-in-clojure > > > > Take a look at how indented the code is after merely 10 lines of code. We > > start to take this for granted in Clojure, but if you look at it with a > > fresh eye, it really is ridiculous. > > In some book (I think some Common Lisp book), I've read that code > leaning to the right is a pretty good indicator for code written in a > functional style. If it's straight top-down, then it's probably more > imperative with one outer let and setf-ing of that let's variables. > > That said, of course there's nothing wrong with macros like the cond > with :let or the let? in this thread. They look really useful, and I > think I have some spots in my code where I could make use of them. > > 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 > Note that posts from new members are moderated - please be patient with your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Clojure/West rock climbing unsession
Keming Labs and Upwind Solutions are sponsoring a trip to the local rock gym the Friday of Clojure/West, immediately after Richard Gabriel's talk. No rock climbing experience required: we're going to be bouldering, i.e., without ropes, not very high up. If you would like to come, RSVP with me via email so I can get a headcount and arrange transportation. best, Kevin Gym info: http://www.planetgranite.com/locations/sunnyvale/sv_faq.php -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure on android over CLI
On 8 March 2012 11:14, Jim - FooBar(); wrote: > There is a clojure repl for android... Jim, my goal is to be able to write android apps in clojure. But to develop an app in clojure on a PC is pain: The android emulator eats a lot of memory and takes minutes to start, 'ant debug install' takes about 1 minute to complete. The JVM (1.7.0_03-b04) running this command crashes quite regularly. In short: a continuous development is simply impossible. So I bought myself a shiny new phone to eliminate some of these obstacles and I'm trying to set up a decent development environment on the android. In the 1st step I want to connect from the PC to the android (over telnet or ssh) and launch the clojure REPL from a bash running on the android. But as I wrote in the prev post the 'java -jar clojure-${ver}.dex.jar clojure.main' doesn't work. regards Bost -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure on android over CLI
Hello, On 9 March 2012 00:47, Daniel Solano Gomez wrote: > In general, Android differs from the standard JVM in how classes are > packed into a JAR. [..] ah! thanx for explanation > Just out of curiousity, which version Android are you testing this on? terminal++@192.168.178.22:~$ uname -a Linux localhost 2.6.32.9-perf #1 PREEMPT Mon Sep 19 08:03:47 2011 armv7l GNU/Linux > Perhaps the java implementation here isn't setting things up quite right? you're right - there seems to be something wrong with the java implementation: terminal++@192.168.178.22:~$ java -version com.spartacusrex.spartacuside.external.InvokeException: No JAR Files specified at com.spartacusrex.spartacuside.external.java.main(java.java:65) at dalvik.system.NativeStart.main(Native Method) Usage : java -v -jar [List of Jar files] CLASSNAME Thank you for the answer Daniel! BTW I've also played with your Neko. I'm gonna post a message about it this weekend. Bost -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure.io
Possible to do I/O without any interop ever being called? No. Possible to define a standard I/O abstraction that hides the details of the underlying VM? Yes. But difficult. I/O is a leaky abstraction at the best of times. -S -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Can Clojure be as readable as Python or Ruby ?
> This has been a fascinating discussion, thanks to everyone involved. So I've been lurking on this thread for some time, and thought I'd go and offer my two cents on the topic. While writing clojure-py, I've been in the unique situation of having to decide which language features will be implemented in Clojure and which will be implemented in Python. For example, deftype is not a compiler feature in clojure-py it is actually big macro that ends up calling the python internal functions to create types. My viewpoint is that, in general, Clojure and python are equal in their "readability" on a feature to feature basis. That is, define feature A in both Clojure and Python and you'll find that it will take you about the same amount of time to grasp what is being done in both implementations. The difference is that it normally takes 1/2 the number of lines of code to do something in Clojure than it does in Python. In other words, Clojure is more terse, and hence more dense than Python. So I think the question of readability I think it really comes down to the programmer making sure that he considers what future readers of his code will think. For example, this is perfectly valid Python, and something I see fairly often in other people's Python code: print [(x, y, x * y) for x in (0,1,2,3) for y in (0,1,2,3) if x < y] But personally I consider this sort of code unacceptable. Instead I tend to write Python code thusly: for x in (0,1,2,3): for y in (0,1,2,3): if x < y: print (x, y, x*y) It looks cleaner and is much easier to understand. In Clojure we have the power to reach the middle-ground: (print (for [x [0 1 2 3] y [0 1 2 3] :when (< x y)] [x y (*x y)])) Here we get the get the "expression" style of the first Python example, with the code structure of the second python example, and at the same time end up with less indents/linewidth than either Python example. This is the reason why the majority of clojure-py is written in clojure and not python. Timothy -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Can Clojure be as readable as Python or Ruby ?
Evan Gamble writes: > (when-let [a foo] > (let [b bar] > (when (even? b) > (let [c baz] > (when (> b c) > (let [d qux] >(f a b c d))) > > becomes: > > (let? [a foo :else nil >b bar :is even? >c baz :when (> b c) >d qux] > (f a b c d)) For yet another take on this, consider using the maybe-m monad from clojure.algo.monads: (domonad maybe-m [a foo b bar :when (even? b) c baz :when (> b c) d qux] (f a b c d)) This is not 100% equivalent because any nil result in the binding list will terminate the whole expression and return nil. That's quite often the right thing to do. If not, there is a way to introduce bindings that are allowed to be nil: (domonad maybe-m [a foo b bar :when (even? b) c baz :when (> b c) :let [d qux]] (f a b c d)) Konrad. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Can Clojure be as readable as Python or Ruby ?
Timothy Baldridge writes: > For example, this is perfectly valid Python, and something I see > fairly often in other people's Python code: > > print [(x, y, x * y) for x in (0,1,2,3) for y in (0,1,2,3) if x < y] > > But personally I consider this sort of code unacceptable. > > Instead I tend to write Python code thusly: > > for x in (0,1,2,3): > for y in (0,1,2,3): > if x < y: > print (x, y, x*y) How about this (my preferred version): print [(x, y, x * y) for x in (0,1,2,3) for y in (0,1,2,3) if x < y] I prefer this especially when the result is used in a computation, rather than printed. It removes the need to initialize some variable to an empty list and then appending to it. Konrad. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: using Clojail dynamically
Indeed. Don't pass it the function +, pass it the symbol '+. On Mar 9, 1:20 am, "Meikel Brandmeyer (kotarak)" wrote: > Hi, > > without being too deep in clojail and the like... > > Try quoting the func and input values to your function-sandbox function. > > 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure on android over CLI
On Fri Mar 9 02:44 2012, Rostislav Svoboda wrote: > On 8 March 2012 11:14, Jim - FooBar(); wrote: > > There is a clojure repl for android... > > Jim, my goal is to be able to write android apps in clojure. But to > develop an app in clojure on a PC is pain: The android emulator eats a > lot of memory and takes minutes to start, 'ant debug install' takes > about 1 minute to complete. The JVM (1.7.0_03-b04) running this > command crashes quite regularly. In short: a continuous development is > simply impossible. If that is what you're trying to accomplish, perhaps a slightly different approach would be helpful. While developing the Clojure REPL, I included a copy of the VimClojure server as part of the app. When the app starts, I would have it start the server, which would listen on a TCP port on the phone/emulator. I then used adb to forward a port from the computer to the VimClojure port on the device. As a result, I would be able to send expressions from my editor, Vim, to the device, which would compile and reload them. This does require my fork of Clojure, as the standard Clojure cannot do dynamic compilation on Android. It was still slow in comparison to doing compilation on the computer, a few seconds or so. However, that's a huge improvement over the standard compile/redeploy cycle using the standard tools. I don't know what kind of editor/development environment you prefer, but a similar approach where you embed a REPL in your application may be the best for you. The main drawback to this approach is that you will probably want to remove some of these development dependencies for a released version of the app. I hope this helps. Sincerely, Daniel > > So I bought myself a shiny new phone to eliminate some of these > obstacles and I'm trying to set up a decent development environment on > the android. In the 1st step I want to connect from the PC to the > android (over telnet or ssh) and launch the clojure REPL from a bash > running on the android. But as I wrote in the prev post the 'java -jar > clojure-${ver}.dex.jar clojure.main' doesn't work. > > regards > > Bost > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en signature.asc Description: Digital signature
Re: Why don't extends? and satisfies? require implementation of all protocol methods?
I just want to point out that I incorrectly stated that Clojure generates abstract stubs for unimplemented protocol methods (or types, for that matter). In fact, Clojure does nothing about them. For classes to fully implement interfaces is enforced by the Java compiler, not the JVM. On Thursday, March 8, 2012 11:40:20 PM UTC-8, Garth Sheldon-Coulson wrote: > > I think Tassilo's ideas about extenders deserve more discussion. But let > me continue the discussion with Armando for now. > > Thank you for offering the Eclipse API example, which is very helpful. I > agree that Java's OO paradigm creates the need for abstract classes. > However, I would like to look further at what is going on in the Eclipse > example and consider if protocols in Clojure are the same or different. > > To clarify the example: Eclipse allows the user to add the user's own > methods for certain kinds of event-handling. Because the language is Java, > these methods must be attached to a class. In order for Eclipse to specify > which methods it expects, Eclipse provides an interface that the user's > class must implement. For convenience, Eclipse also provides default > implementations of the required methods; these are provided in an abstract > class. When the user extends this abstract class, the user can elect to > override none, some, or all of the default methods. > > I have a few observations. > > 1) In the example, it is certainly true that the user may implement none > or just some of the methods of the interface. However, when the user > finally passes an object instance to Eclipse, *all* of the methods of the > interface are in fact implemented by that instance. This is because the > default implementations in the abstract class will fill any holes the user > leaves. Therefore, I respectfully disagree that this is case of "partial > implementation." It may appear so to the user, but not to the language. > > 2) It is true that a Java abstract class can partially implement an > interface. However, an abstract class cannot be instantiated. It must be > extended first. When extending an abstract class, the user must implement > any methods that the abstract class has not implemented. No concrete class > "partially implements" an interface. > > To me, the analogy to Java therefore supports the idea that the extends? > relationship ought to require a datatype/record to implement all of its > protocols' methods. A datatype/record is a piece of data, not a collection > of default methods; it is therefore like an object instance, not an > abstract class. Object instances must implement all of their interfaces' > methods. > > As I said in my last post, it would seem strange for a language to provide > protocols (rather than just fast, un-grouped multimethods) if a piece of > data that "satisfies" a protocol does not necessarily implement even one of > the protocol's methods. > > 3) Armando's worry is valid that requiring implementation of protocol > methods would result in "proliferation of interfaces and protocols that > would prevent reuse; something like > ListWithoutModificationOrBulkOperations." > > However, to me the beauty of protocols is that they can be highly > granular. They are not tied to a rigid inheritance paradigm. They support > direct implementation composition. If, per Armando's example, a protocol > designer felt the need to have a BasicList protocol, a ModifiableList > protocol, and a BulkOperations protocol, to be combined as necessary, that > would be just fine. > > 4) In /The Joy of Clojure/, a few of the examples involve extending a type > to implement just one of a protocol's multiple methods (pp. 193-195). The > authors consider this a valid use case. To leave the /JoC/ examples roughly > intact while giving protocols a bit more bite, let me throw out two ideas > for discussion. > > Idea 1 > == > > Types may be extended to a strict subset of a protocol's methods, but > satisfies? and extends? will return FALSE, not true, in this case. That is: > > => (defprotocol Fixo > (fixo-push [fixo value]) > (fixo-pop [fixo])) > Fixo > > => (extend-type clojure.lang.IPersistentVector > Fixo > (fixo-push [vector value] >(conj vector value))) > [succeeds] > > => (extends? Fixo clojure.lang.IPersistentVector) > FALSE, not true > > > Idea 2 > == > > Types may be extended to new protocols only if *all* of the protocol's > methods are implemented. However, types may be always extended tonew, > ungrouped *methods*. That is: > > => (defprotocol Fixo > (fixo-push [fixo value]) > (fixo-pop [fixo])) > Fixo > > => (extend-type clojure.lang.IPersistentVector > Fixo > (fixo-push [vector value] >(conj vector value))) > [should FAIL - protocol name not allowed here unless all methods are > implemented] > > => (extend-type clojure.lang.IPersistentVector > nil > (fixo-push [vector value] >(conj v
Re: Leiningen 2.0.0-preview1
Yes, it's not supported yet in lein2 because REPL-y doesn't support it yet. But it's definitely on my plate to knock out soon, along with :prompt support, although :repl-* options will likely be collapsed into a :repl-options map. https://github.com/technomancy/leiningen/issues/432 https://github.com/trptcolin/reply/issues/31 -Colin On Friday, March 9, 2012 5:32:33 AM UTC-6, kjeldahl wrote: > > Another problem. I have a ":repl-init myproj.something" in > project.clj . Using "lein repl", that namespace gets pulled in just > fine, but not when I do a "lein2 repl". Any idea why? Looks like it > does not even try to load the namespace until I pull it in inside the > repl manually. > > Thanks, > > Marius K. > > On Mar 9, 5:41 am, Phil Hagelberg wrote: > > Phil Hagelberg writes: > > > Just found a bug that only manifests when you don't have any profiles > > > and are running outside a project. > > > > I released a 2.0.0-preview2 version with this fix. If you are running > > the old preview, running "lein2 upgrade" should take care of it. > > > > thanks, > > Phil -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: using Clojail dynamically
Thank you both! That works. I'm not sure I understand why, though. From the error message, you would think it needs fewer steps of evaluation, not more. Meanwhile, if I do: (defn non-sandbox [func inputs] (map (fn [inp] (eval `(~func ~inp))) inputs)) this has no problem taking a function. But I also notice it works on both quoted and unquoted forms. So is this something I don't understand about Clojure, not Clojail? On Mar 9, 7:41 am, Alan Malloy wrote: > Indeed. Don't pass it the function +, pass it the symbol '+. > > On Mar 9, 1:20 am, "Meikel Brandmeyer (kotarak)" > wrote: > > > > > > > > > Hi, > > > without being too deep in clojail and the like... > > > Try quoting the func and input values to your function-sandbox function. > > > 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Can Clojure be as readable as Python or Ruby ?
Evan Gamble writes: > (let? [a foo :else nil >b bar :is even? >c baz :when (> b c) >d qux] > (f a b c d)) Macros like that just make your code so much LESS readable. I now have to understand the semantics of a bunch of keywords specific to the macro, their order of operations within the macro, as well as recognizing the little ? on the end of the let as I'm scanning. I also have to see if that's a keyword or the start of another binding! :else nil? really? :is ... Geezus christ :when !?!?! Put down that nailgun, kid ;; This maintains the same logic (unless I fucked up transcoding) ;; and also the same err, complexity, in that forms are not exeuted if ;; they don't need to be, as your initial example, without nesting all ;; the way over to the side, or using some weird keyword language. (when-let [a foo] (let [b bar c (when (even? b) baz)] (when (and c (> b c)) (f a b c qux ;; or (when-let [a foo] (let [b bar c (when (even? b) baz) d (when (and c (> b c)) qux)] (when d (f a b c d Keep your constructs simple, and learn to love the nil. Also, people have been writing lisp for a real long time, and they haven't invented a chucklehead macro like let? yet, so prolly not really needed to improve the readability... -- Craig Brozefsky Premature reification is the root of all evil -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Can Clojure be as readable as Python or Ruby ?
Craig Brozefsky writes: Hi Craig, > Also, people have been writing lisp for a real long time, and they > haven't invented a chucklehead macro like let? yet, so prolly not > really needed to improve the readability... They have invented `loop' and `format'. ;-) SCNR, 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Can Clojure be as readable as Python or Ruby ?
I find let? useful and readable, as do others. There's a bit of brain- training necessary to read it, but not a lot. Probably no more than the keyword clauses of the "for" comprehension. The argument that decades of Lisp programmers haven't invented this particular "chucklehead" macro is a bit weak, since there have been many other similar macros. ...and I have learned to love nil, even the :else nil clause that repels you. - Evan On Mar 9, 9:26 am, Craig Brozefsky wrote: > Evan Gamble writes: > > (let? [a foo :else nil > > b bar :is even? > > c baz :when (> b c) > > d qux] > > (f a b c d)) > > Macros like that just make your code so much LESS readable. I now have > to understand the semantics of a bunch of keywords specific to the > macro, their order of operations within the macro, as well as > recognizing the little ? on the end of the let as I'm scanning. I also > have to see if that's a keyword or the start of another binding! > > :else nil? really? > > :is ... Geezus christ > > :when !?!?! Put down that nailgun, kid > > ;; This maintains the same logic (unless I fucked up transcoding) > ;; and also the same err, complexity, in that forms are not exeuted if > ;; they don't need to be, as your initial example, without nesting all > ;; the way over to the side, or using some weird keyword language. > > (when-let [a foo] > (let [b bar > c (when (even? b) baz)] > (when (and c (> b c)) > (f a b c qux > > ;; or > > (when-let [a foo] > (let [b bar > c (when (even? b) baz) > d (when (and c (> b c)) qux)] > (when d (f a b c d > > Keep your constructs simple, and learn to love the nil. > > Also, people have been writing lisp for a real long time, and they > haven't invented a chucklehead macro like let? yet, so prolly not really > needed to improve the readability... > > -- > Craig Brozefsky > Premature reification is the root of all evil -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
ns-publics, ns-map etc in ClojureScript?
Hi, Is there a plan to support namespace-related meta programming functions such as ns-publics, ns-map etc. in ClojureScript? I was wondering about at least the ones that we annotate with ^:export in the CLJS files. Shantanu -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ns-publics, ns-map etc in ClojureScript?
On Fri, Mar 9, 2012 at 3:05 PM, Shantanu Kumar wrote: > Hi, > > Is there a plan to support namespace-related meta programming > functions such as ns-publics, ns-map etc. in ClojureScript? I was > wondering about at least the ones that we annotate with ^:export in > the CLJS files. > > Shantanu > It might make sense to have them available at the REPL but I'm not sure about runtime. David -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Can Clojure be as readable as Python or Ruby ?
On Fri, 2012-03-09 at 10:04 -0800, Evan Gamble wrote: > I find let? useful and readable, as do others. There's a bit of brain- > training necessary to read it, but not a lot. Probably no more than > the keyword clauses of the "for" comprehension. The argument that > decades of Lisp programmers haven't invented this particular > "chucklehead" macro is a bit weak, since there have been many other > similar macros. > > ...and I have learned to love nil, even the :else nil clause that > repels you. There is a bit of brain-training necessary to read code with parens but not a lot. In fact, my editor can read paren code. The let? syntax breaks code walkers. The let? syntax breaks pretty printers. The let? syntax "complexes" read. See the loop package in Common Lisp. Some people swear by it, others swear at it. The idea isn't new. If you want "readable code" write a literate program. Literate programs communicate from person to person rather than having the person "decode" your idea from the code. If you understand the idea, any syntax is easy to read. Tim Daly -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ns-publics, ns-map etc in ClojureScript?
Namespaces don't exist at runtime in ClojureScript. That's not likely to change. -S -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Can Clojure be as readable as Python or Ruby ?
Tassilo Horn writes: > Craig Brozefsky writes: > > Hi Craig, > >> Also, people have been writing lisp for a real long time, and they >> haven't invented a chucklehead macro like let? yet, so prolly not >> really needed to improve the readability... > > They have invented `loop' and `format'. ;-) Yah know, I was thinking of those as I wrote that, and I figured they actually would stand as supporting evidence for my quip 8^) -- Craig Brozefsky Premature reification is the root of all evil -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Can Clojure be as readable as Python or Ruby ?
Well maybe the problem of the let? macro is that it is not standard. If you use standard constructs and I'am proeficient with clojure I'll understand your code fast. I'll concentrate on understanding your code relevant for your application and domain. But just adding a few new constructs specific to ypur libr can make code really complex to read, even to experimented clojurians. That the power of macros (or even functions). Abstract things away. But you also need to know the function/macro. And if it is not standard, we end up with many different version of let? depending of the library, author... By all means I'm not against let? macro or On 9 mar, 19:04, Evan Gamble wrote: > I find let? useful and readable, as do others. There's a bit of brain- > training necessary to read it, but not a lot. Probably no more than > the keyword clauses of the "for" comprehension. The argument that > decades of Lisp programmers haven't invented this particular > "chucklehead" macro is a bit weak, since there have been many other > similar macros. > > ...and I have learned to love nil, even the :else nil clause that > repels you. > > - Evan > > On Mar 9, 9:26 am, Craig Brozefsky wrote: > > > > > > > > > Evan Gamble writes: > > > (let? [a foo :else nil > > > b bar :is even? > > > c baz :when (> b c) > > > d qux] > > > (f a b c d)) > > > Macros like that just make your code so much LESS readable. I now have > > to understand the semantics of a bunch of keywords specific to the > > macro, their order of operations within the macro, as well as > > recognizing the little ? on the end of the let as I'm scanning. I also > > have to see if that's a keyword or the start of another binding! > > > :else nil? really? > > > :is ... Geezus christ > > > :when !?!?! Put down that nailgun, kid > > > ;; This maintains the same logic (unless I fucked up transcoding) > > ;; and also the same err, complexity, in that forms are not exeuted if > > ;; they don't need to be, as your initial example, without nesting all > > ;; the way over to the side, or using some weird keyword language. > > > (when-let [a foo] > > (let [b bar > > c (when (even? b) baz)] > > (when (and c (> b c)) > > (f a b c qux > > > ;; or > > > (when-let [a foo] > > (let [b bar > > c (when (even? b) baz) > > d (when (and c (> b c)) qux)] > > (when d (f a b c d > > > Keep your constructs simple, and learn to love the nil. > > > Also, people have been writing lisp for a real long time, and they > > haven't invented a chucklehead macro like let? yet, so prolly not really > > needed to improve the readability... > > > -- > > Craig Brozefsky > > Premature reification is the root of all evil -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Can Clojure be as readable as Python or Ruby ?
(Sorry for split post). So I'am not against let? macro of whatever you might need. That why we have a lisp here. But be sure you really need it/use it. And it is designed to be intuitive as possible. On 9 mar, 23:05, Nicolas wrote: > Well maybe the problem of the let? macro is that it is not standard. > If you use standard constructs and I'am proeficient with clojure I'll > understand your code fast. I'll concentrate on understanding your code > relevant for your application and domain. But just adding a few new > constructs specific to ypur libr can make code really complex to read, > even to experimented clojurians. > > That the power of macros (or even functions). Abstract things away. > But you also need to know the function/macro. And if it is not > standard, we end up with many different version of let? depending of > the library, author... > > By all means I'm not against let? macro or > > On 9 mar, 19:04, Evan Gamble wrote: > > > > > > > > > I find let? useful and readable, as do others. There's a bit of brain- > > training necessary to read it, but not a lot. Probably no more than > > the keyword clauses of the "for" comprehension. The argument that > > decades of Lisp programmers haven't invented this particular > > "chucklehead" macro is a bit weak, since there have been many other > > similar macros. > > > ...and I have learned to love nil, even the :else nil clause that > > repels you. > > > - Evan > > > On Mar 9, 9:26 am, Craig Brozefsky wrote: > > > > Evan Gamble writes: > > > > (let? [a foo :else nil > > > > b bar :is even? > > > > c baz :when (> b c) > > > > d qux] > > > > (f a b c d)) > > > > Macros like that just make your code so much LESS readable. I now have > > > to understand the semantics of a bunch of keywords specific to the > > > macro, their order of operations within the macro, as well as > > > recognizing the little ? on the end of the let as I'm scanning. I also > > > have to see if that's a keyword or the start of another binding! > > > > :else nil? really? > > > > :is ... Geezus christ > > > > :when !?!?! Put down that nailgun, kid > > > > ;; This maintains the same logic (unless I fucked up transcoding) > > > ;; and also the same err, complexity, in that forms are not exeuted if > > > ;; they don't need to be, as your initial example, without nesting all > > > ;; the way over to the side, or using some weird keyword language. > > > > (when-let [a foo] > > > (let [b bar > > > c (when (even? b) baz)] > > > (when (and c (> b c)) > > > (f a b c qux > > > > ;; or > > > > (when-let [a foo] > > > (let [b bar > > > c (when (even? b) baz) > > > d (when (and c (> b c)) qux)] > > > (when d (f a b c d > > > > Keep your constructs simple, and learn to love the nil. > > > > Also, people have been writing lisp for a real long time, and they > > > haven't invented a chucklehead macro like let? yet, so prolly not really > > > needed to improve the readability... > > > > -- > > > Craig Brozefsky > > > Premature reification is the root of all evil -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Can Clojure be as readable as Python or Ruby ?
The nice thing about Grand's cond macro is that it matches the syntax of using :let inside for comprehensions, so it looks just like other Clojure code. In fact, once you've tried it, it feels surprising that it's not already built into Clojure, specifically because it is so similar to binding with for comprehensions. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Clojars security upgrade
Hello folks! In light of the recent break-in to the Node.js package hosting site (https://gist.github.com/2001456), I've decided to bump the priority of increasing the security on Clojars. I've deployed a fix that uses bcrypt (http://codahale.com/how-to-safely-store-a-password/) for password hashing. The first time you log in, it will re-hash your password using bcrypt and wipe the old weak hash. Note that Clojars has NOT had a security breach at this time. This is a preventative measure to protect your password in the event of a future breach. We are also looking into allowing signed jars (and possibly requiring them for releases). If you're interested in helping out with this effort, (design or code) please join the clojars-maintainers mailing list: http://groups.google.com/group/clojars-maintainers Because we can't ensure that everyone will log in to re-hash their password, at some point in the future (probably 2-3 weeks out) we will WIPE all the old password hashes. Otherwise users who have stopped using Clojars or missed the announcement could have their passwords exposed in the event of a future break-in. I will be sure to send out a few more warnings before this happens, but even if your password has been wiped it's easy to reset it via the "forgot password" functionality. If you have any applications storing passwords hashed with SHA1 (even if you use a salt) I highly recommend you take the same steps; refer to http://codahale.com/how-to-safely-store-a-password/ for details. tl;dr: please log into Clojars to re-hash your password. Thanks for your attention. -Phil -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Clojure 1.4.0-beta4 release
Available soon from Maven Central repository. List of changes available here: http://build.clojure.org/job/clojure/357/ -S -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure.io
On Mar 8, 3:12 pm, cej38 wrote: > This is a NOOB question. > > Would it be possible to write a library that could do IO without > resorting to the underlying VM? I would be suspicious of a cross-implementation wrapper. You'll probably end up with something as awful as the Common Lisp path API. Worse, such an API would most likely be a lowest common denominator, and thus not expose many important aspects of the underlying system (such as file links for example). -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
[ANN] kibit 0.0.2
We have now released kibit[1] 0.0.2 to Clojars. New in this release is * Leiningen 2.0 support * Better at finding source code * More rules * Marginalia docs[3] * Lots of small fixes Kibit is a simple code analysis tool (and leiningen plugin). The purpose of the tool is to tell its users that "Hey, There's already a function for that!". Kibit uses core.logic[2] to search for patterns of code for which there might exist simpler functions. For example, if the analyzer finds (apply concat (apply map ...) It will make the suggestion to use `(mapcat ...)` instead. I would like to thank all contributors and especially Paul deGrandis who has helped me with everything in this release! Jonas [1] https://github.com/jonase/kibit [2] https://github.com/clojure/core.logic [3] http://jonase.github.com/kibit/ -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
ANN: ringMon Ring middleware that provides monitoring and nREPL remote interface to any Ring based Clojure web app
Hi all, The ringMon is Ring middleware that injects single web page into existing Ring application for monitoring, testing and debugging purposes. The page provides periodic display of raw JMX data of interest in hierarchical form. It also displays some derived data such as CPU load over sampling period of 2 seconds. Moreover, the page contains full featured front end to nREPL server that is started by middleware itself and therefore runs in context of the web application. The nREPL user interface is similar to one in CCW Eclipse plugin. It features editor (CodeMirror) with syntax colouring and session persistence. ringMon should be very useful for cloud based runtime environment such as Heroku, since it provides nREPL access over existing communication channel (HTTP). Even if your Clojure app is not web based, including ringMon jar into your project dependencies will pull in Jetty web server and provide the remote web based REPL for testing and monitoring. Of course, ringMon + Jetty combination can be used to provide insight and Clojure scripting to any JVM based application. The Noir based web application that demonstrates ringMon is at http://noirmon.herokuapp.com/ Source code at https://github.com/zoka/ringMon/ Regards Zoka -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ANN: ringMon Ring middleware that provides monitoring and nREPL remote interface to any Ring based Clojure web app
Hi Zoka, That sounds like a great project! I will try it out. The only suggestion I would like to make right now is that it would probably be better to push non-SNAPSHOT JARs to Clojars while making a release. Shantanu On Mar 10, 11:08 am, zoka wrote: > Hi all, > > The ringMon is Ring middleware that injects single web page into > existing Ring application for monitoring, testing and debugging > purposes. The page provides periodic display of raw JMX data of > interest in hierarchical form. It also displays some derived data such > as CPU load over sampling period of 2 seconds. > > Moreover, the page contains full featured front end to nREPL server > that is started by middleware itself and therefore runs in context of > the web application. The nREPL user interface is similar to one in CCW > Eclipse plugin. It features editor (CodeMirror) with syntax colouring > and session persistence. > > ringMon should be very useful for cloud based runtime environment such > as Heroku, since it provides > nREPL access over existing communication channel (HTTP). > > Even if your Clojure app is not web based, including ringMon jar into > your project dependencies > will pull in Jetty web server and provide the remote web based REPL > for testing and monitoring. > > Of course, ringMon + Jetty combination can be used to provide insight > and Clojure scripting to any JVM based application. > > The Noir based web application that demonstrates ringMon is > athttp://noirmon.herokuapp.com/ > Source code athttps://github.com/zoka/ringMon/ > > Regards > Zoka -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en