Re: [ANN] faster-multimethods

2017-10-12 Thread dennis zhuang
why not merge it to clojure.core multimethods?  I think it's a valuable
work, you can create a patch to make clojure better.
See https://clojure.org/community/contributing


2017-10-13 8:13 GMT+08:00 John Alan McDonald :

> Beta release (0.1.0) of faster-multimethods, which brings multimethod
> lookup overhead to roughly the same cost as protocols, with only modest
> changes to the Clojure 1.8.0 implementation.
>
> It is mostly backwards compatible with Clojure 1.8.0. I would very much
> appreciate feedback on the semantic changes described in
> https://github.com/palisades-lakes/faster-multimethods/blob/master/docs/
> changes.md.
>
> I would also appreciate feedback on the choice of benchmarks --- the claim
> of protocol level performance depends on the benchmarks I've chosen, which
> may not be representative of your code.
>
> documentation: https://palisades-lakes.github.io/faster-multimethods/
>
> source for this release: https://github.com/palisades-
> lakes/faster-multimethods/tree/faster-multimethods-0.1.0
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
庄晓丹
Email:killme2...@gmail.com
Site:   http://fnil.net

不学习,毋宁死

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: The performance of plain map vs. defrecord

2017-10-09 Thread dennis zhuang
In fact they are symbols, but print as keywords:

user=> (symbol ":a")
:a
user=> (symbol? (symbol (str :a)))
true



2017-10-09 16:26 GMT+08:00 Peter Hull :

> Slightly off-topic, but why doesn't using the 'incorrect' alphabet-macro
> give an error? If I try and define a Record with keyword keys it tells me
> very clearly not to:
>
> user=> (defrecord Wrong [:a])
> CompilerException java.lang.AssertionError: defrecord and deftype fields
> must be  symbols, user.Wrong had: :a, compiling:(C:\Users\Peter\AppData\
> Local\Temp\form-init3187870874322021043.clj:1:1)
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
庄晓丹
Email:killme2...@gmail.com
Site:   http://fnil.net

不学习,毋宁死

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: The performance of plain map vs. defrecord

2017-10-08 Thread dennis zhuang
First, the  alphabet-macro is wrong, it should use name instead of str in
comp:

user=> (macroexpand-1 '(alphabet-macro))
(do (clojure.core/defrecord Alphabet [:a :b :c :d :e :f :g :h :i :j :k :l
:m :n :o :p :q :r :s :t :u :w :v :x :y :z]) (def dummy-record (Alphabet. 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25)))
user=> (get dummy-record  :a)
nil

fixed it with name:

(defmacro alphabet-macro []
  `(do
 (defrecord ~'Alphabet [~@(map (comp symbol name) a-z-ks)])
 (def ~'dummy-record (~'Alphabet. ~@(range 26)

(alphabet-macro)
user=> (macroexpand-1  '(alphabet-macro))
(do (clojure.core/defrecord Alphabet [a b c d e f g h i j k l m n o p q r s
t u w v x y z]) (def dummy-record (Alphabet. 0 1 2 3 4 5 6 7 8 9 10 11 12
13 14 15 16 17 18 19 20 21 22 23 24 25)))

user=> (get dummy-record  :a)
0

After fixed, the benchmark result is as expected.



2017-10-08 16:40 GMT+08:00 Jiacai Liu :

> As I read JoyOfClojure, it says one of reasons that prefer record over
> plain map is speed, out of curiosity I test this using
> https://github.com/hugoduncan/criterium, but the result is just contrary
> to  my expectation. record is slower than map. Is there any optimizations
> made to clojure 1.8.0 ?
>
> test  code: https://gist.github.com/jiacai2050/
> cdaaffa93079a4b8451727ace0c13064
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
庄晓丹
Email:killme2...@gmail.com
Site:   http://fnil.net

不学习,毋宁死

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Starting Clojure again

2017-09-06 Thread dennis zhuang
1.Maybe you can use :pre metadata:

(defn create-pin
  ([] (create-pin 8))
  ([n]
   {:pre [(<= n 16)
  (>= n 4)]}
   (let [chars (map char (range (int \0) (inc (int \9]
 (reduce str (repeatedly n #(rand-nth chars))

(create-pin 3)
AssertionError Assert failed: (>= n 4)  user/create-pin (NO_SOURCE_FILE:27)


and clojure.spec is great too.
2. you can use concat

(concat seq1 seq2)

see cheat sheet for clojure: https://clojure.org/api/cheatsheet

2017-09-06 16:10 GMT+08:00 Colin Yates :

> Hi Cecil - welcome back!
>
> This would be perfect to test using the new clojure.spec. I can't give
> you any advice on the specifics as I have yet to break into it myself,
> but the properties of this function are crying out for generative
> testing.
>
> Cecil Westerhof writes:
>
> > I want to start using Clojure again. I made the following simple function
> > to generate a PIN:
> > (defn create-pin
> >   ([] (create-pin 8))
> >   ([n]
> >(let [chars (map char (range (int \0) (inc (int \9]
> > (reduce str (repeatedly n #(rand-nth chars))
> >
> > So far so good. But I want to improve a little.
> >
> > I think n should at least be four, but not greater as 16. What is the
> > Clojure way to do this?
> >
> > The next step is that I want to use hexadecimal numbers. So I should use
> > (range (int \0) (inc (int \9))) combined with (range (int \A) (inc (int
> > \F))).
> > How would I do that?
> >
> > Is there anything I should do differently?
> >
> > Of-course I make a general function that is then called from create-pin
> and
> > create-pin-hex.
> >
> > --
> > Cecil Westerhof
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
庄晓丹
Email:killme2...@gmail.com
Site:   http://fnil.net

不学习,毋宁死

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Clojure rookie vs parsing

2017-08-15 Thread dennis zhuang
In my experience, instaparse + defun is a good choice.

https://github.com/Engelberg/instaparse
https://github.com/killme2008/defun/

2017-08-15 22:02 GMT+08:00 Gary Trakhman :

> I enjoyed working with clj-antlr recently, it's a wrapper over a java
> library, but gives you a fast feedback loop with an interpreter instead of
> generated java code.  The 'clojurey' part is that the output is a nested
> sequence, from there it's really effective to use tree zippers and
> core.match to transform the parse-tree into the data structure you need.
>
> Take a look at:
> https://github.com/clojure/core.match
> https://github.com/aphyr/clj-antlr
> https://www.ibm.com/developerworks/library/j-treevisit/
> https://github.com/akhudek/zip-visit
>
> On Tue, Aug 15, 2017 at 9:56 AM Laurens Van Houtven <_...@lvh.cc> wrote:
>
>> Hi,
>>
>>
>> Instaparse is a great parser generator, especially if you already have a
>> BNF.
>>
>> Sent from my iPhone
>>
>> On Aug 15, 2017, at 08:44, sventrax...@gmail.com wrote:
>>
>> Thanks for your input. LFE is quite an unexpected "thing".
>>
>> What I'm trying to do, is just a "lunch time project"; something that I
>> can target without corporate constrains just as a learning exercise.
>> Furthermore I can test the Clojure version against my old working Java
>> version.
>>
>> As I was saying, while experimenting with Instaparse, I'm having the
>> feeling it is not the correct Clojure tool for this type of development
>>
>>
>>
>> On Tuesday, August 15, 2017 at 2:17:50 PM UTC+1, adrians wrote:
>>>
>>> If you need the features of Erlang but would like that in a Lisp (not
>>> Common Lisp, though) environment, have you taken a look at LFE (Lisp
>>> Flavored Erlang)? I'm not trying to discourage you from looking at Clojure,
>>> but if you need/depend on some of the features of Erlang, LFE might be a
>>> closer fit.
>>>
>>> http://lfe.io
>>>
>>> On Tuesday, August 15, 2017 at 8:11:53 AM UTC-4, svent...@gmail.com
>>> wrote:


 Hi

 Months ago I read a review that praised Clojure's clean approach and
 use of JVM that is almost always available in my deployments.

 My background: started with 370 assembly ( so I'm not young!!!) and
 during the last four years I've been using Erlang for network applications.
 For my type of work the functional approach, concurrency and bit handling
 of Erlang are life savings. Nonetheless I feel "the call" of Clojure. As an
 exercise I would like to re implement something I did years ago in Java,
 i.e. a sort of parser. What I have on my hands is a DSL like this

 HeaderRule=hr-ftp
Term=100
   name="ftp"
   From=1
  networkPort="21"
  Protocol=1
 Tcp=1
up
 up
  up
   Then=1
  ProtocolInspection=1
 ftpRuleSet="frs-ftp"
 up
  ServiceDataFlowId=1
 payload=99
 up
  up
   up
up
 HeaderRule=hr-http
   ..

 For my old Java implementation I used state machines to build an
 internal representation, sort of an AST, that would be used to analyze pcap
 files. In my Clojure challenge, I would like to have a different approach.
 Googling around I've found many options: Parsley, Instaparse, cljcc and
 more. Some mentioned on www.clojure-toolbox.com seem to be more
 abandonware.
 At the moment I'm focusing on Instaparse. However, maybe due to the
 previous implementation, I feel that this is not the best approach with
 Clojure. Certainly my rookie state is leading me the wrong way.

 Comments and feedback will be greatly appreciated

 Fred





 --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to 

Re: Java object in eval

2017-03-30 Thread dennis zhuang
You should quote the binding vector:

(let [v '[D (LocalDate/of 2017 03 30)]
  f '(.getYear D)]
  (eval `(let ~v ~f)))



2017-03-30 16:04 GMT+08:00 'Burt' via Clojure :

> Hi,
>
> I want to pass Java objects to a piece of code via let and then get it
> evaluated with eval.
>
> An minimal example:
>
> (ns eval
>   (:import (java.time LocalDate)))
>
> (let [v ['S (String. "ab")]
>   f '(.length S)]
>   (eval `(let ~v ~f)))
>
> ; => 2
>
> (let [v ['D (LocalDate/of 2017 03 30)]
>   f '(.getYear D)]
>   (eval `(let ~v ~f
>
> ; => CompilerException java.lang.RuntimeException: Can't embed object in 
> code, maybe print-dup not defined: 2017-03-30
>
>
> The first example with String works fine and is what I want to do.
>
>
> But if I transfer the example to other Java classes, for example LocalDate I 
> get an error, see the second example.
>
>
> Can anybody help?
>
>
> Kind regards,
>
> Burt
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: {ANN}} Carmine-sentinel: connect redis by sentinel, make carmine to support sentinel.

2016-10-17 Thread dennis zhuang
hi, all

I released carmine-sentinel 0.1.0-RC1, it supports reading data from  Redis
slave and supports other APIs(MQ, Pub/Sub,Lock etc) in carmine.

(def slave-conn {:pool {} :spec {}
 :sentinel-group :group1 :master-name "mymaster"
 :prefer-slave? true})

(defmacro wcars* [& body] `(cs/wcar slave-conn ~@body))

(wcars* (car/set "key" 1)) ;; ExceptionInfo READONLY You can't write
against a read only slave


More info please visit https://github.com/killme2008/carmine-sentinel



2016-10-13 19:43 GMT+08:00 dennis zhuang <killme2...@gmail.com>:

> Hi, all
>
> I wrote a library to make carmine <https://github.com/ptaoussanis/carmine>
> support redis sentinel <http://redis.io/topics/sentinel>:
>
> https://github.com/killme2008/carmine-sentinel
>
> Someone may want to try it if you are interested. It's a beta release,
> feedback is welcome.
>
> --
> 庄晓丹
> Email:killme2...@gmail.com xzhu...@avos.com
> Site:   http://fnil.net
> Twitter:  @killme2008
>
>
>


-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


{ANN}} Carmine-sentinel: connect redis by sentinel, make carmine to support sentinel.

2016-10-13 Thread dennis zhuang
Hi, all

I wrote a library to make carmine 
support redis sentinel :

https://github.com/killme2008/carmine-sentinel

Someone may want to try it if you are interested. It's a beta release,
feedback is welcome.

-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: apply madness

2016-05-12 Thread dennis zhuang
A try:

(let [raw (list  :a 1 :b 2 :c 3)]
  (->> raw
   (partition 2)
   (filter #(even? (second %)))
   (map vec)
   (into {})
   (merge {:raw raw})))

=> {:b 2, :raw (:a 1 :b 2 :c 3)}



2016-05-12 15:46 GMT+08:00 hiskennyness :

> This does what I want but feels nooby-ish, as in "in a month I will do
> this without APPLY":
>
> (let [raw (list  :a 1 :b 2 :c 3)]
>>   (apply assoc {}
>>  :raw raw
>>   (apply concat
>>(filter #(even? (second %))
>>(apply hash-map raw)
>> ;; => {:raw (:a 1 :b 2 :c 3), :b 2}
>
>
> Am I being too hard on myself?
>
> Meta question: is there a better place to ask such questions?
>
> -kt
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: which GC optimizations work better with Clojure?

2016-04-29 Thread dennis zhuang
It depends. CMS or G1 would be better in common cases as you said, clojure
runtime has many short-lived objects. We are using G1 in your production.
But sometimes you would prefer system throughput rather than GC pause time,
you may try Parallel GC.

2016-04-29 19:02 GMT+08:00 Camilo Roca :

>
> Following this thread:
> http://stackoverflow.com/questions/16695874/why-does-the-jvm-full-gc-need-to-stop-the-world
>
> I was wondering if anybody has some experience regarding GC optimizations
> that would work better for Clojure than the default: stop-the-world
> approach.
> My point being that given Clojure's immutable data structures, there is a
> lot of GC that is performed on young-objects which I guess could be
> optimized with some GC tweaks.
>
> Has anybody experience with something similar?
>
> So far the only reference that I have of a Clojure project using such
> optimizations is Overtone:
> https://github.com/overtone/overtone/blob/master/project.clj
>
> Which scenarios do you think that call for GC tweaks in Clojure?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Largest Clojure codebases?

2015-11-15 Thread dennis zhuang
I use cloc(http://cloc.sourceforge.net/) to counting the LOC of our
projects, it's total about 41025 lines of Clojure  code.






2015-11-16 7:22 GMT+08:00 Colin Yates :

> Exactly this. I couldn’t find a reliable way of counting LOC but my
> (Clojure/ClojureSciprt) src tree (excluding test) in the project I have to
> hand is 1.5MB.
>
>
> On 15 Nov 2015, at 21:27, Timothy Baldridge  wrote:
>
> It's funny, because most of the larger OOP projects I worked on were large
> because of class bloat, not because of business concerns. For example, the
> C# app I used to work on was a more or less simple CRUD app. We had a ORM
> that served up objects to a Silverlight UI. So if we wanted to display
> information about a person on the UI we normally had to modify around 5
> classes in 5 files. We had the following layers
>
> ORM - 1.4MB of generated C# for interfacing with the 200 or so SQL tables
> we had
> DTO - Data Transfer Object, where used "normal" C# objects to abstract the
> ORM. This is where we had the "Person" object
> API - A web service that served up DTOs over HTTP
> Data Model - Processed views of DTOs formatted in a way that was easily
> viewable by the UI
> View Model - UI classes that would take data from a Data Model and emit UI
> controls.
>
> All of that ceremonythat is replaced by one thing in Clojure...data.
> Hashmaps and vectors replace all the junk you see above.
>
> So that's where I often assert "Yes, you may have 1 million lines of Java
> codebut that would only be ~10,000 lines of Clojure." With proper
> application of data driven systems (data that configures pipelines and
> writes code) you can easily get a 100:1 ratio of Java to Clojure code.
>
> Timothy
>
>
> On Sun, Nov 15, 2015 at 12:48 PM, Marc O'Morain  wrote:
>
>> We have a large app at CircleCI - as of September:
>>
>> "The repo for our main app contains 93,983 lines of Clojure code. The src 
>> directory
>> of our main app contains 369 namespaces."
>>
>> http://blog.circleci.com/why-were-no-longer-using-core-typed/
>>
>>
>>
>> On Sun, Nov 15, 2015 at 7:22 PM, dilettante.co...@live.com <
>> dilettante.co...@live.com> wrote:
>>
>>> I've been having a (friendly) argument with a friend who is an
>>> old-school OOP programmer.  He insists that you need objects to make
>>> large-scale codebases legible and maintainable over the long run.  Quite
>>> apart from this argument's virtues or lack thereof, this made me curious --
>>> what are the largest programs written in Clojure in terms of LOC?  I know
>>> I've seen mentions of 50k-100k LOC projects (World Singles, if I'm
>>> remembering correctly), but are there any that are larger?
>>>
>>>Vikram
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clojure@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+unsubscr...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to clojure+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> “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 

Re: Locking non-local variable inside macro

2015-11-15 Thread dennis zhuang
I think the reason is in macroexpand-1 result:

user=> (macroexpand-1 '(mac1 1))
(clojure.core/locking # 1)

It's not a valid form to be read and eval by clojure reader,the object form
can't be parsed.

If define obj to be a map {}, it works fine:

user=> (def obj {})
#'user/obj
user=> (mac1 1)
1
user=> (macroexpand-1 '(mac1 1))
(clojure.core/locking {} 1)


2015-11-16 13:55 GMT+08:00 Alice :

> user=> (def obj (Object.))
> #'user/obj
> user=> (defmacro mac1 [& body] `(locking ~obj ~@body))
> #'user/mac1
> user=> (mac1 nil)
> CompilerException java.lang.RuntimeException: Can't embed object in code,
> maybe print-dup not defined: java.lang.Object@2a747a37,
> compiling:(NO_SOURCE_PATH:1:1)
>
>
> Why am I getting the error?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to speedup lein uberjar?

2015-10-27 Thread dennis zhuang
Recommend to use libdir plugin:  https://github.com/djpowell/lein-libdir
Run lein libdir to copy all the dependencies to lib directory, and  just
run lein jar to package the project.
Then you can rsync or copy the project jar with all dependent jars instead
of compiling all dependent namespaces that is really slow.


2015-10-28 7:44 GMT+08:00 Matching Socks :

> If you do not want much to be compiled ahead-of-time and represented in
> the jar as class files, you may use the :impl-ns option on :gen-class.
>
> e.g.,
>
> 1) project.clj says
> :aot [bla.bla-aot]
>
> 2) bla.bla_aot.clj says
> (ns bla.bla-aot (:gen-class :impl-ns bla.bla))
>
> Ahead-of-time compilation does not follow the impl-ns reference.
>
> 3) bla.bla.clj has functions that Java may call as though they were in the
> bla.bla_aot class: for example, a -main function, which Java may call as
> bla.bla_aot.main.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


{{ANN}} defun 0.3.0-alapha: supports clojurescript

2015-10-24 Thread dennis zhuang
defun  is a macro to define clojure
functions with parameter pattern matching just like erlang or elixir based
on core.match.

https://github.com/killme2008/defun

Thanks to sander dijkhuis , it supports
clojurescript right now.

You can use it in clojurescript as below:

  (ns cljs-test.core
(:require [defun :refer-macros [defun]]))

  (defun count-down
([0] (println "Reach zero!"))
([n] (println n)
(recur (dec n

  (count-down 5)  #Count down from five to zero.


Have fun!


-- 
庄晓丹
Email:killme2...@gmail.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Calling object members with symbols

2015-10-18 Thread dennis zhuang
In such case you have to use `eval`, another post

https://groups.google.com/forum/#!topic/clojure/YJNRnGXLr2I

2015-10-19 9:10 GMT+08:00 James Reeves :

> On 18 October 2015 at 23:54, Timur  wrote:
>
>> Hi all,
>>
>> Is there anyway to call an object member using its symbol?
>>
>> For instance we have an object o, we get the symbol of a method, e.g.,
>> toString, of our object o using clojure.reflect/reflect and and I want to
>> execute this method on this object through the symbol.
>>
>> For instance *(. obj sym)* throws an exception. Here symbol for instance
>> contains toString
>>
>> Any ideas about how I can do this?
>>
>
> eval is probably the most straightforward way to achieve this:
>
> (eval `(. ~obj ~sym))
>
> I'm uncertain of the performance of this compared to using the Java
> reflection API, but it's a lot easier to write.
>
> - James
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Calling object members with symbols

2015-10-18 Thread dennis zhuang
You may have to use macro:

user=> (defmacro invoke [obj sym] `(. ~obj ~sym))
#'user/invoke
user=> (invoke 1 toString)
"1"

2015-10-19 6:54 GMT+08:00 Timur :

> Hi all,
>
> Is there anyway to call an object member using its symbol?
>
> For instance we have an object o, we get the symbol of a method, e.g.,
> toString, of our object o using clojure.reflect/reflect and and I want to
> execute this method on this object through the symbol.
>
> For instance *(. obj sym)* throws an exception. Here symbol for instance
> contains toString
>
> Any ideas about how I can do this?
>
> Regards,
>
> Timur
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Bug in DynamicClassLoader?

2015-09-16 Thread dennis zhuang
I don't think it's a bug. Indeed, the class loader will invoke loadClass,
and the loadClass method will checking the parent class loader for the
requested class, if it is not found,then invoke findClass of current class
loader implementation to find the requested class as describe in loadClass
javadoc

.

The DynamicClassLoader extends the URLClassLoader, and wraps a class cache
for it.

Also see the javadoc of findClass:

protected Class

findClass(String

name)
  throws ClassNotFoundException


Finds the class with the specified binary name
.
This method should be overridden by class loader implementations that
follow the delegation model for loading classes, and will be invoked by the
loadClass

method
*after checking the parent class loader for the requested class*. The
default implementation throws a ClassNotFoundException.

2015-09-16 21:23 GMT+08:00 András Pálinkás :

> Can anyone explain to me why do we call super.findClass here:
>
> https://github.com/clojure/clojure/blob/41af6b24dd5be8bd62dc2b463bc53b55e18cd1e5/src/jvm/clojure/lang/DynamicClassLoader.java#L69
>
> I believe, on this line, instead of super.findClass, it should call
> getParent().findClass, otherwise we'll get to the system classloader almost
> immediately (and the parent classloader will never be used).
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Just found out about Elixirs function argument pattern matching...

2015-09-07 Thread dennis zhuang
Thanks for your benchmark.
I will upgrade all the dependencies and release 0.2.0

We are using defun with instparse in a DSL implementation, the performance
is acceptable, but the code is much more readable.





2015-09-06 4:33 GMT+08:00 Rob Lally :

> Out of interest, I ran the benchmarks as is, and got more or less the same
> results - 15x. Then I tried upgrading the defun dependencies - clojure,
> core.match and tools.macro - all of which have newer versions, and then
> running the benchmarks without leiningen’s jvm-opts and in a trampolined
> repl. The results are better (see below). Still not great - but down from
> 15x to 10x.
>
> That said:
>
> * I’m not sure I’d care: for most applications the overhead of function
> dispatch is probably not the bottleneck.
> * Elixir and the BEAM VM are awesome at many things, but I suspect (from
> experience not evidence) that the defun version is still faster than the
> elixir version.
>
>
> Rob
>
> ---
>
> user=> (bench (accum-defn 1))
> WARNING: Final GC required 2.590098761776679 % of runtime
> Evaluation count : 429360 in 60 samples of 7156 calls.
>  Execution time mean : 139.664539 µs
> Execution time std-deviation : 4.701755 µs
>Execution time lower quantile : 134.451108 µs ( 2.5%)
>Execution time upper quantile : 150.214646 µs (97.5%)
>Overhead used : 1.565276 ns
>
> Found 5 outliers in 60 samples (8. %)
> low-severe   5 (8. %)
>  Variance from outliers : 20.5880 % Variance is moderately inflated by
> outliers
>
> user=> (bench (accum-defun 1))
> Evaluation count : 44940 in 60 samples of 749 calls.
>  Execution time mean : 1.361631 ms
> Execution time std-deviation : 40.489537 µs
>Execution time lower quantile : 1.333474 ms ( 2.5%)
>Execution time upper quantile : 1.465123 ms (97.5%)
>Overhead used : 1.565276 ns
>
> Found 9 outliers in 60 samples (15. %)
> low-severe   1 (1.6667 %)
> low-mild 8 (13. %)
>  Variance from outliers : 17.3434 % Variance is moderately inflated by
> outliers
>
> ---
>
>
> On 5 Sep 2015, at 05:16, Amith George  wrote:
>
> Nice. Hadn't heard of it before. It looks interesting. The criterium
> benchmark is kinda disappointing though. The pattern matched function took
> nearly 15x the time of the normal function.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: numbers, why?

2015-09-04 Thread dennis zhuang
Because the literal is readed as BigInt:

user=> (class 6546546546546546546850348954895480584039545804 )
clojure.lang.BigInt

2015-09-04 22:48 GMT+08:00 Ali M :

> why?
>
> 
> user=> (+ 6546546546546546546850348954895480584039545804
> 7548979534287548957345843954749357348757897)
> 6554095526080834095807694798850229941388303701N
>
> user=> (+ Long/MAX_VALUE Long/MAX_VALUE)
>
> ArithmeticException integer overflow
> clojure.lang.Numbers.throwIntOverflow (Numbers.java:1501)
>
> user=> Long/MAX_VALUE
> 9223372036854775807
> 
>
> Why the much bigger numbers get promoted, and a smaller number overflows?
>
> Thank you
> Ali
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


{{ANN}} clj-rate-limiter: rate limiter for clojure backed by memory or redis.

2015-08-17 Thread dennis zhuang
clj-rate-limiter is a rate limiter for clojure,that supports a rolling
window, either in-memory or backed by redis.

https://github.com/killme2008/clj-rate-limiter

Hope it can help someone.

-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] sniper, emacs assistant for deleting dead code

2015-07-29 Thread dennis zhuang
Cool work.

But missing installation or user guide in readme.md? I don't know how to
use it in my project. I want to try it.


2015-07-30 13:26 GMT+08:00 benedek fazekas benedek.faze...@gmail.com:

 hi,

 I wonder if you tried clj-refactor which has find usages listing all the
 usages of your symbol *and* its definition. So if you only find the
 definition and usages in test that symbol might be candidate for deletion...

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


{ANN} clj-archaius releases: wrapper for netflix archaius

2015-07-02 Thread dennis zhuang
Hi,all

I create a new project https://github.com/leancloud/clj-archaius that wraps
netflix  https://github.com/Netflix/archaius
archaius https://github.com/Netflix/archaius library for configuration
management.

It's really simple to use in your project,i hope it can help someone that
is using netflix archaius lib.


-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: {ANN} defun: A beautiful macro to define clojure functions with pattern match.

2014-09-26 Thread dennis zhuang
I will add supporting for clojurescript this weekend.Thanks for your
suggestion.

2014-09-26 1:09 GMT+08:00 Ivan L ivan.laza...@gmail.com:

 Is this clojurescript ready?  This looks amazing, I would also love to
 have it in core.

 On Sunday, September 14, 2014 2:47:28 AM UTC-4, dennis wrote:


 Hi , i am pleased to introduce defun
 https://github.com/killme2008/defun: a beautiful macro to define
 clojure functions with pattern match.

 Some examples:


 (defun say-hi

   ([:dennis] Hi,good morning, dennis.)

   ([:catty] Hi, catty, what time is it?)

   ([:green] Hi,green, what a good day!)

   ([other] (str Say hi to  other)))


 (say-hi :dennis)

 ;;  Hi,good morning, dennis.

 (say-hi :catty)

 ;;  Hi, catty, what time is it?

 (say-hi :green)

 ;;  Hi,green, what a good day!

 (say-hi someone)

 ;;  Say hi to someone


 Recursive function? It's all right:

 (defun count-down

   ([0] (println Reach zero!))

   ([n] (println n)

  (recur (dec n

 (defun fib

 ([0] 0)

 ([1] 1)

 ([n] (+ (fib (- n 1)) (fib (- n 2)



 Guard functions? it's all right:

 (defun valid-geopoint?

 ([(_ :guard #(and ( % -180) ( % 180)))

   (_ :guard #(and ( % -90) ( % 90)))] true)

 ([_ _] false))


 (valid-geopoint? 30 30)

 ;; true

 (valid-geopoint? -181 30)

 ;; false


 It's really cool,all the magic are from core.match, much more details
 please see
 https://github.com/killme2008/defun


 --
 庄晓丹
 Email:killm...@gmail.com xzh...@avos.com
 Site:   http://fnil.net
 Twitter:  @killme2008


   --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I track down a painfully long pause in a small web app?

2014-09-24 Thread dennis zhuang
You can use

jstat -gcutil pid 2000

to print the GC statistics every 2 seconds,
http://docs.oracle.com/javase/1.5.0/docs/tooldocs/share/jstat.html

It the long pause is from GC, the columns FGCT/FGC values would be large.

If you think it's a swap issue, you may want to use

   vmstat 1 1

watch out the si/so columns.

What's your jvm arguments? Too small heap memory size may be the issue.

2014-09-24 9:47 GMT+08:00 larry google groups lawrencecloj...@gmail.com:

 I'm guessing that strace is showing me userland threads? When I quit
 strace I see:

 ^CProcess 19363 detached
 Process 19364 detached
 Process 19365 detached
 Process 19366 detached
 Process 19367 detached
 Process 19368 detached
 Process 19369 detached
 Process 19370 detached
 Process 19371 detached
 Process 19372 detached
 Process 19377 detached
 Process 19378 detached
 Process 19379 detached
 Process 19380 detached
 Process 19381 detached
 Process 19382 detached
 Process 19383 detached
 Process 19384 detached
 Process 19385 detached
 Process 19386 detached
 Process 19387 detached
 Process 19388 detached
 Process 19389 detached
 Process 19390 detached
 Process 19391 detached
 Process 19392 detached
 Process 19393 detached
 Process 19394 detached
 Process 19395 detached
 Process 19396 detached
 Process 19397 detached
 Process 19398 detached
 Process 19399 detached
 Process 19400 detached
 Process 19401 detached
 Process 19402 detached
 Process 19403 detached
 Process 19404 detached
 Process 19405 detached
 Process 19406 detached
 Process 19407 detached
 Process 19408 detached
 Process 19409 detached
 Process 19410 detached
 Process 19606 detached
 % time seconds  usecs/call callserrors syscall
 -- --- --- - - 
  90.06   40.9730721363 30059 10449 futex
   4.231.926411 819  2353   epoll_wait
   3.021.373282  11444012 6 restart_syscall
   1.240.563107   93851 6   accept
   0.990.449988  12 36909   gettimeofday
   0.350.156992   5 29410   clock_gettime
   0.050.021064  67   316   recvfrom
   0.020.010338  30   347   write
   0.010.005117  24   209   sendto
   0.010.004369  24   180   poll
   0.010.002683  24   11222 read
   0.010.002563  24   108 6 epoll_ctl
   0.000.001618  14   112   open
   0.000.001189   5   230   fcntl
   0.000.001132   8   142   mprotect
   0.000.000969   8   118   close
   0.000.000806  3821   writev
   0.000.000685   6   109   ioctl
   0.000.000655   6   110   fstat
   0.000.000229  1317   mmap
   0.000.000216  36 6   shutdown
   0.000.000197  33 6   dup2
   0.000.92  46 2   madvise
   0.000.61   512   setsockopt
   0.000.57  14 4   munmap
   0.000.56   512   getsockname
   0.000.35   4 8   rt_sigprocmask
   0.000.18   5 4   sched_getaffinity
   0.000.10   5 2   clone
   0.000.09   9 1   rt_sigreturn
   0.000.09   5 2   uname
   0.000.09   5 2   set_robust_list
   0.000.08   4 2   gettid
 -- --- --- - - 
 100.00   45.497046100943 10483 total






 On Tuesday, September 23, 2014 9:44:52 PM UTC-4, larry google groups wrote:

 I am intrigued by this article, as the problem sounds the same as mine:

 http://corner.squareup.com/2014/09/logging-can-be-tricky.html

 No significant amount of resources appeared to be in use — disk I/O,
 network I/O, CPU, and memory all looked fairly tame. Furthermore, the bulk
 of queries being served were all performing as expected. 

 So I tried to follow their example regarding strace. But I have never
 worked with strace before. I used grep to find the PID and then I:

  sudo strace -c -f -p 19363

 and I got:

 Process 19363 attached with 45 threads

 Then I ran our health check which is like a series of functional tests
 that ping our actual app (a live environment rather than a test
 environment). I got nothing out of strace except these 2 lines appeared:

 Process 20973 attached
 Process 20974 attached

 What does this mean? I had the impression that the JVM ran in 1 process?
 Does strace show me userland threads (like htop does) or are these child
 processes?





 On Monday, 

Re: [ANN] Monroe 0.1.0 - nrepl client for Emacs

2014-09-24 Thread dennis zhuang
Looks great.But it doesn't support code completion?

2014-09-25 0:50 GMT+08:00 Sanel Zukan san...@gmail.com:

 Hi everyone,

 Here https://github.com/sanel/monroe is initial release for Monroe, a
 new Clojure nREPL client for Emacs. The main idea behind Monroe is to be
 simple, easy to install (just put it in your *load-path*) and to work
 like inferior modes (inferior-lisp or inferior-scheme), providing common
 keybindings in REPL, including color and history support. You will also
 need clojure-mode.el for code syntax highlighting, but this is optional.

 This initial release is ready for consumption (I'm using it on a bit
 larger project) and feel free to drop me a line if you find some issues.

 Again, the url is https://github.com/sanel/monroe

 Best,
 Sanel

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: keywords

2014-09-15 Thread dennis zhuang
Clojure's keyword is using a soft reference cache, they would be garbage
collected  when used memory reaches threshold.


2014-09-15 18:36 GMT+08:00 Paweł Sabat noni...@gmail.com:

 Hi.

 How many :keywords can I create in Clojure? Is there any limited
 number of them? I know of such limitation of Erlang's atoms, which are
 just like Clojure's keywords.


 noniwoo

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


{ANN} defun: A beautiful macro to define clojure functions with pattern match.

2014-09-14 Thread dennis zhuang
Hi , i am pleased to introduce defun https://github.com/killme2008/defun:
a beautiful macro to define clojure functions with pattern match.

Some examples:


(defun say-hi

  ([:dennis] Hi,good morning, dennis.)

  ([:catty] Hi, catty, what time is it?)

  ([:green] Hi,green, what a good day!)

  ([other] (str Say hi to  other)))


(say-hi :dennis)

;;  Hi,good morning, dennis.

(say-hi :catty)

;;  Hi, catty, what time is it?

(say-hi :green)

;;  Hi,green, what a good day!

(say-hi someone)

;;  Say hi to someone


Recursive function? It's all right:

(defun count-down

  ([0] (println Reach zero!))

  ([n] (println n)

 (recur (dec n

(defun fib

([0] 0)

([1] 1)

([n] (+ (fib (- n 1)) (fib (- n 2)



Guard functions? it's all right:

(defun valid-geopoint?

([(_ :guard #(and ( % -180) ( % 180)))

  (_ :guard #(and ( % -90) ( % 90)))] true)

([_ _] false))


(valid-geopoint? 30 30)

;; true

(valid-geopoint? -181 30)

;; false


It's really cool,all the magic are from core.match, much more details
please see
https://github.com/killme2008/defun


-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: {ANN} defun: A beautiful macro to define clojure functions with pattern match.

2014-09-14 Thread dennis zhuang
Released 0.1.0-RC,  defun collect :arglists metadata, another recursive
function example:

 (defun accum
  ([0 ret] ret)
  ([n ret] (recur (dec n) (+ n ret)))
  ([n] (recur n 0)))

 (accum 100) ;; the result is 5050


2014-09-14 14:46 GMT+08:00 dennis zhuang killme2...@gmail.com:


 Hi , i am pleased to introduce defun https://github.com/killme2008/defun:
 a beautiful macro to define clojure functions with pattern match.

 Some examples:


 (defun say-hi

   ([:dennis] Hi,good morning, dennis.)

   ([:catty] Hi, catty, what time is it?)

   ([:green] Hi,green, what a good day!)

   ([other] (str Say hi to  other)))


 (say-hi :dennis)

 ;;  Hi,good morning, dennis.

 (say-hi :catty)

 ;;  Hi, catty, what time is it?

 (say-hi :green)

 ;;  Hi,green, what a good day!

 (say-hi someone)

 ;;  Say hi to someone


 Recursive function? It's all right:

 (defun count-down

   ([0] (println Reach zero!))

   ([n] (println n)

  (recur (dec n

 (defun fib

 ([0] 0)

 ([1] 1)

 ([n] (+ (fib (- n 1)) (fib (- n 2)



 Guard functions? it's all right:

 (defun valid-geopoint?

 ([(_ :guard #(and ( % -180) ( % 180)))

   (_ :guard #(and ( % -90) ( % 90)))] true)

 ([_ _] false))


 (valid-geopoint? 30 30)

 ;; true

 (valid-geopoint? -181 30)

 ;; false


 It's really cool,all the magic are from core.match, much more details
 please see
 https://github.com/killme2008/defun


 --
 庄晓丹
 Email:killme2...@gmail.com xzhu...@avos.com
 Site:   http://fnil.net
 Twitter:  @killme2008





-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: {ANN} defun: A beautiful macro to define clojure functions with pattern match.

2014-09-14 Thread dennis zhuang
Hi Herwig

Actually,defun just define a variadic arguments function,so it doesn't have
different arities. And when using defun macro ,it walk through the body
forms, find 'recur'  forms and replace them with (recur (vector
...arguments)) instead.

A macroexpand-1 result of accum:


(macroexpand-1

  '(defun accum

  ([0 ret] ret)

  ([n ret] (recur (dec n) (+ n ret)))

  ([n] (recur n 0

=


(clojure.core/defn

 accum

 {:arglists '([0 ret] [n ret] [n])}

 [ args__4602__auto__]

 (clojure.core.match/match

  [(clojure.core/vec args__4602__auto__)]

  [[0 ret]]

  (do ret)

  [[n ret]]

  (do (recur (vector (dec n) (+ n ret

  [[n]]

  (do (recur (vector n 0)


The core procedure is at
https://github.com/killme2008/defun/blob/master/src/defun.clj#L97-107



2014-09-15 0:15 GMT+08:00 Herwig Hochleitner hhochleit...@gmail.com:

 Hi Dennis,

 marrying core.match to defn is a pretty neat idea. Thanks for releasing it!

 I see that you actually extended defn in that you made it possible to
 recur between different arities.
 Can you give a quick rundown on how you made that work? Are the arities
 still separate IFn arities? Does it still run in constant stack space?

 kind regards

 PS @adrian: If you feel like Friendly advice ing someone, why not do so
 in a private email?

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: {ANN} defun: A beautiful macro to define clojure functions with pattern match.

2014-09-14 Thread dennis zhuang
And of course ,it still run in constant stack space just like normal recur
form.

P.S. I think adrian's advice is good, please forgive my poor english,and i
changes the description to ' a macro to define clojure functions with
pattern match just like erlang or elixir.

2014-09-15 0:26 GMT+08:00 dennis zhuang killme2...@gmail.com:

 Hi Herwig

 Actually,defun just define a variadic arguments function,so it doesn't
 have different arities. And when using defun macro ,it walk through the
 body forms, find 'recur'  forms and replace them with (recur (vector
 ...arguments)) instead.

 A macroexpand-1 result of accum:


 (macroexpand-1

   '(defun accum

   ([0 ret] ret)

   ([n ret] (recur (dec n) (+ n ret)))

   ([n] (recur n 0

 =


 (clojure.core/defn

  accum

  {:arglists '([0 ret] [n ret] [n])}

  [ args__4602__auto__]

  (clojure.core.match/match

   [(clojure.core/vec args__4602__auto__)]

   [[0 ret]]

   (do ret)

   [[n ret]]

   (do (recur (vector (dec n) (+ n ret

   [[n]]

   (do (recur (vector n 0)


 The core procedure is at
 https://github.com/killme2008/defun/blob/master/src/defun.clj#L97-107



 2014-09-15 0:15 GMT+08:00 Herwig Hochleitner hhochleit...@gmail.com:

 Hi Dennis,

 marrying core.match to defn is a pretty neat idea. Thanks for releasing
 it!

 I see that you actually extended defn in that you made it possible to
 recur between different arities.
 Can you give a quick rundown on how you made that work? Are the arities
 still separate IFn arities? Does it still run in constant stack space?

 kind regards

 PS @adrian: If you feel like Friendly advice ing someone, why not do so
 in a private email?

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




 --
 庄晓丹
 Email:killme2...@gmail.com xzhu...@avos.com
 Site:   http://fnil.net
 Twitter:  @killme2008





-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] Clojure 1.7.0-alpha2

2014-09-11 Thread dennis zhuang
May be the LongAdder in Java8 can beat AtomicLong :D

http://blog.palominolabs.com/2014/02/10/java-8-performance-improvements-longadder-vs-atomiclong/

2014-09-11 17:30 GMT+08:00 Linus Ericsson oscarlinuserics...@gmail.com:

 The volatile construct seems very useful in some particular cases! I have
 been missing ugly-mutable variables for things such as certain types of
 heaps/queues or write-intensive, slightly probabilistic stuff where one
 missed write doesn't matter that much.

 For people who don't have a Java background, I just want to point the very
 useful package java.util.concurrent.atomic, in which one can find gems such
 as AtomicLong, which is almost unbeatable as a counter.

 An example in which an AtomicLong is about three times quicker than an
 atom:

 https://gist.github.com/claj/6711556#file-countertest-clj

 Javadoc for AtomicLong:


 http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicLong.html

 In the sake of completeness,
 Linus

 2014-09-11 11:06 GMT+02:00 Frantisek Sodomka fsodo...@gmail.com:

 Using my timings macro:
 https://gist.github.com/fsodomka/5890711

 I am getting that:
 - creation  derefing is 60% faster
 - swapping is 25% faster
 - resetting is about the same


 ;; volatile vs. atom ;;

 (report
   (timings 1e7
 (deref (volatile! 42))
 (deref (atom 42

 ; |  :expr | :time | :ratio | :perc |
 ; |+---++---|
 ; | (deref (volatile! 42)) | 30.688238 |1.0 | 39.81 |
 ; |  (deref (atom 42)) | 77.081141 |   2.51 | 100.0 |


 (report
   (let [v (volatile! 42)
 a (atom 42)]
 (timings 1e7
   (vswap! v inc)
   (swap! a inc

 ; |  :expr |  :time | :ratio | :perc |
 ; |+++---|
 ; | (vswap! v inc) | 136.052946 |1.0 | 75.08 |
 ; |  (swap! a inc) | 181.218748 |   1.33 | 100.0 |


 (report
   (let [v (volatile! 42)
 a (atom 42)]
 (timings 1e7
   (vreset! v 10)
   (reset! a 10

 ; |  :expr | :time | :ratio | :perc |
 ; |+---++---|
 ; |  (reset! a 10) | 98.755318 |1.0 | 96.69 |
 ; | (vreset! v 10) | 102.13944 |   1.03 | 100.0 |




 On Thursday, September 11, 2014 6:18:08 AM UTC+2, puzzler wrote:

 I'm curious: how much faster are volatiles than atoms?

  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Clojure production environment

2014-08-20 Thread dennis zhuang
jetty + lein jar + lein libdir,and used fabric to deploy applications.Uses
nginx as load balancer.



2014-08-20 16:55 GMT+08:00 Max Penet m...@qbits.cc:

 For web stuff we use jetty (9) apps as uberjar, behind nginx, deployed
 and CC via ansible, hosted on DigitalOcean as well.
 Ansible is super easy to get started with and can grow to complicated
 setups relatively painlessly, can't say enough good things about it.

 On Wednesday, August 20, 2014 10:40:15 AM UTC+2, Bruce Durling wrote:

 Embedded jetty or httpkit + uberjar running behind nginx running
 behind elastic load balancer on aws.

 On Wed, Aug 20, 2014 at 9:37 AM, Michael Klishin
 michael@gmail.com wrote:
  On 20 August 2014 at 11:52:51, Serzh Nechyporchuk (nechyp...@gmail.com)
 wrote:
   I want to ask what environments for production do you use (e.g.
  application server, cloud platform, deploy tool, etc)?
  I think this information will be interesting for many people.
  For now in our project we use Jetty server on Digital Ocean droplet.
  We deploy by copying war file generated by lein ring uberwar.
 
  Jetty + lein uberjar is by far the most popular option from what I see.
 
  You can deploy with Chef/Puppet/etc, run on Heroku or Cloud Foundry, or
 even
  use very basic SSH commands or Capistrano to deploy.
  --
  @michaelklishin, github.com/michaelklishin
 
  --
  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/d/optout.



 --
 @otfrom | CTO  co-founder @MastodonC | mastodonc.com
 See recent coverage of us in the Economist http://econ.st/WeTd2i and
 the Financial Times http://on.ft.com/T154BA

  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Supplied-p parameter in clojure similar to lisp lambda lists

2014-08-18 Thread dennis zhuang
I created a ticket http://dev.clojure.org/jira/browse/CLJ-1508


2014-08-18 11:02 GMT+08:00 dennis zhuang killme2...@gmail.com:

 I think that adding a :p option to destructuring would be great:

 (let [ {:keys [a b c] :p {a a-p}} params]
 (if a-p
 (println a)
 (println a is not exists.)))






 2014-08-17 20:05 GMT+08:00 Dave Tenny dave.te...@gmail.com:

 Well, it took me a while to perhaps get what you were telling me here.

 In my case I I had something like

 (defn foo [  {:keys [bar ... more keys ...] :or {bar 1}} ] ...)

 and I wanted to know whether the user had explicilty invoked foo with
 :bar.

 What wasn't clear to me was that :as solved this problem.
 Reading http://clojure.org/special_forms#Special Forms--Binding Forms
 (Destructuring)-Map binding destructuring
 I guess I can see that it's telling me :as shows things that weren't in
 the init-form, but that's with hindsight.

 So, to emulated common lisp 'supplied-p' semantics, you can check the :as
 form, which will **not**
 contain :or values for keywords.

 E.g.

 user (defn bar [  {:keys [baz] :or {baz 'baz} :as all-keys} ] (println
 baz all-keys))
 #'user/bar
 user (bar :bof 1)
 baz {:bof 1}
 nil

 And not that the all-keys form does not show a binding for baz, and
 that's what I wanted.

 Just fyi in case anybody searches topics for 'supplied-p' again.


 On Saturday, June 21, 2014 7:22:13 PM UTC-4, Jason Felice wrote:

 If you destructure the parameters like this:
 (defn f [ {:as a-map}] ...)

 You can use map primitives on a-map.  But you can also supply defaults
 here.
  On Jun 20, 2014 2:14 PM, Dave Tenny dave@gmail.com wrote:

  What is the commonly accepted technique for declaring/using
 'supplied-p' type lambda list functionality in clojure?

 http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/
 HyperSpec/Body/sec_3-4-1.html


 I have some clojure functions with a large number of keywords and
 various defaults, I want to know if a keyword was specified by the caller
 (rather than defaulted) in some cases.

 Certainly I could implement my own destructuring macros that did this,
 but I'd like to avoid reinventing a wheel here if I can, and also to know
 the idiomatic clojure way to do it.

 Thanks for any tips.


  --
 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/d/optout.

  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




 --
 庄晓丹
 Email:killme2...@gmail.com xzhu...@avos.com
 Site:   http://fnil.net
 Twitter:  @killme2008





-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Supplied-p parameter in clojure similar to lisp lambda lists

2014-08-18 Thread dennis zhuang
Yep, it's an optional syntax sugar.
Indeed, you should use (contains? all-keys :baz) to check if :baz is
present in options. If :baz is present but it's value is nil,then (:baz
all-keys) returns nil too.


2014-08-18 18:57 GMT+08:00 Dave Tenny dave.te...@gmail.com:

 I don't think that a :p feature is necessary, since all you need to do to
 emulate it is a
 (:baz all-keys) to know if the user explicitly specified it.  I.e. I think
 the capability is already present in adequate form but the documentation on
 map destructuring could be improved.




 On Sun, Aug 17, 2014 at 11:02 PM, dennis zhuang killme2...@gmail.com
 wrote:

 I think that adding a :p option to destructuring would be great:

 (let [ {:keys [a b c] :p {a a-p}} params]
 (if a-p
 (println a)
 (println a is not exists.)))






 2014-08-17 20:05 GMT+08:00 Dave Tenny dave.te...@gmail.com:

  Well, it took me a while to perhaps get what you were telling me here.

 In my case I I had something like

 (defn foo [  {:keys [bar ... more keys ...] :or {bar 1}} ] ...)

 and I wanted to know whether the user had explicilty invoked foo with
 :bar.

 What wasn't clear to me was that :as solved this problem.
 Reading http://clojure.org/special_forms#Special Forms--Binding Forms
 (Destructuring)-Map binding destructuring
 I guess I can see that it's telling me :as shows things that weren't in
 the init-form, but that's with hindsight.

 So, to emulated common lisp 'supplied-p' semantics, you can check the
 :as form, which will **not**
 contain :or values for keywords.

 E.g.

 user (defn bar [  {:keys [baz] :or {baz 'baz} :as all-keys} ] (println
 baz all-keys))
 #'user/bar
 user (bar :bof 1)
 baz {:bof 1}
 nil

 And not that the all-keys form does not show a binding for baz, and
 that's what I wanted.

 Just fyi in case anybody searches topics for 'supplied-p' again.


 On Saturday, June 21, 2014 7:22:13 PM UTC-4, Jason Felice wrote:

 If you destructure the parameters like this:
 (defn f [ {:as a-map}] ...)

 You can use map primitives on a-map.  But you can also supply defaults
 here.
  On Jun 20, 2014 2:14 PM, Dave Tenny dave@gmail.com wrote:

  What is the commonly accepted technique for declaring/using
 'supplied-p' type lambda list functionality in clojure?

 http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/
 HyperSpec/Body/sec_3-4-1.html


 I have some clojure functions with a large number of keywords and
 various defaults, I want to know if a keyword was specified by the caller
 (rather than defaulted) in some cases.

 Certainly I could implement my own destructuring macros that did this,
 but I'd like to avoid reinventing a wheel here if I can, and also to know
 the idiomatic clojure way to do it.

 Thanks for any tips.


  --
 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/d/optout.

  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to clojure+unsubscr...@googlegroups.com.

 For more options, visit https://groups.google.com/d/optout.




 --
 庄晓丹
 Email:killme2...@gmail.com xzhu...@avos.com
 Site:   http://fnil.net
 Twitter:  @killme2008


  --
 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 a topic in the
 Google Groups Clojure group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/clojure/jWc51JOkvsA/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 clojure+unsubscr

Re: Supplied-p parameter in clojure similar to lisp lambda lists

2014-08-17 Thread dennis zhuang
I think that adding a :p option to destructuring would be great:

(let [ {:keys [a b c] :p {a a-p}} params]
(if a-p
(println a)
(println a is not exists.)))






2014-08-17 20:05 GMT+08:00 Dave Tenny dave.te...@gmail.com:

 Well, it took me a while to perhaps get what you were telling me here.

 In my case I I had something like

 (defn foo [  {:keys [bar ... more keys ...] :or {bar 1}} ] ...)

 and I wanted to know whether the user had explicilty invoked foo with :bar.

 What wasn't clear to me was that :as solved this problem.
 Reading http://clojure.org/special_forms#Special Forms--Binding Forms
 (Destructuring)-Map binding destructuring
 I guess I can see that it's telling me :as shows things that weren't in
 the init-form, but that's with hindsight.

 So, to emulated common lisp 'supplied-p' semantics, you can check the :as
 form, which will **not**
 contain :or values for keywords.

 E.g.

 user (defn bar [  {:keys [baz] :or {baz 'baz} :as all-keys} ] (println
 baz all-keys))
 #'user/bar
 user (bar :bof 1)
 baz {:bof 1}
 nil

 And not that the all-keys form does not show a binding for baz, and that's
 what I wanted.

 Just fyi in case anybody searches topics for 'supplied-p' again.


 On Saturday, June 21, 2014 7:22:13 PM UTC-4, Jason Felice wrote:

 If you destructure the parameters like this:
 (defn f [ {:as a-map}] ...)

 You can use map primitives on a-map.  But you can also supply defaults
 here.
  On Jun 20, 2014 2:14 PM, Dave Tenny dave@gmail.com wrote:

  What is the commonly accepted technique for declaring/using
 'supplied-p' type lambda list functionality in clojure?

 http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/
 HyperSpec/Body/sec_3-4-1.html


 I have some clojure functions with a large number of keywords and
 various defaults, I want to know if a keyword was specified by the caller
 (rather than defaulted) in some cases.

 Certainly I could implement my own destructuring macros that did this,
 but I'd like to avoid reinventing a wheel here if I can, and also to know
 the idiomatic clojure way to do it.

 Thanks for any tips.


  --
 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/d/optout.

  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


CtorReader bug?

2014-08-16 Thread dennis zhuang
user= #java.lang.String[hello world]
hello world

user= #java.lang.String[(byte-array) utf8]
IllegalArgumentException No matching ctor found for class java.lang.String
 clojure.lang.Reflector.invokeConstructor (Reflector.java:183)

It seems that the CtorReader
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L1187-1245
doesn't eval the arguments before invoking constructor,so it can't find a
valid ctor.

I am not sure whether it's a bug or an expected behaviour.


-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: CtorReader bug?

2014-08-16 Thread dennis zhuang
Sorry,the error example must be:

user= #java.lang.String[(byte-array 10) utf8]
IllegalArgumentException No matching ctor found for class java.lang.String
 clojure.lang.Reflector.invokeConstructor (Reflector.java:183)



2014-08-16 19:59 GMT+08:00 dennis zhuang killme2...@gmail.com:

 user= #java.lang.String[hello world]
 hello world

 user= #java.lang.String[(byte-array) utf8]
 IllegalArgumentException No matching ctor found for class java.lang.String
  clojure.lang.Reflector.invokeConstructor (Reflector.java:183)

 It seems that the CtorReader
 https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L1187-1245
 doesn't eval the arguments before invoking constructor,so it can't find a
 valid ctor.

 I am not sure whether it's a bug or an expected behaviour.


 --
 庄晓丹
 Email:killme2...@gmail.com xzhu...@avos.com
 Site:   http://fnil.net
 Twitter:  @killme2008





-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: CtorReader bug?

2014-08-16 Thread dennis zhuang
Got it.

Thanks for your quick reply.


2014-08-16 20:14 GMT+08:00 Nicola Mometto brobro...@gmail.com:

 It's by design, see the section on ctor literals
 http://clojure.org/reader#toc1

 The elements in the vector part are passed unevaluated to the relevant
 constructor.

 Nicola

 dennis zhuang writes:

  user= #java.lang.String[hello world]
  hello world
 
  user= #java.lang.String[(byte-array) utf8]
  IllegalArgumentException No matching ctor found for class
 java.lang.String
   clojure.lang.Reflector.invokeConstructor (Reflector.java:183)
 
  It seems that the CtorReader
  
 https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L1187-1245
 
  doesn't eval the arguments before invoking constructor,so it can't find a
  valid ctor.
 
  I am not sure whether it's a bug or an expected behaviour.
 
 
  --
  庄晓丹
  Email:killme2...@gmail.com xzhu...@avos.com
  Site:   http://fnil.net
  Twitter:  @killme2008

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


{ANN} clj.qrgen and securen-rand : generate QRCode and secure random in clojure

2014-06-22 Thread dennis zhuang
*clj.qrgen*:  https://github.com/killme2008/clj.qrgen

Generate QRCode  in clojure:

(as-file (from hello world))

*secure-rand*:  https://github.com/killme2008/secure-rand

Secure version for clojure.core/rand etc.

(ns test
  (:refer-clojure :exclude [rand rand-int rand-nth])
  (:use [secure-rand.core :only [rand rand-int rand-nth]]))
(rand)(rand 10)(rand-int 100)(rand-nth (range 10))


Hope they could be helpful for someone.
-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Effective Clojure book?

2014-06-04 Thread dennis zhuang
《The joy of clojure》 ?


2014-06-05 9:30 GMT+08:00 Mike Fikes mikefi...@me.com:

 Are there any books yet that prescribe best practices for Clojure, à la
 Meyers or Bloch?

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


{{ANN} clj-xmemcached release 0.2.4

2014-04-27 Thread dennis zhuang
An opensource memcached client for clojure,it wraps xmemcached.

0.2.4 releases, main highlights:

   - Upgrade xmemcached to
2.0.0https://github.com/killme2008/xmemcached/releases/tag/xmemcached-2.0.0,
   10% performance improved for text protocol and fixed some issues.
   - Added nippy-transcoder to support
nippyhttps://github.com/ptaoussanis/nippyserialization.
   - Added expiration time parameters for incr/decr functions.
   - Added :session-locator option for memcached function to use special
   
MemcachedSessionLocatorhttp://fnil.net/docs/xmemcached/net/rubyeye/xmemcached/MemcachedSessionLocator.html
   .

Manual and home:  https://github.com/killme2008/clj-xmemcached

Thanks.

-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] core.rrb-vector 0.0.11 -- Clojure 1.6 compatibility and bug fixes

2014-03-30 Thread dennis zhuang
I can't find any performance benchmark in the home page.Any links?Thanks.



2014-03-31 2:01 GMT+08:00 Michał Marczyk michal.marc...@gmail.com:

 Hi,

 I am pleased to announce the 0.0.11 release of core.rrb-vector, a
 Clojure Contrib library extending the Clojure vector API with
 logarithmic-time concatenation and slicing:

   https://github.com/clojure/core.rrb-vector

   [org.clojure/core.rrb-vector 0.0.11]

   dependency
 groupIdorg.clojure/groupId
 artifactIdcore.rrb-vector/artifactId
 version${version}/version
   /dependency

   compile org.clojure:core.rrb-vector:${version}

 This release updates the hashing mechanism used by RRB vectors for
 compatibility with Clojure 1.6 (while maintaining compatibility with
 1.5.1) and fixes two bugs. Additionally, the README now states that
 view vectors produced by clojure.core/subvec are handled correctly in
 Clojure = 1.6.0.

 Many thanks to the two new contributors: Jozef Wagner, who reported
 and fixed a bug to do with transient vectors of primitives and who
 reported a bug in sequences over RRB vectors that would surface when
 using such sequences with the reducers library; and Andy Fingerhut,
 who kept on top of the hashing changes and contributed improvements to
 the test suite, which now explicitly checks both hash codes (hasheq
 and hashCode).

 Cheers,
 Michał

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Clojure performance question

2014-03-01 Thread dennis zhuang
The String a=i+another word; is also compiled into using
 StringBuilder, see the byte code by javap -v:

   Code:
  stack=5, locals=5, args_size=1
 0: invokestatic  #2  // Method
java/lang/System.nanoTime:()J
 3: lstore_1
 4: iconst_0
 5: istore_3
 6: iload_3
 7: ldc   #3  // int 1000
 9: if_icmpge 39
12: new   #4  // class
java/lang/StringBuilder
15: dup
16: invokespecial #5  // Method
java/lang/StringBuilder.init:()V
19: iload_3
20: invokevirtual #6  // Method
java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
23: ldc   #7  // String another word
25: invokevirtual #8  // Method
java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
28: invokevirtual #9  // Method
java/lang/StringBuilder.toString:()Ljava/lang/String;
31: astore4
33: iinc  3, 1
36: goto  6
39: getstatic #10 // Field
java/lang/System.out:Ljava/io/PrintStream;
42: invokestatic  #2  // Method
java/lang/System.nanoTime:()J
45: lload_1
46: lsub
47: l2d
48: ldc2_w#11 // double 1.0E9d
51: ddiv
52: invokevirtual #13 // Method
java/io/PrintStream.println:(D)V


I think the performance hotspot in this simple example is the object
allocate/gc  and function calling overhead.The str function create
an anonymous function every time to concat argument strings:

(^String [x  ys]
 ((fn [^StringBuilder sb more]
  (if more
(recur (. sb  (append (str (first more (next more))
(str sb)))
  (new StringBuilder (str x)) ys)))

And we all know that a function in clojure is a java object allocated in
heap.And another overhead is calling the function,it's virtual method.

By watching the gc statistics using 'jstat -gcutil pid 2000', i found
that the clojure sample ran about 670 minor gc,but the java sample is only
120 minor gc.

A improved clojure version,it's performance is closed to java sample:

user= (time (dotimes [n 1000] (- (StringBuilder.) (.append n)
(.append another word) (.toString
Elapsed time: 1009.942 msecs




2014-03-01 18:02 GMT+08:00 bob wee@gmail.com:

 Case :

 clojure verison:

 (time (dotimes [n 1000] (str n another word))) ;; take about 5000msec

 java version

 long time = System.nanoTime();

 for(int i=0 ; i1000 ;i++){
 String a=i+another word;
 }
   System.out.println(System.nanoTime()-time);


 The java version take about 500 msecs, I thought it might be caused by the
 str implementation which is using string builder, and it might not be the
 best choice in the case of no much string to concat, and then I replace
 another word with 5 long strings as the parameter, however no surprise.

 I just wonder what make the difference, or how to find the difference.

 Thanks



 On Saturday, March 1, 2014 1:26:38 PM UTC+8, Shantanu Kumar wrote:

 I have seen (and I keep seeing) a ton of Java code that performs poorly.
 Empirically, it's equally easy to write a slow Java app. You always need a
 discerning programmer to get good performance from any language/tool.

 Numbers like 1/4 or 1/10 can be better discussed in presence of the
 use-cases and perf test cases. Most of the problems you listed can be
 mitigated by `-server` JIT, avoiding reflection, transients, loop-recur,
 arrays, perf libraries and some Java code.

 Shantanu

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




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

Re: Clojure performance question

2014-03-01 Thread dennis zhuang
I forgot to note hat i test the java sample and clojure sample code with
the same jvm options '-server'.



2014-03-01 20:03 GMT+08:00 dennis zhuang killme2...@gmail.com:

 The String a=i+another word; is also compiled into using
  StringBuilder, see the byte code by javap -v:

Code:
   stack=5, locals=5, args_size=1
  0: invokestatic  #2  // Method
 java/lang/System.nanoTime:()J
  3: lstore_1
  4: iconst_0
  5: istore_3
  6: iload_3
  7: ldc   #3  // int 1000
  9: if_icmpge 39
 12: new   #4  // class
 java/lang/StringBuilder
 15: dup
 16: invokespecial #5  // Method
 java/lang/StringBuilder.init:()V
 19: iload_3
 20: invokevirtual #6  // Method
 java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
 23: ldc   #7  // String another word
 25: invokevirtual #8  // Method
 java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
 28: invokevirtual #9  // Method
 java/lang/StringBuilder.toString:()Ljava/lang/String;
 31: astore4
 33: iinc  3, 1
 36: goto  6
 39: getstatic #10 // Field
 java/lang/System.out:Ljava/io/PrintStream;
 42: invokestatic  #2  // Method
 java/lang/System.nanoTime:()J
 45: lload_1
 46: lsub
 47: l2d
 48: ldc2_w#11 // double 1.0E9d
 51: ddiv
 52: invokevirtual #13 // Method
 java/io/PrintStream.println:(D)V


 I think the performance hotspot in this simple example is the object
 allocate/gc  and function calling overhead.The str function create
 an anonymous function every time to concat argument strings:

 (^String [x  ys]
  ((fn [^StringBuilder sb more]
   (if more
 (recur (. sb  (append (str (first more (next more))
 (str sb)))
   (new StringBuilder (str x)) ys)))

 And we all know that a function in clojure is a java object allocated in
 heap.And another overhead is calling the function,it's virtual method.

 By watching the gc statistics using 'jstat -gcutil pid 2000', i found
 that the clojure sample ran about 670 minor gc,but the java sample is only
 120 minor gc.

 A improved clojure version,it's performance is closed to java sample:

 user= (time (dotimes [n 1000] (- (StringBuilder.) (.append n)
 (.append another word) (.toString
 Elapsed time: 1009.942 msecs




 2014-03-01 18:02 GMT+08:00 bob wee@gmail.com:

 Case :

 clojure verison:

 (time (dotimes [n 1000] (str n another word))) ;; take about
 5000msec

 java version

 long time = System.nanoTime();

 for(int i=0 ; i1000 ;i++){
 String a=i+another word;
 }
   System.out.println(System.nanoTime()-time);


 The java version take about 500 msecs, I thought it might be caused by
 the str implementation which is using string builder, and it might not be
 the best choice in the case of no much string to concat, and then I replace
 another word with 5 long strings as the parameter, however no surprise.

 I just wonder what make the difference, or how to find the difference.

 Thanks



 On Saturday, March 1, 2014 1:26:38 PM UTC+8, Shantanu Kumar wrote:

 I have seen (and I keep seeing) a ton of Java code that performs poorly.
 Empirically, it's equally easy to write a slow Java app. You always need a
 discerning programmer to get good performance from any language/tool.

 Numbers like 1/4 or 1/10 can be better discussed in presence of the
 use-cases and perf test cases. Most of the problems you listed can be
 mitigated by `-server` JIT, avoiding reflection, transients, loop-recur,
 arrays, perf libraries and some Java code.

 Shantanu

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




 --
 庄晓丹
 Email:killme2...@gmail.com xzhu...@avos.com
 Site:   http://fnil.net
 Twitter:  @killme2008





-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
You received this message because you are subscribed

Re: Clojure performance question

2014-03-01 Thread dennis zhuang
I think the remaining overhead of clojure sample code is that operators in
java such as '++' and ' etc.They are just an instrument of JVM -- iinc
and if_icmpge. But they are both functions in clojure,and they will be
called by invokevirtual instrument.It cost much more performance.




2014-03-01 20:07 GMT+08:00 dennis zhuang killme2...@gmail.com:

 I forgot to note hat i test the java sample and clojure sample code with
 the same jvm options '-server'.



 2014-03-01 20:03 GMT+08:00 dennis zhuang killme2...@gmail.com:

 The String a=i+another word; is also compiled into using
  StringBuilder, see the byte code by javap -v:

Code:
   stack=5, locals=5, args_size=1
  0: invokestatic  #2  // Method
 java/lang/System.nanoTime:()J
  3: lstore_1
  4: iconst_0
  5: istore_3
  6: iload_3
  7: ldc   #3  // int 1000
  9: if_icmpge 39
 12: new   #4  // class
 java/lang/StringBuilder
 15: dup
 16: invokespecial #5  // Method
 java/lang/StringBuilder.init:()V
 19: iload_3
 20: invokevirtual #6  // Method
 java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
 23: ldc   #7  // String another word
 25: invokevirtual #8  // Method
 java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
 28: invokevirtual #9  // Method
 java/lang/StringBuilder.toString:()Ljava/lang/String;
 31: astore4
 33: iinc  3, 1
 36: goto  6
 39: getstatic #10 // Field
 java/lang/System.out:Ljava/io/PrintStream;
 42: invokestatic  #2  // Method
 java/lang/System.nanoTime:()J
 45: lload_1
 46: lsub
 47: l2d
 48: ldc2_w#11 // double 1.0E9d
 51: ddiv
 52: invokevirtual #13 // Method
 java/io/PrintStream.println:(D)V


 I think the performance hotspot in this simple example is the object
 allocate/gc  and function calling overhead.The str function create
 an anonymous function every time to concat argument strings:

 (^String [x  ys]
  ((fn [^StringBuilder sb more]
   (if more
 (recur (. sb  (append (str (first more (next more))
 (str sb)))
   (new StringBuilder (str x)) ys)))

 And we all know that a function in clojure is a java object allocated in
 heap.And another overhead is calling the function,it's virtual method.

 By watching the gc statistics using 'jstat -gcutil pid 2000', i found
 that the clojure sample ran about 670 minor gc,but the java sample is only
 120 minor gc.

 A improved clojure version,it's performance is closed to java sample:

 user= (time (dotimes [n 1000] (- (StringBuilder.) (.append n)
 (.append another word) (.toString
 Elapsed time: 1009.942 msecs




 2014-03-01 18:02 GMT+08:00 bob wee@gmail.com:

 Case :

 clojure verison:

 (time (dotimes [n 1000] (str n another word))) ;; take about
 5000msec

 java version

 long time = System.nanoTime();

 for(int i=0 ; i1000 ;i++){
 String a=i+another word;
 }
   System.out.println(System.nanoTime()-time);


 The java version take about 500 msecs, I thought it might be caused by
 the str implementation which is using string builder, and it might not be
 the best choice in the case of no much string to concat, and then I replace
 another word with 5 long strings as the parameter, however no surprise.

 I just wonder what make the difference, or how to find the difference.

 Thanks



 On Saturday, March 1, 2014 1:26:38 PM UTC+8, Shantanu Kumar wrote:

 I have seen (and I keep seeing) a ton of Java code that performs
 poorly. Empirically, it's equally easy to write a slow Java app. You always
 need a discerning programmer to get good performance from any 
 language/tool.

 Numbers like 1/4 or 1/10 can be better discussed in presence of the
 use-cases and perf test cases. Most of the problems you listed can be
 mitigated by `-server` JIT, avoiding reflection, transients, loop-recur,
 arrays, perf libraries and some Java code.

 Shantanu

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

Re: Clojure performance question

2014-03-01 Thread dennis zhuang
Yep, you are right, inspecting the byte code generated by the clojure code:

 (loop [n 0]
(when ( n 1000)
  (- (StringBuilder.) (.append n) (.append another word)
(.toString))
  (recur (unchecked-inc n

It is:


L4
LINENUMBER 4 L4
LLOAD 1
LDC 1000
LCMP
IFGE L5
   L6
LINENUMBER 5 L6
   L7
LINENUMBER 5 L7
   L8
LINENUMBER 5 L8
NEW java/lang/StringBuilder
DUP
INVOKESPECIAL java/lang/StringBuilder.init ()V
CHECKCAST java/lang/StringBuilder
LLOAD 1
INVOKEVIRTUAL java/lang/StringBuilder.append
(J)Ljava/lang/StringBuilder;
CHECKCAST java/lang/StringBuilder
LDC another word
CHECKCAST java/lang/String
INVOKEVIRTUAL java/lang/StringBuilder.append
(Ljava/lang/String;)Ljava/lang/StringBuilder;
CHECKCAST java/lang/StringBuilder
INVOKEVIRTUAL java/lang/StringBuilder.toString ()Ljava/lang/String;
POP
   L9
LINENUMBER 6 L9
LLOAD 1
LCONST_1
LADD
LSTORE 1
GOTO L2
GOTO L10
   L11
POP
   L5
ACONST_NULL


It's almost the same with java compiled byte code,except using long type's
instruments (LCMP and LADD etc) and some CHECKCAST (cast type) instruments.





2014-03-01 21:00 GMT+08:00 Jozef Wagner jozef.wag...@gmail.com:

 Clojure math functions compile down to the same JVM 'instruction' as from
 java. See http://galdolber.tumblr.com/post/77153377251/clojure-intrinsics



 On Sat, Mar 1, 2014 at 1:23 PM, dennis zhuang killme2...@gmail.comwrote:

 I think the remaining overhead of clojure sample code is that operators
 in java such as '++' and ' etc.They are just an instrument of JVM -- iinc
 and if_icmpge. But they are both functions in clojure,and they will be
 called by invokevirtual instrument.It cost much more performance.




 2014-03-01 20:07 GMT+08:00 dennis zhuang killme2...@gmail.com:

 I forgot to note hat i test the java sample and clojure sample code with
 the same jvm options '-server'.



 2014-03-01 20:03 GMT+08:00 dennis zhuang killme2...@gmail.com:

 The String a=i+another word; is also compiled into using
  StringBuilder, see the byte code by javap -v:

Code:
   stack=5, locals=5, args_size=1
  0: invokestatic  #2  // Method
 java/lang/System.nanoTime:()J
  3: lstore_1
  4: iconst_0
  5: istore_3
  6: iload_3
  7: ldc   #3  // int 1000
  9: if_icmpge 39
 12: new   #4  // class
 java/lang/StringBuilder
 15: dup
 16: invokespecial #5  // Method
 java/lang/StringBuilder.init:()V
 19: iload_3
 20: invokevirtual #6  // Method
 java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
 23: ldc   #7  // String another word
 25: invokevirtual #8  // Method
 java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
 28: invokevirtual #9  // Method
 java/lang/StringBuilder.toString:()Ljava/lang/String;
 31: astore4
 33: iinc  3, 1
 36: goto  6
 39: getstatic #10 // Field
 java/lang/System.out:Ljava/io/PrintStream;
 42: invokestatic  #2  // Method
 java/lang/System.nanoTime:()J
 45: lload_1
 46: lsub
 47: l2d
 48: ldc2_w#11 // double 1.0E9d
 51: ddiv
 52: invokevirtual #13 // Method
 java/io/PrintStream.println:(D)V


 I think the performance hotspot in this simple example is the object
 allocate/gc  and function calling overhead.The str function create
 an anonymous function every time to concat argument strings:

 (^String [x  ys]
  ((fn [^StringBuilder sb more]
   (if more
 (recur (. sb  (append (str (first more (next more))
 (str sb)))
   (new StringBuilder (str x)) ys)))

 And we all know that a function in clojure is a java object allocated
 in heap.And another overhead is calling the function,it's virtual method.

 By watching the gc statistics using 'jstat -gcutil pid 2000', i found
 that the clojure sample ran about 670 minor gc,but the java sample is only
 120 minor gc.

 A improved clojure version,it's performance is closed to java sample:

 user= (time (dotimes [n 1000] (- (StringBuilder.) (.append n)
 (.append another word) (.toString
 Elapsed time: 1009.942 msecs




 2014-03-01 18:02 GMT+08:00 bob wee@gmail.com:

 Case :

 clojure verison:

 (time (dotimes [n 1000] (str n another word))) ;; take about
 5000msec

 java version

 long time = System.nanoTime();

 for(int i=0 ; i1000 ;i++){
 String a=i+another word;
 }
   System.out.println(System.nanoTime()-time);


 The java version take about 500 msecs, I thought it might be caused by
 the str implementation

Re: JAVA_OPTS not accessible in my Clojure project

2014-01-12 Thread dennis zhuang
Tried System/getenv ?


2014/1/12 aidy lewis aidy.le...@gmail.com

 Hi Phil,

 M-x cider-jack-in, but the JAVA_OPT properties are also nil if I do a lein
 run.

 Thanks

 Aidy


 On 12 January 2014 05:25, Matching Socks phill.w...@gmail.com wrote:

 How did you start the Emacs Cider REPL?

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




 --
 @AidyLewis

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




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
-- 
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 indent clojure code in Emacs

2014-01-03 Thread dennis zhuang
use the 'indent-region' function.You can define a function to indent the
whole buffer:

(defun indent-buffer ()
  Indent whole buffer
  (interactive)
  (indent-region (point-min) (point-max))
  (message format successfully))


Then bind the function to a key, i bound it to F7 for me:

(global-set-key [f7] 'indent-buffer)

Also, you can indent-buffer before saving file:

(defun indent-file-when-save ()
  indent file when save.
  (make-local-variable 'after-save-hook)
  (add-hook 'after-save-hook
(lambda ()
  (if (buffer-file-name)
  (indent-buffer))
  (save-buffer
(add-hook 'clojure-mode-hook 'indent-file-when-save)



2014/1/3 tao tao.zhou2...@gmail.com

  https://github.com/clojure-emacs/clojure-mode

 I have installed this plugin, but I don’t know how to indent clojure code,
 when I already selected a region. In Vim, I can do this using “=“, just a
 simple key stroke.

 This a problem when I copy some clojure code from other place, not typed
 in.

 I already read this tutorial (
 http://www.unexpected-vortices.com/clojure/10-minute-emacs-for-clojure.html),
 but I cannot found the method.

 sorry for disturb. :)

 --
 tao
 Sent with Sparrow http://www.sparrowmailapp.com/?sig

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




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
-- 
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: get fn and not-found

2013-10-27 Thread dennis zhuang
The function's arguments will be evaluated before calling it.
So the (my-foo) will be called before 'get'.



2013/10/28 Ryan arekand...@gmail.com

 Hello,

 I am trying to understanding why is this happening:

  (defn my-foo [] (println Why do I get printed?))
 #'sandbox4724/my-foo
  (get {:b 1} :b (my-foo))
 Why do I get printed?
 1
 


 Shouldn't (my-foo) only be called in case the key isn't found? Why am I
 seeing the above behavior instead?

 Thank you for your time,

 Ryan

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




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
-- 
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: Entwined STM V1.0

2013-08-18 Thread dennis zhuang
That's really cool.
Do you have any performance benchmark between TransactionalMap and
java.util.concurrent.ConcurrentHashMap?  When should i use these
collections instead of java.util.concurrent.* collections?




2013/8/18 Ivan Koblik ivankob...@gmail.com

 Hi All,

 Almost 4 years ago I developed STM with semantic concurrency control for
 my project at CERN. Main feature of this STM is the TransactionalMap that
 lets you merge concurrent changes. Library is heavily tested and is very
 stable. It has been used in production for the past 2 years.

 Recently I released it on GitHub:
 http://entwined.koblik.ch (will redirect to
 https://github.com/CERN-BE/Entwined-STM)

 Since Entwined STM was designed to be used from Java I wrote a simple
 facade for it in Clojure that you can load with

 (require '[cern.entwined.core :as stm])

 Entwined STM operates on a memory with a fixed structure, meaning that you
 have to define what and how many collections you want to have in your STM
 and this can't be changed after construction. To construct memory with 1
 transactional map and 1 transactional queue run this:

 (def memory (stm/create-memory :map (stm/create-map) :queue
 (stm/create-queue)))

 It's impossible to access transactional entities outside of a transaction,
 to run a transaction you can use intrans macro

 (stm/intrans memory data (- data :map (.put :key1 value1)) true)

 (stm/intrans memory data (- data :map (.get :key1))) ;- value1

 First line puts [:key1 value1] pair into the map. True at the end of the
 body tells the memory to commit this transaction. intrans will initiate
 commit if body returns truthy value. Second line just shows that the change
 has been committed.

 A couple more words on the implementation: I used HashMap to implement the
 TransactionalMap, I copy the backing map for every transaction which may be
 expensive for some scenarios. Obvious solution would be to use Clojure's
 persistent map. Commits are eventually serialized and protected with a
 single lock. If you take a look at the Java source you'll see that
 Transaction interface has a second method committed that is called when
 commit is being done. I use this method to write to the hardware knowing
 that execution order of committed callbacks is the same as the commit order.

 I would greatly appreciate any feedback and suggestions. If you have any
 questions don't hesitate to ask here or email me directly. Documentation is
 still somewhat lacking and I'd be interested to know which parts of it
 should be improved first.

 Cheers,
 Ivan.

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




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
-- 
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 we please deprecate the :use directive ?

2013-07-24 Thread dennis zhuang
I am using ':use' for my own namespaces.I know it's discouraged, but if i
can control my own code,why not? Compiler can give me warnings and i
process all warnings carefully.



2013/7/25 Steven Degutis sbdegu...@gmail.com

 If our votes count for anything, then I'd like to add +1 for getting rid
 of :use, and strongly discouraging :refer :all.


 On Wed, Jul 24, 2013 at 11:16 AM, Alex Baranosky 
 alexander.barano...@gmail.com wrote:

 +1 for scary compiler deprecation warning for 1.6.0, then removing :use
 in the 1.7.0 release.


 On Wed, Jul 24, 2013 at 8:49 AM, Softaddicts lprefonta...@softaddicts.ca
  wrote:

 I disagree, when I use tracing fns and other useful REPL tools,
 I like to have them included without having to prefix them with an alias.

 It's not a hack  it's a feature and you are free to use it or not.
 If code writers do not care about code readers it's a choice, maybe bad
 but
 that decision is not yours to take. It's theirs in their own context.

 Now this thread has slowly shifted to can we streamline how we express
 this
 feature to lets forbid this feature to be used. If ends up creating
 such
 policies enforced by the language, it's the wrong route.

 My answer to such proposals is a definite no. This a red line to me
 that should
 not be crossed.

 Luc P.


   I hate it mainly in blogs, where they explain some new API. They :use
  like 3 namespaces and you have to guess which fn is from which ns :)
 
  Agree.
  Code is read much more often than it is written, so omitting a few
  character is not effective time-saving.
  I also don't like :refer :all.
  I think it should be considered hack rather than official feature.
 
  On Wednesday, July 24, 2013 3:17:02 AM UTC+9, Jozef Wagner wrote:
  
   +1, :use is IMO an antipattern.
  
   I hate it mainly in blogs, where they explain some new API. They
 :use like
   3 namespaces and you have to guess which fn is from which ns :)
  
   JW
  
   On Tuesday, July 23, 2013 5:50:50 PM UTC+2, Greg Slepak wrote:
  
   I think I read somewhere that :use is no longer encouraged, but I
 could
   be mistaken.
  
   From what I've read, it seems like most people agree that Clojure
 has too
   many ways of including/importing/referencing/requiring/using things:
  
  
  
 http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html
  
   The above gives a very nice explanation of all the various
 difference,
   but it also acknowledges their complexity.
  
   Since :use uses :require, and since :require can do everything that
 :use
   can, can we simplify Clojure programming a bit for newcomers by
 deprecating
   the use of :use? The situation in ClojureScript is even worse
 because it
   adds :require-macros on top of all the other ways of including
 files.
  
   Ideally, it would be awesome if there was just a single directive
 for
   everything, but perhaps there's some complicated low-level reason
 why
   that's not possible. :-\
  
   Thoughts?
  
   Thanks,
   Greg
  
   P.S. If this has already been brought up you have my sincere
 apologies.
  
   --
   Please do not email me anything that you are not comfortable also
 sharing
   with the NSA.
  
  
 
  --
  --
  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.
 
 
 
 --
 Softaddictslprefonta...@softaddicts.ca sent by ibisMail from my ipad!

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

{{ANN} clj-xmemcached release 0.2.3

2013-07-19 Thread dennis zhuang
An opensource memcached client for clojure,it wraps xmemcached.

0.2.3 releases, main highlights:

1.Supports delete with CAS value in binary protocol


 ;;delete with CAS
(xm/delete num (:cas (gets num)))

2.Supports lighweight distribution lock with try-lock macro:


(def counter (atom 0))
(future (try-lock lock 5 (do (Thread/sleep 3000)
   (swap! counter inc))
(println else1)))
(future (try-lock lock 5 (do (Thread/sleep 3000)
   (swap! counter inc))
(println else2)))
(future (try-lock lock 5 (do (Thread/sleep 3000)
   (swap! counter inc))
(println else3)))

(Thread/sleep 4000)
(is (nil? (get lock)))
(is (= 1 @counter))

3.Through macro:


(through uid (get-user-from-databse uid))

Equals to:


(if-let [rt (get uid)]
rt
(let [rt (get-user-from-database uid)]
(when rt
(add uid rt 0))
rt))

4.Upgrade xmemcached to 1.4.2

More tutorial please visit https://github.com/killme2008/clj-xmemcached

--

庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
-- 
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: core.async

2013-07-06 Thread dennis zhuang
It's so cool,great job!
But i don't find any way to do io blocking operations such as socket.read
in 'go'.
Is there a roadmap to make alts! working with java NIO selector that waits
on socket channels?
Then we can read/write data with socket/file channel in go without blocking.
Thanks,it's really awesome!




2013/7/1 David Pollak dpollak...@gmail.com

 Thanks!


 On Mon, Jul 1, 2013 at 8:13 AM, Sean Corfield seancorfi...@gmail.comwrote:

 On Sun, Jun 30, 2013 at 4:42 PM, David Pollak dpollak...@gmail.com
 wrote:
  Looking forward to it
  being published (even as SNAPSHOT) in a Maven repo.

 It's accessible like this:

 (defproject async 0.1.0-SNAPSHOT
   :description FIXME: write description
   :url http://example.com/FIXME;
   :license {:name Eclipse Public License
 :url http://www.eclipse.org/legal/epl-v10.html}
   :repositories {sonatype-oss-public
 https://oss.sonatype.org/content/groups/public/}
   :dependencies [[org.clojure/clojure 1.5.1]
  [org.clojure/core.async 0.1.0-SNAPSHOT]])
 --
 Sean A Corfield -- (904) 302-SEAN
 An Architect's View -- http://corfield.org/
 World Singles, LLC. -- http://worldsingles.com/

 Perfection is the enemy of the good.
 -- Gustave Flaubert, French realist novelist (1821-1880)

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






-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
-- 
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: reset! and merge for (transient {})

2013-07-02 Thread dennis zhuang
Maybe he means clear?


2013/7/2 Jim jimpil1...@gmail.com

 No merge will not work with transients because it uses conj instead of
 conj!
 If you absolutely have to do this define your own 'merge!' that uses conj!.

 I'm not sure what you mean by reset! for transients...reset! is an
 operation on reference types (atom, ref, agent etc)

 Jim



 On 02/07/13 11:33, Amir Wasim wrote:

 Is there reset! and merge a possibility for (transient {})

 sometimes we have a doseq and it might be requirement sometime.
 --
 --
 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+unsubscribe@**googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://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+unsubscribe@**googlegroups.comclojure%2bunsubscr...@googlegroups.com
 .
 For more options, visit 
 https://groups.google.com/**groups/opt_outhttps://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+unsubscribe@**googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://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+unsubscribe@**googlegroups.comclojure%2bunsubscr...@googlegroups.com
 .
 For more options, visit 
 https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
 .





-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
-- 
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: reset! and merge for (transient {})

2013-07-02 Thread dennis zhuang
Clear the collection.
user= (doc empty)
-
clojure.core/empty
([coll])
  Returns an empty collection of the same category as coll, or nil
nil


2013/7/2 Jim jimpil1...@gmail.com

  what is 'clear' ? cannot find it anywhere...

 Jim



 On 02/07/13 12:03, dennis zhuang wrote:

 Maybe he means clear?


 2013/7/2 Jim jimpil1...@gmail.com

 No merge will not work with transients because it uses conj instead of
 conj!
 If you absolutely have to do this define your own 'merge!' that uses
 conj!.

 I'm not sure what you mean by reset! for transients...reset! is an
 operation on reference types (atom, ref, agent etc)

 Jim



 On 02/07/13 11:33, Amir Wasim wrote:

 Is there reset! and merge a possibility for (transient {})

 sometimes we have a doseq and it might be requirement sometime.
 --
 --
 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.





  --
 庄晓丹
 Email:killme2...@gmail.com xzhu...@avos.com
 Site:   http://fnil.net
 Twitter:  @killme2008


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






-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
-- 
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} clj-xmemacched release 0.2.2

2013-06-24 Thread dennis zhuang
An opensource memcached client for clojure wrapping
xmemcachedhttp://code.google.com/p/xmemcached/.It
released 0.2.2, added 'clj-json-transcoder' that encode/decode values using
clojure.data.json.

https://github.com/killme2008/clj-xmemcached


-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
-- 
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} A clojure macro and ruby script to profile clojure program.

2013-06-08 Thread dennis zhuang
A macro named `p` to log data, and a ruby script to parse log file,and it
will give the statistics result of a clojure program:

Parsing log file test.log ...
Prowl profile results:
Labels:
  Label:logic count:1
Method: method2mean: 10.81
 min: 10.81  max: 10.81  count: 1
Method: method1mean:
145.90 min: 145.90 max: 145.90 count: 1
Method: start  mean:
159.59 min: 159.59 max: 159.59 count: 1

Methods:
  Method: method2mean: 10.81
   min: 10.81  max: 10.81  count: 1
  Method: method1mean: 145.90
   min: 145.90 max: 145.90 count: 1
  Method: start  mean: 159.59
   min: 159.59 max: 159.59 count: 1

It's on github,have fun.

https://github.com/killme2008/prowl

-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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




sorted-map-by issue?

2013-06-06 Thread dennis zhuang
user= (sorted-map-by (constantly 1) :b 1 :a 2)
{:b 1, :a 2}
user= (:a (sorted-map-by (constantly 1) :b 1 :a 2))
nil
user= (keys (sorted-map-by (constantly 1) :b 1 :a 2))
(:b :a)
user= (count (sorted-map-by (constantly 1) :b 1 :a 2))
2
user= (:a (sorted-map-by (constantly 1) :b 1 :a 2))
nil

It looks so strange.The result map has keys :a and :b,but i can't get their
values.
Why? I try to hack the code,but i can't find the reason.


-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
-- 
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: sorted-map-by issue?

2013-06-06 Thread dennis zhuang
Sorry, it's my mistake.
Because treep map use the comparator to compare keys, and if the comparator
returns 1 constantly,it can not find the item that equals the key.

So i can modified the example,and it works:

user= (sorted-map-by #(if (= %1 %2) 0 1) :b 1 :a 2)
{:b 1, :a 2}
user= (:a (sorted-map-by #(if (= %1 %2) 0 1) :b 1 :a 2))
2
user= (:b (sorted-map-by #(if (= %1 %2) 0 1) :b 1 :a 2))
1


2013/6/6 dennis zhuang killme2...@gmail.com

 user= (sorted-map-by (constantly 1) :b 1 :a 2)
 {:b 1, :a 2}
 user= (:a (sorted-map-by (constantly 1) :b 1 :a 2))
 nil
 user= (keys (sorted-map-by (constantly 1) :b 1 :a 2))
 (:b :a)
 user= (count (sorted-map-by (constantly 1) :b 1 :a 2))
 2
 user= (:a (sorted-map-by (constantly 1) :b 1 :a 2))
 nil

 It looks so strange.The result map has keys :a and :b,but i can't get
 their values.
 Why? I try to hack the code,but i can't find the reason.


 --
 庄晓丹
 Email:killme2...@gmail.com xzhu...@avos.com
 Site:   http://fnil.net
 Twitter:  @killme2008





-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
-- 
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: sorted-map-by issue?

2013-06-06 Thread dennis zhuang
Thanks,you are right.I want to creat a map which keeps elements in
insertion order, but clojure doesn‘t have.
在 2013-6-6 下午10:02,Andy Fingerhut andy.finger...@gmail.com写道:

 Your comparator #(if (= %1 %2) 0 1) may happen to give the correct answers
 for your example sorted-maps, but it is also a bad comparator that will
 fail for larger examples:

 user= (:a (sorted-map-by #(if (= %1 %2) 0 1) :z -26 :b 1 :a 2 :c 3 :m 13
 :h 8))
 nil
 user= (:z (sorted-map-by #(if (= %1 %2) 0 1) :z -26 :b 1 :a 2 :c 3 :m 13
 :h 8))
 nil

 That is because if two items are not =, by returning 1 you are telling the
 caller the first argument should come after the second argument.  Thus if
 at some time the comparator is called as (cmp :a :z), and later it is
 called as (cmp :z :a), it returns the inconsistent results that :a should
 come after :z, and later that :z should come after :a.  No sorted tree can
 hope to return correct results given such an inconsistent comparator.

 More examples and discussion at the link below, if you are interested:


 https://github.com/jafingerhut/thalia/blob/master/doc/other-topics/comparators.md

 Andy


 On Thu, Jun 6, 2013 at 4:19 AM, dennis zhuang killme2...@gmail.comwrote:

 Sorry, it's my mistake.
 Because treep map use the comparator to compare keys, and if the
 comparator returns 1 constantly,it can not find the item that equals the
 key.

 So i can modified the example,and it works:

 user= (sorted-map-by #(if (= %1 %2) 0 1) :b 1 :a 2)
 {:b 1, :a 2}
 user= (:a (sorted-map-by #(if (= %1 %2) 0 1) :b 1 :a 2))
 2
 user= (:b (sorted-map-by #(if (= %1 %2) 0 1) :b 1 :a 2))
 1


 2013/6/6 dennis zhuang killme2...@gmail.com

 user= (sorted-map-by (constantly 1) :b 1 :a 2)
 {:b 1, :a 2}
 user= (:a (sorted-map-by (constantly 1) :b 1 :a 2))
 nil
 user= (keys (sorted-map-by (constantly 1) :b 1 :a 2))
 (:b :a)
 user= (count (sorted-map-by (constantly 1) :b 1 :a 2))
 2
 user= (:a (sorted-map-by (constantly 1) :b 1 :a 2))
 nil

 It looks so strange.The result map has keys :a and :b,but i can't get
 their values.
 Why? I try to hack the code,but i can't find the reason.


 --
 庄晓丹
 Email:killme2...@gmail.com xzhu...@avos.com
 Site:   http://fnil.net
 Twitter:  @killme2008





 --
 庄晓丹
 Email:killme2...@gmail.com xzhu...@avos.com
 Site:   http://fnil.net
 Twitter:  @killme2008


  --
 --
 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: Use of io!

2013-05-30 Thread dennis zhuang
Yep,wrap code that has side effects, prevent it to be evaluated in STM
transaction.


2013/5/30 Maik Schünemann maikschuenem...@gmail.com

 I think It stops other code to wrap around the code with the explicit io!
 call.
 Its declarative way of saying: I am doing io! DONT USE me inside a dosync.


 On Thu, May 30, 2013 at 7:47 AM, Josh Kamau joshnet2...@gmail.com wrote:

 Hi ;

 Whats the point of using io! inside dosync if all it does is make an
 exception to be thrown? Please someone make me understand.

 Regards.
 Josh

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






-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
-- 
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: Do you know which language the clojure is written by?

2013-04-22 Thread dennis zhuang
Java.

But there is some clojure version written in ruby,python,c# and javascript.


2013/4/22 ljcppu...@gmail.com

 Hi,
 Do you know which language the clojure is written by?

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






-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
-- 
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: Imported Java lib can't find classes compiled on the fly

2013-03-17 Thread dennis zhuang
You can make the clojure class loader by yourself:

(import '(clojure.lang RT))
(def class-loader (RT/makeClassLoader))

user= (.loadClass class-loader user.Foo)
user.Foo



2013/3/17 vemv v...@vemv.net

 Most definitely :) But that something is hard/confusing should'nt be
 enough reason to give up.


 On Sunday, March 17, 2013 4:11:34 AM UTC+1, James Xu wrote:

 Then things will get complicated and ugly.

   原始邮件
 *发件人:* Víctor M. Valenzuelave...@vemv.net
 *收件人:* clojureclo...@**googlegroups.com
 *发送时间:* 2013年3月17日(周日) 11:05
 *主题:* Re: Imported Java lib can't find classes compiled on the fly

 My guess is it was set via Thread.currentThread().**
 setContextClassLoader()...?

 On Sun, Mar 17, 2013 at 3:07 AM, Víctor M. Valenzuela ve...@vemv.netwrote:

 Yeah I was working in that direction now!

 Anyway, how come (Class/forName) can work if used from the repl? My
 understanding is that the classloader provided by Class is different from
 DynamicClassLoader.


 On Sun, Mar 17, 2013 at 3:01 AM, Michael Klishin 
 michael@gmail.comwrote:


 2013/3/17 vemv ve...@vemv.net

 I guess that somehow the Java library uses a different classloader or
 something like that? Any possible solution?


 Clojure itself uses a separate classloader: a 
 clojure.lang.**DynamicClassLoader
 instance.

 If you can use an instance of that classloader, you should be fine.
 --
 MK

 http://github.com/**michaelklishin http://github.com/michaelklishin
 http://twitter.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 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=enhttp://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups Clojure group.
 To unsubscribe from this topic, visit https://groups.google.com/d/**
 topic/clojure/-n3jul1IeZ8/**unsubscribe?hl=enhttps://groups.google.com/d/topic/clojure/-n3jul1IeZ8/unsubscribe?hl=en
 .
  To unsubscribe from this group and all its topics, send an email to
 clojure+u...@**googlegroups.com.

 For more options, visit 
 https://groups.google.com/**groups/opt_outhttps://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=enhttp://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_outhttps://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.






-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
-- 
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: Laziness in filter

2013-03-17 Thread dennis zhuang
Yep,it's chunked sequence,just like batch processing.
You can use the seq1 function in fogus blog.

2013/3/17 Evan Mezeske emeze...@gmail.com

 I'd guess that what you're seeing is related to chunked sequences:
 http://blog.fogus.me/2010/01/22/de-chunkifying-sequences-in-clojure/ .


 On Sunday, March 17, 2013 1:12:17 AM UTC-7, bruce li wrote:

 Hello, everyone. I'm writing some code that utilizes the lazy sequence.
 But I found something strange. Here is how:

 The code is like:

 (first (filter some-expensive-io urls))

 The code is aimed to find the first result of the operations on the urls
 that is not nil. However, it seems that the io operations are executed once
 more than needed. As the operations are slow, one more round increases the
 overhead dramatically.

 Then I tested other pieces of code, such as:

 (first (filter #(when ( % 1) (println %) %) (range)))

 It prints out:
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31

 and returns: 2

 So why the lazy sequence is realized more than it is needed? Could I
 enforce the laziness and save unnecessary operation?


 Thanks,
 Bruce Li

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






-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
-- 
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: Question about doseq

2012-10-30 Thread dennis zhuang
Please use prn insteadof println. By default, pr and prn print in a way
that objects can be read by the reader,but print and println produce output
for human consumption.

2012/10/31 arekanderu arekand...@gmail.com

 Hello all,

 I have the following code:

 (def my-hash {1 {:a-key {:value a value} :another-key another value
 :a-third-key []}

  2 {:a-key {:value a value} :another-key another
 value :a-third-key []}}


 In the following example i get the following result:

 user= (doseq [[id item] my-hash] (println item))

 {:a-key {:value a value}, :another-key another value, :a-third-key []}

 {:a-key {:value a value}, :another-key another value, :a-third-key []}

 nil


 On the above example, it looks *almost* normal to me. For instance, why 
 *{:value
 a value}* is not returned as *{:value a value} *? Same goes for *:another
 key*
 It still looks like a hashmap though. Isn't it?

 The behavior however which confused me even more is the following:

 user= (doseq [[id item] my-hash
   key (:a-key item)]
 (println key))
 [:value a value]
 [:value a value]
 nil


 I was expecting the above to return:

 {:value a value}
 {:value a value}
 nil


 Can someone explain to me why vector is being returned and how can I
 achieve the result I was expecting? What am I missing here? Am i misusing
 the doseq http://clojuredocs.org/clojure_core/clojure.core/doseqbindings?

 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




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

Re: Why does (conj (transient {}) {}) fail with CCE?

2012-08-09 Thread dennis zhuang
you must use conj! instead of conj.
在 2012-8-9 PM8:49,Jacek Laskowski ja...@japila.pl写道:

 Hi,

 I've been digging into the sources of Clojure and found frequencies.
 There's the transient function and I thought I'd use it with a map and
 conj. Why does this fail?

 user= (conj {} {:y 1})
 {:y 1}
 user= (conj (transient {}) {:y 1})
 ClassCastException   [trace missing]

 I ran into the issue before and got a more comprehensible exception.

 ClassCastException clojure.lang.PersistentArrayMap$TransientArrayMap
 cannot be cast to clojure.lang.IPersistentCollection
 clojure.core/conj (core.clj:83)

 I can't explain why the exception is reported in two different versions.

 Should the exception be thrown? What's the rationale behind
 TransientArrayMap *not* being a IPersistentCollection?

 Jacek

 --
 Jacek Laskowski
 Functional languages (Clojure), Java EE, and IBM WebSphere -
 http://blog.japila.pl
 Never discourage anyone who continually makes progress, no matter how
 slow. Plato

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


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

Re: [ANN] Okku 0.1.0 - Akka interface for Clojure

2012-07-21 Thread dennis zhuang
Great work.Thanks.

2012/7/20 Gary Verhaegen gary.verhae...@gmail.com

 Okku is a thin wrapper around the Akka library that makes it easy to
 use it from Clojure. The Actor model can be considered a nice
 alternative for concurrent programming, but it really shines when you
 want to distribute your application - it really is nearly transparent.

 As the version number suggests, the library is in a very early stage.
 This is also my very first time sharing any type of code with anyone
 (I'm still at university), so do not expect too much in terms of
 quality. On the other hand, I'm eager to learn, so do not hesitate to
 (constructively) criticize it.

 In particular, the core library needs some internal refactorings, and
 as of right now there is absolutely no test or documentation in the
 library itself. I have, however, translated two Akka tutorials to
 Okku, which you can find here:

 https://github.com/gaverhae/okku-pi
 https://github.com/gaverhae/okku-remote

 Together, these two tutorials currently show off almost all the
 features of Okku. The actual library can be found on github:

 https://github.com/gaverhae/okku

 and is already available on clojars as [org.clojure.gaverhae/okku 0.1.0]

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




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

Re: [ANN] Okku 0.1.0 - Akka interface for Clojure

2012-07-21 Thread dennis zhuang
I try to run okku-pi,but it could not find okku 0.1.1-SNAPSHOT:

Could not find artifact org.clojure.gaverhae:okku:jar:0.1.1-SNAPSHOT in
clojars (https://clojars.org/repo/)

Should i use 0.1.0?

2012/7/21 dennis zhuang killme2...@gmail.com

 Great work.Thanks.

 2012/7/20 Gary Verhaegen gary.verhae...@gmail.com

 Okku is a thin wrapper around the Akka library that makes it easy to
 use it from Clojure. The Actor model can be considered a nice
 alternative for concurrent programming, but it really shines when you
 want to distribute your application - it really is nearly transparent.

 As the version number suggests, the library is in a very early stage.
 This is also my very first time sharing any type of code with anyone
 (I'm still at university), so do not expect too much in terms of
 quality. On the other hand, I'm eager to learn, so do not hesitate to
 (constructively) criticize it.

 In particular, the core library needs some internal refactorings, and
 as of right now there is absolutely no test or documentation in the
 library itself. I have, however, translated two Akka tutorials to
 Okku, which you can find here:

 https://github.com/gaverhae/okku-pi
 https://github.com/gaverhae/okku-remote

 Together, these two tutorials currently show off almost all the
 features of Okku. The actual library can be found on github:

 https://github.com/gaverhae/okku

 and is already available on clojars as [org.clojure.gaverhae/okku 0.1.0]

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




 --
 庄晓丹
 Email:killme2...@gmail.com xzhu...@avos.com
 Site:   http://fnil.net
 Twitter:  @killme2008






-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

Re: {ANN} ring.velocity: render apache velocity templates for ring in clojure.

2012-07-19 Thread dennis zhuang
I've released ring.velocity 0.1.0
https://github.com/killme2008/ring.velocity
Thanks.

2012/7/18 Sun Ning classicn...@gmail.com

 enlive最大的好处是页面html页面不会掺入任何模板语言**,直接就可以在浏览器里预览页面设计
 但是用的时候思维确实和传统的模板引擎不太一样


 On Wed 18 Jul 2012 12:50:39 PM CST, Shen, Feng wrote:

 同感enlive较复杂。前段时间,转向了Mustache。

 沈锋
 美味书签 http://mei.fm



 On Wed, Jul 18, 2012 at 11:59 AM, dennis zhuang killme2...@gmail.com
 mailto:killme2...@gmail.com wrote:

 其实就是几行代码封装下,**我觉的velocity比什么enlive好用多了。

 2012/7/18 Shen, Feng shen...@gmail.com mailto:shen...@gmail.com


 不错不错。
 velocity 在java中用得较广。
 这样为potential 的 clojure用户铺了一下道路。

 沈锋
 美味书签 http://meiwei.fm http://mei.fm




 On Wed, Jul 18, 2012 at 12:00 AM, dennis zhuang
 killme2...@gmail.com mailto:killme2...@gmail.com wrote:

 A little error in getting started missing :age


 |(render test.vm :name dennis :age 29)|


 2012/7/17 dennis zhuang killme2...@gmail.com
 mailto:killme2...@gmail.com

 Hi,all

 Apache velocity http://velocity.apache.org/**is a

 great java template engine used widely. I want to use
 it in clojure with compojure and ring framework,so
 i've created this project---ring.velocity.

 Home: 
 https://github.com/killme2008/**ring.velocityhttps://github.com/killme2008/ring.velocity
 Getting started:

 Adds dependency in leiningen project.clj:


 |   [ring.velocity 0.1.0-SNAPSHOT]
 |

 Create a directory named |templates| in your project
 directory to keep all velocity templates.

 Create a template |templates/test.vm|:


 |   hello,$name,your age is $age.
 |

 Use ring.velocity in your namespace:


 |   (use '[ring.velocity.core :only [render]])
 |

 Use |render| function to render template with vars:


 |   (render test.vm :name dennis 29)
 |

 The |test.vm| will be interpreted equals to:


 |   hello,dennis,your age is 29.
 |

 Use ring.velocity in compojure:


 |   (defroutes app-routes
   (GET / [] (render test.vm :name dennis :age
 29))
   (route/not-found Not Found))
 |

 Use ring.velocity in ring:


 |   (use '[ring.util.response])
(response (render test.vm :name dennis :age 29))
 |

 Custom velocity properties,just put a file named
 |ring-velocity.properties| to your classpath or
 resource paths.The default velocity properties is in
 src/default/velocity.**properties
 https://github.com/**killme2008/ring.velocity/blob/**
 master/src/default/velocity.**propertieshttps://github.com/killme2008/ring.velocity/blob/master/src/default/velocity.properties
 .


 --
 庄晓丹
 Email: killme2...@gmail.com
 mailto:killme2...@gmail.com xzhu...@avos.com
 mailto:xzhu...@avos.com
 Site: http://fnil.net http://fnil.net
 Twitter:  @killme2008






 --
 庄晓丹
 Email: killme2...@gmail.com mailto:killme2...@gmail.com
 xzhu...@avos.com mailto:xzhu...@avos.com
 Site: http://fnil.net http://fnil.net
 Twitter:  @killme2008







 --
 庄晓丹
 Email: killme2...@gmail.com mailto:killme2...@gmail.com
 xzhu...@avos.com mailto:xzhu...@avos.com
 Site: http://fnil.net http://fnil.net
 Twitter:  @killme2008







-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

Re: {ANN} clojure-control 0.4.1 released.

2012-07-18 Thread dennis zhuang
I see,thanks.

Pallet is more powerful than clojure-control.It seems that it contains many
features for cloud service rather than just a deployment tool.

And clojure-control is just a deployment tool like fabric in python for
many machines using SSH,it can reuse tasks and clusters,and have a simple
bash script to run them.


2012/7/18 Murtaza Husain murtaza.hus...@sevenolives.com


 http://palletops.com/


 On Wednesday, July 18, 2012 11:41:11 AM UTC+5:30, dennis wrote:

 I am sorry,i don't know pallet,any links? thanks.

 2012/7/18 Murtaza Husain 
 murtaza.husain@sevenolives.**commurtaza.hus...@sevenolives.com
 


 Hi,

 How is this different from pallet ?

 Thanks,
 Murtaza


 On Wednesday, July 18, 2012 10:52:57 AM UTC+5:30, dennis wrote:

 Clojure-control https://github.com/killme2008/clojure-control is a
 clojure tool library to execute user defined tasks on remote machines
 grouped into cluster just like fabric in python or node-control in node.js.

 *Home*: 
 https://github.com/**killm**e2008/clojure-controlhttps://github.com/killme2008/clojure-control

 Control 0.4.1 released,it has a little improvement in command line,
 introduced -f option to set control file,for example

control -f mycontrol.clj run mycluster mytask

 You can upgrade it by

control upgrade

 Thanks.

 --
 庄晓丹
 Email:killme2...@gmail.com xzhu...@avos.com
 Site:   http://fnil.net
 Twitter:  @killme2008



   --
 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+unsubscribe@**googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://groups.google.com/group/clojure?hl=en




 --
 庄晓丹
 Email:killme2...@gmail.com xzhu...@avos.com
 Site:   http://fnil.net
 Twitter:  @killme2008



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




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

Re: why does Clojure need to cache keywords?

2012-07-18 Thread dennis zhuang
Compare keywords can be very fast.
在 2012-7-18 PM4:51,jaime xiejianm...@gmail.com写道:

 Hello,

 When I read the source code keyword, say, Keyword.java (V1.3), I found
 that when we intern a keyword,   (if I understand it correctly)  it uses
 a cache for keywords:
 =
 public static Keyword intern(Symbol sym) {
 if (sym.meta() != null)
 sym = (Symbol) sym.withMeta(null);
 *Util.clearCache(rq, table);*
 Keyword k = new Keyword(sym);
 ReferenceKeyword existingRef = table.putIfAbsent(sym,
 new WeakReferenceKeyword(k, rq));
 if (existingRef == null)
 return k;
 Keyword existingk = existingRef.get();
 if (existingk != null)
 return existingk;
 // entry died in the interim, do over
 table.remove(sym, existingRef);
 return intern(sym);
 }
 ==

 well, I just don't understand why we need caching for keywords. Anyone
 could give me a hint?

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

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

Re: why does Clojure need to cache keywords?

2012-07-18 Thread dennis zhuang
I think this cache is just the same with String.intern method in java,it
just want to reduce the cost (memory  cpu) of producing keywords
frequently especial when using them with map structure.

2012/7/18 jaime xiejianm...@gmail.com

 I doubt because keyword will use its internal Symbol object to compare
 with each other (or other objects), it means it's Symbol's interned
 strings(ns  name) make the comparison fast but not this caching stuff. I
 found a find() method in source code but not sure if the cache is
 relevant to this method.

 在 2012年7月18日星期三UTC+8下午4时52分25秒,dennis写道:

 Compare keywords can be very fast.
 在 2012-7-18 PM4:51,jaime xiejianm...@gmail.com写道:

 Hello,

 When I read the source code keyword, say, Keyword.java (V1.3), I found
 that when we intern a keyword,   (if I understand it correctly)  it uses
 a cache for keywords:
 ==**===
 public static Keyword intern(Symbol sym) {
  if (sym.meta() != null)
 sym = (Symbol) sym.withMeta(null);
 *Util.clearCache(rq, table);*
  Keyword k = new Keyword(sym);
 ReferenceKeyword existingRef = table.putIfAbsent(sym,
  new WeakReferenceKeyword(k, rq));
 if (existingRef == null)
  return k;
 Keyword existingk = existingRef.get();
 if (existingk != null)
  return existingk;
 // entry died in the interim, do over
 table.remove(sym, existingRef);
  return intern(sym);
 }
 ==**

 well, I just don't understand why we need caching for keywords. Anyone
 could give me a hint?

 --
 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+unsubscribe@**googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://groups.google.com/group/clojure?hl=en

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




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

{ANN} ring.velocity: render apache velocity templates for ring in clojure.

2012-07-17 Thread dennis zhuang
Hi,all

Apache velocity http://velocity.apache.org/is a great java template
engine used widely. I want to use it in clojure with compojure and ring
framework,so i've created this project---ring.velocity.

Home: https://github.com/killme2008/ring.velocity
Getting started:

  Adds dependency in leiningen project.clj:

  [ring.velocity 0.1.0-SNAPSHOT]

Create a directory named templates in your project directory to keep all
velocity templates.

Create a template templates/test.vm:

  hello,$name,your age is $age.

Use ring.velocity in your namespace:

  (use '[ring.velocity.core :only [render]])

Use render function to render template with vars:

  (render test.vm :name dennis 29)

The test.vm will be interpreted equals to:

  hello,dennis,your age is 29.

Use ring.velocity in compojure:

  (defroutes app-routes
 (GET / [] (render test.vm :name dennis :age 29))
 (route/not-found Not Found))

Use ring.velocity in ring:

  (use '[ring.util.response])
  (response (render test.vm :name dennis :age 29))

Custom velocity properties,just put a file named ring-velocity.properties to
your classpath or resource paths.The default velocity properties is in
src/default/velocity.propertieshttps://github.com/killme2008/ring.velocity/blob/master/src/default/velocity.properties
.

-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

Re: {ANN} ring.velocity: render apache velocity templates for ring in clojure.

2012-07-17 Thread dennis zhuang
A little error in getting started missing :age

(render test.vm :name dennis :age 29)


2012/7/17 dennis zhuang killme2...@gmail.com

 Hi,all

 Apache velocity http://velocity.apache.org/is a great java template
 engine used widely. I want to use it in clojure with compojure and ring
 framework,so i've created this project---ring.velocity.

 Home: https://github.com/killme2008/ring.velocity
 Getting started:

   Adds dependency in leiningen project.clj:

   [ring.velocity 0.1.0-SNAPSHOT]

 Create a directory named templates in your project directory to keep all
 velocity templates.

 Create a template templates/test.vm:

   hello,$name,your age is $age.

 Use ring.velocity in your namespace:

   (use '[ring.velocity.core :only [render]])

 Use render function to render template with vars:

   (render test.vm :name dennis 29)

 The test.vm will be interpreted equals to:

   hello,dennis,your age is 29.

 Use ring.velocity in compojure:

   (defroutes app-routes
  (GET / [] (render test.vm :name dennis :age 29))
  (route/not-found Not Found))

 Use ring.velocity in ring:

   (use '[ring.util.response])
   (response (render test.vm :name dennis :age 29))

 Custom velocity properties,just put a file named ring-velocity.properties to
 your classpath or resource paths.The default velocity properties is in
 src/default/velocity.propertieshttps://github.com/killme2008/ring.velocity/blob/master/src/default/velocity.properties
 .

 --
 庄晓丹
 Email:killme2...@gmail.com xzhu...@avos.com
 Site:   http://fnil.net
 Twitter:  @killme2008






-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

Re: {ANN} ring.velocity: render apache velocity templates for ring in clojure.

2012-07-17 Thread dennis zhuang
其实就是几行代码封装下,我觉的velocity比什么enlive好用多了。

2012/7/18 Shen, Feng shen...@gmail.com

 不错不错。
 velocity 在java中用得较广。
 这样为potential 的 clojure用户铺了一下道路。

 沈锋
 美味书签 http://meiwei.fm http://mei.fm



 On Wed, Jul 18, 2012 at 12:00 AM, dennis zhuang killme2...@gmail.comwrote:

 A little error in getting started missing :age

 (render test.vm :name dennis :age 29)


 2012/7/17 dennis zhuang killme2...@gmail.com

 Hi,all

 Apache velocity http://velocity.apache.org/is a great java
 template engine used widely. I want to use it in clojure with compojure and
 ring framework,so i've created this project---ring.velocity.

 Home: https://github.com/killme2008/ring.velocity
 Getting started:

   Adds dependency in leiningen project.clj:

   [ring.velocity 0.1.0-SNAPSHOT]

 Create a directory named templates in your project directory to keep
 all velocity templates.

 Create a template templates/test.vm:

   hello,$name,your age is $age.

 Use ring.velocity in your namespace:

   (use '[ring.velocity.core :only [render]])

 Use render function to render template with vars:

   (render test.vm :name dennis 29)

 The test.vm will be interpreted equals to:

   hello,dennis,your age is 29.

 Use ring.velocity in compojure:

   (defroutes app-routes
  (GET / [] (render test.vm :name dennis :age 29))
  (route/not-found Not Found))

 Use ring.velocity in ring:

   (use '[ring.util.response])
   (response (render test.vm :name dennis :age 29))

 Custom velocity properties,just put a file named
 ring-velocity.properties to your classpath or resource paths.The
 default velocity properties is in 
 src/default/velocity.propertieshttps://github.com/killme2008/ring.velocity/blob/master/src/default/velocity.properties
 .

 --
 庄晓丹
 Email:killme2...@gmail.com xzhu...@avos.com
 Site:   http://fnil.net
 Twitter:  @killme2008






 --
 庄晓丹
 Email:killme2...@gmail.com xzhu...@avos.com
 Site:   http://fnil.net
 Twitter:  @killme2008







-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

{ANN} clojure-control 0.4.1 released.

2012-07-17 Thread dennis zhuang
Clojure-control https://github.com/killme2008/clojure-control is a
clojure tool library to execute user defined tasks on remote machines
grouped into cluster just like fabric in python or node-control in node.js.

*Home*: https://github.com/killme2008/clojure-control

Control 0.4.1 released,it has a little improvement in command line,
introduced -f option to set control file,for example

   control -f mycontrol.clj run mycluster mytask

You can upgrade it by

   control upgrade

Thanks.

-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

Re: Why :inline have to define the function twice?

2012-07-16 Thread dennis zhuang
Yes, thank you for your reply,i total agree with you about why we need
:inline form in meta map.
But my problem is that why clojure compiler could not use the body form as
the :inline value automatically for us instead of writing a duplicate form?
I think below codes is more suitable:

(defn pos?

  Returns true if num is greater than zero, else false

  {

   :inline true

   :added 1.0}

  [x] (. clojure.lang.Numbers (isPos x)))


Then clojure compiler finds out that we set :inline to be true and captures
the body form as the :inline value automatically,is it not better?

If the function accepts different arguments arities, we can set
:inline-arities value to make compiler captures the body form  which
arguments count equals to :inline-arities value as :inline value.



2012/7/16 Aaron Cohen aa...@assonance.org

 My guess: to allow functions with :inline metadata to still be used as
 higher order (first class) functions.

 Note, the fn specified by :inline is more of a macro than a function, it's
 called at compile time.

 How would the following work without a function body?

 (map pos? [-1 0 1])

 definline gives you what you're asking for, a way to define an :inline
 function without repetition.

 --Aaron

 On Sun, Jul 15, 2012 at 10:43 PM, dennis zhuang killme2...@gmail.comwrote:

 Inline a function in clojure is easy,just define a :inline form to meta
 map and it will be inlined into the form which calls it.For example,the
 pos? function in clojure.core:

 (defn pos?

   Returns true if num is greater than zero, else false

   {

:inline (fn [x] *`(. clojure.lang.Numbers (isPos ~x))*)

:added 1.0}

   [x] *(. clojure.lang.Numbers (isPos x))*)


 But i have a question about the usage,why we have to write the body
 form(Here is *(. clojure.lang.Numbers (isPos ~x))*) twice both in
 function's body and :inline value? Why :inline form could not just use the
 form in function's body instead of duplicate definition?


 --
 庄晓丹
 Email:killme2...@gmail.com xzhu...@avos.com
 Site:   http://fnil.net
 Twitter:  @killme2008



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


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




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

Re: Why :inline have to define the function twice?

2012-07-16 Thread dennis zhuang
Thanks.
Yeath,i know the defline macro,and it is the best way to define inline
function.I got your point,thanks.

2012/7/17 Aaron Cohen aa...@assonance.org

 On Mon, Jul 16, 2012 at 11:26 AM, dennis zhuang killme2...@gmail.com
 wrote:
 
  Yes, thank you for your reply,i total agree with you about why we need
 :inline form in meta map.
  But my problem is that why clojure compiler could not use the body form
 as the :inline value automatically for us instead of writing a duplicate
 form? I think below codes is more suitable:

  (defn pos?
Returns true if num is greater than zero, else false
{
 :inline true
 :added 1.0}
[x] (. clojure.lang.Numbers (isPos x)))
 
 
  Then clojure compiler finds out that we set :inline to be true and
 captures the body form as the :inline value automatically,is it not better?
 
  If the function accepts different arguments arities, we can set
 :inline-arities value to make compiler captures the body form  which
 arguments count equals to :inline-arities value as :inline value.
 

 As I said, that's precisely what definline does. As many things in
 clojure, the simple pieces are given and easy things can be built on
 top of them. I don't know precisely when in clojure.clj that pos? is
 defined, but if it is late enough that definline has been defined,
 it could be rewritten as:

 (definline pos?
 Returns true if num is greater than zero, else false
 {:added 1.0}
[x] `(. clojure.lang.Numbers (isPos x)))

 Which is pretty much what you asked for, isn't it?

 The fact that it isn't written that way is either historical or
 because it needs to exist before definline does.

 --Aaron

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




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

Re: Buggy FP behavior with Clojure 1.3

2012-06-25 Thread dennis zhuang
user= Double/MAX_VALUE
1.7976931348623157E308


2012/6/26 Sean Corfield seancorfi...@gmail.com

 On Mon, Jun 25, 2012 at 9:19 PM, Cedric Greevey cgree...@gmail.com
 wrote:
  user= 1e309
  Infinity

 FWIW, on 1.4.0 I get:

 user= 1e309
 CompilerException java.lang.RuntimeException: Unable to resolve
 symbol: Infinity in this context, compiling:(NO_SOURCE_PATH:1)
 --
 Sean A Corfield -- (904) 302-SEAN
 An Architect's View -- http://corfield.org/
 World Singles, LLC. -- http://worldsingles.com/

 Perfection is the enemy of the good.
 -- Gustave Flaubert, French realist novelist (1821-1880)

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




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

Re: Buggy FP behavior with Clojure 1.3

2012-06-25 Thread dennis zhuang
Added a postfix M to make the number as BigDecimal or N as a BigInteger:

user= 1e308M
1E+308M
user= (class 1e308M)
java.math.BigDecimal
user= (* 10.0 1e108M)
1.0E109

2012/6/26 Cedric Greevey cgree...@gmail.com

 On Tue, Jun 26, 2012 at 1:11 AM, Sean Corfield seancorfi...@gmail.com
 wrote:
  On Mon, Jun 25, 2012 at 9:19 PM, Cedric Greevey cgree...@gmail.com
 wrote:
  user= 1e309
  Infinity
 
  FWIW, on 1.4.0 I get:
 
  user= 1e309
  CompilerException java.lang.RuntimeException: Unable to resolve
  symbol: Infinity in this context, compiling:(NO_SOURCE_PATH:1)

 That's *really* broken.

 Unfortunately, digging deeper I found that the 1023 exponent limit is
 2^1023, not 10^1023, which means it really is around 309. I've had to
 reimplement some stuff using BigDecimals and to write these, since
 there seem to be no corresponding methods built into Java anywhere:

 (defn log [x]
   (if (instance? BigDecimal x)
 (let [s (.scale x)]
   (+ (Math/log (.scaleByPowerOfTen x s)) (* (- s) (Math/log 10.0
 (Math/log x)))

 (defn log10 [x]
   (/ (log x) (Math/log 10.0)))

 (defn exp [x]
   (let [r (Math/exp x)]
 (if (.isInfinite r)
   (let [p10 (int (/ x (Math/log 10.0)))]
   (.scaleByPowerOfTen (bigdec (Math/exp (- x (* p10 (Math/log
 10.0) p10))
   r)))

 These seem to work fine, where extended precision isn't really needed,
 only large exponents. However, I've run into another problem, which is
 that when doubles and BigDecimals mix 1.3 seems to convert to doubles.
 This appears to contradict part of

 http://dev.clojure.org/display/doc/Documentation+for+1.3+Numerics

 specifically When different types of numbers are used in a math
 operation, the result will be the larger or more general of the two
 types.

 That doesn't seem to hold when the types are double and BigDecimal,
 for some reason. Is there any setting I can change (analogous to
 with-precision) to force BigDecimal contagion? I considered using
 those icky primed operators, but for some reason /' seems to be
 missing from the set and I need division...

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




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

{ANN} clj.monitor: monitoring applications in clojure

2012-05-12 Thread dennis zhuang
Hi,all

I've implemented a simple DSL for monitoring apps in clojure based on
SSH.

Usage:  goog_1871645686https://github.com/killme2008/clj.monitor
An example:

  (defcluster mysql
:clients [{:user deploy :host mysql.app.com}])
  (defmonitor mysql-monitor
 ;;Tasks to monitor mysql,we just ping mysql and make sure that
average load in 5 minutes is less than 3
 :tasks [(ping-mysql root password)
 (system-load :5 3)]
 ;;Mysql clusters for monitoring
 :clusters [:mysql])

   (start-monitors
 :cron * 0/5 * * * ? ;;run monitors every five
minutes.
 :alerts [(mail :from al...@app.com :to yourn...@app.com)]
;;send alerts to email address.
 :monitors [mysql-monitor])

Now it is just a beta release, if you have any questions or find
issues,please let me know,thanks.




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

Re: {ANN} Clojure-control 0.3.4 released

2012-05-10 Thread dennis zhuang
*A new release 0.3.5:*

--Now you can run a task with user@host rather than a pre-defined cluster
by:

  lein control run user@host task args

*Upgrade:*

   lein plugin install control 0.3.5



2012/5/10 dennis zhuang killme2...@gmail.com

 Clojure-control:  a clojure DSL for system admin and deployment with many
 remote machines via ssh

 Usage: https://github.com/killme2008/clojure-control

 *Release 0.3.4*

 - New function (local cmd) to execute command on local machine : (local
 tar zcvf app.tar.gz app/)
 - Custer name could be a symbol rather than keyword
 - (set-options!) now could accept several options: (set-options! :user
 deploy :parallel true)
 - New function (clear-options!) to clear global options.
 - Using host and user of cluster in task by host and user :
  (deftask test [] (println (str user @ host)))
 *
 *
 *Upgrade:*

lein plugin install control 0.3.4


 --
 庄晓丹
 Email:killme2...@gmail.com xzhu...@avos.com
 Site:   http://fnil.net
 Twitter:  @killme2008






-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

Re: {ANN} Clojure-control 0.3.4 released

2012-05-10 Thread dennis zhuang
I am sorry, 0.3.5 will break the example with only :clients in cluster.
I've push 0.3.6 to clojars, upgrade control by:

  lein plugin install control 0.3.6

Sorry for this issue,thanks.

2012/5/11 Rostislav Svoboda rostislav.svob...@gmail.com

 I took the steps from your README.md and it seems like something's
 missing :( see below

 Bost

 bost@bost-desktop:~/dev$ rm -rf mycontrol/
 bost@bost-desktop:~/dev$ lein1 version
 Leiningen 1.7.1 on Java 1.7.0_04 Java HotSpot(TM) Client VM
 bost@bost-desktop:~/dev$ lein1 plugin install control 0.3.5
 [INFO] Unable to find resource 'control:control:jar:0.3.5' in
 repository central (http://repo1.maven.org/maven2)
 Installing shell wrapper to /home/bost/.lein/bin/clojure-control
 Copying 2 files to /tmp/lein-f0119cb7-6660-4181-aeed-149113f38fc1/lib
 Including control-0.3.5.jar
 Including clojure-1.3.0.jar
 Including tools.cli-0.2.1.jar
 Created control-0.3.5.jar
 bost@bost-desktop:~/dev$ lein1 new mycontrol
 Created new project in: /home/bost/dev/mycontrol
 Look over project.clj and start coding in mycontrol/core.clj
 bost@bost-desktop:~/dev$ cd mycontrol/
 bost@bost-desktop:~/dev/mycontrol$ lein1 control init
 bost@bost-desktop:~/dev/mycontrol$ cat
 classes/ control.clj  .gitignore   project.clj  README   src/
   test/
 bost@bost-desktop:~/dev/mycontrol$ cat control.clj
 (defcluster :default-cluster
  :clients [
{:host localhost :user root}
  ])

 (deftask :date echo date on cluster  []
  (ssh date))
 bost@bost-desktop:~/dev/mycontrol$ lein1 control run default-cluster date
 Empty hosts for cluster default-cluster
 Exception in thread main java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at jline.ConsoleRunner.main(ConsoleRunner.java:69)
 Caused by: java.lang.RuntimeException: Empty hosts for cluster
 default-cluster (NO_SOURCE_FILE:0)
at clojure.lang.Compiler.eval(Compiler.java:5440)
at clojure.lang.Compiler.eval(Compiler.java:5391)
at clojure.core$eval.invoke(core.clj:2382)
at clojure.main$eval_opt.invoke(main.clj:235)
at clojure.main$initialize.invoke(main.clj:254)
at clojure.main$script_opt.invoke(main.clj:270)
at clojure.main$main.doInvoke(main.clj:354)
at clojure.lang.RestFn.invoke(RestFn.java:551)
at clojure.lang.Var.invoke(Var.java:390)
at clojure.lang.AFn.applyToHelper(AFn.java:193)
at clojure.lang.Var.applyTo(Var.java:482)
at clojure.main.main(main.java:37)
... 5 more
 Caused by: java.lang.RuntimeException: Empty hosts for cluster
 default-cluster
at control.core$do_begin.invoke(core.clj:353)
at leiningen.control$run_control.invoke(control.clj:30)
at leiningen.control$run.doInvoke(control.clj:97)
at clojure.lang.RestFn.applyTo(RestFn.java:139)
at clojure.core$apply.invoke(core.clj:542)
at leiningen.control$control.doInvoke(control.clj:136)
at clojure.lang.RestFn.invoke(RestFn.java:464)
at clojure.lang.Var.invoke(Var.java:377)
at clojure.lang.AFn.applyToHelper(AFn.java:172)
at clojure.lang.Var.applyTo(Var.java:482)
at clojure.core$apply.invoke(core.clj:542)
at leiningen.core$apply_task.invoke(core.clj:262)
at leiningen.core$_main.doInvoke(core.clj:329)
at clojure.lang.RestFn.applyTo(RestFn.java:139)
at clojure.core$apply.invoke(core.clj:542)
at leiningen.core$_main.invoke(core.clj:332)
at user$eval42.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:5424)
... 16 more

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




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

{ANN} Clojure-Control 0.3.3 release

2012-04-30 Thread dennis zhuang
Clojure-control:  a clojure DSL for system admin and deployment with many
remote machines via ssh

Usage: https://github.com/killme2008/clojure-control

*Release 0.3.3*

- New function (set-options! key value) to set global options,include keys
:ssh-options,:scp-options,:rsync-options and :user for all cluster.
-Task name could be a symbol rather than keyword
- Improve documents and leiningen plugin commands.
- Other small changes.

*Upgrade:*

   lein plugin install control 0.3.3



-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

Re: Inconsistent refs within an STM transaction.

2012-04-16 Thread dennis zhuang
Hi

  Transaction read point is changed every time when transaction is
started or retried.So the result is all right.If you want the ref1 cloud
not be modified by other transactions ,you can use ensure:

(defn deref-delay-deref [ref1 ref2 delay]
(.start
   (Thread.
  #((println READ start)
(dosync
 (println transaction starting)
* (ensure ref1)*
  (let [a @ref2]
 (Thread/sleep delay)
 (println S r1= @ref1))) ; should be consistent with
@ref2
(println READ end)

2012/4/17 Herwig Hochleitner hhochleit...@gmail.com

  So if you create 2 refs and then read them in a transaction they could be
  inconsistent with each other. i.e they won't necessarily return the value
  the ref had at the start of the transaction.
 
  However, if you give the refs some history by updating them in a prior
  transaction, then the two refs will be consistent with each other in
  subsequent transactions.
 
  This seems rather dangerous to me. Is there a rational for not creating
 at
  least 1 history entry for a ref at ref creation time.

 I haven't looken into your examples in detail, but clojure has
 http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/ensure
 to get consistent reads.

 I don't know exactly why read skew is allowed by default. Maybe it's
 along the lines of: If reads were consistent by default, performance
 would suffer and write skew would still be possible (which can be
 prevented by (ref-set ref @ref))

 kind regards

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




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

Re: question about partial

2012-04-16 Thread dennis zhuang
user= (defn f[x y] (+ x y))
#'user/f
user= (- 3 ((partial f 2)))
5

It must works :). Please notice the extra parentheses.

2012/4/17 larry larrye2...@gmail.com



 On Monday, April 16, 2012 10:02:48 AM UTC-7, Cedric Greevey wrote:

 (- 3 ((partial f 2))) should also work.



 I just wrote that it DOESN'T WORK. That's the point of the question.I
 should get 5 instead I get
 t#core$partial$fn__3796 clojure.core$partial$fn__3796@4c629f43


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




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

Re: seeking a lazy way to interleave a constant

2012-04-09 Thread dennis zhuang
D o you want this?
user= (def x (interleave (iterate inc 1) (repeat 0)))
#'user/x
user= (take 10 x)
(1 0 2 0 3 0 4 0 5 0)

2012/4/10 Andrew ache...@gmail.com

 Given a lazy sequence of numbers is there a way to interleave a constant
 and get another lazy sequence? Say the first sequence is 1 2 3 4 ... I'd
 like the second sequence to be 1 0 2 0 3 0 4 0 

 Thanks in advance!

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




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

{ANN}Clojure-Control 0.3.2 is out

2012-03-24 Thread dennis zhuang
Hi,all
   I am pleased to announce that clojure-control 0.3.2 is
out.Clojure-control is a clojure DSL for system admin and deployment with
many remote machines via ssh.Please see
https://github.com/killme2008/clojure-control

   Main highlights in 0.3.2:
1.You can include other clusters in defcluster,for example,you have defined
cluster named frontend and backend,then you can define a new cluster
named all to include all of them:

  (defcluster :all
  :includes [:frontend :backend])

2.Fixed issue 11: control could not run on some jdk version.
3.Adds new commands for lein control plugin,you can start a control server
by lein control server,then you don't have to compile control file every
time when running task,you can run task by lein control run mycluster task
-r,it will connect to control server and run the task on server,returns
result to client at last.
4.Improve api document.

You can upgrade control by lein plugin install control 0.3.2 and change
the dependency version in project.clj.



--
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

Re: Clojure Toolbox

2012-03-24 Thread dennis zhuang
Another link http://cnlojure.org/open.html

2012/3/24 Rostislav Svoboda rostislav.svob...@gmail.com

 A nice list of tools and libraries I stumbled upon. Enjoy!

 http://www.clojure-toolbox.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




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

Re: Parallel SSH and system monitoring in Clojure

2012-03-15 Thread dennis zhuang
There is a clojure-control:
https://github.com/killme2008/clojure-control

2012/3/16 Chris McBride cmm7...@gmail.com

 Hi,

   I releases two simple clojure libraries to help running commands
 via SSH on multiple servers. Hopefully someone will find it useful.


 http://info.rjmetrics.com/blog/bid/54114/Parallel-SSH-and-system-monitoring-in-Clojure
   https://github.com/RJMetrics/Parallel-SSH
   https://github.com/RJMetrics/Server-Stats

 Best,
 Chris McBride

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




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

{ANN} Clojure-Control 0.3.0 is out

2012-02-18 Thread dennis zhuang
Hi,all
Clojure-control https://github.com/killme2008/clojure-control is a
clojure DSL for system admin and deployment with many remote machines via
ssh.
I am pleased to annoucment that clojure-control 0.3.0 is out.It adds
some  powerful features in this release ,includes:

   - ssh and scp both have a new option :sudo  to be executed as root on
   remote machines,for example:

   (ssh /etc/init.d/ssh restart :sudo true)

   - scp has a new  option :mode to change file modes copied from local:

   (scp start.sh /etc/init.d/start.sh :sudo true :mode 755)

   - A  new function exists? to test if a file exists on remote
   machines:

   (if (not (exists? (str /home/deploy/.ssh)))
 (ssh (sudo (str mkdir -p /home/deploy/.ssh

   - Call other task in deftask with call function:

   (deftask :ps A task to grep process [process]
   (ssh (str ps aux | grep  process)))
   (deftask :start_ha []
   (ssh /etc/init.d/haproxy start)
   (call :ps haproxy))

   - A new function append to append a line to a file on remote machines:

   (ssh (append /etc/hosts 192.168.1.100 web :sudo true))

   - A new function sed to replace lines in a file on remote machines,and
   comm/uncomm to comment/uncomment a line in a file:

(sed file before after :flags flags :limit limit :backup backup)

   Equivalent to

sed -ibackup -r -e limit s/before/after/flagsg filename

   -

   Limits max output line to 1.

   -

   Adds more documents in wiki:
https://github.com/killme2008/clojure-control/wiki goog_909345399



You can install the new version by :

lein plugin install control 0.3.0   #For clojure 1.3
lein plugin install control 0.3.1   #For clojure 1.2

More information please visit it on github:
https://github.com/killme2008/clojure-control

And wiki: https://github.com/killme2008/clojure-control/wiki
goog_909345399  ../../../




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

Re: Problem with amap over byte arrays

2012-02-16 Thread dennis zhuang
Because bit-xor returns a integer,so you have to cast it to byte:

(amap ^bytes an-array
 idx
 ret
 (byte (bit-xor (byte 0)
(aget ^bytes an-array idx

2012/2/17 Andreas Kostler andreas.koestler.le...@gmail.com

 Hi all,
 I'm experiencing the following problem:

 (def an-array (byte-array 200 (byte 1)))
 (amap ^bytes an-array
  idx
  ret
  (bit-xor (byte 0)
 (aget ^bytes an-array idx)))

 Resulting in:

 No matching method found: aset

 Wheras this:

 (def another-array (int-array 200 (int 1)))
 (amap ^ints an-array
  idx
  ret
  (bit-xor (int 0)
 (aget ^ints another-array idx)))

 Works as expected. Does anyone know what's going on?
 Clojure version is 1.3.0

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




-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

{ANN} clojure-control 0.2.4 is out

2012-02-13 Thread dennis zhuang
Hi,all

Clojure-control is a clojure DSL for system admin and deployment with
many remote machines via ssh,and i have checked out a branch to make it
work with clojure 1.3 now. At last, control 0.2.4 works well with clojure
1.3,and 0.2.3 works well with clojure 1.2:

:dev-dependencies [[control 0.2.3]]   ; clojure 1.2
:dev-dependencies [[control 0.2.4]]   ; clojure 1.3

More information please visit the project home:

https://github.com/killme2008/clojure-control

-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

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

Re: Sorry Don't understand for macro, a bug or a newbie-question??

2012-01-18 Thread dennis zhuang
for returns a lazy sequence.You may prefer doseq:
(defn fortest2 []
 (doseq [a (range 2 10)
 b (range 2 10)]
   (do
 (println x:  a  b: b)
 (list a b)))
 (println ende)
 )
(fortest2)

doseq will be forced for side-effects.

2012/1/19 Jack Moffitt j...@metajack.im

  doesn't show any effect of the for.
  The only difference is the additional statement at the end.
  I can not imagine how this statement sequentially behind can influence
  the for.

 for returns a lazy sequence. In the first case, in printing out the
 result to the REPL, the lazy sequence is realized, and in the second,
 the result is discarded so it is never realized.

 jack.

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




-- 
庄晓丹
Email:killme2...@gmail.com
伯岩(花名)  bo...@taobao.com
Site:   http://fnil.net

淘宝(中国)软件有限公司 / 产品技术部 / Java中间件

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

Re: A STM profile tool

2012-01-16 Thread dennis zhuang
hi,all
I've upgraded the version to 1.0.1-SNAPSHOT.
And added a new function ref-stats to get the statistics information of a
reference.For example:

=(use'stm)
=(def a (ref 1))
=(def b (ref 2))
=(dotimes [_ 100] (future (dosync (alter a + 1) (alter b - 1

=@a
101
=@b
-98

=(stm-stats)
{(alter a + 1)(alter b - 1) {:not-running 9, :average-retry 15,
:total-cost 3048, :get-fault 52, :barge-fail 372, :change-committed 1064,
:total-times 100, :average-cost 30}}

=(ref-stats a)
{(alter a + 1)(alter b - 1) {:alter 1601, :get-fault 52, :barge-fail 372,
:change-committed 1064}}

We can get a detail information of a reference involed in a tranaction.The
:alter means it was invoked with alter 1601 times including retry times.
:get-fault means we can't get a committed value before the transaction read
point,so we have to retry it. :change-commited means that other transaction
has commited a new value of this reference before our transaction,so we
have to retry it again. :barge-fail means we wanted to barge other
transaction,but we failed,we still have to retry the transaction.

2012/1/16 Jonathan Cardoso jonathancar...@gmail.com

 Interesting!

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




-- 
庄晓丹
Email:killme2...@gmail.com
伯岩(花名)  bo...@taobao.com
Site:   http://fnil.net

淘宝(中国)软件有限公司 / 产品技术部 / Java中间件

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

Re: converting a string to a list

2012-01-14 Thread dennis zhuang
You can do this
 ((comp #(map str %) seq) abcdef)
(a b c d e f)

2012/1/15 Bruce Durling b...@otfrom.com

 Sam,

 Strings can be turned into sequences with seq.

  (seq foo)
 (\f \o \o)

 The backslashes are because f o and o are character literals.

 cheers,
 Bruce

 On Sat, Jan 14, 2012 at 10:13, Samuel Lê samuel...@gmail.com wrote:
  Hi,
 
  I was wondering if there was a function to convert a list into a string,
  something like:
  (string-to-list abcde)   ;; (a b c d e)
 
  thanks!
 
  Sam
 
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clojure@googlegroups.com
  Note that posts from new members are moderated - please be patient with
 your
  first post.
  To unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en

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




-- 
庄晓丹
Email:killme2...@gmail.com
伯岩(花名)  bo...@taobao.com
Site:   http://fnil.net

淘宝(中国)软件有限公司 / 产品技术部 / Java中间件

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

Re: A memcached client for clojure wrapping xmemcached

2011-10-29 Thread dennis zhuang
An example with more detail is on

https://github.com/killme2008/clj-xmemcached/blob/master/example/demo.clj


2011/10/29 dennis killme2...@gmail.com

 Hi,all

 I wrote a memcached client for clojure wrapping xmemcached.Xmemcached
 is an opensource high performance memcached client for java.

  It's name is clj-xmemcached,and it is on github

 https://github.com/killme2008/clj-xmemcached

 A basic example:

 (ns demo
  (:use [clj-xmemcached.core]))

 (def client (xmemcached localhost:12000))
 (xset client key value)
 (prn (xget client key))
 (xcas client key #(str %  update))
 (xshutdown client)

 More detail please visit the github homepage.





-- 
庄晓丹
Email:killme2...@gmail.com
伯岩(花名)  bo...@taobao.com
Site:   http://fnil.net

淘宝(中国)软件有限公司 / 产品技术部 / Java中间件

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