Re: recommended way to write loop where a binding depends on a previous 'useless binding' operation?

2013-02-11 Thread Evan Mezeske
Generally when you are calling functions that have (and depend on) side-effects, you will end up using "do" a lot. Also, I noticed that in your example there's really no reason to make the x and y bindings part of the loop. I haven't tried this code but I think it's along the lines of what you

Re: recommended way to write loop where a binding depends on a previous 'useless binding' operation?

2013-02-11 Thread Baishampayan Ghose
What's the stopping condition for your loop? ~BG On Tue, Feb 12, 2013 at 12:55 PM, George Oliver wrote: > hi, > > I have a loop that looks like this, > > (loop > [x (a-function) >y (another-function)] ; another-function must be called after a-function > () ; x is not used in body >

recommended way to write loop where a binding depends on a previous 'useless binding' operation?

2013-02-11 Thread George Oliver
hi, I have a loop that looks like this, (loop [x (a-function) y (another-function)] ; another-function must be called after a-function () ; x is not used in body (recur (a-function) (another-function))) This gets the job done (my a-function is a select() call which I don't use th

Re: Can't use Clojure 1.5 with emacs and swank

2013-02-11 Thread Daniel Glauser
The momentum is definitely headed the nrepl direction but if you do want to get Clojure 1.5 working with slime/swank you can just bump the lein-swank plugin to the latest version, 1.4.5. I tried this tonight and played with some reducer code, everything seems to be working. Cheers, Daniel On M

Re: Can't use Clojure 1.5 with emacs and swank

2013-02-11 Thread Baishampayan Ghose
Devin, would you be kind enough to share the hackery you did to get nREPL to work like a normal slime/swank setup? I personally found many of the keybinding choices in nrepl.el to be quite different from slime/swank. ~BG On Tue, Feb 12, 2013 at 5:05 AM, Devin Walters wrote: > That's definitely th

Re: how to automatically and idiomatically add newlines to clojure code in emacs

2013-02-11 Thread Feng Shen
(defun indent-buffer () (interactive) (indent-region (point-min) (point-max))) (defun cleanup-buffer () (interactive) (indent-buffer) (untabify-buffer) (delete-trailing-whitespace)) ;; bind to other key if you like(global-set-key (kbd "M-q") 'cleanup-buffer) cleanup-buffer is very f

Re: how to automatically and idiomatically add newlines to clojure code in emacs

2013-02-11 Thread Andy Fingerhut
On Feb 11, 2013, at 6:28 PM, John Fries wrote: > How are people currently handling this situation? Is it part of most > people's clojure/emacs workflow to > 1) Just insert the newlines by hand? (perhaps I'm the only one finding > this repetitive) I find inserting newlines by hand less repetitive

how to automatically and idiomatically add newlines to clojure code in emacs

2013-02-11 Thread John Fries
Clojure Users, I'm relatively new to clojure and wanted to get some workflow advice. I often find myself staring at something like this: (defun func1 [a b c d] (func5 (let [f (func3 c)] (func2 a b f)) (let [e 5] (func4 c d e and wishing for a function to automatically and idiomatically break

Re: [ANN] analyze 0.3.0 - Hygienic transformation

2013-02-11 Thread ronen
My educated guess is that each symbol has a separate representation analyze.hygienic=> (-> (ast (let [a 1 a a b a a a] a)) ast-hy emit-hy) ((fn* ([] (let* [a 1 a2921 a b a2921 a2922 a2921] a2922 In this example the first a is a in the AST the second one is a2921 This prevents collisions whe

Re: ANN: NEVER use clojure.core/read or read-string for reading untrusted data

2013-02-11 Thread Andy Fingerhut
I will try to get confirmation of my semi-educated guesses below and add it to my longer writeup, but I believe the main reasons are: (1) clojure.edn/read and read-string have been added to Clojure 1.5, designed for use in reading data from untrusted sources without any of the kinds of side eff

Re: ANN: NEVER use clojure.core/read or read-string for reading untrusted data

2013-02-11 Thread Brent Millare
Is it possible to elaborate on the reasons for not using read/read-string with *read-eval* bound to false for clojure 1.5 and greater? Is it just because they can execute dumb code that takes CPU cycles? It's not obvious to me. Best, Brent On Monday, February 11, 2013 1:59:06 PM UTC-5, Mimmo C

Re: Easier imperative-style programming

2013-02-11 Thread Armando Blancas
Here's an example of using a state monad for updating a position. The state goes into a simple map and there's a function to add coordinates. (def init {:position [100 100] :st :st0 :keys-held #{:left}}) (defn v+ [v1 v2] (vec (map + v1 v2))) The state monad can compute a value and maintain some

Re: How to invoke java method obtained using clojure.reflect

2013-02-11 Thread juan.facorro
Since a macro's arguments must be available at compile time, creating one for calling a runtime defined method won't work. Because of this we are left with *eval*, which actually compiles and then evaluates at runtime the expression it receives as an argument. Here's a function that receives an

Re: `let` to automatically add metadata / fn names?

2013-02-11 Thread dgrnbrg
vary-meta slipped my mind! I've updated the gist to include it. The reason I check for IObj and IMeta is that I want symbols and other custom deftypes to recieve the metadata as well. I thought about namespacing the let-names, but for my current purposes I don't need that extra data (although I

Re: Clojure + Web Services + Web Sockets

2013-02-11 Thread Matthew
+1 for Aleph. I've used it loads and it's great. On Tuesday, February 12, 2013 10:12:57 AM UTC+11, Ryan T. wrote: > > Unless someone has to suggest something better, it seems that the best way > to achieve what i want is to use aleph > which > allows you to i

Re: Clojure + Web Services + Web Sockets

2013-02-11 Thread Ryan T.
Thanks both for your answers. @Bob, I didn't know the existance of http-kit; seems promising. There is also a post 600k concurrent HTTP connections, with Clojure & http-kit, very interesting. I also want to add to my own original qu

Re: Can't use Clojure 1.5 with emacs and swank

2013-02-11 Thread Devin Walters
That's definitely the issue. Switch to nrepl or see if there's an updated swank-clojure. I switched and it took some getting used to and hackery to get it working like my swank setup did, but I think it was worth it. '(Devin Walters) On Feb 11, 2013, at 5:01 PM, David Nolen wrote: > I'm not s

Re: Clojure + Web Services + Web Sockets

2013-02-11 Thread Devin Walters
Check out browserchannel: http://thegeez.net/2012/04/03/why_browserchannel.html Cheers, '(Devin Walters) On Feb 11, 2013, at 5:22 PM, Bob Hutchison wrote: > > On 2013-02-11, at 6:12 PM, Ryan T. wrote: > >> Unless someone has to suggest something better, it seems that the best way >> to achi

Re: ANN Titanium, a Clojure library on top of Titan

2013-02-11 Thread Devin Walters
Another day, another great clojurewerkz library. Well done, gents. *golf clap* '(Devin Walters) On Feb 11, 2013, at 11:37 AM, Michael Klishin wrote: > Titanium [1] is a Clojure graph library that is built on top of Titan [2]. > It combines a Clojure-friendly API and graph processing DSL with

Re: Clojure + Web Services + Web Sockets

2013-02-11 Thread Bob Hutchison
On 2013-02-11, at 6:12 PM, Ryan T. wrote: > Unless someone has to suggest something better, it seems that the best way to > achieve what i want is to use aleph which allows you to initialize it with a > wrapped ring handler. You might have a look at http://http-kit.org/ Cheers, Bob > > I

Re: Clojure + Web Services + Web Sockets

2013-02-11 Thread Justin Steward
On Tue, Feb 12, 2013 at 9:54 AM, Ryan T. wrote: > I was hoping to be able to build my clojure project and use jetty in > development and tomcat on production. I can't add anything on the websockets side, but one thing that's been beaten into me over the past few years, is to develop on the same s

Re: Jormungandr: Prototype-based OO on top of functions

2013-02-11 Thread eduardoejp
Hi, Mikera. Thanks for the feedback, it was a very interesting read. > Nice, I have been looking for something like this to experiment with. Glad to see someone else who likes to experiment with weird code :P However, I must admit that I made it mainly as a toy project, with no serious intent f

Re: Clojure + Web Services + Web Sockets

2013-02-11 Thread Ryan T.
Unless someone has to suggest something better, it seems that the best way to achieve what i want is to use aleph which allows you to initialize it with a wrapped ring handler. If you have more details on the issue or alternatives I would love to hear abou

Re: Can't use Clojure 1.5 with emacs and swank

2013-02-11 Thread David Nolen
I'm not sure if swank-clojure has been patched for 1.5, I believe the line & column information changes might have broken things. nrepl.el works pretty well as a replacement and development seems to be moving along pretty quickly. David On Mon, Feb 11, 2013 at 5:53 PM, JvJ wrote: > I added "1

Re: How to Process Files in Background

2013-02-11 Thread Max Penet
Hi, I made a small library a while ago to help with this. It wraps different java executors and has a version of clojure future and future-call that allows you to pass an executor as argument: https://github.com/mpenet/knit (require '[qbits.knit :as k]) (def x (k/executor :fixed :num-threads

Clojure + Web Services + Web Sockets

2013-02-11 Thread Ryan T.
Hello, I am trying to figure out how to setup my clojure project in order to be able to serve both normal http requests which will return json and also handle requests over websockets. Is it possible to do both and listen on same port? or do i need two separate projects? or ? I did find t

Can't use Clojure 1.5 with emacs and swank

2013-02-11 Thread JvJ
I added "1.5.0-beta13" to my lein project file, and now I get something like this when I try M-x clojure-jack-in signal(error ("Could not start swank server: ...etc... Does anyone know what I should do about this? Thanks. -- -- You received this message because you are subscribed to the G

Re: How to Process Files in Background

2013-02-11 Thread Timothy Baldridge
For that, look up Executors in Java. They'll have exactly what you are looking for. Create a new fixed sized executor: http://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/Executors.html They expect Runnable objects, but clojure Fns implement Runnable, so you can simply pass the execu

Belgium Clojure Meetup

2013-02-11 Thread Thomas Goossens
*With some fellow Belgian clojurians (Frederik De Bleser& Wim De Clerq) I’m planning to organise a Clojure meetup in Belgium while being inspired by the Amsterdam clojurians. So far no decisions have been made so don’t expect to find information like the planning, a d

Re: How to Process Files in Background

2013-02-11 Thread Ari
>From what I understand, futures would work. But is there a way to limit thread creation to a predetermined pool size? I'm concerned as more files are uploaded the continual future calls would soon overwhelm the system. -Ari On Monday, February 11, 2013 11:54:19 AM UTC-5, Zack Maril wrote: > >

Re: Easier imperative-style programming

2013-02-11 Thread James Reeves
You want to think more abstractly. What are the common elements in your code? For instance, a naive first pass: (defn move [subject delta] (update-in subject [:position] v+ delta)) (defn key-held [key] (@*keys-held* :left)) (defmacro on [subject event action] `(if ~event (-> ~subject ~act

How to invoke java method obtained using clojure.reflect

2013-02-11 Thread Pablo Nussembaum
Hey all, I'm a newbie that is trying to use clojure for my university grade thesis. In our project we have to generate a graph structure invoking some methods on a standard java class. This class is provided at run time, so the methods that need to be called must be obtained by reflection. I've

Re: Easier imperative-style programming

2013-02-11 Thread Timothy Baldridge
Some swear by monads, others (like myself) tend to swear at them. I would suggest breaking the code apart a bit more. From the looks of it, you're writing something like a game. The first 4 clauses could be redone as something like this: (def dirs {:left [-10 0] :up [0 -10] :right [0 10]

Re: Easier imperative-style programming

2013-02-11 Thread Jordan Berg
I think cond-> would work well https://github.com/clojure/clojure/blob/master/changes.md#24-new-threading-macros On Mon, Feb 11, 2013 at 3:10 PM, JvJ wrote: > I'm writing a simple game engine in Clojure, and each game object supplies > its own unique update function, which takes the original o

Re: Easier imperative-style programming

2013-02-11 Thread Ben Wolfson
yes, you could do this with a state monad, though how the results will end up looking will depend on the particular monad implementation you go for. On Mon, Feb 11, 2013 at 12:10 PM, JvJ wrote: > I'm writing a simple game engine in Clojure, and each game object supplies > its own unique update fu

Easier imperative-style programming

2013-02-11 Thread JvJ
I'm writing a simple game engine in Clojure, and each game object supplies its own unique update function, which takes the original object (a map of properties) and returns an updated version. However, writing the updates is somewhat cumbersome because each line of code has to return either the

Re: GSOC 2013 projects?

2013-02-11 Thread Daniel Solano Gómez
Hello, Yes, I just saw that. I'll be setting up the pages for organising on the Clojure community space within the next couple of days. In the meantime, if anyone is going to Clojure/West and interesting in a GSoC unsession, be sure to note your interest on

Re: GSOC 2013 projects?

2013-02-11 Thread Omer Iqbal
Hey Daniel, GSOC 2013 just got announced:( http://google-opensource.blogspot.sg/2013/02/flip-bits-not-burgers-google-summer-of.html ) Would be super awesome to see clojure there :) Cheers, Omer On Fri, Feb 1, 2013 at 3:04 AM, Daniel Solano Gómez wrote: > On Thu Jan 31 11:52 2013, David Nolen wro

Re: ANN: NEVER use clojure.core/read or read-string for reading untrusted data

2013-02-11 Thread Mimmo Cosenza
thanks by me too. mimmo On Feb 11, 2013, at 7:36 PM, AtKaaZ wrote: > thank you, this was an easy read even for me > > > On Mon, Feb 11, 2013 at 7:32 PM, Andy Fingerhut > wrote: > And just in case it gets edited by someone else before you have a chance to > read it, I've copied and pasted t

Re: ANN Titanium, a Clojure library on top of Titan

2013-02-11 Thread Michael Klishin
2013/2/11 AtKaaZ > should I be reporting any of these somewhere else? Feel free to submit pull requests to https://github.com/clojurewerkz/titanium.docs ;) -- MK http://github.com/michaelklishin http://twitter.com/michaelklishin -- -- You received this message because you are subscribed

Re: ANN: NEVER use clojure.core/read or read-string for reading untrusted data

2013-02-11 Thread AtKaaZ
thank you, this was an easy read even for me On Mon, Feb 11, 2013 at 7:32 PM, Andy Fingerhut wrote: > And just in case it gets edited by someone else before you have a chance > to read it, I've copied and pasted the current version below for reference. > Correction/comments/questions all welcom

Re: ANN Titanium, a Clojure library on top of Titan

2013-02-11 Thread James Thornton
This looks cool Michael, and it looks like it has made it to the front page of HN (http://news.ycombinator.com). I have been working with Titan in Clojure so I'll definitely check it out. - James On Monday, February 11, 2013 11:37:14 AM UTC-6, Michael Klishin wrote: > > Titanium [1] is a Cloju

Re: ANN: NEVER use clojure.core/read or read-string for reading untrusted data

2013-02-11 Thread Andy Fingerhut
And just in case it gets edited by someone else before you have a chance to read it, I've copied and pasted the current version below for reference. Correction/comments/questions all welcome. On Feb 11, 2013, at 10:29 AM, Andy Fingerhut wrote: > Following up on the thread "*read-eval* vulnerab

Re: ANN Titanium, a Clojure library on top of Titan

2013-02-11 Thread AtKaaZ
a small typo here: http://titanium.clojurewerkz.org/articles/getting_started.html at " Removing Edges " (tg/remove-edge e)) should be: (tg/remove-edge g e)) should I be reporting any of these somewhere else? On Mon, Feb 11, 2013 at 6:37 PM, Michael Klishin < michael.s.klis...@gmail.com> wr

ANN: NEVER use clojure.core/read or read-string for reading untrusted data

2013-02-11 Thread Andy Fingerhut
Following up on the thread "*read-eval* vulnerability", I started writing some documentation for how to read Clojure data safely. That isn't ready yet, but before I get the time to finish that I wanted to quickly get out a warning that is obvious to some, but probably not all: NEVER use cl

Re: ANN Titanium, a Clojure library on top of Titan

2013-02-11 Thread AtKaaZ
this is awesome! there is some format issue on this page: http://titanium.clojurewerkz.org/articles/getting_started.html search for this twice to see both: clojurewerkz.titanium.elements/merge! On Mon, Feb 11, 2013 at 6:37 PM, Michael Klishin < michael.s.klis...@gmail.com> wrote: > Titanium [1]

Re: [ANN] analyze 0.3.0 - Hygienic transformation

2013-02-11 Thread kovas boguta
What is a hygienic AST? Thanks k On Sun, Feb 10, 2013 at 10:45 PM, Ambrose Bonnaire-Sergeant wrote: > Hi everyone, > > Happy to release analyze 0.3.0 with new hygienic code transformation > capabilities. > > [analyze "0.3.0"] > > In a line: > > analyze.hygienic=> (-> (ast (let [a 1 a a b a a a]

ANN Titanium, a Clojure library on top of Titan

2013-02-11 Thread Michael Klishin
Titanium [1] is a Clojure graph library that is built on top of Titan [2]. It combines a Clojure-friendly API and graph processing DSL with the power of Titan. Full announcement and more details: http://blog.clojurewerkz.org/blog/2013/02/11/introducing-titanium/ 1. http://titanium.clojurewerkz.o

Re: How to Process Files in Background

2013-02-11 Thread AtKaaZ
someone posted this [1] earlier, I think it might help you [1] http://clojure-doc.org/articles/language/concurrency_and_parallelism.html On Mon, Feb 11, 2013 at 5:50 PM, Ari wrote: > Hi, > > I'd like my web application to process uploaded text files in the > background; in which ways can I acc

Re: How to Process Files in Background

2013-02-11 Thread Zack Maril
Is there any reason why a future wouldn't work? http://clojuredocs.org/clojure_core/clojure.core/future -Zack On Monday, February 11, 2013 8:50:03 PM UTC+4, Ari wrote: > > Hi, > > I'd like my web application to process uploaded text files in the > background; in which ways can I accomplish this

How to Process Files in Background

2013-02-11 Thread Ari
Hi, I'd like my web application to process uploaded text files in the background; in which ways can I accomplish this? I thought of using a message queue like 0mq to push jobs to workers within the web app itself. While relatively straight forward this option seems a bit involved. Suggestions