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 want:

(loop []
  (do
(a-function)
(let [y (another-function)]
  (... code that uses y ...))
(recur)))

On Monday, February 11, 2013 11:25:23 PM UTC-8, 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
>   (recur (a-function) (another-function)))
>
> This gets the job done (my a-function is a select() call which I don't use 
> the return value of in the body), but it feels a little hacky so I'm 
> wondering what's a better way?
>
>

-- 
-- 
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/groups/opt_out.




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
>   (recur (a-function) (another-function)))
>
> This gets the job done (my a-function is a select() call which I don't use
> the return value of in the body), but it feels a little hacky so I'm
> wondering what's a better way?
>
> --
> --
> 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/groups/opt_out.
>
>



--
Baishampayan Ghose
b.ghose at gmail.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/groups/opt_out.




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 
the return value of in the body), but it feels a little hacky so I'm 
wondering what's a better way?

-- 
-- 
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/groups/opt_out.




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 Monday, February 11, 2013 4:35:36 PM UTC-7, Devin Walters (devn) wrote:
>
> 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 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.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 Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>  -- 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com .
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
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/groups/opt_out.




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 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 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.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 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/groups/opt_out.
>>
>>
>
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> 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/groups/opt_out.
>
>
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> 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/groups/opt_out.
>
>



-- 
Baishampayan Ghose
b.ghose at gmail.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/groups/opt_out.




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 fast, I hit it all the time.  



On Tuesday, February 12, 2013 10:28:43 AM UTC+8, John Fries wrote:
>
> 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 it 
> up into multiple lines and indent it: 
> (defun func1 [a b c d] 
>   (func5 
>   (let [f (func3 c)] 
> (func2 a b f)) 
>   (let [e 5] 
>  (func4 c d e 
>
> I find the latter form more readable, but inserting the newlines by 
> hand is getting repetitive (also, I am not always confident in my 
> choice of idiomatic breakpoints). Once I insert the newlines, I can 
> trigger auto-indentation by hitting M-q (which on my system is mapped 
> to paredit-reindent-defun) or by highlighting the region and hitting 
> M-C-\ (which on my system is indent-region). 
>
> My question(s) is: 
> 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) 
> 2) Do people have some accepted pretty printing function they are 
> using within emacs? 
> 3) Is there some larger issue I'm not seeing that maybe makes this 
> whole idea irrelevant? 
>
> I've seen this document: 
> http://richhickey.github.com/clojure/doc/clojure/pprint/PrettyPrinting.html 
> But I haven't found any guide to using that function *within emacs*. 
> If this is not a common thing to do, then why is it not common? 
>
> Thanks, 
> John 
>
> caveat: My init.el is an amalgam of ideas from ESK, prelude and emacs 
> live, so it could be the case that this functionality is provided out 
> of the box, if only I were configured properly. If people have some 
> way of doing this in their emacs environment, a clue as to the kit or 
> configuration you are using would be very much appreciated. 
>

-- 
-- 
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/groups/opt_out.




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 than inserting spaces between 
symbols and words by hand :-)

Honestly I don't consciously notice either of those things unless I'm redoing 
the line breaks in some code, which typically only happens if I'm changing its 
indent level by a significant amount (e.g. 10 more or 10 less spaces of indent 
before each line, because it is being nested more/less deeply in other code 
than it was before).

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/groups/opt_out.




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 it
up into multiple lines and indent it:
(defun func1 [a b c d]
  (func5
  (let [f (func3 c)]
(func2 a b f))
  (let [e 5]
 (func4 c d e

I find the latter form more readable, but inserting the newlines by
hand is getting repetitive (also, I am not always confident in my
choice of idiomatic breakpoints). Once I insert the newlines, I can
trigger auto-indentation by hitting M-q (which on my system is mapped
to paredit-reindent-defun) or by highlighting the region and hitting
M-C-\ (which on my system is indent-region).

My question(s) is:
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)
2) Do people have some accepted pretty printing function they are
using within emacs?
3) Is there some larger issue I'm not seeing that maybe makes this
whole idea irrelevant?

I've seen this document:
http://richhickey.github.com/clojure/doc/clojure/pprint/PrettyPrinting.html
But I haven't found any guide to using that function *within emacs*.
If this is not a common thing to do, then why is it not common?

Thanks,
John

caveat: My init.el is an amalgam of ideas from ESK, prelude and emacs
live, so it could be the case that this functionality is provided out
of the box, if only I were configured properly. If people have some
way of doing this in their emacs environment, a clue as to the kit or
configuration you are using would be very much appreciated.

-- 
-- 
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/groups/opt_out.




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 when working with the AST, gensyms in macros 
achieve similar results

I guess this is useful in typed Clojure or similar tools to perform type 
checking 

Ronen

On Monday, February 11, 2013 7:54:31 PM UTC+2, kovasb wrote:
>
> 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] a)) ast-hy emit-hy) 
> > ((fn* ([] (let* [a 1 a2921 a b a2921 a2922 a2921] a2922 
> > 
> > Hygienic AST's have enabled large performance boosts in core.typed. I'm 
> > excited to see how it could 
> > be as useful to others. 
> > 
> > Note: "hygienic" AST's (those transformed with `analyze.hygienic/ast-hy` 
> can 
> > be printed normally with `analyze.emit-form/emit-form`, and hygienically 
> > with `analyze.hygienic/emit-hy`. 
> > 
> > https://github.com/frenchy64/analyze 
> > 
> > Thanks, 
> > Ambrose 
> > 
> > -- 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Clojure" group. 
> > To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com . 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
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/groups/opt_out.




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 
effects that clojure.core/read and read-string have.

(2) Attempting to find and plug all possible potential security vulnerabilities 
in clojure.core/read and read-string when *read-eval* is bound to false would 
make it too easy to miss something, especially when combined with avoiding 
breakage of existing functionality needed by the Clojure compiler.  Some of 
that functionality relies upon the side effects that can occur during read.

It isn't just clojure.core/read executing code that can consume CPU cycles that 
is the issue, it is clojure.core/read executing code that can wreak havoc with 
your system and allow attackers to gain remote control of it.

Andy

On Feb 11, 2013, at 5:45 PM, Brent Millare wrote:

> 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 Cosenza wrote:
> 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 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* 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 clojure.core/read or read-string for reading data from 
>> > untrusted sources, only trusted ones.  Even from trusted sources, binding 
>> > *read-eval* to false is probably a good idea, but that depends on your 
>> > particular use case.
>> >
>> >
>> > An example I wrote on ClojureDocs.org for function clojure.core/read 
>> > several months ago was very badly wrong.  It said that binding *read-eval* 
>> > to false would cause clojure.core/read to read data safely, even if that 
>> > data came from an untrusted source.
>> >
>> > I have modified that example to be a lot longer, and hopefully as correct 
>> > and scary as it should be.  Please take a look at it if you use read or 
>> > read-string anywhere in your Clojure code:
>> >
>> >http://clojuredocs.org/clojure_core/clojure.core/read
>> >
>> > Andy
>> 
>> 
>> ;; WARNING: You SHOULD NOT use clojure.core/read or clojure.core/read-string 
>> to
>> ;; read data from untrusted sources.  They were designed only for reading 
>> Clojure
>> ;; code and data from trusted sources (e.g. files that you know you wrote
>> ;; yourself, and no one else has permission to modify them).
>> 
>> ;; Instead, either:
>> 
>> ;; (a) use another data serialization format such as JSON, XML, etc. and a
>> ;; library for reading them that you trust not to have vulnerabilities, or
>> 
>> ;; (b) if you want a serialization format that can be read safely and looks 
>> like
>> ;; Clojure data structures, use edn (https://github.com/edn-format/edn), for
>> ;; which Clojure 1.5 has functions clojure.edn/read and 
>> clojure.edn/read-string
>> ;; to read them safely.
>> 
>> ;; You definitely should not use clojure.core/read or read-string if 
>> *read-eval*
>> ;; has its default value of true, because an attacker could cause your
>> ;; application to execute arbitrary code while it is reading.  Example:
>> 
>> user=> (read-string "#=(clojure.java.shell/sh \"echo\" \"hi\")")
>> {:exit 0, :out "hi\n", :err ""}
>> 
>> ;; It is straightforward to modify the example above into more destructive
>> ;; ones that remove all of your files, copy them to someone else's computer
>> ;; over the Internet, install Trojans, etc.
>> 
>> ;; Even if you do bind *read-eval* to false first, like so:
>> 
>> (defn read-string-unsafely [s]
>>   (binding [*read-eval* false]
>> (read-string s)))
>> 
>> ;; you may hope you are safe reading untrusted data that way, but in Clojure 
>> 1.4
>> ;; and earlier, an attacker can send data that causes your system to execute
>> ;; arbitrary Java constructors.  Most of these are benign, but it only takes 
>> one
>> ;; to ruin your application's day.  Examples that should scare you:
>> 
>> ;; This causes a socket to be opened, as long as the JVM
>> ;; sandboxing allows it.
>> (read-string-unsafely "#java.net.Socket[\"www.google.com\" 80]")
>> 
>> ;; This causes precious

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 Cosenza wrote:
>
> 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 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* 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 clojure.core/read or read-string for reading data from 
>> untrusted sources, only trusted ones.  Even from trusted sources, binding 
>> *read-eval* to false is probably a good idea, but that depends on your 
>> particular use case.
>> >
>> >
>> > An example I wrote on ClojureDocs.org for function clojure.core/read 
>> several months ago was very badly wrong.  It said that binding *read-eval* 
>> to false would cause clojure.core/read to read data safely, even if that 
>> data came from an untrusted source.
>> >
>> > I have modified that example to be a lot longer, and hopefully as 
>> correct and scary as it should be.  Please take a look at it if you use 
>> read or read-string anywhere in your Clojure code:
>> >
>> >http://clojuredocs.org/clojure_core/clojure.core/read
>> >
>> > Andy
>>
>>
>> ;; WARNING: You SHOULD NOT use clojure.core/read or 
>> clojure.core/read-string to
>> ;; read data from untrusted sources.  They were designed only for reading 
>> Clojure
>> ;; code and data from trusted sources (e.g. files that you know you wrote
>> ;; yourself, and no one else has permission to modify them).
>>
>> ;; Instead, either:
>>
>> ;; (a) use another data serialization format such as JSON, XML, etc. and a
>> ;; library for reading them that you trust not to have vulnerabilities, or
>>
>> ;; (b) if you want a serialization format that can be read safely and 
>> looks like
>> ;; Clojure data structures, use edn (https://github.com/edn-format/edn), 
>> for
>> ;; which Clojure 1.5 has functions clojure.edn/read and 
>> clojure.edn/read-string
>> ;; to read them safely.
>>
>> ;; You definitely should not use clojure.core/read or read-string if 
>> *read-eval*
>> ;; has its default value of true, because an attacker could cause your
>> ;; application to execute arbitrary code while it is reading.  Example:
>>
>> user=> (read-string "#=(clojure.java.shell/sh \"echo\" \"hi\")")
>> {:exit 0, :out "hi\n", :err ""}
>>
>> ;; It is straightforward to modify the example above into more destructive
>> ;; ones that remove all of your files, copy them to someone else's 
>> computer
>> ;; over the Internet, install Trojans, etc.
>>
>> ;; Even if you do bind *read-eval* to false first, like so:
>>
>> (defn read-string-unsafely [s]
>>   (binding [*read-eval* false]
>> (read-string s)))
>>
>> ;; you may hope you are safe reading untrusted data that way, but in 
>> Clojure 1.4
>> ;; and earlier, an attacker can send data that causes your system to 
>> execute
>> ;; arbitrary Java constructors.  Most of these are benign, but it only 
>> takes one
>> ;; to ruin your application's day.  Examples that should scare you:
>>
>> ;; This causes a socket to be opened, as long as the JVM
>> ;; sandboxing allows it.
>> (read-string-unsafely "#java.net.Socket[\"www.google.com\" 80]")
>>
>> ;; This causes precious-file.txt to be created if it doesn't
>> ;; exist, or if it does exist, its contents will be erased (given
>> ;; appropriate JVM sandboxing permissions, and underlying OS file
>> ;; permissions).
>> (read-string-unsafely "#java.io.FileWriter[\"precious-file.txt\"]")
>>
>> ;; The particular issue of executing arbitrary Java constructors used in 
>> the
>> ;; examples above no longer works in Clojure 1.5 when *read-eval* is 
>> false.
>> ;; Even so, you SHOULD NEVER USE clojure.core/read or 
>> clojure.core/read-string
>> ;; for reading untrusted data.
>>
>> ;; If you understand all of the above, and want to use read or 
>> read-string to
>> ;; read data from a _trusted_ source, continue on below.
>>
>> ;; read wants *in* set to a java.io.PushbackReader.
>> ;; with-open sets *in* and closes it after it's done.
>> ;; *read-eval* specifies whether to evaluate #=() forms
>> ;; when reading.
>> (defn read-from-file-with-trusted-contents [filename]
>>   (with-open
>> [r (java.io.PushbackReader.
>>  (clojure.java.io/reader filename))]
>> 

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 arbitrary state. In 
this case, the statements produce side-effects but nothing is actually 
computed, which is fine. You'd want to model each statement to encapsulate 
some action and return a State instance. For simplicity, the function move 
mixes the conditional statement with the then-branch, but that can be 
easily separated later:
;; shameless plug
(use 'blancas.morph.core 
 'blancas.morph.monads)

(defn move [key v]
  (monad [held (gets :keys-held)]
(if (held key)
  (modify-state #(update-in % [:position] v+ v))
  (state :empty-stmt

This function takes the key that was pressed. If it's one held in storage, 
the state will be modified pretty much the way it was before; otherwise the 
statement evaluates into a state instance whose value is the empty 
statement.

Each of the following elements models a conditional statement: if x do this:

(def stmts [(move :left  [-10   0])
(move :right [ 10   0])
(move :up[  0 -10])
(move :down  [  0  10])])

This "runs" the sequence of monads and returns the value of the resulting 
state (not the value since it's not computing anything:

(exec-state (seqm stmts) init)
;; {:position [90 100], :st :st0, :keys-held #{:left}}

Here we do the same but then change the key and re-evaluate the statements. 
The combinators seqm and >> are similar; seqm takes a collection.
(exec-state (>> (seqm stmts)
(modify-state assoc :keys-held #{:down})
(seqm stmts))
init)
;; {:position [90 110], :st :st0, :keys-held #{:down}}

This shows a computation; say you want to compute: [50 50] + [12 -5]
For this you'd write a new version of v+ that takes "monadic" args (boxed 
in a State). As above, the (monad) macro binds the results of monads to the 
variables, as in a let. Then wraps the result in a state:

(defn v+ [v1 v2]
  (monad [x v1 y v2]
(state (vec (map + x y)

(This function could take simple vectors, but in a real use case you'd be 
taking expressions, not just values.)
Now you can get the result like so:

(eval-state (v+ (state [50 50]) (state [12 -5])) init)
;; [62 45]

If you want both the computed value and the finate state you can get them 
both in a Pair:

(run-state (v+ (state [50 50]) (state [12 -5])) init)
;; Pair([62 45],{:position [100 100], :st :st0, :keys-held #{:left}})

On Monday, February 11, 2013 12:10:24 PM UTC-8, 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 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 
> original or updated object.  I'd like to see if I can clean up this code, 
> possibly by using monads (which I don't understand very well).  Does anyone 
> have any advice?  Thanks (Code examples below)
>
> The pseudocode for what i want to do looks something like this:
>
> if left key is held
>g.position += [-10 0]
> if right key is held
>g.position += [10 0]
> if up key is held
>g.position += [0 -10]
> if down key is held
>g.position += [0 10]
> if q is pressed
>fire event {:type :dialogue, :text "Hello"}
> if space is pressed
>g.switchstate(:s2)
>
>
> But the code I ended up writing is this mess:
>
>
> (fn [g]
>   (-> g
>   (#(if (@*keys-held* :left)
>   (update-in % [:position] v+ [-10 0])
>   %))
>   (#(if (@*keys-held* :right)
>   (update-in % [:position] v+ [10 0]) %))
>   (#(if (@*keys-held* :up)
>   (update-in % [:position] v+ [0 -10]) %))
>   (#(if (@*keys-held* :down)
>   (update-in % [:position] v+ [0 10]) %))
>   (#(if (@*keys-pressed* \q)
>   (do (fire-event {:type :dialogue
>:text "Hello!"})
>   %)
>   %))
>   (#(if (@*keys-pressed* :space)
>   (do (comment (println "spaced!"))
>   (switch-state % :s2)) %
>

-- 
-- 
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

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 object, a method name (as a symbol or 
string) and optional arguments; and then uses eval to find the result:


(ns calling-methods
  (:require [clojure.reflect :as r]))
;-
(defn call-method* [obj m & args]
  (eval `(. ~obj ~(symbol m) ~@args)))
;-  
(def method-def (->> (r/reflect "String")
:members
(filter #(= "toString" (str (:name %
first))
 
(let [x {:a 1 :b 2}
  s "hi"
  upper "toUpperCase"]
  (println (call-method* x (:name method-def)))
  (println (call-method* "hi" (:name method-def)))
  (println (call-method* "hi" upper)))


Hope it helps.

J

On Monday, February 11, 2013 5:34:00 PM UTC-3, Bauna wrote:
>
> 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 been trying to use clojure.reflect, but I was not able to 
> find a way to invoke a method on the class with the symbols retrieved from 
> reflect (I know that I can use java interop and 
> use standard java reflection api). 
>
> Here is and example of what I want to do: 
> user=> (require '[clojure.reflect :as r]) 
> user=> (def method-def (filter #(= "toString" (str (:name %)))  (:members 
> (r/reflect "aClass" 
>
> How do I invoke "toString" using "method-definition"? 
>
> Thanks and regards, 
> -- 
> Pablo Nussembaum 
>
>
>
>  what is better to use java interop using java reflection API or use 
> clojure.reflect to option 
>

-- 
-- 
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/groups/opt_out.




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 can imagine when it would be useful, 
and a complete implementation should store the namespace, the line number, 
and maybe further info).

I am using this in my project Piplin, a DSL for programming FPGAs in 
Clojure. I'll be talking about Piplin and some of the embedding tricks I 
use at Clojure/West. This let' macro gives me a higher-fidelity way to 
translate Clojure source to Verilog source purely at runtime, which is a 
different approach from other Clojure cross-compilers.

On Sunday, February 10, 2013 7:40:51 PM UTC-5, vemv wrote:
>
> Glad to hear that Phil! You're entirely right - I didn't realise that 
> distributing jar to Java consumers doesn't imply AOT-compiling the 
> libraries at all.
>
> David, on your implementation - I may be missing something, but why not 
> just vary-meta each collection found in the bindings?
>
> Also, it might interest you performing the tagging tree-recursively (e.g. 
> in (let x [[][][]]) the four colls would get tagged), and with namespaced 
> names.
>
> More importantly, how are you using this? One thing I haven't thought 
> about yet is how to map the "tags" to stack traces.
>

-- 
-- 
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/groups/opt_out.




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 initialize it with a wrapped ring handler. 
>
> If you have more details on the issue or alternatives I would love to hear 
> about them.
>
> On Tuesday, February 12, 2013 12:54:53 AM UTC+2, Ryan T. wrote:
>>
>> 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 
>> this 
>> but 
>> from what I read Webbit is not the best solution for what I need. I was 
>> hoping to be able to build my clojure project and use jetty in development 
>> and tomcat on production.
>>
>> Thank you for your time
>>
>

-- 
-- 
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/groups/opt_out.




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 question, that aleph is capable of 
doing synchronous and asynchronous requests with the same server and port. 
All you have to do is to use different endpoints, even though it's possible 
to have the same one as well.

On Tuesday, February 12, 2013 1:22:13 AM UTC+2, 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 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
>
>
> If you have more details on the issue or alternatives I would love to hear 
> about them.
>
> On Tuesday, February 12, 2013 12:54:53 AM UTC+2, Ryan T. wrote:
>>
>> 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 
>> this 
>> but 
>> from what I read Webbit is not the best solution for what I need. I was 
>> hoping to be able to build my clojure project and use jetty in development 
>> and tomcat on production.
>>
>> Thank you for your time
>>
>
> -- 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com .
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  
>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
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/groups/opt_out.




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 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.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 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/groups/opt_out.
> 
> -- 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> 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/groups/opt_out.
>  
>  

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
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/groups/opt_out.




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 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
> 
>> 
>> If you have more details on the issue or alternatives I would love to hear 
>> about them.
>> 
>> On Tuesday, February 12, 2013 12:54:53 AM UTC+2, Ryan T. wrote:
>>> 
>>> 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 this but from what I read Webbit is not the best solution for 
>>> what I need. I was hoping to be able to build my clojure project and use 
>>> jetty in development and tomcat on production.
>>> 
>>> Thank you for your time
>> 
>> 
>> -- 
>> -- 
>> 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/groups/opt_out.
> 
> -- 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> 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/groups/opt_out.
>  
>  

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
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/groups/opt_out.




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 the power of 
> Titan.
> 
> Full announcement and more details:
> http://blog.clojurewerkz.org/blog/2013/02/11/introducing-titanium/
> 
> 1. http://titanium.clojurewerkz.org
> 2. http://thinkaurelius.github.com/titan/
> -- 
> MK
> 
> http://github.com/michaelklishin
> http://twitter.com/michaelklishin
> -- 
> -- 
> 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/groups/opt_out.
>  
>  

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
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/groups/opt_out.




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

> 
> If you have more details on the issue or alternatives I would love to hear 
> about them.
> 
> On Tuesday, February 12, 2013 12:54:53 AM UTC+2, Ryan T. wrote:
> 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 this but from what I read Webbit is not the best solution for what 
> I need. I was hoping to be able to build my clojure project and use jetty in 
> development and tomcat on production.
> 
> Thank you for your time
> 
> -- 
> -- 
> 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/groups/opt_out.
>  
>  

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
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/groups/opt_out.




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
stack that you'll be using in production. Minimise surprises as much
as you absolutely can.

~Justin

-- 
-- 
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/groups/opt_out.




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 for actually using it (I actually try to avoid OO as much as 
possible, since I don't see it as a good solution to most problems). I just 
wanted to see how feasible it was to implement an OO system on top of 
functions. However, reading what you wrote gave me some ideas, so I might 
work on it more and see where it takes me. The implementation itself has 
only ~70 LoC, so it turned out to be pretty easy to do.

> Suggestions on syntax: It would be much nicer to use and more idiomatic 
if the method name came first, e.g.
> (method some-object arg1 arg2)

The idea was for objects to be functions, which means they have to go 
first. Having the methods be keywords and not other functions also gave it 
a sort of message-passing feel that is kinda nice.

> This would bring many benefits: you could use the standard "->" syntax, 
you can "apply" a method, it will fit much better when composed with 
Clojure library functions etc.

Being able to use Clojure's "->" macro would have been real nice, but 
having the objects be functions made it impossible. It's just a sad reality 
I'll have to live with.

> You could also potentially use any associative data structure as your 
object type.

There are only two alternatives to regular Clojure maps when it comes to 
associative data structures. One is vectors, but I'm not sure what the 
semantics of using vectors as the storage unit would be. The other is 
allowing custom "map-like" datatypes made by users. However, one fear I had 
was allowing people to use mutable implementations (like a KV cache, for 
example), which would have messed up the functional feel of the library.

One idea I had was also to create an object datatype that implemented the 
interfaces to behave like a map and a function. That way people would have 
been able to use assoc & dissoc, for example. However, wanting to keep 
things minimal and to rely only on regular functions, I discarded that 
option.

> You could also potentially have special handling for null object values, 
default implementations in case of missing methods etc.

The idea for the missing methods is quite nice. I'm thinking maybe a way 
could be added to the library to create hooks into several "life-cycle 
events" of the objects.
You could have hooks for calling functions:
  + That way you could implement before|after|around mixin functionality.
  + You could also have method-missing code to work by doing that.

You could have hooks for reading/writing attributes:
  + That would you could have setter-like validation of changes.
  + You could also implement virtual-slots with it, reading from fields 
that are actually calculated on-the-fly.

> This suggests to me that it would be a better design if each method was 
defined as a function that looked up the specific implementation in the 
prototype object and called it.
> Obviously, this means that you need to explicitly declare prototype 
methods.
> But I think this is a good idea anyway: it ensures a bit more discipline 
and testability (which is often the biggest problem in prototype-based 
systems.)

That is something that can certainly be done, but I'm not sure if the 
library should implement it.
What I mean by that is this: the implementation is meant to provide the 
bare minimum you need to build everything else you need on top.
That functionality can easily be built on top without needing to modify the 
OO system itself; so although it would be cool to have that, I don't think 
the library should concern itself with providing it.

Regarding the discipline and testability: I really like to strive towards 
those two things, but thinking about incorporating those changes kinda 
makes me feel like we're back in the class-based OO world. Not because we 
have actual classes around, but because providing so much specification 
code feels like we have supplanted classes with some sort of implicit 
quasi-class-like OO specification, and I'm not sure if that would play so 
well with the dynamicity that the library strives to achieve.

-- 
-- 
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

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 
about them.

On Tuesday, February 12, 2013 12:54:53 AM UTC+2, Ryan T. wrote:
>
> 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 
> this 
> but 
> from what I read Webbit is not the best solution for what I need. I was 
> hoping to be able to build my clojure project and use jetty in development 
> and tomcat on production.
>
> Thank you for your time
>

-- 
-- 
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/groups/opt_out.




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.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 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/groups/opt_out.
>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
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/groups/opt_out.




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 10)

(k/future x (do-something) (do-more))

;; or you can just use k/execute with a callable:
(k/execute x (fn [] ...))


- Max


On Monday, February 11, 2013 5:50:03 PM UTC+1, Ari wrote:
>
> 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/recommendations appreciated.
>
> Best,
> Ari 
>

-- 
-- 
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/groups/opt_out.




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 
this 
but 
from what I read Webbit is not the best solution for what I need. I was 
hoping to be able to build my clojure project and use jetty in development 
and tomcat on production.

Thank you for your time

-- 
-- 
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/groups/opt_out.




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 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/groups/opt_out.




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 executor a (fn []) that wraps up all the data needed
for the task.

Timothy


On Mon, Feb 11, 2013 at 2:48 PM, Ari  wrote:

> 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:
>>
>> 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? 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/recommendations appreciated.
>>>
>>> Best,
>>> Ari
>>>
>>  --
> --
> 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/groups/opt_out.
>
>
>



-- 
“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/groups/opt_out.




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 date and the 
location in this post yet. This message is merely a quick check whether 
people are interested. If you are interested in a meetup, please let us 
know.

Why a meetup?
It is always interesting to meet people with common interests. Wanting to 
share opinions, insights and projects is a really valuable virtue. Sharing 
ideas gets more fun and easy if you can talk to each other in person. It's 
the interaction that makes the transfer rate of knowledge increase rapidly. 
Doing this in group only makes this process more pleasurable and 
interesting.

What will it be about?
There are a lot of options of what the meetup could be about. So this part 
of the meetup is still in brainstorm-phase.
For instance, we could have some sessions on some different clojure related 
topics / projects. The topics might be very diverse: going from big data, 
music/visuals, core.logic, to meta-stuff and projects you worked on.

A quick idea: One might give a session on heroku, where we build a website 
for this meetup group and deploy it to heroku. (Or something alike)

If you have any interesting ideas about what we could do as well, don’t 
hesitate to let us know. Also if you are interested in giving a session you 
can let us know as well.

Where and when?
At this early stage of setup, it is really hard to tell. But belgium is not 
that 
large so a finding a suitable location shouldn’t be that hard.
Nevertheless,  I would like to ask anyone interested in the meetup to leave 
a comment to let us know what city you live in, what time of the day you 
would prefer and what locations you prefer.

What now?
Everything is still a bit vague at the moment but as soon as decisions are 
going to be made, I’ll be sure to post updates. 
We really hope that we’ll be able to get it started so any advice is really 
appreciated (also from non belgian people!)

You can also follow the latest developments by following @belgiumclj on 
twitter. *

-- 
-- 
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/groups/opt_out.




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:
>
> 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? 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/recommendations appreciated.
>>
>> Best,
>> Ari 
>>
>

-- 
-- 
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/groups/opt_out.




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 ~action))

Then you could write:

  (-> g
(on (key-held :left) (move [-10 0]))
(on (key-held :right) (move [10 0]))
(on (key-held :up) (move [0 -10]))
(on (key-held :down) (move [0 10]))

But if you're designing a game, you usually want to separate the event loop
from the event handling. That's a big topic though, and I can't really go
into much detail in a single post.

- James



On 11 February 2013 20:10, 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 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
> original or updated object.  I'd like to see if I can clean up this code,
> possibly by using monads (which I don't understand very well).  Does anyone
> have any advice?  Thanks (Code examples below)
>
> The pseudocode for what i want to do looks something like this:
>
> if left key is held
>g.position += [-10 0]
> if right key is held
>g.position += [10 0]
> if up key is held
>g.position += [0 -10]
> if down key is held
>g.position += [0 10]
> if q is pressed
>fire event {:type :dialogue, :text "Hello"}
> if space is pressed
>g.switchstate(:s2)
>
>
> But the code I ended up writing is this mess:
>
>
> (fn [g]
>   (-> g
>   (#(if (@*keys-held* :left)
>   (update-in % [:position] v+ [-10 0])
>   %))
>   (#(if (@*keys-held* :right)
>   (update-in % [:position] v+ [10 0]) %))
>   (#(if (@*keys-held* :up)
>   (update-in % [:position] v+ [0 -10]) %))
>   (#(if (@*keys-held* :down)
>   (update-in % [:position] v+ [0 10]) %))
>   (#(if (@*keys-pressed* \q)
>   (do (fire-event {:type :dialogue
>:text "Hello!"})
>   %)
>   %))
>   (#(if (@*keys-pressed* :space)
>   (do (comment (println "spaced!"))
>   (switch-state % :s2)) %
>
> --
> --
> 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/groups/opt_out.
>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
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/groups/opt_out.




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 been trying to use clojure.reflect, but I was not able to find 
a way to invoke a method on the class with the symbols retrieved from reflect 
(I know that I can use java interop and
use standard java reflection api).

Here is and example of what I want to do:
user=> (require '[clojure.reflect :as r])
user=> (def method-def (filter #(= "toString" (str (:name %)))  (:members 
(r/reflect "aClass"

How do I invoke "toString" using "method-definition"?

Thanks and regards,
-- 
Pablo Nussembaum



 what is better to use java interop using java reflection API or use 
clojure.reflect to option

-- 
-- 
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/groups/opt_out.




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]
   :down [10 0]})

(def key-maps
   {:t-key :left})

(reduce
  (fn [acc key]
  (if (pressed? key)
  (update-in acc [:position] v+ (-> key key-maps dirs))
   acc))
   state
   keys)


Using the new reducers lib, you should be able get tolerable performance
from code like this. If you want other states (pressed, held, etc.) think
about using a multi method:

(defmulti key-dispatch (fn [state key]
 [(to-char key) (pressed? key) (held?
key) (released? key)]))

(defmethod key-dispatch [\t true false false]
[state key]
(do-stuff))

Timothy


On Mon, Feb 11, 2013 at 1:12 PM, Ben Wolfson  wrote:

> 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 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
> > original or updated object.  I'd like to see if I can clean up this code,
> > possibly by using monads (which I don't understand very well).  Does
> anyone
> > have any advice?  Thanks (Code examples below)
> >
> > The pseudocode for what i want to do looks something like this:
> >
> > if left key is held
> >g.position += [-10 0]
> > if right key is held
> >g.position += [10 0]
> > if up key is held
> >g.position += [0 -10]
> > if down key is held
> >g.position += [0 10]
> > if q is pressed
> >fire event {:type :dialogue, :text "Hello"}
> > if space is pressed
> >g.switchstate(:s2)
> >
> >
> > But the code I ended up writing is this mess:
> >
> >
> > (fn [g]
> >   (-> g
> >   (#(if (@*keys-held* :left)
> >   (update-in % [:position] v+ [-10 0])
> >   %))
> >   (#(if (@*keys-held* :right)
> >   (update-in % [:position] v+ [10 0]) %))
> >   (#(if (@*keys-held* :up)
> >   (update-in % [:position] v+ [0 -10]) %))
> >   (#(if (@*keys-held* :down)
> >   (update-in % [:position] v+ [0 10]) %))
> >   (#(if (@*keys-pressed* \q)
> >   (do (fire-event {:type :dialogue
> >:text "Hello!"})
> >   %)
> >   %))
> >   (#(if (@*keys-pressed* :space)
> >   (do (comment (println "spaced!"))
> >   (switch-state % :s2)) %
> >
> > --
> > --
> > 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/groups/opt_out.
> >
> >
>
>
>
> --
> Ben Wolfson
> "Human kind has used its intelligence to vary the flavour of drinks,
> which may be sweet, aromatic, fermented or spirit-based. ... Family
> and social life also offer numerous other occasions to consume drinks
> for pleasure." [Larousse, "Drink" entry]
>
> --
> --
> 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/groups/opt_out.
>
>
>


-- 
“One of the main causes of the fall 

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 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
> original or updated object.  I'd like to see if I can clean up this code,
> possibly by using monads (which I don't understand very well).  Does anyone
> have any advice?  Thanks (Code examples below)
>
> The pseudocode for what i want to do looks something like this:
>
> if left key is held
>g.position += [-10 0]
> if right key is held
>g.position += [10 0]
> if up key is held
>g.position += [0 -10]
> if down key is held
>g.position += [0 10]
> if q is pressed
>fire event {:type :dialogue, :text "Hello"}
> if space is pressed
>g.switchstate(:s2)
>
>
> But the code I ended up writing is this mess:
>
>
> (fn [g]
>   (-> g
>   (#(if (@*keys-held* :left)
>   (update-in % [:position] v+ [-10 0])
>   %))
>   (#(if (@*keys-held* :right)
>   (update-in % [:position] v+ [10 0]) %))
>   (#(if (@*keys-held* :up)
>   (update-in % [:position] v+ [0 -10]) %))
>   (#(if (@*keys-held* :down)
>   (update-in % [:position] v+ [0 10]) %))
>   (#(if (@*keys-pressed* \q)
>   (do (fire-event {:type :dialogue
>:text "Hello!"})
>   %)
>   %))
>   (#(if (@*keys-pressed* :space)
>   (do (comment (println "spaced!"))
>   (switch-state % :s2)) %
>
> --
> --
> 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/groups/opt_out.
>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
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/groups/opt_out.




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 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
> original or updated object.  I'd like to see if I can clean up this code,
> possibly by using monads (which I don't understand very well).  Does anyone
> have any advice?  Thanks (Code examples below)
>
> The pseudocode for what i want to do looks something like this:
>
> if left key is held
>g.position += [-10 0]
> if right key is held
>g.position += [10 0]
> if up key is held
>g.position += [0 -10]
> if down key is held
>g.position += [0 10]
> if q is pressed
>fire event {:type :dialogue, :text "Hello"}
> if space is pressed
>g.switchstate(:s2)
>
>
> But the code I ended up writing is this mess:
>
>
> (fn [g]
>   (-> g
>   (#(if (@*keys-held* :left)
>   (update-in % [:position] v+ [-10 0])
>   %))
>   (#(if (@*keys-held* :right)
>   (update-in % [:position] v+ [10 0]) %))
>   (#(if (@*keys-held* :up)
>   (update-in % [:position] v+ [0 -10]) %))
>   (#(if (@*keys-held* :down)
>   (update-in % [:position] v+ [0 10]) %))
>   (#(if (@*keys-pressed* \q)
>   (do (fire-event {:type :dialogue
>:text "Hello!"})
>   %)
>   %))
>   (#(if (@*keys-pressed* :space)
>   (do (comment (println "spaced!"))
>   (switch-state % :s2)) %
>
> --
> --
> 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/groups/opt_out.
>
>



-- 
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks,
which may be sweet, aromatic, fermented or spirit-based. ... Family
and social life also offer numerous other occasions to consume drinks
for pleasure." [Larousse, "Drink" entry]

-- 
-- 
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/groups/opt_out.




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 
original or updated object.  I'd like to see if I can clean up this code, 
possibly by using monads (which I don't understand very well).  Does anyone 
have any advice?  Thanks (Code examples below)

The pseudocode for what i want to do looks something like this:

if left key is held
   g.position += [-10 0]
if right key is held
   g.position += [10 0]
if up key is held
   g.position += [0 -10]
if down key is held
   g.position += [0 10]
if q is pressed
   fire event {:type :dialogue, :text "Hello"}
if space is pressed
   g.switchstate(:s2)


But the code I ended up writing is this mess:


(fn [g]
  (-> g
  (#(if (@*keys-held* :left)
  (update-in % [:position] v+ [-10 0])
  %))
  (#(if (@*keys-held* :right)
  (update-in % [:position] v+ [10 0]) %))
  (#(if (@*keys-held* :up)
  (update-in % [:position] v+ [0 -10]) %))
  (#(if (@*keys-held* :down)
  (update-in % [:position] v+ [0 10]) %))
  (#(if (@*keys-pressed* \q)
  (do (fire-event {:type :dialogue
   :text "Hello!"})
  %)
  %))
  (#(if (@*keys-pressed* :space)
  (do (comment (println "spaced!"))
  (switch-state % :s2)) %

-- 
-- 
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/groups/opt_out.




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
.

Sincerely,

Daniel


On Tue Feb 12 03:24 2013, Omer Iqbal wrote:
> 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 wrote:
> > > I helped manage the process last year. It's not a small amount of work. I
> > > don't think I have the time to put into it this year, though I'd be
> > willing
> > > to be a mentor.
> > >
> > > Anybody want to step forward and lead that process?
> >
> > I'd be happy to give it a go.  I thought it was a really good experience
> > last year, and I'd love to see Clojure participate again.
> >
> > Sincerely,
> >
> > Daniel
> >
> 
> -- 
> -- 
> 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/groups/opt_out.
> 
> 


signature.asc
Description: Digital signature


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 wrote:
> > I helped manage the process last year. It's not a small amount of work. I
> > don't think I have the time to put into it this year, though I'd be
> willing
> > to be a mentor.
> >
> > Anybody want to step forward and lead that process?
>
> I'd be happy to give it a go.  I thought it was a really good experience
> last year, and I'd love to see Clojure participate again.
>
> Sincerely,
>
> Daniel
>

-- 
-- 
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/groups/opt_out.




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 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* 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 clojure.core/read or read-string for reading data from 
> > untrusted sources, only trusted ones.  Even from trusted sources, binding 
> > *read-eval* to false is probably a good idea, but that depends on your 
> > particular use case.
> >
> >
> > An example I wrote on ClojureDocs.org for function clojure.core/read 
> > several months ago was very badly wrong.  It said that binding *read-eval* 
> > to false would cause clojure.core/read to read data safely, even if that 
> > data came from an untrusted source.
> >
> > I have modified that example to be a lot longer, and hopefully as correct 
> > and scary as it should be.  Please take a look at it if you use read or 
> > read-string anywhere in your Clojure code:
> >
> >http://clojuredocs.org/clojure_core/clojure.core/read
> >
> > Andy
> 
> 
> ;; WARNING: You SHOULD NOT use clojure.core/read or clojure.core/read-string 
> to
> ;; read data from untrusted sources.  They were designed only for reading 
> Clojure
> ;; code and data from trusted sources (e.g. files that you know you wrote
> ;; yourself, and no one else has permission to modify them).
> 
> ;; Instead, either:
> 
> ;; (a) use another data serialization format such as JSON, XML, etc. and a
> ;; library for reading them that you trust not to have vulnerabilities, or
> 
> ;; (b) if you want a serialization format that can be read safely and looks 
> like
> ;; Clojure data structures, use edn (https://github.com/edn-format/edn), for
> ;; which Clojure 1.5 has functions clojure.edn/read and 
> clojure.edn/read-string
> ;; to read them safely.
> 
> ;; You definitely should not use clojure.core/read or read-string if 
> *read-eval*
> ;; has its default value of true, because an attacker could cause your
> ;; application to execute arbitrary code while it is reading.  Example:
> 
> user=> (read-string "#=(clojure.java.shell/sh \"echo\" \"hi\")")
> {:exit 0, :out "hi\n", :err ""}
> 
> ;; It is straightforward to modify the example above into more destructive
> ;; ones that remove all of your files, copy them to someone else's computer
> ;; over the Internet, install Trojans, etc.
> 
> ;; Even if you do bind *read-eval* to false first, like so:
> 
> (defn read-string-unsafely [s]
>   (binding [*read-eval* false]
> (read-string s)))
> 
> ;; you may hope you are safe reading untrusted data that way, but in Clojure 
> 1.4
> ;; and earlier, an attacker can send data that causes your system to execute
> ;; arbitrary Java constructors.  Most of these are benign, but it only takes 
> one
> ;; to ruin your application's day.  Examples that should scare you:
> 
> ;; This causes a socket to be opened, as long as the JVM
> ;; sandboxing allows it.
> (read-string-unsafely "#java.net.Socket[\"www.google.com\" 80]")
> 
> ;; This causes precious-file.txt to be created if it doesn't
> ;; exist, or if it does exist, its contents will be erased (given
> ;; appropriate JVM sandboxing permissions, and underlying OS file
> ;; permissions).
> (read-string-unsafely "#java.io.FileWriter[\"precious-file.txt\"]")
> 
> ;; The particular issue of executing arbitrary Java constructors used in the
> ;; examples above no longer works in Clojure 1.5 when *read-eval* is false.
> ;; Even so, you SHOULD NEVER USE clojure.core/read or clojure.core/read-string
> ;; for reading untrusted data.
> 
> ;; If you understand all of the above, and want to use read or read-string to
> ;; read data from a _trusted_ source, continue on below.
> 
> ;; read wants *in* set to a java.io.PushbackReader.
> ;; with-open sets *in* and closes it after it's done.
> ;; *read-eval* specifies whether to evaluate #=() forms
> ;; when reading.
> (defn read-from-file-with-trusted-contents [filename]
>   (with-open
> [r (java.io.PushbackReader.
>  (clojure.java.io/reader filename))]
>   (binding [*read-eval* false]
> (read r
> 
> user=> (spit "testfile.txt" "{:a 1 :b 2 :c 3}")
> nil
> user=> (read-from-file-with-trusted-contents "testfile.txt")
> {:a 1, :b 2, :c 3}
> 
> --
> --
> 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 -

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 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/groups/opt_out.




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 welcome.
>
> On Feb 11, 2013, at 10:29 AM, Andy Fingerhut wrote:
>
> > 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 clojure.core/read or read-string for reading data from
> untrusted sources, only trusted ones.  Even from trusted sources, binding
> *read-eval* to false is probably a good idea, but that depends on your
> particular use case.
> >
> >
> > An example I wrote on ClojureDocs.org for function clojure.core/read
> several months ago was very badly wrong.  It said that binding *read-eval*
> to false would cause clojure.core/read to read data safely, even if that
> data came from an untrusted source.
> >
> > I have modified that example to be a lot longer, and hopefully as
> correct and scary as it should be.  Please take a look at it if you use
> read or read-string anywhere in your Clojure code:
> >
> >http://clojuredocs.org/clojure_core/clojure.core/read
> >
> > Andy
>
>
> ;; WARNING: You SHOULD NOT use clojure.core/read or
> clojure.core/read-string to
> ;; read data from untrusted sources.  They were designed only for reading
> Clojure
> ;; code and data from trusted sources (e.g. files that you know you wrote
> ;; yourself, and no one else has permission to modify them).
>
> ;; Instead, either:
>
> ;; (a) use another data serialization format such as JSON, XML, etc. and a
> ;; library for reading them that you trust not to have vulnerabilities, or
>
> ;; (b) if you want a serialization format that can be read safely and
> looks like
> ;; Clojure data structures, use edn (https://github.com/edn-format/edn),
> for
> ;; which Clojure 1.5 has functions clojure.edn/read and
> clojure.edn/read-string
> ;; to read them safely.
>
> ;; You definitely should not use clojure.core/read or read-string if
> *read-eval*
> ;; has its default value of true, because an attacker could cause your
> ;; application to execute arbitrary code while it is reading.  Example:
>
> user=> (read-string "#=(clojure.java.shell/sh \"echo\" \"hi\")")
> {:exit 0, :out "hi\n", :err ""}
>
> ;; It is straightforward to modify the example above into more destructive
> ;; ones that remove all of your files, copy them to someone else's computer
> ;; over the Internet, install Trojans, etc.
>
> ;; Even if you do bind *read-eval* to false first, like so:
>
> (defn read-string-unsafely [s]
>   (binding [*read-eval* false]
> (read-string s)))
>
> ;; you may hope you are safe reading untrusted data that way, but in
> Clojure 1.4
> ;; and earlier, an attacker can send data that causes your system to
> execute
> ;; arbitrary Java constructors.  Most of these are benign, but it only
> takes one
> ;; to ruin your application's day.  Examples that should scare you:
>
> ;; This causes a socket to be opened, as long as the JVM
> ;; sandboxing allows it.
> (read-string-unsafely "#java.net.Socket[\"www.google.com\" 80]")
>
> ;; This causes precious-file.txt to be created if it doesn't
> ;; exist, or if it does exist, its contents will be erased (given
> ;; appropriate JVM sandboxing permissions, and underlying OS file
> ;; permissions).
> (read-string-unsafely "#java.io.FileWriter[\"precious-file.txt\"]")
>
> ;; The particular issue of executing arbitrary Java constructors used in
> the
> ;; examples above no longer works in Clojure 1.5 when *read-eval* is false.
> ;; Even so, you SHOULD NEVER USE clojure.core/read or
> clojure.core/read-string
> ;; for reading untrusted data.
>
> ;; If you understand all of the above, and want to use read or read-string
> to
> ;; read data from a _trusted_ source, continue on below.
>
> ;; read wants *in* set to a java.io.PushbackReader.
> ;; with-open sets *in* and closes it after it's done.
> ;; *read-eval* specifies whether to evaluate #=() forms
> ;; when reading.
> (defn read-from-file-with-trusted-contents [filename]
>   (with-open
> [r (java.io.PushbackReader.
>  (clojure.java.io/reader filename))]
>   (binding [*read-eval* false]
> (read r
>
> user=> (spit "testfile.txt" "{:a 1 :b 2 :c 3}")
> nil
> user=> (read-from-file-with-trusted-contents "testfile.txt")
> {:a 1, :b 2, :c 3}
>
> --
> --
> 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
> Fo

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 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.org
> 2. http://thinkaurelius.github.com/titan/
> -- 
> MK
>
> http://github.com/michaelklishin
> http://twitter.com/michaelklishin
>  

-- 
-- 
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/groups/opt_out.




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* 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 clojure.core/read or read-string for reading data from untrusted 
> sources, only trusted ones.  Even from trusted sources, binding *read-eval* 
> to false is probably a good idea, but that depends on your particular use 
> case.
> 
> 
> An example I wrote on ClojureDocs.org for function clojure.core/read several 
> months ago was very badly wrong.  It said that binding *read-eval* to false 
> would cause clojure.core/read to read data safely, even if that data came 
> from an untrusted source.
> 
> I have modified that example to be a lot longer, and hopefully as correct and 
> scary as it should be.  Please take a look at it if you use read or 
> read-string anywhere in your Clojure code:
> 
>http://clojuredocs.org/clojure_core/clojure.core/read
> 
> Andy


;; WARNING: You SHOULD NOT use clojure.core/read or clojure.core/read-string to
;; read data from untrusted sources.  They were designed only for reading 
Clojure
;; code and data from trusted sources (e.g. files that you know you wrote
;; yourself, and no one else has permission to modify them).

;; Instead, either:

;; (a) use another data serialization format such as JSON, XML, etc. and a
;; library for reading them that you trust not to have vulnerabilities, or

;; (b) if you want a serialization format that can be read safely and looks like
;; Clojure data structures, use edn (https://github.com/edn-format/edn), for
;; which Clojure 1.5 has functions clojure.edn/read and clojure.edn/read-string
;; to read them safely.

;; You definitely should not use clojure.core/read or read-string if *read-eval*
;; has its default value of true, because an attacker could cause your
;; application to execute arbitrary code while it is reading.  Example:

user=> (read-string "#=(clojure.java.shell/sh \"echo\" \"hi\")")
{:exit 0, :out "hi\n", :err ""}

;; It is straightforward to modify the example above into more destructive
;; ones that remove all of your files, copy them to someone else's computer
;; over the Internet, install Trojans, etc.

;; Even if you do bind *read-eval* to false first, like so:

(defn read-string-unsafely [s]
  (binding [*read-eval* false]
(read-string s)))

;; you may hope you are safe reading untrusted data that way, but in Clojure 1.4
;; and earlier, an attacker can send data that causes your system to execute
;; arbitrary Java constructors.  Most of these are benign, but it only takes one
;; to ruin your application's day.  Examples that should scare you:

;; This causes a socket to be opened, as long as the JVM
;; sandboxing allows it.
(read-string-unsafely "#java.net.Socket[\"www.google.com\" 80]")

;; This causes precious-file.txt to be created if it doesn't
;; exist, or if it does exist, its contents will be erased (given
;; appropriate JVM sandboxing permissions, and underlying OS file
;; permissions).
(read-string-unsafely "#java.io.FileWriter[\"precious-file.txt\"]")

;; The particular issue of executing arbitrary Java constructors used in the
;; examples above no longer works in Clojure 1.5 when *read-eval* is false.
;; Even so, you SHOULD NEVER USE clojure.core/read or clojure.core/read-string
;; for reading untrusted data.

;; If you understand all of the above, and want to use read or read-string to
;; read data from a _trusted_ source, continue on below.

;; read wants *in* set to a java.io.PushbackReader.
;; with-open sets *in* and closes it after it's done.
;; *read-eval* specifies whether to evaluate #=() forms
;; when reading.
(defn read-from-file-with-trusted-contents [filename]
  (with-open
[r (java.io.PushbackReader.
 (clojure.java.io/reader filename))]
  (binding [*read-eval* false]
(read r

user=> (spit "testfile.txt" "{:a 1 :b 2 :c 3}")
nil
user=> (read-from-file-with-trusted-contents "testfile.txt")
{:a 1, :b 2, :c 3}

-- 
-- 
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...@goog

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> 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 the power
> of Titan.
>
> Full announcement and more details:
> http://blog.clojurewerkz.org/blog/2013/02/11/introducing-titanium/
>
> 1. http://titanium.clojurewerkz.org
> 2. http://thinkaurelius.github.com/titan/
> --
> MK
>
> http://github.com/michaelklishin
> http://twitter.com/michaelklishin
>
> --
> --
> 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/groups/opt_out.
>
>
>



-- 
Please correct me if I'm wrong or incomplete,
even if you think I'll subconsciously hate 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/groups/opt_out.




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 clojure.core/read or read-string for reading data from untrusted 
sources, only trusted ones.  Even from trusted sources, binding *read-eval* to 
false is probably a good idea, but that depends on your particular use case.


An example I wrote on ClojureDocs.org for function clojure.core/read several 
months ago was very badly wrong.  It said that binding *read-eval* to false 
would cause clojure.core/read to read data safely, even if that data came from 
an untrusted source.

I have modified that example to be a lot longer, and hopefully as correct and 
scary as it should be.  Please take a look at it if you use read or read-string 
anywhere in your Clojure code:

http://clojuredocs.org/clojure_core/clojure.core/read

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/groups/opt_out.




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] 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.org
> 2. http://thinkaurelius.github.com/titan/
> --
> MK
>
> http://github.com/michaelklishin
> http://twitter.com/michaelklishin
>
> --
> --
> 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/groups/opt_out.
>
>
>



-- 
Please correct me if I'm wrong or incomplete,
even if you think I'll subconsciously hate 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/groups/opt_out.




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] a)) ast-hy emit-hy)
> ((fn* ([] (let* [a 1 a2921 a b a2921 a2922 a2921] a2922
>
> Hygienic AST's have enabled large performance boosts in core.typed. I'm
> excited to see how it could
> be as useful to others.
>
> Note: "hygienic" AST's (those transformed with `analyze.hygienic/ast-hy` can
> be printed normally with `analyze.emit-form/emit-form`, and hygienically
> with `analyze.hygienic/emit-hy`.
>
> https://github.com/frenchy64/analyze
>
> Thanks,
> Ambrose
>
> --
> --
> 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/groups/opt_out.
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
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/groups/opt_out.




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.org
2. http://thinkaurelius.github.com/titan/
-- 
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin

-- 
-- 
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/groups/opt_out.




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 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/recommendations appreciated.
>
> Best,
> Ari
>
> --
> --
> 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/groups/opt_out.
>
>
>



-- 
Please correct me if I'm wrong or incomplete,
even if you think I'll subconsciously hate 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/groups/opt_out.




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? 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/recommendations appreciated.
>
> Best,
> Ari 
>

-- 
-- 
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/groups/opt_out.




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/recommendations appreciated.

Best,
Ari 

-- 
-- 
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/groups/opt_out.