Re: Heidegger, literate programming, and communication
Gregg and Gary, I understand where you are coming from. Indeed, Maturana [0] is on your side of the debate. Since even the philosophers can't agree, I doubt we will find a common ground. Unfortunately, I've decided to take on the task of documenting the Clojure internals because, yaknow, *I* don't feel I understand something until I know what the hardware does; consider this a flaw in my personality :-) I have to say that the posted Clojure code is somewhat lacking in the communication department. Perhaps it is only intended for an audience of one, and I'm not the one. :-) Contrary to popular belief, I am reading the code. As a result, I have a strongly held opinion that there is a lot that could be done to make it less of a struggle. From my point of view there are at least a few things that seem clear: 1. I think that Gregg Reynolds and I agree on a lot, but I would add to his remarks that there is almost always a human audience for source code, as well as the compiler/interpreter. Sometimes, the audience is just the originally programmer, perhaps at a later date. (If I missed something, Gregg, sorry, but I don't think you disagree, anyway.) I agree; whoever writes the code automatically forms an audience of one. I guess I would say reader/responder. Hmmm. Common Lisp is about 25 years old. Assume Clojure lives that long. What are the odds that the original authors will be maintaining the code? Will the code still be an audience of one? Are you sure that's a worthwhile goal? 2. Since Clojure is a general-purpose tool, Clojure source code has no single kind of human audience for the code. In general, I do different things with comments, or with my coding style, depending on whether I expect that I will be the only maintainer of the code, or expect that others with whom I'm collaborating will need to interface with it, for example. Further, I think about the skill levels and background of those who will read the code. And I think about what they would want to do with it. And then I make decisions that involve tradeoffs between competing desiderata. My experience in industry with general-purpose tool code is that code does look a lot different from project to project and language to language. But as code moved out of its childhood and off the desk, it began to grow hair and get ugly. The authors all assumed they would be the only maintainer. For instance, I once had to maintain a C program that had 14 pages of nested ifdefs just to choose the correct #include files. Each include file had ifdefs. The code ran everywhere, Intel, ARM, 68000s, SUNs, DEC, etc. but nearly every line was based on experience (e.g. compensating for floating-point errors on various platforms, hacking around errors in various C compilers and their optimizers, etc.) with ifdefs around each hack. I had to run the compiler intermediate stage to figure out what the actual code would be for my platform. And then I had to reverse-engineer the fix into the appropriate include files; uncommented I might add. I wouldn't want to ruin the style. Sophisticated Lisp programmers use macros A LOT. Axiom, for instance, compiles code from a high-level algebra language, essentially a DSL, into macros that index into vectors for the function to call, or the category to inherit which might contain the call, and the environment passed to each function is a huge vector. DSLs, which make the top level code so clear, often are macros generating machine-code-like lisp doing super-efficient vector indexing. One finds macros expanding into macros expanding into macros. Quick, what does the spadcall macro do? And we won't even mention that despite the use of a DSL, the DSL code isn't perfectly clear either. This is especially true when it gets mixed with inline, non-DSL code. For instance, Axiom's algebra code regularly invokes low-level lisp functions. Exactly. Conclusion: it's hard, maybe impossible, to generalize about what all code should look like. Maybe it's essentially pluralistic. Yes, it is hard to generalize about what all code should look like. But it is not hard to generalize that reading natural language explanations is faster, more accurate, and a lot easier than reverse-engineering code. It is MUCH easier to understand Greg Humphrey's rendering code than it is to understand the Clojure internals. Consider a randomly chosen paragraph from Physically Based Rendering (p356): To do the permutation, this function loops over the samples, randomly permuting the sample points in one dimension at a time. Note that this is a different permutation than the earlier Shuffle() routine: that routine does one permutation, keeping all nDim sample points in each sample together, while here nDim separate permutations of a single dimension at a time are done. (Figure 7.21) for (uint32_t i = 0; i nDim; ++1) { for (uint32_t j =
Re: passing a non-anoymous function as an argument to another clojure function
On Wed, May 21, 2014 at 07:53:18PM -0700, David Gartner wrote: (defn div [x y] (/ x y)) (defn throw-catch [f] [(try (f) (catch ArithmeticException e No dividing by zero!) (catch Exception e (str You are so bad (.getMessage e))) (finally (println returning... )))]) ... Can anyone enlighten me? So, your issue is that your div function expects two arguments, while your throw-catch function calls it (although with the name f) with zero arguments. Using an anonymous function like #(div 10 5) creates a new function of zero arguments which then calls your div function with its two arguments. So, you should find that this will work for your div function: (defn throw-catch-2 [f a b] (try (f a b) (catch ArithmeticException e No dividing by zero!) (catch Exception e (str You are so bad (.getMessage e))) (finally (println returning... (throw-catch-2 div 10 5) To do this more generally, we can use clojure's rest arguments and apply to make this work: (defn throw-catch-many [f args] (try (apply f args) (catch ArithmeticException e No dividing by zero!) (catch Exception e (str You are so bad (.getMessage e))) (finally (println returning... (throw-catch-many div 10 5) (throw-catch-many #(div 10 5)) You can even just use / as your function name now, if you'd like: (throw-catch-many / 10 5) (throw-catch-many / 10 0) signature.asc Description: Digital signature
How to refactor data safely?
I have a nested data structure, used by a bunch of functions that presume knowledge of its structure, and I wonder how to change a part of the structure in a safe way, preferably in small incremental steps, rather than having my code broken until I update all the functions and tests for the new structure. I believe many of you must have experiences with this, would you care to share some tips? The data structure is first built incrementally and the collected data is later summarized. Instead of replacing the raw data with their summary, I want to keep both, so I want to wrap the data with a map; i.e. from: { id [ data...] } ;; later replaced with {id summary} to {id {:data [data...], :summary ...} I have a number of functions operating on the structure and tests for those functions (with test data that also need to be updated w.r.t. the refactoring). When I change one of the functions to produce the new data structure (i.e. data wrapped in a map instead of the data itself), everything else breaks. So I fix some tests and another function and get even more failures. This does not feel as a good way to do it as I prefer to have limited redhttp://www.infoq.com/presentations/The-Limited-Red-Societyand am fond of parallel changehttp://theholyjava.wordpress.com/wiki/development/parallel-design-parallel-change/for that reason. Ideally, I would have an automated refactoring or the possibility to wrap the data in some kind of a two-faced proxy that could behave both as a vector (towards the old code) or as a map containing the vector (towards the updated code) [some thing like lenses/cursor?!]. I haven't either so I guess the only option remaining is a well-controlled process of updating the structure and code. Any advice? Thank you! /Jakub -- *Forget software. Strive to make an impact, deliver a valuable change.* *(**Vær så snill og hjelp meg med å forbedre norsken **min –** skriftlig og muntlig. Takk!**)* Jakub Holy Solutions Engineer | +47 966 23 666 Iterate AS | www.iterate.no The Lean Software Development Consultancy - http://theholyjava.wordpress.com/ - -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: How to refactor data safely?
How are you accessing the data? I suppose that if you were accessing (maybe you are) the data via helper functions, that's where most of the refactoring should happen. On 22 May 2014 09:17, Jakub Holy jakub.h...@iterate.no wrote: I have a nested data structure, used by a bunch of functions that presume knowledge of its structure, and I wonder how to change a part of the structure in a safe way, preferably in small incremental steps, rather than having my code broken until I update all the functions and tests for the new structure. I believe many of you must have experiences with this, would you care to share some tips? The data structure is first built incrementally and the collected data is later summarized. Instead of replacing the raw data with their summary, I want to keep both, so I want to wrap the data with a map; i.e. from: { id [ data...] } ;; later replaced with {id summary} to {id {:data [data...], :summary ...} I have a number of functions operating on the structure and tests for those functions (with test data that also need to be updated w.r.t. the refactoring). When I change one of the functions to produce the new data structure (i.e. data wrapped in a map instead of the data itself), everything else breaks. So I fix some tests and another function and get even more failures. This does not feel as a good way to do it as I prefer to have limited redhttp://www.infoq.com/presentations/The-Limited-Red-Societyand am fond of parallel changehttp://theholyjava.wordpress.com/wiki/development/parallel-design-parallel-change/for that reason. Ideally, I would have an automated refactoring or the possibility to wrap the data in some kind of a two-faced proxy that could behave both as a vector (towards the old code) or as a map containing the vector (towards the updated code) [some thing like lenses/cursor?!]. I haven't either so I guess the only option remaining is a well-controlled process of updating the structure and code. Any advice? Thank you! /Jakub -- *Forget software. Strive to make an impact, deliver a valuable change.* *(**Vær så snill og hjelp meg med å forbedre norsken **min –** skriftlig og muntlig. Takk!**)* Jakub Holy Solutions Engineer | +47 966 23 666 Iterate AS | www.iterate.no The Lean Software Development Consultancy - http://theholyjava.wordpress.com/ - -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Heidegger, literate programming, and communication
Howdy Tim, On Thu, May 22, 2014 at 1:16 AM, u1204 d...@axiom-developer.org wrote: Gregg and Gary, I understand where you are coming from. Indeed, Maturana [0] is on your side of the debate. Since even the philosophers can't agree, I doubt we will find a common ground. Ah, but philosophers never agree. Disagreement is part of their job description. Why should programmers be any different? Unfortunately, I've decided to take on the task of documenting the Clojure internals because, yaknow, *I* don't feel I understand something until I know what the hardware does; consider this a flaw in my personality :-) I suffer from a similar malady, which compels me to continually rewrite other peoples code, since, gee whiz, foo is not quite the perfect name for that darn variable, bar would be just slightly better, and on and on. You can see why I prefer code to commentary. ... 1. I think that Gregg Reynolds and I agree on a lot, but I would add to his remarks that there is almost always a human audience for source code, as well as the compiler/interpreter. Sometimes, the audience is just the originally programmer, perhaps at a later date. (If I missed something, Gregg, sorry, but I don't think you disagree, anyway.) I agree; whoever writes the code automatically forms an audience of one. I guess I would say reader/responder. Hmmm. Common Lisp is about 25 years old. Assume Clojure lives that long. What are the odds that the original authors will be maintaining the code? Will the code still be an audience of one? Are you sure that's a worthwhile goal? I think you may have misunderstood me (dunno about Gary): my point is that even one-off code that gets discarded immediately has a human reader, namely the author. A statement of (minimal) fact, not a goal. ... Sophisticated Lisp programmers use macros A LOT. That's because they are language designers, and they know it. expanding into macros expanding into macros. Quick, what does the spadcall macro do? HCF? Exactly. Conclusion: it's hard, maybe impossible, to generalize about what all code should look like. Maybe it's essentially pluralistic. Yes, it is hard to generalize about what all code should look like. But it is not hard to generalize that reading natural language explanations is faster, more accurate, and a lot easier than reverse-engineering code. Whoa Nelly! I don't agree with that at all, either in principle or by experience. Well, ok, you've rigged the game. Easier than reverse-engineering code - what does that mean? I guess you mean reading well-written natural language explanations is faster etc. than reading badly written code - but so what? It's not a meaningful comparison. Would you take a comparison between a sample of well-written code and a sample badly written LP as evidence against LP? I would not. To me the question is whether well-written natural language explanation adds anything of substance to well-written code. It is MUCH easier to understand Greg Humphrey's rendering code than it is to understand the Clojure internals. Ok, but I don't see how exhibiting a piece of transparent code next to a piece of opaque code demonstrates anything. Consider a randomly chosen paragraph from Physically Based Rendering (p356): To do the permutation, this function loops over the samples, randomly permuting the sample points in one dimension at a time. Note that this is a different permutation than the earlier Shuffle() routine: that routine does one permutation, keeping all nDim sample points in each sample together, while here nDim separate permutations of a single dimension at a time are done. (Figure 7.21) for (uint32_t i = 0; i nDim; ++1) { for (uint32_t j = 0; j nSamples; ++j) { uint32_t other = j + (rng.RandomUInt() % (nSamples - j)); swap(samples[nDim + j + i], samples[nDim * other + i]); } } Footnote: While it's not necessary to permute the first dimension of the LHS pattern, the implementation here does so anyway since making the elements of the first dimension be randomly ordered means that LHS patterns can be used in conjunction with sampling patterns from other sources without danger of correlation between their sample points. So we learned what the code does. We also learned not to optimize the code by replacing it with Shuffle(). Further, we learned that we shouldn't optimize the code by removing the apparently useless shuffle of the first dimension. And, as a bonus, we get a figure. NONE OF THIS INFORMATION IS IN THE CODE ITSELF. For what the code does: /* inline random, total, in-place matrix permutation - contrast Shuffle() */ ...code... The first line of commentary is totally redundant, so it is a waste of time to read both it and the code. As for what not to optimize: if none of the conclusions you draw are in the code, they're not in the commentary, either. Replacing
[ANN] Alia 2.0.0-rc3 - Lightweight Cassandra driver integrated with core.async - Hayt (query dsl)
Alia 2.* [1] versions bring compatibility with the latest java-driver from Datastax. Support for the latest driver's additions were implemented (query paging among other nice things). On the core.async side we have a new function that allows to stream rows into a channel and perform queries over potentially enormous amount of results without becoming a ressource hog, giving you full control over paging and buffering. Be sure to read the changelog [2] if you are upgrading from 1.* and the docs [3] Hayt [4], the query DSL changed quite a bit from the 1.* versions too, bringing improvements from the latest revisions of the CQL3 specification, a new/cleaner api for some clauses and performance tweaks here and there. If you are upgrading from 1.* be sure to read the changelog [5] and the docs [6]. Both project still follow the same goals: being lightweight, simple and fast, while integrating with modern libraries. 1. https://github.com/mpenet/alia 2. https://github.com/mpenet/alia/blob/master/CHANGELOG.md 3. http://mpenet.github.io/alia/qbits.alia.html 4. https://github.com/mpenet/hayt 5. https://github.com/mpenet/hayt/blob/master/CHANGELOG.md 6. http://mpenet.github.io/hayt/codox/qbits.hayt.html -- Max Penet ___ github: https://github.com/mpenet twitter: http://twitter.com/mpenet ___ -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[ANN] Alia 2.0.0-rc3 - Lightweight Cassandra driver integrated with core.async - Hayt (query dsl)
Alia / Hayt are a great combo thanks Max! I'm looking forward to trying Cassandra as a lazy-seq. Colin -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [ANN] Alia 2.0.0-rc3 - Lightweight Cassandra driver integrated with core.async - Hayt (query dsl)
To give credit where it is due: thanks for the great suggestion(s) :) On Thursday, May 22, 2014 12:17:25 PM UTC+2, coltnz wrote: Alia / Hayt are a great combo thanks Max! I'm looking forward to trying Cassandra as a lazy-seq. Colin -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
how to add a function to a collection ?
Hi all, do you know how is possible to add a function result, that is another function, to a collection, a list for example: (defn *f1* [msg] (*fn[msg](println (str hello msg))*)) (def collection '()) (cons (f1) collection) in this situation f1 must be of type ISeq to can be added to 'collection'. Do you know how is this possible because if I call (cons (seq (f1)) collection) it doesn't work. Thanks, Sorin -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
How should I implement an elevator state-machine with loops and core.async?
Hey guys, I am trying to build a program that can instruct a single elevator, 2 floor system how to behave based on the state of an atom that is being constantly checked for updates by a loop. The state of the atom at a given time is then used to determine the conditional behavior of a move-elevator function. It is the first time I have ever written a program like this before, so I am not sure if I am doing it efficiently or not. Everything works fine up until the final *init* loop, where it freezes up my computer or ends prematurely. In Joy of Clojure, I saw a cool program using *case* and* trampoline *that is related to elevators, but somewhat different from what I am doing. I am not sure if those functions, *cond,* or perhaps *condp*, using *recur*, would be better for my use-case. I run a go-loop in the background that reads inputs from first or second floor button presses, *up* or *down,* from a channel, and updates the state of an atom, that is read by the move-elevator function. I am not sure if/how to call the move-elevator function to have the whole process run continuously, by itself, after I call the *init *function. Right now I have to call the move-function manually. Other than that, the whole things works fine. Could somebody please give me some helpful pointers to make my code more professional and/or sophisticated, or more general advice on using Clojure to design programs that interface with in mechanical systems? Is using an async channel to store presses here a good choice? This article here, creating ATM machine functionality using case and core.async, also inspired me: http://www.neo.com/2014/05/18/using-a-core-async-routine-as-a-state-machine The code is a little long (80 lines), so below is a link to the github gist. https://gist.github.com/gamma235/4ea0d7a0d0efb8d4399f Thanks ahead of time! Jesse -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: How should I implement an elevator state-machine with loops and core.async?
I haven't taken a detailed look yet, but you say you're watching the atom in a background loop - would http://clojuredocs.org/clojure_core/1.2.0/clojure.core/add-watch be more idiomatic and more efficient? Best, Rob On 22 May 2014 14:17, Jesse jesus.diama...@gmail.com wrote: Hey guys, I am trying to build a program that can instruct a single elevator, 2 floor system how to behave based on the state of an atom that is being constantly checked for updates by a loop. The state of the atom at a given time is then used to determine the conditional behavior of a move-elevator function. It is the first time I have ever written a program like this before, so I am not sure if I am doing it efficiently or not. Everything works fine up until the final init loop, where it freezes up my computer or ends prematurely. In Joy of Clojure, I saw a cool program using case and trampoline that is related to elevators, but somewhat different from what I am doing. I am not sure if those functions, cond, or perhaps condp, using recur, would be better for my use-case. I run a go-loop in the background that reads inputs from first or second floor button presses, up or down, from a channel, and updates the state of an atom, that is read by the move-elevator function. I am not sure if/how to call the move-elevator function to have the whole process run continuously, by itself, after I call the init function. Right now I have to call the move-function manually. Other than that, the whole things works fine. Could somebody please give me some helpful pointers to make my code more professional and/or sophisticated, or more general advice on using Clojure to design programs that interface with in mechanical systems? Is using an async channel to store presses here a good choice? This article here, creating ATM machine functionality using case and core.async, also inspired me: http://www.neo.com/2014/05/18/using-a-core-async-routine-as-a-state-machine The code is a little long (80 lines), so below is a link to the github gist. https://gist.github.com/gamma235/4ea0d7a0d0efb8d4399f Thanks ahead of time! Jesse -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: how to add a function to a collection ?
(defn *f1* [msg] (*fn[msg](println (str hello msg))*)) (def collection '()) (cons (f1) collection) change (cons (f1) collection) into (cons (f1 xxx) collection) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Community Interest in a Clojure Application Config Library, using Zookeeper?
Yes, please do open source it! On Tuesday, May 20, 2014 5:33:05 PM UTC-4, Thomas Steffes wrote: Hey folks, At Room Key we're using Apache Zookeeper and a home-grown clojure library called drcfg for real-time application configuration management. We're debating open-sourcing drcfg and are trying to gauge community interest in such a tool. We think it's got great usage semantics, basically you just def an atom in any namespace where you'd like a variable that can be changed in real-time on a running system. When you define the atom, you can also provide defaults to fall back to if zookeeper is unavailable, a validator to be run on any value when a change is attempted (to prevent invalid configuration data), as well as some meta-data about the variable. We've also got a web UI we use to change configuration data, but that would likely be released separate of drcfg itself. If anyone's interested, could you reply to this post? I can provide more information as well if need be. -Thomas Steffes @ Room Key -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: how to add a function to a collection ?
I see, this is the problem even if I call correct the function, sorry for that missing function parameter, when it will try to add the result of 'f1 xxx to 'collection' it will try to transform the result, fn..., to an type ISeq, this is what collection support, and there appear the problem *(defn f1 [msg] (fn[msg](println (str hello msg(def collection '())(cons collection (seq (f1 xxx)))* 'IllegalArgumentException Don't know how to create ISeq from: ro.srncristea.blogspot.clojure.concurrency$f1$fn__2158 clojure.lang.RT.seqFrom (RT.java:505)' thanks, sorin. On Thursday, May 22, 2014 3:04:39 PM UTC+3, Di Xu wrote: (defn *f1* [msg] (*fn[msg](println (str hello msg))*)) (def collection '()) (cons (f1) collection) change (cons (f1) collection) into (cons (f1 xxx) collection) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [RFC] Roundtripping namespaced xml documents for data.xml
Slightly Off topic, but how can I add new an element to an existing XML file with data.xml. For instance I have: a b /b /a and I want to add element c to this like this: a b c /c /b /a The documentation isn't particular clear on how to use the library unfortunately. Thomas -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: How should I implement an elevator state-machine with loops and core.async?
I haven't taken a detailed look yet, but you say you're watching the atom in a background loop - would http://clojuredocs.org/clojure_core/1.2.0/clojure.core/add-watch be more idiomatic and more efficient? I took the loop out of the* init* function and stuck an *add-watch* on the atom to call the *move-elevator* function when it gets updated, but now when I call *up* or *down* the watch function is either not getting called. or causing a gnarly error. Can you tell me how I should implement the watch and have run move-elevator, as it updates? I am updating the gist now, and will also add the stack-trace in a comment underneath it. I think the problem is coming when, during the move function execution, the atom gets updated and subsequently re-calls the *move-elevator* function, again and again with each update, making a smorgasbord of updates. Jesse On Thursday, May 22, 2014 8:25:39 PM UTC+9, Rob Day wrote: I haven't taken a detailed look yet, but you say you're watching the atom in a background loop - would http://clojuredocs.org/clojure_core/1.2.0/clojure.core/add-watch be more idiomatic and more efficient? Best, Rob On 22 May 2014 14:17, Jesse jesus.d...@gmail.com javascript: wrote: Hey guys, I am trying to build a program that can instruct a single elevator, 2 floor system how to behave based on the state of an atom that is being constantly checked for updates by a loop. The state of the atom at a given time is then used to determine the conditional behavior of a move-elevator function. It is the first time I have ever written a program like this before, so I am not sure if I am doing it efficiently or not. Everything works fine up until the final init loop, where it freezes up my computer or ends prematurely. In Joy of Clojure, I saw a cool program using case and trampoline that is related to elevators, but somewhat different from what I am doing. I am not sure if those functions, cond, or perhaps condp, using recur, would be better for my use-case. I run a go-loop in the background that reads inputs from first or second floor button presses, up or down, from a channel, and updates the state of an atom, that is read by the move-elevator function. I am not sure if/how to call the move-elevator function to have the whole process run continuously, by itself, after I call the init function. Right now I have to call the move-function manually. Other than that, the whole things works fine. Could somebody please give me some helpful pointers to make my code more professional and/or sophisticated, or more general advice on using Clojure to design programs that interface with in mechanical systems? Is using an async channel to store presses here a good choice? This article here, creating ATM machine functionality using case and core.async, also inspired me: http://www.neo.com/2014/05/18/using-a-core-async-routine-as-a-state-machine The code is a little long (80 lines), so below is a link to the github gist. https://gist.github.com/gamma235/4ea0d7a0d0efb8d4399f Thanks ahead of time! Jesse -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com javascript: For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com javascript:. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Community Interest in a Clojure Application Config Library, using Zookeeper?
Currently config changes that require restart of a component are not supported by our drcfg On Wednesday, May 21, 2014 12:59:18 PM UTC-4, Ben Mabey wrote: On 5/20/14, 3:33 PM, Thomas Steffes wrote: Hey folks, At Room Key we're using Apache Zookeeper and a home-grown clojure library called drcfg for real-time application configuration management. We're debating open-sourcing drcfg and are trying to gauge community interest in such a tool. We think it's got great usage semantics, basically you just def an atom in any namespace where you'd like a variable that can be changed in real-time on a running system. When you define the atom, you can also provide defaults to fall back to if zookeeper is unavailable, a validator to be run on any value when a change is attempted (to prevent invalid configuration data), as well as some meta-data about the variable. We've also got a web UI we use to change configuration data, but that would likely be released separate of drcfg itself. If anyone's interested, could you reply to this post? I can provide more information as well if need be. -Thomas Steffes @ Room Key Hi Thomas, I'd be interested in learning more about your solution. Have you ever ran into the case where a config change needs to restart a component? If so, have you written the logic that handles the updating of your entire system based on this change? e.g. a new DB config requires that your DB component be restarted and each component that relies on the DB component be restarted as well to get the new connection. Thanks, Ben -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: how to add a function to a collection ?
You have a couple of problems in your code. Let's take it a line at a time: (defn f1 [msg] (fn [msg] (println (str hello msg Here you have two msg arguments. The inner one will override the outer one. If you want both, they need to be different names. For example: (defn f1 [greet] (fn [name] (println greet name))) The outer function sets the greeting, while the inner one sets the name: ((f1 hello) joe) = hello joe You then define an empty collection: (def collection '()) Which is fine, and the perform a cons: (cons collection (seq (f1 xxx))) However, you have the arguments backward, and you've added in a seq that will just cause an error. Functions cannot be transformed directly into seqs. Instead, try: (cons (f1 hello) collection) This should work fine. - James On 22 May 2014 14:14, sorin cristea srncris...@gmail.com wrote: I see, this is the problem even if I call correct the function, sorry for that missing function parameter, when it will try to add the result of 'f1 xxx to 'collection' it will try to transform the result, fn..., to an type ISeq, this is what collection support, and there appear the problem *(defn f1 [msg] (fn[msg](println (str hello msg(def collection '())(cons collection (seq (f1 xxx)))* 'IllegalArgumentException Don't know how to create ISeq from: ro.srncristea.blogspot.clojure.concurrency$f1$fn__2158 clojure.lang.RT.seqFrom (RT.java:505)' thanks, sorin. On Thursday, May 22, 2014 3:04:39 PM UTC+3, Di Xu wrote: (defn *f1* [msg] (*fn[msg](println (str hello msg))*)) (def collection '()) (cons (f1) collection) change (cons (f1) collection) into (cons (f1 xxx) collection) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
ANN: ClojureScript 0.0-2227
ClojureScript, the Clojure compiler that emits JavaScript source code. README and source code: https://github.com/clojure/clojurescript New release version: 0.0-2227 Leiningen dependency information: [org.clojure/clojurescript 0.0-2227] Enhancements * optimized case * CLJS-802: Add :pseudo-names compiler option * CLJS-795: 10X performance enchancement for multimethods * CLJS-801: str macro emits unoptimizable js code * CLJS-656: search classpath for goog-style JavaScript dependencies Fixes - * CLJS-792: Implement IReduce on PersistentArrayMap * CLJS-804: Binding *print-length* breaks str * CLJS-775: Fix cljs.reader cljs.reader parses radix form of int literals * CLJS-805: add-watch returns map of watch fns instead of watched reference * CLJS-787: cljs.reader does not read blank string as nil * CLJS-784: Fix *Map.-conj for map-entry seqs, that don't implement INext * CLJS-784: make conj on maps behave as it does in Clojure * CLJS-793: fix memoize (non-truthy values don't get cached) * CLJS-800: PersistentQueueSeq extended to IPrintWithWriter -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Heidegger, literate programming, and communication
On Wed, May 21, 2014 at 11:16 PM, u1204 d...@axiom-developer.org wrote: Heck, it is only 4 lines of C++. Why bother? *I* can read C++. I can even reverse engineer it (probably by inventing the diagram in Figure 2.7 on a napkin). Maybe it lives in the src/SamRecon/StratSam, which is all the organization necessary. :-) But I can't reverse engineer the important information in either paragraph of text. For comparison, refer back to the multi-page Java code I posted from the Clojure core. As a maintenance programmer, which would you rather maintain? Tim, as someone already mentioned, the multi-page Java code you posted from the Clojure core is actually one file from the Java ASM library, copied into the Clojure Github repository from one version of that library available from here: http://asm.ow2.org There are 18,821 lines of Java code in that library, as it has been copied into Clojure in the src/jvm/clojure/asm directory. I would strongly recommend that you *not* spend a lot of time reading and documenting that code, if you want to document things that are unique to Clojure. That library is used by other projects besides Clojure. Between Clojure 1.5.1 and Clojure 1.6.0, a new version of it was copied over the older version that was used before then. http://dev.clojure.org/jira/browse/CLJ-713 That will likely happen again in a future Clojure release, to better support JDK8: http://dev.clojure.org/jira/browse/CLJ-1323 I would strongly recommend focusing on the 36,501 lines of Java code in src/jvm/clojure/lang, and/or the 19,207 lines of Clojure code in src/clj/clojure, first, and save the ASM library for later, if ever. Andy -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Community Interest in a Clojure Application Config Library, using Zookeeper?
+1 for open sourcing drcfg! Might be interesting to apply the same idea (drcfg) to the SS component model, where a component manages the atoms instead of having to def them. I did something very similar but on top of Curator. One component defined as a service discovery component, and others that depend on it. The discovery component exposes a listenable interface; when a service is discovered the callbacks are fired and the dependent components are notified. Related but slightly OT - I didn't think the component lib provided the ability to restart an individual component within a system? - Matt On Thursday, May 22, 2014 10:29:50 AM UTC-4, Thomas Steffes wrote: Currently config changes that require restart of a component are not supported by our drcfg On Wednesday, May 21, 2014 12:59:18 PM UTC-4, Ben Mabey wrote: On 5/20/14, 3:33 PM, Thomas Steffes wrote: Hey folks, At Room Key we're using Apache Zookeeper and a home-grown clojure library called drcfg for real-time application configuration management. We're debating open-sourcing drcfg and are trying to gauge community interest in such a tool. We think it's got great usage semantics, basically you just def an atom in any namespace where you'd like a variable that can be changed in real-time on a running system. When you define the atom, you can also provide defaults to fall back to if zookeeper is unavailable, a validator to be run on any value when a change is attempted (to prevent invalid configuration data), as well as some meta-data about the variable. We've also got a web UI we use to change configuration data, but that would likely be released separate of drcfg itself. If anyone's interested, could you reply to this post? I can provide more information as well if need be. -Thomas Steffes @ Room Key Hi Thomas, I'd be interested in learning more about your solution. Have you ever ran into the case where a config change needs to restart a component? If so, have you written the logic that handles the updating of your entire system based on this change? e.g. a new DB config requires that your DB component be restarted and each component that relies on the DB component be restarted as well to get the new connection. Thanks, Ben -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Count vowels in a string
keep is cool, thanks for showing me that :) On Wednesday, May 21, 2014 2:35:50 AM UTC-5, Vesa Marttila wrote: On Wednesday, May 21, 2014 2:03:14 AM UTC+3, Brad Kurtz wrote: I saw a rant online about interviewing developers that mentioned candidates not being able to count the number of vowels in a string. So naturally, I decided to see if I could do it in Clojure! I wanted to see others' opinions on other ways of doing it. *https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e https://gist.github.com/bradkurtz/6ce500d0361ccdc08c8e* Hi, I ended up with this: https://gist.github.com/ponzao/7399c08bb3b40d349289 (def vowels #{\a \e \i \o \u}) (defn count-vowels [s] (count (keep vowels (.toLowerCase s Vesa -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Heidegger, literate programming, and communication
Forward from Ralf Hemmecke: On 05/22/2014 11:21 AM, Gregg Reynolds wrote: I can tell you I would rather maintain the four lines of C++ without the largely useless commentary. That's a simple AXIOM program, but I'm sure one can easily translate it into any programming language. foo(a: Integer, b: Integer): Integer == if a 0 then if a b then return foo(b,a) return foo(b-a,a)) return b Question: Does the program have a bug? Ralf -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Heidegger, literate programming, and communication
Tim, as someone already mentioned, the multi-page Java code you posted from the Clojure core is actually one file from the Java ASM library, copied into the Clojure Github repository from one version of that library available from here: Hmmm, I didn't see that in the documentation :-) Thanks for the warning. In order to write the book I took a clone of the repository at a particular time with the intention of walking up the diffs after I had a clue about the details. There are 18,821 lines of Java code in that library, as it has been copied into Clojure in the src/jvm/clojure/asm directory. Oh, good. That means I can read the library documentation :-) I would strongly recommend that you *not* spend a lot of time reading and documenting that code, if you want to document things that are unique to Clojure. That library is used by other projects besides Clojure. Between Clojure 1.5.1 and Clojure 1.6.0, a new version of it was copied over the older version that was used before then. http://dev.clojure.org/jira/browse/CLJ-713 That will likely happen again in a future Clojure release, to better support JDK8: and again for JDK9... and again for JDK10... and again for... If Clojure needs the library then it needs to be documented. I am using a reference model. If code references a function then document the function. If no code references the library then it won't get documented. Any living piece of software is going to have changes made but I'm hoping that the core remain reasonably stable. Assuming, of course, I can distinguish core code. Reading code is SO much fun :-) Anyway, thanks for the warning. 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [RFC] Roundtripping namespaced xml documents for data.xml
2014-05-21 21:06 GMT+02:00 Paul Gearon gea...@gmail.com: Are QNames strictly necessary? Keywords seem to do the trick, and they work in nicely with what already exists. I know that there are some QName forms that are not readable as a keyword, but the XML parsing code will always call (keyword ...) and that holds any kind of QName, I've argued this at some length on the dev thread. IMO QNames are not nessecary, but we want another datatype than keywords. I think the main argument for using keywords would be xml literals in code and there readability (i.e. not having to use (keyword ..)) counts. A reader tag is far better suited for this. In the course of that argument, I also came up with a way to represent resolved names as keywords in literals. Please check out the design page for this. Are the reverse mappings (uri-prefix) definitely necessary? My first look at this made me think that they were (particularly so I could call XMLStreamWriter.getPrefix), but it seemed that the XmlWriter keeps enough state that it isn't necessary. My final code didn't need them at all. The XmlWriter does keep enough state, but I also want to support tree transformers that have the full information without needing to pipe through Xml{Reader,Parser}. uri-prefix could be reconstructed from prefix-uri in linear time, so again, the reason for the reverse mapping is performance. I was mostly considering round-tripping the data, and the parser is good at not repeating namespaces for child elements, so the emitter didn't need to either. As a result I didn't need to filter out prefix-uri bindings from parent elements when emitting namespaces, though that should be easy. What I meant are redundant prefixes, e.g. binding xmlns:D=DAV: at the root element, xmlns:E=DAV: in a child element. If uri-prefix is needed, then a simple map would need that, yes. However, if I needed the reverse mapping then I'd use a pair of stacks of maps - one for each direction. (BTW, a stack of maps sounds complex, but the top of the stack is just the new bindings merged onto the previous top of the stack). In this case, XmlNamespaceImpl is just that, modulo the stack. It is meant to be updated at every child element that binds xmlns prefixes, so the stack is implicit. I don't keep the parent XmlNamespaceImpl, because an xml element doesn't keep a parent pointer either. ad. Thomas' quesion Slightly Off topic, but how can I add new an element to an existing XML file with data.xml. Since you mentioned zippers, I assume you are familiar with them. I wholeheartedly recommend them for manipulating xml. Enlive is also built on zippers and I think it shouldn't take too much effort to make it work with the proposed namespace support. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [Axiom-developer] Heidegger, literate programming, and communication
PS I have many chunks of code that I wrote 20-30 years ago and I have no idea why and what the code was written for even after reading each line of the code This is what got me interested in literate programming. Axiom was written at IBM as research code, mostly by people trying to get a PhD. I wrote bits and pieces of the internals but didn't bother to document anything, especially since I write dirt simple code. Fifteen years later I'm looking at my own code. I know what it does. I can even tell you what bytes the compiler will lay down in memory. I know the code is needed since the system fails if I remove it. But I have no clue WHY I wrote it. The person who wrote the code failed to communicate with the person who maintains the code. I have the misfortune of being both people. I understand the strong opposition to writing good documentation at any level. Especially when writing code; it just seems wasteful to state the obvious. One non-obvious side effect of doing literate programming is that the code quality improves a LOT. As Bill Hart said: Another thing I've been enjoying lately is literate programming. Amazingly it turns out to be faster to write a literate program than an ordinary program because debugging takes almost no time. I fear that we're going to have the same approach as the physicists. New theories get accepted when the previous generation dies out. Fortunately statistics show that programmers retire into management at age 35 so we won't have to wait that long. If there is any justice, the managers will have to hire noobs to maintain code they wrote so they get to listen to the noobs trash talk about their code. :-) 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Heidegger, literate programming, and communication
Tim, Your project of LP'ing the Clojure internals is not at all inconsistent with my view. That is code that would benefit from being widely understood, even by people who won't maintain it. I learned a lot from reading the Lions book on an early version of Unix, even though I probably never even used hardware old enough to run it. (On the other hand, I'm not sure that there should be documentation that explains the complexities of the chunking mechanism both at the definitions of `map` and `doseq`, for example. That seems redundant. Maybe LP software has convenient ways of dealing with that sort of issue, though.) And I agree that won't can't know what code will live for 25 years, and what won't, and how many people will have to maintain the code. So one approach is simply to assume that all code will live a long time and be maintained by many people, many of whom will be unfamiliar with the code. But that means that you waste a lot of time on code that gets put aside (for reasons other than lack of documentation). Yeah, there are tradeoffs. We have to make our best judgments. One option: Write with whatever documentation you think will help the code's forseen uses. Then, if you discover later, that it needs better documentation, write it then. That won't be as easy as writing it in the first place: In hindsight, it's less efficient, but it may be more efficient overall across all projects. (i.e. one faults in the documentation: It's sometimes most efficient to allocate all of an executable's image and heap as soon it runs, but modern OSes instead often allocate memory only as needed, which, in hindsight, is less efficient, but overall, makes for a more efficient system.) (I think I am the Gary mentioned above, although that isn't my name. But I'm happy to take on that name in this discussion.) -Gary -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [Axiom-developer] Heidegger, literate programming, and communication
Hi folks, I suspect I'm the Gary that Tim thought he was referring to since I've posted on several of his other LP-related threads (though not this one until now). I'm reading along and enjoying the back and forth as usual, but I'm sorry to say that I don't have much to add to this philosophical swordfight. As I've stated on other threads, I find LP quite useful to me, both in helping me remember later what my old code does (and WHY I wrote it that way in the first place) as well as helping me to write clearer and more parsimonious code in the first place (since I don't want to document a crazy web of unnecessary complexity if I can avoid it). All in all, my personal LP journey has been an interesting and reasonably productive one. And of course, using an expressive functional language like Clojure does allow me to keep my code snippets shorter and more isolated from one another. All good things for LP as well. I know that Tim likes to poke the mailing list occasionally and remind people that LP is the bee's knees and that they should really get on board with it. I also know that without fail one or more folks will quickly respond that LP doesn't provide enough value above docstrings, inline comments, autogenerated API docs, and the occasional blog post to invest the necessary time in developing new LP-mindful workflows. And, of course, someone will inevitably chime in with the rally cry clear code doesn't need documentation. I understand that really embracing LP does require relearning how to program in several fundamental respects, AND it makes it quite difficult to use many of the developer tools many folks in the Clojure community have come to rely on. This makes the task appear somewhere between challenging and onerous to many programmers (or so I would imagine from following Tim's threads over the past year). However, (speaking only for myself here) I think the maintenance benefits often outweigh the upfront investment for any piece of software I intend to keep around for more than a few months. So for me, it's a net good. For some folks it's not. I get that. Enough said. But really, at the end of the day, I'm just getting tired of listening to people razzing on LP for the reasons listed above. There ARE good tools out there for doing this kind of programming. People just have to invest time and energy into learning them. I regularly cite Emacs' Org-mode as providing most everything you might need to comfortably create LP programs without even writing one line of LaTeX or XML (if you're allergic to those languages). Obviously, as Tim points out, it's an almost trivial assignment to roll your own tangle and weave scripts in whatever language you like (and I've tried that route too). So guys, if you don't like the ideas behind LP or just feel like it is too much of a hassle to use, then I completely understand that you don't want to use it. But could we maybe call a truce on this mailing list on the topic? Perhaps instead of constantly being pulled into philosophical arguments, those of us who actually do enjoy exploring LP could then use this forum to discuss amongst ourselves what tools or references we are finding useful in our journey. Clearly some folks (Gregg included) are churning out some pretty neat looking tools to make LP easier to do in the Clojure world. I for one would love to see more lively discussion around that and not feel like we're just bear-baiting whenever we mention the forbidden paradigm of Literate Programming. My 2c, ~ (the actual) Gary -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Heidegger, literate programming, and communication
On Thu, May 22, 2014 at 11:05 AM, Tim Daly d...@axiom-developer.org wrote: Tim, as someone already mentioned, the multi-page Java code you posted from the Clojure core is actually one file from the Java ASM library, copied into the Clojure Github repository from one version of that library available from here: Hmmm, I didn't see that in the documentation :-) Thanks for the warning. I know Clojure doesn't have all the documentation many would like, but Tim, this bit of info is in readme.txt, and the first 3 lines of every source file from the library :-) Andy -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Heidegger, literate programming, and communication
I know Clojure doesn't have all the documentation many would like, but Tim, this bit of info is in readme.txt, and the first 3 lines of every source file from the library :-) Touche! +2 points to you! I love it when my oh-so-noisy self gets skewered by facts! :-) 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [Axiom-developer] Heidegger, literate programming, and communication
On Thursday, May 22, 2014 4:05:58 PM UTC-5, Gary Johnson wrote: Hi folks, I suspect I'm the Gary that Tim thought he was referring to since I've posted on several of his other LP-related threads (though not this one until now). I cede the name Gary to Gary. But really, at the end of the day, I'm just getting tired of listening to people razzing on LP for the reasons listed above. For my part, I have never intended to criticize LP per se. When it sounds as if someone is arguing that everyone should use LP all the time (or something similar), I sometimes object. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Question regarding tools.analyzer.jvm and the :tag, :o-tag, and :class entries
Hi, When using tools.analyzer.jvm you have to remember that its primary use-case is as a front-end for a compiler, in this case :tag and :o-tag serve to inform tools.emitter.jvm when to emit a cast thus might not always reflect the :tag meta of the expression :form. Regarding the :tag/:o-tag difference, :o-tag (you can read it as original tag) holds the static type of the node known at that point and might be either inferred by the :tag of some children nodes or from the class of the :form of the node in case it's a literal, :tag on the other hand can be either the same of :o-tag or hold the Class that node needs to be cast to, usually because of an explicit type-hint. For example, ^IPersistentCollection [] will have :o-tag PersistentVector and :tag IPersistentCollection. :class is an attribute of some nodes that deal with host interop forms, like :new, :instance-call and others and holds the Class that node deals with; for example it might hold the Class a :new node is going to instantiate, the Class an :instance-method belongs to etc. BTW, you don't need to roll your own `analyze` function providing those bindings, jvm/analyze already sets up the right bindings for you. I hope this helps, Nicola On Wed, May 21, 2014 at 10:00 AM, guns s...@sungpae.com wrote: Hello, This question is primarily addressed to Nicola Mometto, but I am sending it to the list so it may be helpful to other Clojure developers. Help is appreciated, regardless of the source. I am using tools.analyzer(.jvm) to build a Closeable resource linter, but I have run into the following problem: a function call's type hint is lost when an instance method is called on its output. For example, given the following setup: (alias 'ana 'clojure.tools.analyzer) (alias 'ast 'clojure.tools.analyzer.ast) (alias 'jvm 'clojure.tools.analyzer.jvm) (defn analyze [form] (binding [ana/macroexpand-1 jvm/macroexpand-1 ana/create-varjvm/create-var ana/parse jvm/parse ana/var? var?] (jvm/analyze form (jvm/empty-env (defn analyze-debug [form] (for [ast (ast/nodes (analyze form)) :let [{:keys [op form tag o-tag class]} ast]] (array-map :op op :form form :tag tag :o-tag o-tag :class class))) (defn ^java.io.FileInputStream fis [^String x] (java.io.FileInputStream. x)) I would like to detect that (fis x) returns a java.io.FileInputStream. If I call: (analyze-debug '(str (fis x))) I receive: ({:op :invoke, :form (str (fis x)), :tag java.lang.String, :o-tag java.lang.Object, :class nil} {:op :var, :form str, :tag clojure.lang.AFunction, :o-tag java.lang.Object, :class nil} {:op :invoke, :form (fis x), :tag java.io.FileInputStream, ; ◀ The desired metadata :o-tag java.lang.Object, :class nil} {:op :var, :form fis, :tag clojure.lang.AFunction, :o-tag java.lang.Object, :class nil} {:op :const, :form x, :tag java.lang.String, :o-tag java.lang.String, :class nil}) However, if I call: (analyze-debug '(.toString (fis x))) - ({:op :instance-call, :form (. (fis x) toString), :tag java.lang.String, :o-tag java.lang.String, :class java.lang.Object} {:op :invoke, :form (fis x), :tag java.lang.Object, ; ◀ The type hint is missing! :o-tag java.lang.Object, :class nil} {:op :var, :form fis, :tag clojure.lang.AFunction, :o-tag java.lang.Object, :class nil} {:op :const, :form x, :tag java.lang.String, :o-tag java.lang.String, :class nil}) The :tag of (fis x) is now java.lang.Object, and java.io.FileInputStream is not present in the node. Calling java.io.InputStream#markSupported sheds more light on the matter: (analyze-debug '(.markSupported (fis x))) - ({:op :instance-call, :form (. (fis x) markSupported), :tag boolean, :o-tag boolean, :class java.io.InputStream} {:op :invoke, :form (fis x), :tag java.io.InputStream, ; ◀ The instance method's class :o-tag java.lang.Object, :class nil} {:op :var, :form fis, :tag clojure.lang.AFunction, :o-tag java.lang.Object, :class nil} {:op :const, :form x, :tag java.lang.String, :o-tag java.lang.String, :class nil}) Finally, calling java.io.FileInputStream#getFD on (fis x) returns the expected :tag entry: (analyze-debug '(.getFD (fis x))) - (… {:op :invoke, :form (fis x), :tag java.io.FileInputStream, ; ◀ Also the instance method's class :o-tag java.lang.Object, :class nil} …) Is there a reliable way to retrieve the
Re: [Axiom-developer] Heidegger, literate programming, and communication
On Thursday, May 22, 2014 6:20:39 PM UTC-4, Mars0i wrote: On Thursday, May 22, 2014 4:05:58 PM UTC-5, Gary Johnson wrote: Hi folks, I suspect I'm the Gary that Tim thought he was referring to since I've posted on several of his other LP-related threads (though not this one until now). I cede the name Gary to Gary. No worries. You can be Gary too if you'd like. It's a passable name, all things considered. ;-) But really, at the end of the day, I'm just getting tired of listening to people razzing on LP for the reasons listed above. For my part, I have never intended to criticize LP per se. When it sounds as if someone is arguing that everyone should use LP all the time (or something similar), I sometimes object. Hey, point taken. I'm certainly not out to force LP on anyone. I'm just here to soak up advice from the folks who have been using it for awhile. I'm happy keeping the kool-aid to myself, so to speak. :-P -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: passing a non-anoymous function as an argument to another clojure function
Awesome ... thanks a bunch Carlo :) On Wednesday, May 21, 2014 8:53:18 PM UTC-6, David Gartner wrote: A totally noob question so please bear with me ... I'm trying to pass a function to another function in the REPL like so: function number 1: (defn div [x y] (/ x y)) function number 2: ;; this is from the joy of clojure (defn throw-catch [f] [(try (f) (catch ArithmeticException e No dividing by zero!) (catch Exception e (str You are so bad (.getMessage e))) (finally (println returning... )))]) throw-catch works as expected if I use an anonymous function as shown in the book. But what I'd like to do is pass my div function to the throw-catch function. I've tried a number of iterations but throw-catch always throws an exception (throw-catch div 10 2) ;; throws an exception (throw-catch '(div 10 2)) ;; throws an exception (throw-catch [div 10 2]) ;; throws an exception ... you get the idea (throw-catch #(/ 10 5));; returns 2 Can anyone enlighten me? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[ANN] core.async (and more) video tutorials
Thanks for the videos. The first one was good. What text editor are you using in the videos? I haven't seen that one before. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [ANN] core.async (and more) video tutorials
I'm using Cursive Clojure (Intelij). It has a Presentation Mode which is pretty good, but I use Cursive as my main IDE these days. On Thu, May 22, 2014 at 7:41 PM, Jason Gilman jason.gil...@gmail.comwrote: Thanks for the videos. The first one was good. What text editor are you using in the videos? I haven't seen that one before. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
SocketError when using DataInputStream with Clojure TCP server
I am working with the TCP server example from the *Clojure Cookbook* to create an echo server. I am trying to modify it so that the receive function uses a DataInputStream and reads the incoming request as a byte array. However, I am having difficulty getting it to work. Here is what I have so far: (defn receive [socket] (with-open [reader (DataInputStream. socket)] (let [bytes-in (byte-array 146)] (.read reader bytes-in) (println Made it here))) (comment - This receive function works, the above doesn't (defn receive [socket] (let [r (.readLine (clojure.java.io/reader socket))] (println r))) ) (defn run [port] (let [running (atom true)] (future (with-open [socket (ServerSocket. port)] (while @running (with-open [sock (.accept socket)] (receive sock) running)) Executing the run function on the REPL: (tcp.server/run ) Then, when I try to send a request via my TCP client, it results in a SocketException: (tcp.client/run :sync 1 10) Transmitting message --- Message Size : 93 bytes Host IP : 127.0.0.1 Host Port: Transmitting message --- Message Size : 93 bytes Host IP : 127.0.0.1 Host Port: SocketException Broken pipe java.net.SocketOutputStream.socketWrite0 (SocketOutputStream.java:-2) It appears that I am able to send two of the ten requests before a Broken pipe occurs, and on the server side it doesn't ever appear to make it to the receive function, as the println statement doesn't show any output. I know the client works, as I have tested it with my instructor's server, so it definitely appears to be a problem with the server. If anyone has any insight, please share. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Help with a memory leak
On Wednesday, May 21, 2014 7:43:41 PM UTC-5, Bauna wrote: The main loop is here[2] in the function trace-gen that generates a lazy list. I don't care about the memory required during the execution of the function but after it should be GC'd all. Just a quick question: Have you checked to make sure that that you are not keeping a reference to the beginning (or other position) of the lazy list after you're done processing it? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.