hash function behaves different with empty vector in clojure and clojurescript

2015-01-05 Thread Feng Xue
 

These days, I was trying to utilize function hash in clojure/clojurescript 
to generate unique id, but it turns out this function has very strange 
behaviour to empty vector parsed from read-string in cljs with in clj.

In clojure, hash function return -2017569654 for empty vector and the one 
parsed from read-string

user=> (hash [])-2017569654
user=> (hash (read-string "[]"))-2017569654

However, in cljs, (hash []) returns surprisingly 0. And [] are also equal 
to (read-string "[]").

cljs.user=> (hash (cljs.reader/read-string "[]"))-2017569654

cljs.user=> (hash [])0

cljs.user=> (= [] (cljs.reader/read-string "[]"))
true

Does any one know the reason of it and how to solve it in cljs?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 web server benchmarks

2014-01-14 Thread Shen, Feng
Hi,  nginx-clojure looks great!

A small tip: ab may not be the best tool, since it's single threaded.   A
better tool is wrk:  https://github.com/wg/wrk

You can use wrk to better test nginx-clojure,  It should perform even
better than others.




沈锋
http://shenfeng.me


On Tue, Jan 14, 2014 at 5:26 PM, Peter Taoussanis wrote:

> Oh wow, that's fantastic!
>
> For those watching: Xfeep's fixed a number of config issues, updated all
> the servers, and completely updated the chart.
>
> Absolutely well worth a look if you're interested in Clojure web server
> performance.
>
> * Results are here:
> https://github.com/ptaoussanis/clojure-web-server-benchmarks
> * His GitHub page: https://github.com/xfeep
> * His nginx/clojure lib: https://github.com/xfeep/nginx-clojure
>
> Cheers! :-)
>
> --
> *Peter Taoussanis*
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from 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/UrRLCdex7d4/unsubscribe.
> To unsubscribe from this group and all its topics, 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: Nginx-Clojure Let You Deploy Clojure Web App on Nginx Without Any Java Web Server

2014-01-14 Thread Feng Shen
Hi, 

Thanks for your work on nginx-clojure. It looks great!  

As I know Nginx spawns many processes(correct me if I am wrong),  does that 
mean, there will be many JVM process?




On Tuesday, January 14, 2014 4:44:18 PM UTC+8, Xfeep Zhang wrote:
>
>
> I have done the first one. The result is 
> HERE( 
> https://github.com/ptaoussanis/clojure-web-server-benchmarks )
> Thanks Taoussanis for his invitation to the project 
> clojure-web-server-benchmarkshosted
>  on Github.
>
> On Tuesday, January 14, 2014 10:31:03 AM UTC+8, Xfeep Zhang wrote:
>>
>> You're welcome.
>>
>> I think there are several difficult phases :
>>
>> (1)  update the test program in 
>> clojure-web-server-benchmarks,
>>  make the some packages to be the latest. (eg. http-kit from 1.3.0-alpha2 
>> --> 2.1.16) and add nginx-php testing
>> (2)  test about real world size contents by group eg. tiny, small, 
>> medium, huge. 
>> (3)  test about real world connection circumstances where a lot of 
>> connection is inactive but keep open.
>> (4)  try some real asynchronous test to fetch external resources (eg. 
>> rest service , db) before response to the client. eg.  using 
>> libdrizzlea no-blocking mysql  client from  
>> https://launchpad.net/drizzle
>>
>> On Tuesday, January 14, 2014 2:41:50 AM UTC+8, Sergey Didenko wrote:
>>>
>>> Looks very interesting, thank you for your work!
>>>
>>> I wonder how this is going to improve latency in comparison to nginx + 
>>> http-kit for some real world test that is not using heavy DB operations.
>>>
>>>
>>> On Mon, Jan 13, 2014 at 5:57 AM, Xfeep Zhang  wrote:
>>>

 So far I have found why nginx-clojure is slower than http-kit when 
 1 concurrents. (when < = 1000 concurrents nginx-clojure is faster than 
 http-kit.)
 I have set too many connections per nginx worker (worker_connections = 
 2) . This make nginx only use one worker to handle ab  requests (every 
 request is tiny).
 I plan to take note of 
 c-erlang-java-performanceand
  fork 
 clojure-web-server-benchmarksto
   do some  real world tests.



 On Sunday, January 12, 2014 11:21:06 PM UTC+8, Xfeep Zhang wrote:
>
> Sorry for my mistake!
>
> 1. In the static file test, the ring-jetty result is about 10 
> concurrents. NOT 1 concurrents  ("Concurrency Level:  10" in  the 
> ab report ).
> 2. In the small string test, All results about three server are about 
> 10 concurrents. NOT 1 concurrents.
>
> There are right results about these two mistake :
>
> 1. static file test
>
> (3) ring-jetty  more bad than 10 concurrents
> 
> ===
> Document Path:  /
> Document Length:29686 bytes
>
> *Concurrency Level:  1*
> Time taken for tests:   6.303 seconds
> Complete requests:  10
> Failed requests:0
> Write errors:   0
> Total transferred:  298220 bytes
> HTML transferred:   296860 bytes
> Requests per second:15864.43 [#/sec] (mean)
> Time per request:   630.341 [ms] (mean)
> Time per request:   0.063 [ms] (mean, across all concurrent 
> requests)
> Transfer rate:  462020.65 [Kbytes/sec] received
>
> Connection Times (ms)
>   min  mean[+/-sd] median   max
> Connect:   12  328 535.0 433041
> Processing:25  124 112.9 963523
> Waiting:8   47  99.4 283523
> Total: 52  452 544.51574546
>
> Percentage of the requests served within a certain time (ms)
>   50%157
>   66%305
>   75%   1071
>   80%   1102
>   90%   1139
>   95%   1155
>   98%   1462
>   99%   3100
>  100%   4546 (longest request)
>
>
> 2. simple string (1 concurrents)
>
> http-kit is the fastest.  But nginx-clojure is too young and has vast 
> room for growth :)
>
> (1) nginx-clojure-0.1.0
>
> Document Path:  /
> Document Length:15 bytes
>
> *Concurrency Level:  1*
> Time taken for tests:   2.834 seconds
> Complete requests:  10
> Failed requests:0
> Write errors:   0
> Total transferred:  1700 bytes
> HTML transferred:   150 bytes
> Requests per second:35291.16 [#/sec] (mean)
> Time per request:   283.357 [ms] (mean)
> Time per request:   0.028 [ms] (mean, across all concurrent 
> requests)
> Transf

http-kit 2.1.16: bug fixes, new features

2014-01-03 Thread Shen, Feng
Hi,

[http-kit "2.1.16"]



Change log: https://github.com/http-kit/http-kit/blob/master/history.md

2.1.16 (2014/1/3)

HTTP Client: follow 301, 302, 303, 307, 308 properly (thanks paulbutcher)
 2.1.15
(2014/1/1)

HTTP client:

   1. New feature: support automatically follow redirects
   2. New feature: support multipart/form-data file upload

 
2.1.14
(2013/12/23)

HTTP client: Fix #98 Strange timeout bug: SocketChannel.connect() may
return true if the connection is established immediately, then the
OP_CONNECT event will not be tiggered again. (thanks @cannedprimates)
 
2.1.13
(2013/10/19)

Allow callback to be a multimethod for HTTP requests. (thanks @jaley)
 
2.1.12
(2013/10/11)

Fix 84. 1. client sent Connection: Close => server, server try to streaming
the response, server close the connection after first write, which makes a
bad streaming. (thanks @rufoa)



沈锋
http://shenfeng.me

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


Re: ANN: ClojureScript 0.0-2060

2013-11-21 Thread Feng Hou
On Thursday, November 21, 2013 10:12:55 AM UTC-5, David Nolen wrote:
> ClojureScript, the Clojure compiler that emits JavaScript source code.
> 
> 
> README and source code: https://github.com/clojure/clojurescript
> 
> 
> 
> New release version: 0.0-2060
> 
> 
> Leiningen dependency information:
> 
> 
>     [org.clojure/clojurescript "0.0-2060"]
> 
> 
> Source map accuracy is considerably improved in this release. Source
> 
> maps now work great under incremental compilation regardless of the
> level of optimization. PersistentVector performance is considerably
> improved for conj and instantiation.
> 
> 
> 
> Enhancements:
> * CLJS-683: :source-map-path compiler option to simplify web server
>   integration
> * enable-console-print! for console.log based printing
> * *print-length* now supported
> 
> 
> 
> Bug fixes:
> * CLJS-691: IComparable for keywords and symbols
> * CLJS-674: relativization of source map paths
> * CLJS-687: error when deftype/record used as a function
> 
> * CLJS-639: warnings when record initialized incorrectly
> * CLJS-672: source maps + optimizations + :libs breaks building
> * CLJS-676: source map stale under incremental compilation + closure
>   optimization
> 
> * CLJS-684: throw on circular dependency
> * CLJS-583: duplicate keys in sets
> * CLJS-680: function name shadows JS globals
> * CLJS-699: namespaced keyword regression
> * CLJS-647: js-obj keys could not be expressions

Hi David,

Got these errors in optimizations :none with source-map

Uncaught TypeError: undefined is not a function core.cljs:3852
Uncaught TypeError: Cannot read property 'EMPTY' of undefined net.cljs:24
Uncaught TypeError: Cannot call method 'call' of undefined repl.cljs:21
Uncaught TypeError: undefined is not a function template.cljs:7
Uncaught TypeError: Cannot read property 'EMPTY' of undefined 

The first one above points to this line at PersistentQueue. 

(set! cljs.core.PersistentQueue.EMPTY (PersistentQueue. nil 0 nil [] 0))

In simple mode without source-map, points to this line

cljs.core.PersistentQueue.EMPTY = new cljs.core.PersistentQueue(null, 0, null, 
cljs.core.with_meta(cljs.core.PersistentVector.EMPTY, new 
cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null, "end-line", 
"end-line", 2693041432), 3852, new cljs.core.Keyword(null, "end-column", 
"end-column", 3799845882), 69], null)), 0);

No error in advanced mode though (optimized out?)

Thanks,
Feng

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: [ClojureScript] Re: ANN: ClojureScript 0.0-2060

2013-11-21 Thread Feng Hou
On Thursday, November 21, 2013 10:48:42 PM UTC-5, Tim Visher wrote:
> Thanks for the patch, Feng.
> 
> 
> 
> Patches don't tend to get discussed on the mailing list for Clojure.
> 
> Do you have your CA signed yet? http://clojure.org/contributing
> 
> 
> 
> Ironically, I had basically produced this patch, line for line, a
> 
> couple of hours ago. Hopefully we can get a release out soon. This was
> 
> totally my fault. :\
> 
> 
> 
> For now, you should be able to `lein install` your patched version and
> 
> depend on that until the official release goes out. Sorry!
> 


Tim - Not a problem at all. It's a travel fix. Appreciate if you could submit 
your patch.

Regards,
Feng

> 
> 
> On Thu, Nov 21, 2013 at 10:43 PM, Feng Hou  wrote:
> 
> > On Thursday, November 21, 2013 10:12:55 AM UTC-5, David Nolen wrote:
> 
> >> ClojureScript, the Clojure compiler that emits JavaScript source code.
> 
> >>
> 
> >>
> 
> >> README and source code: https://github.com/clojure/clojurescript
> 
> >>
> 
> >>
> 
> >>
> 
> >> New release version: 0.0-2060
> 
> >>
> 
> >>
> 
> >> Leiningen dependency information:
> 
> >>
> 
> >>
> 
> >> [org.clojure/clojurescript "0.0-2060"]
> 
> >>
> 
> >>
> 
> >> Source map accuracy is considerably improved in this release. Source
> 
> >>
> 
> >> maps now work great under incremental compilation regardless of the
> 
> >> level of optimization. PersistentVector performance is considerably
> 
> >> improved for conj and instantiation.
> 
> >>
> 
> >>
> 
> >>
> 
> >> Enhancements:
> 
> >> * CLJS-683: :source-map-path compiler option to simplify web server
> 
> >>   integration
> 
> >> * enable-console-print! for console.log based printing
> 
> >> * *print-length* now supported
> 
> >>
> 
> >>
> 
> >>
> 
> >> Bug fixes:
> 
> >> * CLJS-691: IComparable for keywords and symbols
> 
> >> * CLJS-674: relativization of source map paths
> 
> >
> 
> > I'm stuck with java 6 on an old MacAir. This patch does the same thing 
> > without using java 7 methods. All asserts in these files pass on Mac and 
> > Linux.
> 
> >
> 
> > diff --git a/src/clj/cljs/closure.clj b/src/clj/cljs/closure.clj
> 
> > index b13adf0..e67409c 100644
> 
> > --- a/src/clj/cljs/closure.clj
> 
> > +++ b/src/clj/cljs/closure.clj
> 
> > @@ -987,8 +987,8 @@
> 
> >
> 
> >  (defn same-or-subdirectory-of? [dir path]
> 
> >"Checks that path names a file or directory that is the dir or a 
> > subdirectory there of."
> 
> > -  (let [dir-path  (.toAbsolutePath (.toPath (io/file dir)))
> 
> > -path-path (.toAbsolutePath (.toPath (io/file path)))]
> 
> > +  (let [dir-path  (.getCanonicalPath (io/file dir))
> 
> > +path-path (.getCanonicalPath (io/file path))]
> 
> >  (.startsWith path-path dir-path)))
> 
> >
> 
> >  (defn check-output-to [{:keys [output-to] :as opts}]
> 
> > diff --git a/src/clj/cljs/source_map.clj b/src/clj/cljs/source_map.clj
> 
> > index 9363601..edc5739 100644
> 
> > --- a/src/clj/cljs/source_map.clj
> 
> > +++ b/src/clj/cljs/source_map.clj
> 
> > @@ -165,14 +165,12 @@
> 
> >:default
> 
> >(let [unrelativized-jpath (-> bare-munged-path
> 
> >  io/file
> 
> > -.toPath
> 
> > -.toAbsolutePath)
> 
> > +.toURI)
> 
> >  source-map-parent-jpath (-> source-map
> 
> >  io/file
> 
> > -.toPath
> 
> > -.toAbsolutePath
> 
> > -.getParent)]
> 
> > -(str (.relativize source-map-parent-jpath 
> > unrelativized-jpath))
> 
> > +.getParentFile
> 
> > +.toURI)]
> 
> > +(.getPath (.relativize source-map-parent-jpath 
> > unrelativized-jpath))
> 
> >
> 
> >  (defn encode
> 
> >"

Re: ANN: ClojureScript 0.0-2060

2013-11-21 Thread Feng Hou
On Thursday, November 21, 2013 10:12:55 AM UTC-5, David Nolen wrote:
> ClojureScript, the Clojure compiler that emits JavaScript source code.
> 
> 
> README and source code: https://github.com/clojure/clojurescript
> 
> 
> 
> New release version: 0.0-2060
> 
> 
> Leiningen dependency information:
> 
> 
>     [org.clojure/clojurescript "0.0-2060"]
> 
> 
> Source map accuracy is considerably improved in this release. Source
> 
> maps now work great under incremental compilation regardless of the
> level of optimization. PersistentVector performance is considerably
> improved for conj and instantiation.
> 
> 
> 
> Enhancements:
> * CLJS-683: :source-map-path compiler option to simplify web server
>   integration
> * enable-console-print! for console.log based printing
> * *print-length* now supported
> 
> 
> 
> Bug fixes:
> * CLJS-691: IComparable for keywords and symbols
> * CLJS-674: relativization of source map paths

I'm stuck with java 6 on an old MacAir. This patch does the same thing without 
using java 7 methods. All asserts in these files pass on Mac and Linux.

diff --git a/src/clj/cljs/closure.clj b/src/clj/cljs/closure.clj
index b13adf0..e67409c 100644
--- a/src/clj/cljs/closure.clj
+++ b/src/clj/cljs/closure.clj
@@ -987,8 +987,8 @@
 
 (defn same-or-subdirectory-of? [dir path]
   "Checks that path names a file or directory that is the dir or a 
subdirectory there of."
-  (let [dir-path  (.toAbsolutePath (.toPath (io/file dir)))
-path-path (.toAbsolutePath (.toPath (io/file path)))]
+  (let [dir-path  (.getCanonicalPath (io/file dir))
+path-path (.getCanonicalPath (io/file path))]
 (.startsWith path-path dir-path)))
 
 (defn check-output-to [{:keys [output-to] :as opts}]
diff --git a/src/clj/cljs/source_map.clj b/src/clj/cljs/source_map.clj
index 9363601..edc5739 100644
--- a/src/clj/cljs/source_map.clj
+++ b/src/clj/cljs/source_map.clj
@@ -165,14 +165,12 @@
   :default
   (let [unrelativized-jpath (-> bare-munged-path
 io/file
-.toPath
-.toAbsolutePath)
+.toURI)
 source-map-parent-jpath (-> source-map
 io/file
-.toPath
-.toAbsolutePath
-.getParent)]
-(str (.relativize source-map-parent-jpath unrelativized-jpath))
+.getParentFile
+.toURI)]
+(.getPath (.relativize source-map-parent-jpath 
unrelativized-jpath))
 
 (defn encode
   "Take an internal source map representation represented as nested

> * CLJS-687: error when deftype/record used as a function
> 
> * CLJS-639: warnings when record initialized incorrectly
> * CLJS-672: source maps + optimizations + :libs breaks building
> * CLJS-676: source map stale under incremental compilation + closure
>   optimization
> 
> * CLJS-684: throw on circular dependency
> * CLJS-583: duplicate keys in sets
> * CLJS-680: function name shadows JS globals
> * CLJS-699: namespaced keyword regression
> * CLJS-647: js-obj keys could not be expressions

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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] http-kit 2.1.5 released, bug fix, please upgrade if using the Websocket API

2013-07-05 Thread Shen, Feng
Hi,

[http-kit "2.1.5"]

Just released,  if you are using the Websocket API, please upgrade. This
release fixes a bug reported by Andrew Rudenko:  #68 Loop of Close
frames


   1. A WebSocket client like Autobahn.Android
 will
   trigger the bug
   2. Browsers do not trigger the bug
   3. The bug will cause a LOOP,  sever and client sent a close frame to
   each other infinitely
   4. The server will continue to respond other requests, but the loop use
   a lot CPU and Network resources of the server, which is bad


沈锋

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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] http-kit 2.1.1. Bug fix release, please upgrade if using the WebSocket

2013-05-06 Thread Shen, Feng
Hi,

It's a bug fix release. *If using the WebSocket support, please upgrade.
All older version has this bug.*

The bug is "Large websocket requests get corrupted". Detail:
https://github.com/http-kit/http-kit/issues/47. And thanks Gal Dolber for
reporting it.

Condition this bug will be triggered:

   1. A large message sent to server,  server may received this message
   segmented, will likely to unmark the message wrongly
   2. Small message ( 1k - 30k kilobytes, is less likely to have this
   problem)


The fixed version is already push to clojars:

[http-kit "2.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/groups/opt_out.




Re: [ANN] http-kit 2.0.0 released

2013-05-04 Thread Shen, Feng
> Will there be a client-side for browsers in ClojureScript or Javascript?
I mean something similar to sockjs implementation.

I have't plan to do that yet.  http-kit is focused to provide a HTTP
library for Clojure.

沈锋



On Sat, May 4, 2013 at 6:48 PM, Hoàng Minh Thắng  wrote:

> On Friday, March 29, 2013 1:03:38 PM UTC+7, Feng Shen wrote:
>>
>> Hello folks.
>>
>> I just released version 2.0.0 of http-kit.
>>
>
> Looks great, Feng Shen.
> I couldn't find a road-map so I ask here. Will there be a client-side for
> browsers in ClojureScript or Javascript? I mean something similar to sockjs
> implementation.
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from 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/YcezxQKG6rs/unsubscribe?hl=en.
> To unsubscribe from this group and all its topics, send an email to
> clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: [ANN] http-kit 2.0.0 released

2013-05-04 Thread Shen, Feng
> I hope support autoload .It's very useful for develop!

http://http-kit.org/migration.html#reload

沈锋



On Sat, May 4, 2013 at 9:08 PM, 张保良  wrote:

> I hope support autoload .It's very useful for develop!
>
> 在 2013年3月29日星期五UTC+8下午2时03分38秒,Feng Shen写道:
>
>> Hello folks.
>>
>> I just released version 2.0.0 of http-kit.
>>
>>
>> *2.0.0 (2013/3/29)*
>>
>>1. Unify WebSocket and HTTP long polling/streaming with Channel
>>protocol and with-channel (API breaks with the RC)
>>2. WebSocket support sending and receiving binary frame with byte[]
>>3. Support HTTP streaming
>>4. WebSocket message ordering is guaranteed by server
>>
>>
>> Updated documentation: 
>> http://http-**kit.org/server.html<http://http-kit.org/server.html>
>>
>> Let's build amazing realtime applications with Clojure, using http-kit.
>>
>> The with-channel API is not compatible with the RC releases. The new is
>> better and much easier to understand and use. The old's documentation can
>> be found here <http://http-kit.org/server_old.html>
>>
>> - feng
>>
>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from 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/YcezxQKG6rs/unsubscribe?hl=en.
> To unsubscribe from this group and all its topics, 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: http-kit 2.0.0 released

2013-05-03 Thread Shen, Feng
> Could you please let me know whether HTTP-Kit has built-in support for
applying backpressure, and if it
does then how to configure the same

If the backpressure is something like this:
http://mechanical-sympathy.blogspot.jp/2012/05/apply-back-pressure-when-overloaded.html

Then yes.  http-kit uses a bounded queue for accepting request, when too
many request coming, they get queued, if the queue exceeds a certain
size(control by :queue-size option), request get rejected, client will get
503.
And, there is another option :thread controls how many worker threads to
compute HTTP response from request.

There is another possible problem: many requests come in short time, server
compute the response (which is large) very fast(so the request did not get
rejected), and the output link is slow(like low bandwidth network
connection). In this scenario, the HTTP response get queued, wait for TCP
buffer to flush.


沈锋



On Sat, May 4, 2013 at 3:58 AM, Shantanu Kumar wrote:

> Congratulations on the release! Could you please let me know whether
> HTTP-Kit has built-in support for applying backpressure, and if it
> does then how to configure the same?
>
> Shantanu
>
> On May 3, 9:05 pm, Feng Shen  wrote:
> > Hi,
> >
> > just released 2.1.0.
> >
> > [http-kit "2.1.0"] ; Add to your project.clj.
> >
> > Compare to 2.0.0, noticeable changes:
> >
> >1. Much faster: about 30%~80% faster.
> >2. The client support HTTPS now
> >3. :as option to do client output coercion
> >
> > Not that noticeable changes:
> >
> >1. few minor bugs fixes
> >2. less RAM usage
> >
> > The full update log:
> https://github.com/http-kit/http-kit/blob/master/history.md
> >
> > Updated client documentation:http://http-kit.org/client.html
> >
> >
> >
> >
> >
> >
> >
> > On Friday, March 29, 2013 2:03:38 PM UTC+8, Feng Shen wrote:
> >
> > > Hello folks.
> >
> > > I just released version 2.0.0 of http-kit.
> >
> > > *2.0.0 (2013/3/29)*
> >
> > >1. Unify WebSocket and HTTP long polling/streaming with Channel
> > >protocol and with-channel (API breaks with the RC)
> > >2. WebSocket support sending and receiving binary frame with byte[]
> > >3. Support HTTP streaming
> > >4. WebSocket message ordering is guaranteed by server
> >
> > > Updated documentation:http://http-kit.org/server.html
> >
> > > Let's build amazing realtime applications with Clojure, using http-kit.
> >
> > > The with-channel API is not compatible with the RC releases. The new is
> > > better and much easier to understand and use. The old's documentation
> can
> > > be found here <http://http-kit.org/server_old.html>
> >
> > > - feng
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from 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/YcezxQKG6rs/unsubscribe?hl=en.
> To unsubscribe from this group and all its topics, send an email to
> clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: [ANN] http-kit 2.0.0 released

2013-05-03 Thread Shen, Feng
> regarding the perf. improvements, is it client or server?

It's the server.  Due to IO model change: One IO thread (reading and
writing) => One thread reading, decoding + many threads writing

沈锋



On Sat, May 4, 2013 at 7:54 AM, László Török  wrote:

> Hi,
>
> regarding the perf. improvements, is it client or server?
>
> Thx
>
> Las
>
>
> 2013/5/3 Michael Klishin 
>
>>
>> 2013/5/3 Feng Shen 
>>
>>> Compare to 2.0.0, noticeable changes:
>>>
>>>1. Much faster: about 30%~80% faster.
>>>2. The client support HTTPS now
>>>3. :as option to do client output coercion
>>>
>>> Not that noticeable changes:
>>>
>>>1. few minor bugs fixes
>>>2. less RAM usage
>>>
>>> The full update log:
>>> https://github.com/http-kit/http-kit/blob/master/history.md
>>>
>>
>> I'd highly recommend starting a new thread for each new version.
>> Also, your change log is in chronological order. Keeping it in
>> reverse chronological order (2.1.0 first) would make it much easier
>> to quickly discover recent changes.
>>
>> Good job on the performance improvements!
>> --
>> MK
>>
>> http://github.com/michaelklishin
>> http://twitter.com/michaelklishin
>>
>> --
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>>
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
>
> --
> László Török
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from 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/YcezxQKG6rs/unsubscribe?hl=en.
> To unsubscribe from this group and all its topics, send an email to
> clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: [ANN] http-kit 2.0.0 released

2013-05-03 Thread Feng Shen
Hi,  

just released 2.1.0.

[http-kit "2.1.0"] ; Add to your project.clj.


Compare to 2.0.0, noticeable changes: 

   1. Much faster: about 30%~80% faster. 
   2. The client support HTTPS now
   3. :as option to do client output coercion

Not that noticeable changes:

   1. few minor bugs fixes
   2. less RAM usage

The full update log: 
https://github.com/http-kit/http-kit/blob/master/history.md

Updated client documentation: http://http-kit.org/client.html


On Friday, March 29, 2013 2:03:38 PM UTC+8, Feng Shen wrote:
>
> Hello folks. 
>
> I just released version 2.0.0 of http-kit. 
>
>
> *2.0.0 (2013/3/29)*
>
>1. Unify WebSocket and HTTP long polling/streaming with Channel 
>protocol and with-channel (API breaks with the RC)
>2. WebSocket support sending and receiving binary frame with byte[] 
>3. Support HTTP streaming
>4. WebSocket message ordering is guaranteed by server
>
>
> Updated documentation: http://http-kit.org/server.html
>
> Let's build amazing realtime applications with Clojure, using http-kit.
>
> The with-channel API is not compatible with the RC releases. The new is 
> better and much easier to understand and use. The old's documentation can 
> be found here <http://http-kit.org/server_old.html>
>
> - feng
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: http-kit on heroku?

2013-04-30 Thread Feng Shen
Hi,  here is how to do hot code reload: 

http://http-kit.org/migration.html#reload


On Monday, April 15, 2013 12:48:50 PM UTC+8, Wei Hsu wrote:
>
> Thanks guys, got it sorted out.
>
> If I may ask a followup question, how do you run it in development? 
> Pre-http-kit, I've been using lein ring server, which has a nice feature 
> that reloads code automatically as it is saved so you don't have to restart 
> the server.
>
> On Sunday, April 14, 2013 8:39:50 PM UTC-7, Ryan McGowan wrote:
>>
>> Maik is right. However, if you still want an example application you can 
>> check out a side project  of mine. 
>> It works just fine on Heroku.
>>
>> Originally it was a noir/jetty application which I have since moved to 
>> http-kitand
>>  Compojure. Enjoy :)
>>
>> On Sunday, April 14, 2013 2:36:44 PM UTC-4, Maik Schünemann wrote:
>>>
>>> I don't have an example of deploying http-kit on Heroku, but I think it 
>>> should be straightforward - basically your local setup should work on 
>>> heroku.
>>> Just like you can deploy your application, which starts up jetty to 
>>> heroku I think you can deploy your http-kit application on heroku.
>>> The only think to remember is that the port of the server is stored in 
>>> the port environment variable.
>>>
>>> So,
>>> just try :)
>>>
>>>
>>> On Sat, Apr 13, 2013 at 11:22 PM, Wei Hsu  wrote:
>>>
 Does anyone have an example of deploying http-kit on Heroku? The official 
 example  uses Jetty. 

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

>>>
>>>

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




Re: [GSOC 2013] Android UI as Clojure Data

2013-04-11 Thread Osbert Feng
Be sure to look at neko and lein-droid, both most recently being worked on
by alexander-yakushev, I believe as a previous GSOC project:

http://clojure-android.blogspot.com/
https://gist.github.com/alexander-yakushev/2907442
https://github.com/alexander-yakushev/lein-droid/blob/master/sample/src/clojure/test/leindroid/sample/main.clj



On Wed, Apr 10, 2013 at 7:19 PM, Dave Sann  wrote:

> Caveat - I haven't do any android dev and don't know details of their UI
> apis
>
> But not letting that get in the way of an opinion,  I also suggest that
> you look at what Dave Ray has done with Seesaw for swing. There my well be
> useful ideas in there for you.
>
> https://github.com/daveray/seesaw/
>
> infoq preso
> http://www.infoq.com/presentations/Building-User-Interfaces-with-Seesaw
>
> Dave
>
>
> On Thursday, 11 April 2013 04:42:25 UTC+10, Junseok Lee wrote:
>>
>> Hello! My name is Junseok Lee, and I'm studying CS at UC Berkeley. I was
>> lead to Clojure through my interest in the Lisp family of languages,
>> initiated by my studies of Scheme in my coursework. I've been lurking on
>> this group for a while and thought it was about time to introduce myself.
>>
>> I'm hoping to find an effective way to express Android UI layouts with
>> Clojure during this year's Google Summer of Code. I'm very well versed in
>> Java and the Android API, and am currently studying the core.match library.
>> My first thought is to implement something similar to Hiccup's HTML
>> generation. Am I on the right track or did I get the idea completely wrong?
>>
>> Any suggestions are welcome. 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




[ANN] http-kit 2.0.0 released

2013-03-28 Thread Shen, Feng
Hello folks.

I just released version 2.0.0 of http-kit.


*2.0.0 (2013/3/29)*

   1. Unify WebSocket and HTTP long polling/streaming with Channel protocol
   and with-channel (API breaks with the RC)
   2. WebSocket support sending and receiving binary frame with byte[]
   3. Support HTTP streaming
   4. WebSocket message ordering is guaranteed by server


Updated documentation: http://http-kit.org/server.html

Let's build amazing realtime applications with Clojure, using http-kit.

The with-channel API is not compatible with the RC releases. The new is
better and much easier to understand and use. The old's documentation can
be found here <http://http-kit.org/server_old.html>

- feng

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: what is a good book about Java queues?

2013-03-09 Thread Feng Shen
Yes, the javadoc is quite good, paste a link here:

http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/BlockingQueue.html


On Friday, March 8, 2013 4:32:38 AM UTC+8, larry google groups wrote:
>
>
> At some point on this mailist, someone suggested that to best understand 
> concurrency in Java, once should read: 
>
> Java Concurrency In Practice
>
>
> http://www.amazon.com/Java-Concurrency-Practice-Brian-Goetz/dp/0321349601/ref=sr_1_1?ie=UTF8&qid=1362688125&sr=8-1&keywords=java+concurrency+in+practice
>
> So I read it, but I am surprised that it says fairly little about working 
> with queues. I am curious if anyone would recommend a book for learning 
> more about working with Java queues? 
>
> I suffer the problem that I learned Clojure without first learning Java, 
> and Clojure leans on Java rather heavily, so I am now trying to come up to 
> speed on 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
--- 
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: AOT and side-effects associated to ns initialization

2013-02-27 Thread Feng Shen
Hi, 

Another option:

(ns you.ns // add :aot [you.ns] to project.clj
  (:gen-class))

(def server (atom nil))

(defn -main [& args]; command line args
  (reset! server (jetty/run-jetty #'app {:port 8000 :join? false})))

;;; run it and pass command line arguments
java -cp your-aot-compiled.jar you.ns --port 9090



On Thursday, February 28, 2013 8:47:36 AM UTC+8, vemv wrote:
>
> So I was playing with AOT for the first time. My main reason to use it is 
> so the consumer Java code doesn't look so alien / run-timey.
>
> The thing is, I encountered that the following line causes `lein compile` 
> to hang:
>
>  (def server (jetty/run-jetty #'app {:port 8000 :join? false}))
>
> (for those not familiar with Jetty, the expression causes a web server to 
> launch.)
>
> I can sort of see why this code represents a fault, from a compiler's 
> point of view. But OTOH, in e.g. Java it's not that much of a rare practice 
> to bind a the result of a side-effectful op to a variable definition, right?
>
> My question is quite simply, why can't the given code compile? It is not 
> entirely clear to me, as I don't thoroughly understand how Clojure's 
> compiler works (or any compiler at all, for that matter).

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Building/inserting multiple records

2013-02-15 Thread Feng Shen
> Is it easy (and immutable) to build a collection of records to insert? 
 I've been told CONJ is a good start.

map maybe be helpful:  (map (fn [d] return-map-of-records) datasets)

> Does the clojure jdbc interface support insertion of multiple records?  I 
haven't seen such a function yet.

clojure.java.jdbc/insert-records



On Saturday, February 16, 2013 11:30:08 AM UTC+8, Jonathon McKitrick wrote:
>
> I'm iterating a large dataset and inserting a record for each row.  After 
> working in a Salesforce environment, I'm thinking it would be better to 
> build a collection of records and insert them in one fell swoop.
>
> 1.  Is it easy (and immutable) to build a collection of records to insert? 
>  I've been told CONJ is a good start.
> 2.  Does the clojure jdbc interface support insertion of multiple records? 
>  I haven't seen such a function yet.
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Help on drafting a protocol for realtime communication between client and ring server

2013-02-15 Thread Feng Shen
Opps, this post is intended to be posted on the Ring group, sorry for 
the noise. 


On Friday, February 15, 2013 5:50:15 PM UTC+8, Feng Shen wrote:
>
> Hi,  I am trying to draft a protocol for realtime communication between 
> client and ring server. 
>
> http-kit <http://http-kit.org/> try to implement the protocol,  provide a 
> fast & scalable ring adapter with websocket & async extension for Clojure 
> web developers.
>
> Here is an initial version, any thought/comment/suggestion welcome. 
>
> (defprotocol Channel
>   "Asynchronous channel for HTTP streaming/long polling & websocekt"
>   (open? [] "Tells whether or not this channel is still open")
>   (close []
> "Closes this channel. If this channel is already closed then invoking 
> this method has no effect. Any further attempt to invoke I/O operations 
> is welcomed by IllegalStateException")
>   (send! [data & [close-after-send]]
> "Send data to client. Weclomed by IllegalStateException if already closed 
> If `close-after-send` is true, `close` get called after sent. For 
> Webocket, a text frame is sent to client. For streaming: 1. First 
> call of send!, data expect to be {:headers _ :status _ :body _} or just body. 
>if `close-after-send` is true, a normal HTTP response is assembled and 
> sent to client,useful for HTTP client that does not support chunked 
> encoding(like ab). Otherwise, achunked encoding response is 
> assembled, `close` signals end this response. 2. Any further call, only 
> body(String, File, InputStream, ISeq) is expected.The data is encoded 
> as chunk, sent to client")
>   (on-send [callback]
> "Callback: (fn [data]) Do something with the data (like JSON 
> encoding) before sending it off")
>   (on-mesg [callback]
> "Callback: (fn [message-string]) Set the handler to get notified when 
> there is message from client. Only valid for websocket. For streaming,
>  another HTTP connection can be used to emulate the behaviour")
>   (on-close [callback]
> "Callback: (fn [status]) Set the handler to get notified when channel 
> get closed, by client `close` called. Callback is called once if server 
> and client both close the channel Useful for clean up. Status code: 0 
> if closed by sever, closed by client: -1 if streaming, websocket: 
> http://tools.ietf.org/html/rfc6455#section-7.4.1";))
>
> Thanks.
> Feng
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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.




Help on drafting a protocol for realtime communication between client and ring server

2013-02-15 Thread Feng Shen
Hi,  I am trying to draft a protocol for realtime communication between 
client and ring server. 

http-kit <http://http-kit.org/> try to implement the protocol,  provide a 
fast & scalable ring adapter with websocket & async extension for Clojure 
web developers.

Here is an initial version, any thought/comment/suggestion welcome. 

(defprotocol Channel
  "Asynchronous channel for HTTP streaming/long polling & websocekt"
  (open? [] "Tells whether or not this channel is still open")
  (close []
"Closes this channel. If this channel is already closed then invoking 
this method has no effect. Any further attempt to invoke I/O operations is 
welcomed by IllegalStateException")
  (send! [data & [close-after-send]]
"Send data to client. Weclomed by IllegalStateException if already closed   
  If `close-after-send` is true, `close` get called after sent. For 
Webocket, a text frame is sent to client. For streaming: 1. First call 
of send!, data expect to be {:headers _ :status _ :body _} or just body.
if `close-after-send` is true, a normal HTTP response is assembled and sent to 
client,useful for HTTP client that does not support chunked 
encoding(like ab). Otherwise, achunked encoding response is assembled, 
`close` signals end this response. 2. Any further call, only body(String, 
File, InputStream, ISeq) is expected.The data is encoded as chunk, sent 
to client")
  (on-send [callback]
"Callback: (fn [data]) Do something with the data (like JSON encoding) 
before sending it off")
  (on-mesg [callback]
"Callback: (fn [message-string]) Set the handler to get notified when 
there is message from client. Only valid for websocket. For streaming, 
another HTTP connection can be used to emulate the behaviour")
  (on-close [callback]
"Callback: (fn [status]) Set the handler to get notified when channel 
get closed, by client `close` called. Callback is called once if server and 
client both close the channel Useful for clean up. Status code: 0 if 
closed by sever, closed by client: -1 if streaming, websocket: 
http://tools.ietf.org/html/rfc6455#section-7.4.1";))

Thanks.
Feng

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Packaging/Deploying Web App

2013-02-13 Thread Feng Shen
Hi,  here is one solution:

add (:gen-class) to the main namespace, add something in your project.clj

  :aot [rssminer.main, rssminer.admin]
  :main rssminer.main
  :uberjar-name "rssminer-standalone.jar"


lein uberjar

Package up the project files and all dependencies into a jar file

java -jar rssminer-standalone.jar

Starts your application



On Thursday, February 14, 2013 12:47:11 AM UTC+8, Ari wrote:
>
> Hi,
>
> In my limited experience with Clojure based web apps that are comprised of 
> jetty + ring + compojure I've used the lein-ring plugin to create jars or 
> wars depending on deployment needs. I'm curious to learn:
>
>1. How can I create a deployable jar or war manually (or at least in a 
>less auto-magically way), i.e. without the lein-ring (or lien-war) plugin?
>2. How can I create a deployable jar or war -- with or without 
>lein-ring/lein-war -- when the app relies on an alternative adapter such 
> as 
>aleph, http-kit, etc? 
>
> Thanks.
>
> -Ari
>

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




Re: Bootstrapping Web Apps

2013-02-12 Thread Feng Shen
Hi,  here is what I did for rssminer (A Clojure web app):

https://github.com/shenfeng/rssminer/blob/master/src/rssminer/main.clj

define a main function, accept args from stdin, parse them,  save the 
argument, call `start-server`, do init, bind to port,  accept request




On Wednesday, February 13, 2013 4:10:00 AM UTC+8, Ari wrote:
>
> Hi,
>
> How does one bootstrap web apps comprised of ring + compojure (and/or 
> aleph) + hbase/mongodb? Is there a best practice or recommended way? For 
> example, in Rails based apps a series of predetermined "initialization" 
> files are executed to fulfill various tasks, i.e. connect to dbs, message 
> queues, active background jobs, etc. Thanks.
>
> -Ari
>

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




Re: Clojure + Web Services + Web Sockets

2013-02-12 Thread Feng Shen
I updated http-kit's server documentation:  http://http-kit.org/server.html
How http-kit is used to serve both HTTP and websocket: 
http://http-kit.org/server.html#routing

Cheers,
Feng

On Tuesday, February 12, 2013 7:36:46 AM UTC+8, Ryan T. wrote:
>
> Thanks both for your answers.
>
> @Bob, I didn't know the existance of http-kit; seems promising. There is 
> also a post 600k concurrent HTTP connections, with Clojure & 
> http-kit<http://http-kit.org/600k-concurrent-connection-http-kit.html>, 
> very interesting.
>
> I also want to add to my own original question, that aleph is capable of 
> doing synchronous and asynchronous requests with the same server and port. 
> All you have to do is to use different endpoints, even though it's possible 
> to have the same one as well.
>
> On Tuesday, February 12, 2013 1:22:13 AM UTC+2, Bob Hutchison wrote:
>>
>>
>> On 2013-02-11, at 6:12 PM, Ryan T.  wrote:
>>
>> Unless someone has to suggest something better, it seems that the best 
>> way to achieve what i want is to use 
>> aleph<https://github.com/ztellman/aleph/> which 
>> allows you to initialize it with a wrapped ring handler. 
>>
>>
>> You might have a look at http://http-kit.org/ 
>>
>> Cheers,
>> Bob
>>
>>
>> If you have more details on the issue or alternatives I would love to 
>> hear about them.
>>
>> On Tuesday, February 12, 2013 12:54:53 AM UTC+2, Ryan T. wrote:
>>>
>>> Hello,
>>>
>>> I am trying to figure out how to setup my clojure project in order to be 
>>> able to serve both normal http requests which will return json and also 
>>> handle requests over websockets. Is it possible to do both and listen on 
>>> same port? or do i need two separate projects? or ?
>>>
>>> I did find 
>>> this<http://blog.jayfields.com/2011/02/clojure-web-socket-introduction.html>
>>>  but 
>>> from what I read Webbit is not the best solution for what I need. I was 
>>> hoping to be able to build my clojure project and use jetty in development 
>>> and tomcat on production.
>>>
>>> Thank you for your time
>>>
>>
>> -- 
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>>
>>

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




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

2013-02-11 Thread Feng Shen


(defun indent-buffer ()
  (interactive)
  (indent-region (point-min) (point-max)))
(defun cleanup-buffer ()
  (interactive)
  (indent-buffer)
  (untabify-buffer)
  (delete-trailing-whitespace))
;; bind to other key if you like(global-set-key (kbd "M-q") 'cleanup-buffer)


cleanup-buffer is very fast, I hit it all the time.  



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

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




Re: Building a REST API / efficient RPC interface in Clojure

2013-02-08 Thread Feng Shen
Hi,  I did something similar during work (we are using Clojure)

   1. Use HTTP as the transport:  browser ajax call,  mobile API call, 
   intertal use
   2. JSON as encoding.  Javascript support it natively, mobile can decode 
   it easily,  Clojure has very good support for it

Clojure can decode and encode json*[1]* very efficiently.  Nginx can be 
configured to zip the data to save bandwidth.  http-kit*[2]* to do http 
very efficiently.
Compojure[3] can be used to define the mapping cleanly.  

One API, used everywhere.

I am currently writing a lein new template plugin, to setup the config 
automatically, kills boilerplate, I expect it to be ready in the next few 
days.

[1]  https://github.com/clojure/data.json
[2]  http://http-kit.org
[3]  https://github.com/weavejester/compojure





On Saturday, February 9, 2013 9:54:54 AM UTC+8, Mikera wrote:
>
> Hi All,
>
> I'm looking for a library (or set of libraries that can easily be 
> composed) that lets me do the following:
>
>  - Define an API in terms of messages 
>  - Maintain a mapping between these messages and specific data types (some 
> Java classes, Clojure data structures etc.)
>  - Also maintain a mapping between the API and handler functions that get 
> called in response to receiving a message
>  - Expose the API as a general purpose REST API for the web
>  - Also expose the same API using some form of efficient binary 
> serialisation for RPC usage
>
> FWIW, the objective is make the same API available to both external users 
> and internally within a cluster, without duplicating code but also without 
> adding substantial messaging overhead to internal cluster usage.
>
> What would be the best tools / approach in the Clojure ecosystem at the 
> moment for doing something like this?
>
>   Mike.
>

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




Re: ANN: http-kit 2.0.0.RC2, high performance HTTP Server & Client for Clojure

2013-02-08 Thread Feng Shen
Just to add:  2.0.0-RC3 released, with a general purpose timer added: 
http://http-kit.org/timer.html 


On Sunday, February 3, 2013 11:20:27 AM UTC+8, Feng Shen wrote:
>
> Hi, 
>
> After extensive test,  known bugs  fixed, documentation ready,  http-kit 
> reaches 2.0.0.RC2
>
> [http-kit "2.0.0-RC2"] ; Add to your project.clj
>
> Documentation: http://http-kit.org
> Github: https://github.com/http-kit/http-kit
>
> The goal of http-kit is to provide a clean, robust HTTP server/client, 
> with Nginx alike performance and concurrency, for Clojure.
> The server is ring compliant adapter with async and websocket support. 
>  I expect it to be faster than node.
> The client has a clj-http alike API,  asynchronous in nature, synchronous 
> with @promise.
>
> I invite everybody who interested to have a look, 
> questions/comments/suggestions/whatever are welcome! 
>
> Thanks @ptaoussanis and others for their contribution. 
>
> Feng
>

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




Re: Clojure Wiki

2013-02-08 Thread Feng Shen
http://clojure-docs.org/ => http://clojuredocs.org/



On Friday, February 8, 2013 8:17:41 PM UTC+8, Konrad wrote:
>
> Hello, fellow clojurians!
>
> For the next couple of months (or until I get a new functional job), I'll 
> be working on honing my clojure skills, starting with getting a perspective 
> of what lies *out there*: events, podcasts, guides, etc.
>
> I've created a freely-editable wiki , just like 
> EmacsWiki  and CLiki , for this 
> purpose, and filled it with I already knew. There are so many cool things 
> that I found by accident (like 
> ClojureGazette),
>  
> that I wonder how many more I am missing - and everybody is missing! - 
> without such an iniciative. I know there is already a blog aggregator, a 
> couple of websites with courses, a list of meetups, but no single place 
> with everything categorized and neatly divided, which is what I'm building.
>
> I've already spent some time on the wiki so to make it worth clicking, but 
> it's still in the beginning and much can be improved, so I invite to come 
> around and participate in shaping it. Advertise your own tool, your own 
> event; add a website you find particularly valuable; tell what you'd like 
> to see!
>
> Suggestions and comments are very welcome!
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Simple Network Messaging

2013-02-07 Thread Feng Shen
For json, Clojure has a convenient lib:  
https://github.com/clojure/data.json 

for networking, how about using HTTP as the transport?  Clojure has 
many libraries for HTTP server & client,  c# has many libraries too.



On Friday, February 8, 2013 5:44:06 AM UTC+8, JvJ wrote:
>
> I'm looking to do some simple messaging (json strings) between programs 
> running on the same machine.  One will be in C# and one will be in Clojure. 
>  Is there a library/set of libraries that could simplify this 
> communication?  I haven't done much networking in the past, and I'd like to 
> keep this as painless as possible.
>
> Thanks.
>

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




Re: Sending Clojure Objects over TCP

2013-02-07 Thread Feng Shen


slacker - Transparent, non-invasive RPC by clojure and for clojure.


https://*github*.com/sunng87/*slacker*
*
*

   1. 
   2. 
   
On Thursday, February 7, 2013 9:16:03 AM UTC+8, JvJ wrote:
>
> Does anyone know if there's a simplified networking library that allows 
> this?

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Callbacks as Sequences

2013-02-06 Thread Feng Shen
I did something for a http lib:

;; get them concurrently(let [response1 (http/get "http://http-kit.org/";)
  response2 (http/get "http://clojure.org/";)]
  ;; handle responses one-by-one, waiting for response as necessary
  ;; other keys :headers :status :error :opts
  (println "response1: " (:body @response1))
  (println "response2: " (:body @response2)))



On Thursday, February 7, 2013 2:45:36 AM UTC+8, da...@dsargeant.com wrote:
>
> I'm not to clojure/clojurescript and was wondering if anyone has taken a 
> crack at writing a macro that transforms callbacks into a sequence.  There 
> is an awesome implementationion in LispyScript show here: 
> https://gist.github.com/santoshrajan/3715526.  Thanks for help.
>
> David
>

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

2013-02-04 Thread Feng Shen
Hi, "11" < "2" if string,  
11 > 2 if integer.
Your keys are string, convert to integer if need numeric order. 


On Monday, February 4, 2013 6:37:13 PM UTC+8, Amir Wasim wrote:
>
> I want to sort a  map by its keys according to dictionary when i do the 
> following
>
> (into (sorted-map) {"1" "A" "2" "B" "11" "C" "3" "D"})
>
> the result is
>
> {"1" "A", "11" "C", "2" "B", "3" "D"}
>
>
>
> which is expected result but what i expect is dictionary sort, {"1" "A", 
> "2" "B", 3 "D", "11" "C"}. is there something in clojure or i just go with 
> java Collator 
>
> thanks
>
>
>

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




Re: ANN: http-kit 2.0.0.RC2, high performance HTTP Server & Client for Clojure

2013-02-04 Thread Feng Shen
Inspired by golang helloworld 45% slower than 
node.js<https://groups.google.com/forum/?fromgroups=#!topic/golang-nuts/zeLMYnjO_JA>
 , 
I did some test, get some numbers, for fun:

CPU: Intel(R) Core(TM) i5-2500 CPU @ 3.30GHz
RAM: 16G
#  redis, SET: 217391.30 requests per second# It's the upper limit, probably  
redis-benchmark -q 
# nginx, response a file of 1K# Requests per second:148442.25 [#/sec] 
(mean), 
ab -n 30 -c 100 -k http://127.0.0.1/  
# http-kit (http://http-kit.org)  respond hello world# code: 
https://gist.github.com/4704565# Requests per second:79.02 [#/sec] 
(mean)
ab -n 40 -c 100 -k http://127.0.0.1:8080/
# The hello world go version, with modification of "http" => "net/http" # 
Requests per second:17465.92 [#/sec] (mean)
ab -n 10 -c 100 -k http://127.0.0.1:8080/
# node v0.6.19 # Requests per second:12964.05 [#/sec] (mean)
ab -n 10 -c 100 -k http://127.0.0.1:8080



On Sunday, February 3, 2013 11:20:27 AM UTC+8, Feng Shen wrote:
>
> Hi, 
>
> After extensive test,  known bugs  fixed, documentation ready,  http-kit 
> reaches 2.0.0.RC2
>
> [http-kit "2.0.0-RC2"] ; Add to your project.clj
>
> Documentation: http://http-kit.org
> Github: https://github.com/http-kit/http-kit
>
> The goal of http-kit is to provide a clean, robust HTTP server/client, 
> with Nginx alike performance and concurrency, for Clojure.
> The server is ring compliant adapter with async and websocket support. 
>  I expect it to be faster than node.
> The client has a clj-http alike API,  asynchronous in nature, synchronous 
> with @promise.
>
> I invite everybody who interested to have a look, 
> questions/comments/suggestions/whatever are welcome! 
>
> Thanks @ptaoussanis and others for their contribution. 
>
> Feng
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Why is this code so slow?

2013-02-03 Thread Shen, Feng
> I was able to shave off some more by writing (not= 0 (rem i d)) as (<
0 (rem i d)).

the running time is about 4787ms on my computer, compare to *2759ms *of the
java version, a bit slower, but not much.


沈锋
美味书签 : http://meiweisq.com
博客: http://shenfeng.me


On Sun, Feb 3, 2013 at 6:42 PM, Shantanu Kumar wrote:

>
>
> On Feb 3, 12:54 pm, Curtis Gagliardi 
> wrote:
> > I took your version Feng and used rem instead of mod and added a type
> hint
> > and got down from:
> > 23217.321626 => 11398.389942
> >
> > No idea where to go from here though.  I'm surprised there's such a
> > difference even not using any sort of collection.
> >
> > (defn smallest-multiple-of-1-to-n-hinted-rem
> >   [^long n]
> >   (loop [i n]
> > (if (loop [d 2]
> >   (cond (> d n) true
> > (not= 0 (rem i d)) false
> > :else (recur (inc d
> >   i
> >   (recur (inc i
>
> I was able to shave off some more by writing (not= 0 (rem i d)) as (<
> 0 (rem i d)).
>
> 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.
>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Why is this code so slow?

2013-02-02 Thread Feng Shen
I can only think about a bit faster version:   46555ms => 23846ms for 20

(defn smallest-multiple-of-1-to-n
 [n]
  (let [divisors (range 2 (inc n))]
   (loop [i n]
 (if (loop [d 2]
(cond (> d n) true
  (not= 0 (mod i d)) false
  :else (recur (inc d
 i
 (recur (inc i))


I am not familiar with how Clojure's numeric works.  There should be a 
faster way of doing it in Clojure.

On Sunday, February 3, 2013 10:28:09 AM UTC+8, Alexandros Bantis wrote:
>
> Hello all. I'm working through the Project Euler problems in Java, 
> Scala, & Clojure (trying to learn all three?!?). I notice that for one 
> particular problem, I use--more or less--a similar algorithm for all 
> three, but the clojure code runs about 20-30 times slower than the 
> java/scala versions. Does anyone have any idea why this might be? It 
> strikes me that it might have something to do with every? but I don't 
> know because I'm a newbie with Clojure. 
>
>
> http://stackoverflow.com/questions/14668272/what-can-i-do-to-speed-up-this-code
>  
>
> thanks, 
>
> alex 
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: http-kit 2.0.0.RC2, high performance HTTP Server & Client for Clojure

2013-02-02 Thread Shen, Feng
Hi,

After extensive test,  known bugs  fixed, documentation ready,  http-kit
reaches 2.0.0.RC2

[http-kit "2.0.0-RC2"] ; Add to your project.clj

Documentation: http://http-kit.org
Github: https://github.com/http-kit/http-kit

The goal of http-kit is to provide a clean, robust HTTP server/client, with
Nginx alike performance and concurrency, for Clojure.
The server is ring compliant adapter with async and websocket support.
 I expect it to be faster than node.
The client has a clj-http alike API,  asynchronous in nature, synchronous
with @promise.

I invite everybody who interested to have a look,
questions/comments/suggestions/whatever are welcome!

Thanks @ptaoussanis and others for their contribution.

Feng

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: is intellij idea a good ide for clojure development?

2013-01-29 Thread Feng Shen
I have programming Clojure for almost 2 years, for a living.

Emacs is highly recommended. 
Emacs Lisp => lisp, Clojure is also Lisp.  Emacs has special support for 
Lisp than others.

As for intellj: I think it's quite good. Emacs is the perfect one. 


On Monday, January 28, 2013 7:37:54 PM UTC+8, HamsterofDeath wrote:
>
> the only ides i have used so far for clojure are intellij idea and 
> netbeans. is there one that is a lot better? if yes, why?
> i am not interested in details or single features, i just want to know if 
> there is some magic editor out there that i should look into because it is 
> *obviously a lot* better - like in "you should use an ide for java 
> development instead of notepad"
>  

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




Re: Clojure web server benchmarks

2013-01-25 Thread Feng Shen
Hey, thanks for point out latency, I haven't look at them deeply.  Here is 
how http-kit compare to Nginx when concurrency is 96:  

Server Software:http-kit
Server Hostname:127.0.0.1
Server Port:8087

Document Path:  /
Document Length:1163 bytes

Concurrency Level:  96
Time taken for tests:   2.858 seconds
Complete requests:  12
Failed requests:0
Write errors:   0
Keep-Alive requests:12
Total transferred:  15696 bytes
HTML transferred:   13956 bytes
Requests per second:41981.59 [#/sec] (mean)
Time per request:   2.287 [ms] (mean)
Time per request:   0.024 [ms] (mean, across all concurrent requests)
Transfer rate:  53624.92 [Kbytes/sec] received

Connection Times (ms)
  min  mean[+/-sd] median   max
Connect:00   0.1  0   4
Processing: 12   0.7  2   7
Waiting:12   0.7  2   7
Total:  12   0.7  2   7

*Percentage of the requests served within a certain time (ms)*
*  50%  2*
*  66%  2*
*  75%  2*
*  80%  2*
*  90%  3*
*  95%  4*
*  98%  5*
*  99%  5*

* 100% 7 (longest request) *


Server Software:nginx
Server Hostname:127.0.0.1
Server Port:8081

Document Path:  /
Document Length:1163 bytes

Concurrency Level:  96
Time taken for tests:   3.492 seconds
Complete requests:  12
Failed requests:0
Write errors:   0
Keep-Alive requests:118844
Total transferred:  164754220 bytes
HTML transferred:   13956 bytes
Requests per second:34365.55 [#/sec] (mean)
Time per request:   2.793 [ms] (mean)
Time per request:   0.029 [ms] (mean, across all concurrent requests)
Transfer rate:  46076.41 [Kbytes/sec] received

Connection Times (ms)
  min  mean[+/-sd] median   max
Connect:00   0.1  0   4
Processing: 03   2.2  2  23
Waiting:03   2.2  2  23
Total:  03   2.2  2  23

*Percentage of the requests served within a certain time (ms)*
*  50%  2*
*  66%  3*
*  75%  4*
*  80%  5*
*  90%  6*
*  95%  7*
*  98%  9*
*  99%  9*
* 100% 23 (longest request)*


btw, I am the author of http-kit :  
https://github.com/shenfeng/http-kit . http-kit was written from scratch 
for performance.  Clojure web application can be very fast, as fast as 
Nginx can do. Clojure web application can handle high concurrency as Nginx 
can do too.


On Friday, January 25, 2013 8:14:07 PM UTC+8, hutch wrote:
>
>
> On 2013-01-25, at 6:24 AM, Peter Taoussanis > 
> wrote:
>
> I'd consider adding a graph if folks think these numbers are sufficiently 
> interesting?
>
>
> That would be great! This is very important information for me. And, 
> unless things have improved markedly over that last year or so (I hope so), 
> I think you'll be 'amused' by what you see.
>
> Cheers,
> Bob
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 question about running embedded jetty

2013-01-19 Thread Feng Shen
I did not know #'app is for reload.  It's very helpful. Thanks.

On Saturday, January 19, 2013 5:26:06 PM UTC+8, Baishampayan Ghose wrote:
>
> On Sat, Jan 19, 2013 at 5:24 AM, faenvie > 
> wrote: 
> > i have learned that for a ring/compojure-app the embedded jetty 
> > service can be started like this: 
> > 
> > (def app (handler/site routes)) 
> > 
> > (defn start [port] 
> >   (ring/run-jetty (var app) {:port (or port 8080) 
> >  :join? false})) 
> > 
> > can anyone explain, what is the var for ? why '(var app)' or #'app ? 
> > i found some remarks about being able to change the app without 
> > having to restart the server but how exactly does this relate ? 
>
> If you pass in the app as it is, then the var gets evaluated to the 
> function that the var refers to and the jetty adapter uses that 
> function to run the server. 
>
> Now if you recompile your ring handlers (aka functions) the same app 
> var will get rebound to a new function while the jetty server will 
> continue holding on to the old handler function, so if you refresh the 
> page, etc. you won't see the change on your browser. You will have to 
> kill the server and restart jetty. 
>
> If you pass just the var instead, jetty holds on to the container (the 
> var) and not the value. The jetty-adapter derefs the var on every 
> request and sends the response back. As a result if you recompile your 
> handlers you'll see the effects immediately without restarting the 
> server. 
>
> The derefing has a penalty, albeit minor. Thus, you may choose to not 
> pass in the app as a var in production deployments. 
>
> Regards, 
> BG 
>
>
>
> -- 
> Baishampayan Ghose 
> b.ghose at gmail.com 
>

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

Re: a question about running embedded jetty

2013-01-18 Thread Feng Shen
Hi:
(var app)  can be simplified to just app.

The detail:
app is a function: accept a request map, return a response map. your 
server's logic is in app.
( see ring spec https://github.com/ring-clojure/ring/blob/master/SPEC for 
more detail)

(var app) or #'app: get the var (clojure.lang.Var) of the function.  

when (#'app request-map) :  
will call Var's invoke function:

public Object invoke(Object arg1) {

return fn().invoke(arg1);

}

final public IFn fn(){

 return (IFn) deref();

}

after deref(), you just get app.  


i found some remarks about being able to change the app without
> having to restart the server but how exactly does this relate ?


Yes. It's possible.   The easiest of doing that is by 
using https://github.com/weavejester/lein-ring







On Saturday, January 19, 2013 7:54:08 AM UTC+8, faenvie wrote:
>
> dear clojure users,
>
> i have learned that for a ring/compojure-app the embedded jetty
> service can be started like this:
>
> (def app (handler/site routes))
>
> (defn start [port]
>   (ring/run-jetty (var app) {:port (or port 8080)
>  :join? false}))
>
> can anyone explain, what is the var for ? why '(var app)' or #'app ?
> i found some remarks about being able to change the app without
> having to restart the server but how exactly does this relate ?
>
>
> thanks & have a successful 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

Re: How to (easily) show the advantages of Clojure

2013-01-16 Thread Feng Shen
How about Clojure's web

   1. Plain Clojure function as handler,  request and response are just 
   maps, they are printable.
   2. Easy testable: handler is a function, pass a request, get the 
   response, assert the response is wanted.
   3. Easy mockable: use bindings to mock centain functions. Like talking 
   to a database, read the content of a file.



On Wednesday, January 16, 2013 11:08:41 PM UTC+8, Thomas wrote:
>
> Hi All,
>
> Something that came up last night in the blank? thread. What is a good way 
> to show someone the advantages of Clojure. Something that is simple, not 
> too complicated, easily understood, shows a (significant) benefit, etc.
>
> Any ideas? (As said in the other thread, I have used the blank? example 
> from Stuart Halloway to show people the difference).
>
> Thomas
>

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

Re: emacs - how to wean me off the family of Java IDEs

2013-01-16 Thread Feng Shen
Hi:

   I use  Everything <http://www.emacswiki.org/emacs/Everything>  to find 
files in project.  Just type a part of the name, all files filter by your 
typing  listed for you to choose from.  Something like Eclipse's
   Ctrl +Shift + R (or Command + Shift + R on mac) . But you need some time 
to set it up.  
Here<https://github.com/shenfeng/dotfiles/blob/master/emacs.d/feng-anything.el>is
 my config for your reference.

   rainbow-delimiters is helpful for my lisp coding.



On Wednesday, January 16, 2013 10:29:36 PM UTC+8, Colin Yates wrote:
>
> Hi all,
>
> After 15 off years of using IDEs I am making the jump into Emacs.  I have 
> read http://dev.clojure.org/display/doc/Getting+Started+with+Emacs and 
> https://github.com/technomancy/emacs-starter-kit and I am just at the 
> point where I have stopped yelling at paredit and starting to appreciate 
> its point.
>
> My current major stumbling block though is navigating my project.  Whilst 
> (I expect) the density and sane namespacing capabilities of Clojure to 
> significantly reduce the number of files, that isn't true of everything. 
>  In particular, ExtJS encourages you to follow the "one file per class". 
>  You don't have to but eventually you will have more than a handful of 
> files regardless.  
>
> So my questions:
>  - is there a decent project explorer.  I really miss the "tree on the 
> left, editor on the right" layout
>  - is there a decent JS and clojure autocompletion aware plugin
>  - other than paredit, nrepl and clojure-mode (and the excellent 
> coffee-mode for coffeescript), what other plugins should I install
>
> Thanks all.
>
> Col
>
> P.S>  Please don't turn this into a flame war :)
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: How to integrate front-end designers into Clojure/Ring/Jetty workflow?

2013-01-12 Thread Feng Shen
I have some similar experience, put here try to be helpful 
I am in a team:

   1. 1 designer:  No experience with Clojure, little knowledge about 
   programming, but knowing HTML & CSS well
   2. 1 fronend developer: No experience with Clojure, knowing JS & HTML 
   well,
   3. 2 Clojure coder. 

Everyone commit code: contribute directly, everybody run the same code!

The things we do:

   1. A bash script that start the ring web app, like  ./scripts/run, for 
   everybody to run the code easily.
   2. Templating by  Mustache   : 
   Mustache is very simple: I managed to explain mustache to them in less than 
   10 minutes.  And reload is easy!

(ns .tmpls
  ;; templates => clojure functions : templates/help.tpl => help
  (gen-tmpls-from-resources "templates" [".tpl"]))
;;; reload template, put it in your middleware. make sure only execute in dev 
mode(require :reload '.tmpls)


There is another tool I write you may find interesting:  
http-watcher
Basically, it's a web server for web developers: automatically refresh 
browser when code changed.  It's quite useful for our team. 

On Friday, January 11, 2013 7:28:02 AM UTC+8, larry google groups wrote:
>
>
> So, I am working on a web app that is buillt with Clojure/Ring/Jetty 
> and, importantly, Enlive. My directory structure is like this: 
>
> /resources 
> /public 
> /css 
> /js 
> /img 
> /templates 
>
> /src 
> /discovery 
> core.clj 
>
>
> The great thing about Enlive is that the templates are pure HTML. This 
> makes it easier for graphic designers and frontenders to work with 
> them directly. I am working with a designer and frontend developer, 
> who  have absolute power over the stuff going into the /resources 
> folder. 
>
> I have 2 questions: 
>
> 1.) In my routes, I am using (wrap-resource) instead of (wrap-file). 
> Is there any way to enable live updates, so that if the designer 
> changes the images in /resources/public/img, they can then see the 
> changed images when looking at the app in their browser? Right now I 
> have to recompile the app and restart it for change to be visible to 
> the designer. 
>
> 2.) I notice that if a change is made in /resources, but no change is 
> made anywhere else, then if I run "lein compile" nothing happens. Is 
> there a way to force lein to compile? 
>
> I have little insight about how to build a multiperson workflow while 
> doing Clojure development. One thought I had: I could automate the re- 
> build of the app, and give the designer an easy way to trigger that 
> rebuild (click a button in Jenkins -- easy enough because we rely on 
> Jenkins for all of our builds, and the interface is simple enough for 
> non-programmers to handle). But I would like to hear what other people 
> do. 
>
>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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] Yet another {{mustache}} for Clojure

2012-07-19 Thread Shen, Feng
Great! Congratulation. You improved it a lot.
This should do good to stencil users, the code runs much faster now.

I did not implement the  "Set Delimiter" and "lambdas" and "Dotted Names",
etc.  You implemented the whole SPEC, this should be point out.

For a little background why I implemented
Mustache.clj<https://github.com/shenfeng/mustache.clj>
:
I was doing https://github.com/shenfeng/rssminer ,the way I generate HTML
is slow.
I love Mustache, it's great. I rewrite it using Mustache by using the
Clojure implention list here: http://mustache.github.com/.
The performance did not improve much.
*Without further reseach to find another one*, I write a Mustache
implementation for myself to reduce the latency of Rssminer.


On Fri, Jul 20, 2012 at 5:11 AM, David Santiago wrote:

> Just wanted to stop by and update this thread with the latest
> information. I just released Stencil 0.3, at
> http://github.com/davidsantiago/stencil and it contains many
> performance improvements. I have pushed the benchmarks I use to test
> it, including an adaptation of yours, to
> http://github.com/davidsantiago/mustachequerade; the readme has an
> example run. Performance of course depends on the templates and data,
> but 0.3 ranges from nearly as fast as your mustache to 2x the runtime.
>
> In particular, for the benchmark you posted, I now get runtimes for a
> single template render of 13us in mustache.clj vs. 25us in Stencil.
> I'm not satisfied with those numbers, and will continue to push them
> lower in future versions, but the 10x difference in runtime is clearly
> no longer the case.
>
>   David
>
> On Wed, Jul 11, 2012 at 8:50 PM, Shen, Feng  wrote:
> > Yes, you are right.  Stencil did a very good job.
> > I only implement a subset.  Test code .   "Set Delimiter" and "lambdas"
> and
> > "Dotted Names" are not implemented.
> >
> > The algorithm of this implementation is borrowed from Mustache.js.
> > I read the code,  It's brilliant.
> >
> > I'v used Mustache in several projects. I like it. It's simple and
> brilliant.
> > "Set Delimiter" and "lambdas" are never used.  This is why they are not
> > implemented currently. I will implement the whole Spec when I find the
> time.
> >
> >
> > On Thu, Jul 12, 2012 at 9:26 AM, Anthony Grimes  >
> > wrote:
> >>
> >> Stencil is spec compliant (the tests actually run against the spec)
> while
> >> this implementation is not. A major goal behind stencil is to be totally
> >> spec compliant and as fast as possible. However, implementing the slow
> parts
> >> of the spec is important too.
> >>
> >>
> >> On Wednesday, July 11, 2012 6:28:23 PM UTC-5, Feng Shen wrote:
> >>>
> >>> From http://mustache.github.com/, I only notice clostache, which is a
> >>> little slow.
> >>> I have not noticed stencil, if I do, probability, I will not do one
> >>> myself. It's pretty fast.
> >>> My implementation seems faster than stencil, in a test run, up to 10x.
> >>> Test code:
> >>>
> https://github.com/shenfeng/mustache.clj/blob/master/test/me/shenfeng/perf_bench.clj
> >>> It seems stencil is more feature rich than mine.  For example, I did
> not
> >>> implement "Set Delimiter".
> >>>
> >>>
> >>> On Wednesday, July 11, 2012 9:45:51 PM UTC+8, Baishampayan Ghose wrote:
> >>>>
> >>>> > I did yet another {{mustache}} implementation for Clojure
> >>>> >
> >>>> > https://github.com/shenfeng/mustache.clj
> >>>> >
> >>>> > I did it because I need a faster one when I am doing Rssminer . And
> I
> >>>> > dit
> >>>> > it.
> >>>> > By the way, Rssminer is yet another RSS reader, but written in
> >>>> > Clojure.
> >>>> >
> >>>> > Usage:
> >>>> >
> >>>> > [me.shenfeng/mustache "0.0.4"]
> >>>> >
> >>>> > (:use me.shenfeng.mustache)
> >>>> >
> >>>> > (deftemplate template "{{template}}")
> >>>> > (to-html template {:you-data "data"}) ;; returns String
> >>>> >
> >>>> > Let me know if you have any ideas or questions.
> >>>>
> >>>> Shen,
> >>>>
> >>>> Very nice work. Have you benchmarked your mustache lib with stencil?
> >>>> 

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

2012-07-17 Thread Shen, Feng
同感enlive较复杂。前段时间,转向了Mustache。

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



On Wed, Jul 18, 2012 at 11:59 AM, dennis zhuang wrote:

> 其实就是几行代码封装下,我觉的velocity比什么enlive好用多了。
>
> 2012/7/18 Shen, Feng 
>
> 不错不错。
>> velocity 在java中用得较广。
>> 这样为potential 的 clojure用户铺了一下道路。
>>
>> 沈锋
>> 美味书签 http://meiwei.fm <http://mei.fm>
>>
>>
>>
>> On Wed, Jul 18, 2012 at 12:00 AM, dennis zhuang wrote:
>>
>>> A little error in getting started missing :age
>>>
>>> (render "test.vm" :name "dennis" :age 29)
>>>
>>>
>>> 2012/7/17 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.properties<https://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

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

2012-07-17 Thread Shen, Feng
不错不错。
velocity 在java中用得较广。
这样为potential 的 clojure用户铺了一下道路。

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



On Wed, Jul 18, 2012 at 12:00 AM, dennis zhuang wrote:

> A little error in getting started missing :age
>
> (render "test.vm" :name "dennis" :age 29)
>
>
> 2012/7/17 dennis zhuang 
>
>> Hi,all
>>
>> Apache velocity 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.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] Yet another {{mustache}} for Clojure

2012-07-11 Thread Shen, Feng
Yes, you are right.  Stencil did a very good job.
I only implement a subset.  Test
code<https://github.com/shenfeng/mustache.clj/blob/master/test/me/shenfeng/mustache_test.clj>
.
  "Set Delimiter" and "lambdas" and "Dotted Names" are not implemented.

The algorithm of this implementation is borrowed from
Mustache.js<https://github.com/janl/mustache.js>
.
I read the code,  It's brilliant.

I'v used Mustache in several projects. I like it. It's simple
and brilliant.
"Set Delimiter" and "lambdas" are never used.  This is why they are not
implemented currently. I will implement the whole Spec when I find the time.


On Thu, Jul 12, 2012 at 9:26 AM, Anthony Grimes wrote:

> Stencil is spec compliant (the tests actually run against the spec) while
> this implementation is not. A major goal behind stencil is to be totally
> spec compliant and as fast as possible. However, implementing the slow
> parts of the spec is important too.
>
>
> On Wednesday, July 11, 2012 6:28:23 PM UTC-5, Feng Shen wrote:
>>
>> From http://mustache.github.com/, I only notice clostache, which is a
>> little slow.
>> I have not noticed stencil, if I do, probability, I will not do one
>> myself. It's pretty fast.
>> My implementation seems faster than stencil, in a test run, up to 10x.
>> Test code: https://github.com/shenfeng/**mustache.clj/blob/master/test/**
>> me/shenfeng/perf_bench.clj<https://github.com/shenfeng/mustache.clj/blob/master/test/me/shenfeng/perf_bench.clj>
>> It seems stencil is more feature rich than mine.  For example, I did not
>> implement "Set Delimiter".
>>
>>
>> On Wednesday, July 11, 2012 9:45:51 PM UTC+8, Baishampayan Ghose wrote:
>>>
>>> > I did yet another {{mustache}} implementation for Clojure
>>> >
>>> > https://github.com/shenfeng/**mustache.clj<https://github.com/shenfeng/mustache.clj>
>>> >
>>> > I did it because I need a faster one when I am doing Rssminer . And I
>>> dit
>>> > it.
>>> > By the way, Rssminer is yet another RSS reader, but written in
>>> Clojure.
>>> >
>>> > Usage:
>>> >
>>> > [me.shenfeng/mustache "0.0.4"]
>>> >
>>> > (:use me.shenfeng.mustache)
>>> >
>>> > (deftemplate template "{{template}}")
>>> > (to-html template {:you-data "data"}) ;; returns String
>>> >
>>> > Let me know if you have any ideas or questions.
>>>
>>> Shen,
>>>
>>> Very nice work. Have you benchmarked your mustache lib with stencil?
>>> It would be an interesting comparison.
>>>
>>> Regards,
>>> BG
>>>
>>> --
>>> Baishampayan Ghose
>>> b.ghose at gmail.com
>>>
>>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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] Yet another {{mustache}} for Clojure

2012-07-11 Thread Feng Shen
>From http://mustache.github.com/, I only notice clostache, which is a 
little slow.
I have not noticed stencil, if I do, probability, I will not do one myself. 
It's pretty fast.
My implementation seems faster than stencil, in a test run, up to 10x.
Test code: 
https://github.com/shenfeng/mustache.clj/blob/master/test/me/shenfeng/perf_bench.clj
It seems stencil is more feature rich than mine.  For example, I did not 
implement "Set Delimiter". 


On Wednesday, July 11, 2012 9:45:51 PM UTC+8, Baishampayan Ghose wrote:
>
> > I did yet another {{mustache}} implementation for Clojure 
> > 
> > https://github.com/shenfeng/mustache.clj 
> > 
> > I did it because I need a faster one when I am doing Rssminer . And I 
> dit 
> > it. 
> > By the way, Rssminer is yet another RSS reader, but written in Clojure. 
> > 
> > Usage: 
> > 
> > [me.shenfeng/mustache "0.0.4"] 
> > 
> > (:use me.shenfeng.mustache) 
> > 
> > (deftemplate template "{{template}}") 
> > (to-html template {:you-data "data"}) ;; returns String 
> > 
> > Let me know if you have any ideas or questions. 
>
> Shen, 
>
> Very nice work. Have you benchmarked your mustache lib with stencil? 
> It would be an interesting comparison. 
>
> Regards, 
> BG 
>
> -- 
> Baishampayan Ghose 
> b.ghose at gmail.com 
>

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

[ANN] Yet another {{mustache}} for Clojure

2012-07-11 Thread Shen, Feng
Hi:

I did yet another {{mustache }} implementation
for Clojure

https://github.com/shenfeng/mustache.clj

I did it because I need a faster one when I am doing
Rssminer .
And I dit it.
By the way, Rssminer is yet another RSS reader, but written in Clojure.

Usage:

[me.shenfeng/mustache "0.0.4"]

(:use me.shenfeng.mustache)

(deftemplate template "{{template}}")
(to-html template {:you-data "data"}) ;; returns String

Let me know if you have any ideas or questions.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Tornado-like async (web) server framework?

2012-04-16 Thread Feng Shen
I am working on a tiny web server and http client in clojure and java.
It's using java's async Socket IO.
https://github.com/shenfeng/http-kit
The code is mostly written in java, It will expose a nice clojure API.
My goal are async, fast, RAM efficiency, clean and compact code.
I write it for Rssminer(http://rssminer.net, 
https://github.com/shenfeng/rssminer).

The documentation is not ready. The server's unit test code:
https://github.com/shenfeng/http-kit/blob/master/test/me/shenfeng/http/server/server_test.clj

The production code of Rssminer is now using:
https://github.com/shenfeng/async-http-client
https://github.com/shenfeng/async-ring-adapter
The two are written on top of netty, a great java NIO framework.  I
plan to replace it with http-kit.


On Apr 16, 9:51 am, Stefan Arentz  wrote:
> There is a lovely little web server for Python called Tornado.
>
> Tornado is an async server that also includes an async http client that plugs 
> right in the server's event loop. This makes it really simple to build 
> scalable web services that call other web services, which is what I mostly 
> use it for.
>
> I would love to do the same in Clojure but I have no idea where to start.
>
> Ideally I would use an async server or framework in the style of Tornado or 
> Twisted. But since Java has excellent thread support I guess I could also use 
> an http lib that allows me to run requests in parallel.
>
> Who has some hints or pointers?
>
>  S.

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


Re: How to write `when-lets`

2011-08-05 Thread Shen, Feng
I learned a lot. Thanks.

Best Regards
Shen Feng


On Wed, Jul 27, 2011 at 8:50 PM, Feng Shen  wrote:

> Clojure core.clj has a macro when-let,
> I am wondering how to write a macro `when-lets`
>
> (when-lets [symbol-1 test-1
>   symbol-2 test-2
>...
>]
>   body
>   )
>
> body only get evaluated when (and test-1 test-2 )
> I am thinking about it, anybody has any clue?

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

How to write `when-lets`

2011-07-27 Thread Feng Shen
Clojure core.clj has a macro when-let,
I am wondering how to write a macro `when-lets`

(when-lets [symbol-1 test-1
   symbol-2 test-2
...
]
   body
   )

body only get evaluated when (and test-1 test-2 )
I am thinking about it, anybody has any clue?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 for large programs

2011-07-07 Thread Feng Shen
Our codebase is 6.8k kloc of production code,  4k of test code. We use
emacs, slime+swank to develop.
The editor is great, REPL is great. But lacking debuging and
refactoring support is a pain.

On Jul 3, 9:26 am, Mark Engelberg  wrote:
> Ideally, I was hoping to start a more in-depth discussion about the
> pros and cons of "programming in the large" in Clojure than just
> waxing poetic about Clojure/Lisp's capabilities in the abstract :)
>
> Yes, much of the initial excitement around Clojure comes from the
> feeling of "Wow, I can do so much with so little code".  But at some
> point, all projects grow.  I'm thinking that by now, there may be
> enough people using Clojure in large projects and on large teams to
> offer some good feedback about how well that works.
>
> My Clojure codebase is somewhere around 2-3kloc and I already feel
> like I'm bumping up against some frustration when it comes time to
> refactor, maintain, and extend the code, all while keeping up with
> ongoing changes to libraries, contrib structures, and Clojure
> versions.
>
> I want to hear war stories from those with even larger code bases than
> mine.  Has it proven to be a major hassle on large projects to avoid
> circular dependencies in the modules?  Are the lack of debugging
> tools, documentation tools, and refactoring tools holding you back?
> Anyone miss static typing?
>
> One of my main gripes is that some of Clojure's built-ins return
> nonsensical results (or nil), rather than errors, for certain classes
> of invalid inputs.  To me, one of the main benefits of functional
> programming is that debugging is generally easier, in large part
> because failures usually occur within close proximity of the flaw that
> triggered the failure.  Erlang, in particular, has really promoted the
> idea of "fail fast" as a way to build robust systems.  But Clojure's
> lack of a "fail-fast" philosophy has burned me several times, with
> hard-to-track-down bugs that were far-removed from the actual cause.
> The larger my code grows, the more this annoys me, reminding me too
> much of my days tracking down bugs in imperative programs.
>
> One specific example of this is get, which returns nil whenever the
> first input isn't something that supports get.  For example, (get 2 2)
>  produces nil.  This becomes especially problematic when you pass
> something to get that seems like it should support get, but doesn't.
> For example, (get (transient #{1}) 1) produces nil, when there's
> absolutely no reason to think that (get (transient #{1} 1) would
> behave any differently from ((transient #{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


1.3 master commit for lazy defn loading

2011-03-31 Thread Feng
Hello,

Is this code valid?

Clojure 1.3.0-master-SNAPSHOT
user=>
(let []
  (defn foo [] :foo))
#'user/foo
user=> (foo)
ClassNotFoundException user$eval1450$foo__1451
java.lang.Class.forName0 (Class.java:-2)

It was valid before this commit.

https://github.com/clojure/clojure/commit/71930b6b6537a796cdf13c4ffa7cf93eb53b6235

Regards,
- Feng

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: trunk

2011-03-06 Thread Feng


On Mar 4, 8:08 pm, Feng  wrote:
> On Mar 4, 1:45 pm, Stuart Sierra  wrote:
>
> > swank-clojure breaks in a number of small ways on Clojure 1.3 alphas, mostly
> > because of moved/renamed functions.
>
> This seems not the case. I'm aware of print-doc and pprint caused
> breaks. All fixed in my local swank clone. The same code works fine
> for this commit.
>
> macair:clojure houf$ git log -1
> commit 174bd5001264f5c43276922505ba526aae471028
> Author: Stuart Halloway 
> Date:   Fri Feb 25 16:24:21 2011 -0500
>
>     tests for #737
>
> Go to the very next commit "lazy defn loading", it breaks. I couldn't
> find any moved/renamed functions in that commit. Stacktrace and Var
> value clearly show it has something to do with FnLoaderThunk.
>

Ok. samples to isolate the issue.

(ns swank.test)

(let []
  (defn foo [] :foo))

(let [v :bar]
  (defn bar [] v))

(def bob
  (let []
(fn [] :bob)))

user=> (swank.test/foo)
ClassNotFoundException swank/test$eval1856$foo__1857
java.lang.Class.forName0 (Class.java:-2)
user=> (swank.test/bar)
:bar
user=> (swank.test/bob)
:bob
user=>

It breaks when non-toplevel def(n) form binds to fn that does not
capture any lexical vars?

Regards,
- Feng

> It's ok master branch break things. I just want to report this early
> so that  it won't become too hard later to narrow down which commit
> caused it.
>
> Regards,
> - Feng
>
>
>
>
>
>
>
> > -Stuart Sierra
> > clojure.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


Re: trunk

2011-03-04 Thread Feng

On Mar 4, 1:45 pm, Stuart Sierra  wrote:
> swank-clojure breaks in a number of small ways on Clojure 1.3 alphas, mostly
> because of moved/renamed functions.
>

This seems not the case. I'm aware of print-doc and pprint caused
breaks. All fixed in my local swank clone. The same code works fine
for this commit.

macair:clojure houf$ git log -1
commit 174bd5001264f5c43276922505ba526aae471028
Author: Stuart Halloway 
Date:   Fri Feb 25 16:24:21 2011 -0500

tests for #737

Go to the very next commit "lazy defn loading", it breaks. I couldn't
find any moved/renamed functions in that commit. Stacktrace and Var
value clearly show it has something to do with FnLoaderThunk.

It's ok master branch break things. I just want to report this early
so that  it won't become too hard later to narrow down which commit
caused it.

Regards,
- Feng

> -Stuart Sierra
> clojure.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


trunk

2011-03-02 Thread Feng
Hello Rich,

Lazy defn loading commit to 1.3.0-master introduced a bug or breakage.

Clojure 1.3.0-master-SNAPSHOT
user=> (require 'swank.swank)
user=> (swank.commands.basic/connection-info)
ClassNotFoundException swank/commands/basic
$eval695$connection_info__696 java.lang.Class.forName0 (Class.java:-2)
user=> (.printStackTrace *e)
java.lang.ClassNotFoundException: swank/commands/basic
$eval695$connection_info__696
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at clojure.lang.FnLoaderThunk.load(FnLoaderThunk.java:52)
at clojure.lang.FnLoaderThunk.doInvoke(FnLoaderThunk.java:45)
at clojure.lang.RestFn.invoke(RestFn.java:398)
at user$eval1506.invoke(NO_SOURCE_FILE:2)
at clojure.lang.Compiler.eval(Compiler.java:6301)
at clojure.lang.Compiler.eval(Compiler.java:6268)
at clojure.core$eval.invoke(core.clj:2680)
at clojure.lang.FnLoaderThunk.invoke(FnLoaderThunk.java:31)
at clojure.main$repl$read_eval_print__5558.invoke(main.clj:244)
at clojure.main$repl$fn__5563.invoke(main.clj:265)
at clojure.main$repl.doInvoke(main.clj:265)
at clojure.lang.RestFn.invoke(RestFn.java:422)
at clojure.lang.FnLoaderThunk.invoke(FnLoaderThunk.java:36)
at clojure.main$repl_opt.invoke(main.clj:331)
at clojure.lang.FnLoaderThunk.invoke(FnLoaderThunk.java:36)
at clojure.main$main.doInvoke(main.clj:427)
at clojure.lang.RestFn.invoke(RestFn.java:398)
at clojure.lang.AFn.applyToHelper(AFn.java:159)
at clojure.lang.RestFn.applyTo(RestFn.java:133)
at clojure.lang.FnLoaderThunk.doInvoke(FnLoaderThunk.java:46)
at clojure.lang.RestFn.invoke(RestFn.java:398)
at clojure.lang.Var.invoke(Var.java:397)
at clojure.lang.AFn.applyToHelper(AFn.java:159)
at clojure.lang.Var.applyTo(Var.java:518)
at clojure.main.main(main.java:37)
nil
user=> (var-get #'swank.commands.basic/connection-info)
#
user=> (source swank.commands.basic/connection-info)
(defslimefn connection-info []
  `(:pid ~(sys/get-pid)
 :style :spawn
 :lisp-implementation (:type "Clojure"
 :name "clojure"
 :version ~(clojure-version))
 :package (:name ~(name (ns-name *ns*))
 :prompt ~(name (ns-name *ns*)))
 :version ~(deref protocol-version)))
nil
user=> (source swank.commands/defslimefn)
(defmacro defslimefn
  ([fname & body]
 `(alter-var-root #'slime-fn-map
  assoc
  (symbol "swank" ~(name fname))
  (defn ~fname ~@body)))
  {:indent 'defun})

Same code running in 1.2.0 produced

user=> (clojure-version)
"1.2.0"
user=> (require 'swank.swank)
nil
user=> (swank.commands.basic/connection-info)
(:pid "789" :style :spawn :lisp-implementation (:type "Clojure" :name
"clojure" :version "1.2.0") :package (:name "user" :prompt
"user") :version "20100404")
user=> (var-get #'swank.commands.basic/connection-info)
#

Sorry I was not able to come up a simple test case.

Regards,
Feng

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: ClojureQL 1.0.0 now released

2011-01-07 Thread Feng


On Jan 7, 7:36 pm, Rick Mouritzen  wrote:
> A prepared statement is something inside a database. The true object
> isn't part of JDBC or a JDBC driver.

Some JDBC drivers and JEE Datasources (all Oracle and IBM products) do
cache stmt per connection (i.e. stmt.close() doesn't really close it,
just put it back to cache). The cache is just a ConcurrentHashMap of
SQL text to stmt object , with some MRU or MFU algorithm.

>
> So you open a connection, then create your SQL using JDBC's
> PreparedStatement to tell the DB to use a prepared statement. Next
> time that same SQL is used with another JDBC PreparedStatement, the DB
> will do it's magic.

In Oracle, this causes a soft parsing hitting db server library cache,
lot less overhead compare to hard parsing. But, in extremely high
concurrent (100s threads) pushing high frequent short transactions.
Latch contention on db library cache can be scalability killer. JDBC
client side stmt cache reduces the contention significantly in same
cases. The situation is rare, but I did see > 50% throughput increase
by tuning stmt caching in two systems I worked on.

Agreed ClojureQL should not be bothered with this. Just to clarify the
point.

>
> Re-using a single PreparedStatement within a Connection is something
> you can only do with one Connection on one thread. Generally it's not
> worth over-thinking. Using batching is where you really see
> performance gains.
>
> This is all separate from parsing from ClojureQL to SQL/JDBC, of course.
>
>
>
>
>
>
>
> On Fri, Jan 7, 2011 at 10:22 AM, Feng  wrote:
> > I'd suggest ClojureQL only optimize lisp form to SQL text
> > transformation, and provide options whether to use PreparedStatement
> > or not. Leave other kind of optimizations to databases/drivers.
>
> > Some thoughts below:
>
> > - PreparedStatement avoids high cost of frequent query planning
> > (oracle call it hard parsing) and SQL injection, which are critical
> > for OLTP workload. However, it's not always good practice for
> > datawarehousing queries. In some high end databases, query planner
> > need to see join and filter conditions as constant for the best query
> > planning (e.g. leveraging histogram, partition statistics).  ClojureQL
> > can provide controls to evaluate clojure variables right before
> > creating SQL string. Not sure about whether at variable level, or
> > statement level, or connection level though. I can see various trade-
> > offs (simplicity vs flexibility etc).
>

In previous version a while ago, ClojureQL seems always use Statement
with var values inlined into SQL text. This is actually good for data
warehousing queries.
Maybe just introduce a flag :use-prepared (default true) in db config
object,  bring back old implementation when set it to false?
It's rarely seen mixed OLTP and ad hoc analytical queries to a single
database, so this will cover both use cases well. Stmt or var level
control may destroy elegancy of ClojureQL API, which is less
desirable.

> > - Client side JDBC Statement caching should leave to db Driver, or
> > DataSource implementations. Most of high end database and JEE
> > appserver do, with various trade-offs and complexities. I think
> > ClojureQL should stay away from them.
>
> > BTW, great library and fun to use!
>
> > On Jan 7, 6:23 am, LauJensen  wrote:
> >> Hi Sean,
>
> >> Half right - It will compile everytime, but not necessary create the
> >> AST everytime:
>
> >> (let [my-table (-> (table :user)
> >>     (select (where (= :id user-id)))
> >>     (project [:dateofbirth :gender :zipcode]))]
> >>   (repeatedly @my-table))
>
> >> However I see there are some good thoughts on optimization in this
> >> thread already.
> >> Perhaps is the AST always kept the SQL representation in a field, we
> >> could totally
> >> avoid re-compilation for repeat queries. That would still created the
> >> preparedStatement,
> >> but Im not sure thats a real time-stealer. I'll have to check.
>
> >> On Jan 7, 1:33 am, Sean Corfield  wrote:
>
> >> > On Thu, Jan 6, 2011 at 2:33 AM, LauJensen  
> >> > wrote:
> >> > > Yes the two statements are equivalent. ClojureQL compiles everything
> >> > > to prepared
> >> > > statements, with every argument automatically paramterized.
>
> >> > Cool, that's what I'd hoped. But just to clarify...
>
> >> > If I have code that repeatedly calls this:
>
> >> > @(-> (table :user)
> >> >     (select (where (= :id user-id)))
> >> >     (project [:dateofbirth 

Re: ANN: ClojureQL 1.0.0 now released

2011-01-07 Thread Feng
I'd suggest ClojureQL only optimize lisp form to SQL text
transformation, and provide options whether to use PreparedStatement
or not. Leave other kind of optimizations to databases/drivers.

Some thoughts below:

- PreparedStatement avoids high cost of frequent query planning
(oracle call it hard parsing) and SQL injection, which are critical
for OLTP workload. However, it's not always good practice for
datawarehousing queries. In some high end databases, query planner
need to see join and filter conditions as constant for the best query
planning (e.g. leveraging histogram, partition statistics).  ClojureQL
can provide controls to evaluate clojure variables right before
creating SQL string. Not sure about whether at variable level, or
statement level, or connection level though. I can see various trade-
offs (simplicity vs flexibility etc).

- Client side JDBC Statement caching should leave to db Driver, or
DataSource implementations. Most of high end database and JEE
appserver do, with various trade-offs and complexities. I think
ClojureQL should stay away from them.

BTW, great library and fun to use!

On Jan 7, 6:23 am, LauJensen  wrote:
> Hi Sean,
>
> Half right - It will compile everytime, but not necessary create the
> AST everytime:
>
> (let [my-table (-> (table :user)
>     (select (where (= :id user-id)))
>     (project [:dateofbirth :gender :zipcode]))]
>   (repeatedly @my-table))
>
> However I see there are some good thoughts on optimization in this
> thread already.
> Perhaps is the AST always kept the SQL representation in a field, we
> could totally
> avoid re-compilation for repeat queries. That would still created the
> preparedStatement,
> but Im not sure thats a real time-stealer. I'll have to check.
>
> On Jan 7, 1:33 am, Sean Corfield  wrote:
>
> > On Thu, Jan 6, 2011 at 2:33 AM, LauJensen  wrote:
> > > Yes the two statements are equivalent. ClojureQL compiles everything
> > > to prepared
> > > statements, with every argument automatically paramterized.
>
> > Cool, that's what I'd hoped. But just to clarify...
>
> > If I have code that repeatedly calls this:
>
> > @(-> (table :user)
> >     (select (where (= :id user-id)))
> >     (project [:dateofbirth :gender :zipcode]))
>
> > it is going to construct that AST and compile it to SQL every time it
> > hits it, yes?
> > --
> > Sean A Corfield -- (904) 302-SEAN
> > Railo Technologies, Inc. --http://getrailo.com/
> > An Architect's View --http://corfield.org/
>
> > "If you're not annoying somebody, you're not really alive."
> > -- Margaret Atwood

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Possible BUG: NPE

2009-12-09 Thread Feng


On Dec 7, 9:39 pm, David Nolen  wrote:
> http://github.com/jochu/swank-clojure/blob/master/src/main/clojure/sw...
>
> Is the offending line.

It's really hard to reason about it in clojure source code. I see, in
jswat debbuger, the root cause of NPE appears around byte code
(putfield ...) for a mutual recursive letfn form.

Here is a simple way to reproduce it. I did it this time with latest
master branch. Can anybody else reproduce it on different OS/JVM
version?

(ns test.letfn)

(defn debug [n]
  (letfn [(even [n]
(if (== n 0)
  true
  (odd (- n 1
  (odd [n]
   (if (== n 0)
 false
 (even (- n 1]
(odd n)))

Listening for transport dt_socket at address: 
Clojure 1.1.0-master-SNAPSHOT
user=> (require 'test.letfn)
nil
user=> (test.letfn/debug 5)
java.lang.NullPointerException (NO_SOURCE_FILE:0)
user=> (.. *e getCause printStackTrace)
java.lang.NullPointerException
at test.letfn$debug__17.invoke(letfn.clj:3)
at user$eval__4.invoke(NO_SOURCE_FILE:2)
at clojure.lang.Compiler.eval(Compiler.java:4642)
at clojure.core$eval__5254.invoke(core.clj:2035)
at clojure.main$repl__7403$read_eval_print__7415.invoke
(main.clj:183)
at clojure.main$repl__7403.doInvoke(main.clj:200)
at clojure.lang.RestFn.invoke(RestFn.java:426)
at clojure.main$repl_opt__7449.invoke(main.clj:254)
at clojure.main$main__7484.doInvoke(main.clj:341)
at clojure.lang.RestFn.invoke(RestFn.java:402)
at clojure.lang.Var.invoke(Var.java:355)
at clojure.lang.AFn.applyToHelper(AFn.java:171)
at clojure.lang.Var.applyTo(Var.java:476)
at clojure.main.main(main.java:37)
nil
user=>

macbook-wifi:/ fenghou$ uname -a
Darwin macbook-wifi 8.11.1 Darwin Kernel Version 8.11.1: Wed Oct 10
18:23:28 PDT 2007; root:xnu-792.25.20~1/RELEASE_I386 i386 i386
macbook-wifi:/ fenghou$ java -version
java version "1.5.0_19"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_19-
b02-306)
Java HotSpot(TM) Client VM (build 1.5.0_19-138, mixed mode, sharing)

- Feng

> On Mon, Dec 7, 2009 at 9:34 PM, David Nolen  wrote:
> > Looking at the stacktrace it looks like this is because of swank_fuzzy.clj.
> > I can start up the SLIME Repl no problem, I see your exact same stack trace
> > only if I try to trigger fuzzy completion via C-c TAB.
>
> > David
>
> > On Mon, Dec 7, 2009 at 9:24 PM, Feng  wrote:
>
> >> On Dec 7, 8:57 pm, David Nolen  wrote:
> >> > I was getting this as well, but this was before the last 3 commits to
> >> new.
> >> > Did you wipe your old jars and class files and start afresh?
>
> >> Yes, just to make sure not waste Rich's time. I did doubt and triple
> >> checks, ant clean, find $HOME -name clojure\*.jar |xargs rm ...
>
> >> I use Jeff's git master clone, not Phil's branch. No magic in emacs. I
> >> load everything (clojure-*.jar, swank-clojure/src) in clojure.sh. And
> >> always start swank from console repl in screen, then M-x slime-
> >> connect. So I'm pretty sure where everything is.
>
> >> > David
>
> >> > On Mon, Dec 7, 2009 at 8:31 PM, Feng  wrote:
> >> > > Hi,
>
> >> > > After git pull on new branch
>
> >> > > commit 1da63ad10d2531264e86eb705a10b3cebc9b1067
> >> > > Author: Rich Hickey 
> >> > > Date:   Mon Dec 7 16:44:41 2009 -0500
>
> >> > >    init CLEAR_SITES
>
> >> > > Got NPE in slime
>
> >> > > java.lang.RuntimeException: java.lang.RuntimeException:
> >> > > java.lang.RuntimeException: java.lang.RuntimeException:
> >> > > java.lang.NullPointerException
> >> > >  [Thrown class java.lang.RuntimeException]
>
> >> > > Backtrace:
> >> > >  0: clojure.lang.LazySeq.sval(LazySeq.java:47)
> >> > >  1: clojure.lang.LazySeq.seq(LazySeq.java:56)
> >> > >  2: clojure.lang.RT.seq(RT.java:440)
> >> > >  3: clojure.core$seq__3970.invoke(core.clj:105)
> >> > >  4: clojure.core$sort__4671.invoke(core.clj:1994)
> >> > >  5: swank.commands.contrib.swank_fuzzy
> >> > > $fuzzy_generate_matchings__1781.invoke(swank_fuzzy.clj:256)
> >> > >  6: swank.commands.contrib.swank_fuzzy
> >> > > $fuzzy_completion_set__1838$fn__1840.invoke(swank_fuzzy.clj:310)
> >> > >  7: swank.commands.contrib.swank_fuzzy$call_with_timeout__1703.invoke
> >> > > (swank_fuzzy.clj:127)
> >> > >  8: swank.commands.contrib.swank_fuzzy
> >&

Re: Possible BUG: NPE

2009-12-07 Thread Feng
Yes, fuzzy-completion seems the only way to trigger it.  For what it's
worth, it did not happen if reset to

commit a3e95cf5a72b22cd0728aba152d5f77603b722fc
Author: Rich Hickey 
Date:   Fri Dec 4 11:22:04 2009 -0500

update example in reify doc

- Feng

On Dec 7, 9:34 pm, David Nolen  wrote:
> Looking at the stacktrace it looks like this is because of swank_fuzzy.clj.
> I can start up the SLIME Repl no problem, I see your exact same stack trace
> only if I try to trigger fuzzy completion via C-c TAB.
>
> David
>
> On Mon, Dec 7, 2009 at 9:24 PM, Feng  wrote:
>
> > On Dec 7, 8:57 pm, David Nolen  wrote:
> > > I was getting this as well, but this was before the last 3 commits to
> > new.
> > > Did you wipe your old jars and class files and start afresh?
>
> > Yes, just to make sure not waste Rich's time. I did doubt and triple
> > checks, ant clean, find $HOME -name clojure\*.jar |xargs rm ...
>
> > I use Jeff's git master clone, not Phil's branch. No magic in emacs. I
> > load everything (clojure-*.jar, swank-clojure/src) in clojure.sh. And
> > always start swank from console repl in screen, then M-x slime-
> > connect. So I'm pretty sure where everything is.
>
> > > David
>
> > > On Mon, Dec 7, 2009 at 8:31 PM, Feng  wrote:
> > > > Hi,
>
> > > > After git pull on new branch
>
> > > > commit 1da63ad10d2531264e86eb705a10b3cebc9b1067
> > > > Author: Rich Hickey 
> > > > Date:   Mon Dec 7 16:44:41 2009 -0500
>
> > > >    init CLEAR_SITES
>
> > > > Got NPE in slime
>
> > > > java.lang.RuntimeException: java.lang.RuntimeException:
> > > > java.lang.RuntimeException: java.lang.RuntimeException:
> > > > java.lang.NullPointerException
> > > >  [Thrown class java.lang.RuntimeException]
>
> > > > Backtrace:
> > > >  0: clojure.lang.LazySeq.sval(LazySeq.java:47)
> > > >  1: clojure.lang.LazySeq.seq(LazySeq.java:56)
> > > >  2: clojure.lang.RT.seq(RT.java:440)
> > > >  3: clojure.core$seq__3970.invoke(core.clj:105)
> > > >  4: clojure.core$sort__4671.invoke(core.clj:1994)
> > > >  5: swank.commands.contrib.swank_fuzzy
> > > > $fuzzy_generate_matchings__1781.invoke(swank_fuzzy.clj:256)
> > > >  6: swank.commands.contrib.swank_fuzzy
> > > > $fuzzy_completion_set__1838$fn__1840.invoke(swank_fuzzy.clj:310)
> > > >  7: swank.commands.contrib.swank_fuzzy$call_with_timeout__1703.invoke
> > > > (swank_fuzzy.clj:127)
> > > >  8: swank.commands.contrib.swank_fuzzy
> > > > $fuzzy_completion_set__1838.invoke(swank_fuzzy.clj:309)
> > > >  9: swank.commands.contrib.swank_fuzzy
> > > > $eval__1849$fuzzy_completions__1851.invoke(swank_fuzzy.clj:323)
> > > >  10: clojure.lang.Var.invoke(Var.java:385)
> > > >  11: user$eval__2042.invoke(NO_SOURCE_FILE)
> > > >  12: clojure.lang.Compiler.eval(Compiler.java:5256)
> > > >  13: clojure.lang.Compiler.eval(Compiler.java:5224)
> > > >  14: clojure.core$eval__4688.invoke(core.clj:2036)
> > > >  15: swank.core$eval_in_emacs_package__399.invoke(core.clj:58)
> > > >  16: swank.core$eval_for_emacs__468.invoke(core.clj:126)
> > > >  17: clojure.lang.Var.invoke(Var.java:373)
> > > >  18: clojure.lang.AFn.applyToHelper(AFn.java:182)
> > > >  19: clojure.lang.Var.applyTo(Var.java:482)
> > > >  20: clojure.core$apply__4058.invoke(core.clj:437)
> > > >  21: swank.core$eval_from_control__401.invoke(core.clj:65)
> > > >  22: swank.core$eval_loop__403.invoke(core.clj:70)
> > > >  23: swank.core$spawn_repl_thread__526$fn__557$fn__559.invoke(core.clj:
> > > > 179)
> > > >  24: clojure.lang.AFn.applyToHelper(AFn.java:172)
> > > >  25: clojure.lang.AFn.applyTo(AFn.java:164)
> > > >  26: clojure.core$apply__4058.invoke(core.clj:437)
> > > >  27: swank.core$spawn_repl_thread__526$fn__557.doInvoke(core.clj:176)
> > > >  28: clojure.lang.RestFn.invoke(RestFn.java:398)
> > > >  29: clojure.lang.AFn.run(AFn.java:37)
> > > >  30: java.lang.Thread.run(Thread.java:613)
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > > > Groups "Clojure" group.
> > > > To post to this group, send email to clojure@googlegroups.com
> > > > Note that posts from new members are moderated - please be patient with
> > > > your first post.
> > > > To unsubscribe f

Re: Possible BUG: NPE

2009-12-07 Thread Feng


On Dec 7, 8:57 pm, David Nolen  wrote:
> I was getting this as well, but this was before the last 3 commits to new.
> Did you wipe your old jars and class files and start afresh?
>

Yes, just to make sure not waste Rich's time. I did doubt and triple
checks, ant clean, find $HOME -name clojure\*.jar |xargs rm ...

I use Jeff's git master clone, not Phil's branch. No magic in emacs. I
load everything (clojure-*.jar, swank-clojure/src) in clojure.sh. And
always start swank from console repl in screen, then M-x slime-
connect. So I'm pretty sure where everything is.

> David
>
> On Mon, Dec 7, 2009 at 8:31 PM, Feng  wrote:
> > Hi,
>
> > After git pull on new branch
>
> > commit 1da63ad10d2531264e86eb705a10b3cebc9b1067
> > Author: Rich Hickey 
> > Date:   Mon Dec 7 16:44:41 2009 -0500
>
> >    init CLEAR_SITES
>
> > Got NPE in slime
>
> > java.lang.RuntimeException: java.lang.RuntimeException:
> > java.lang.RuntimeException: java.lang.RuntimeException:
> > java.lang.NullPointerException
> >  [Thrown class java.lang.RuntimeException]
>
> > Backtrace:
> >  0: clojure.lang.LazySeq.sval(LazySeq.java:47)
> >  1: clojure.lang.LazySeq.seq(LazySeq.java:56)
> >  2: clojure.lang.RT.seq(RT.java:440)
> >  3: clojure.core$seq__3970.invoke(core.clj:105)
> >  4: clojure.core$sort__4671.invoke(core.clj:1994)
> >  5: swank.commands.contrib.swank_fuzzy
> > $fuzzy_generate_matchings__1781.invoke(swank_fuzzy.clj:256)
> >  6: swank.commands.contrib.swank_fuzzy
> > $fuzzy_completion_set__1838$fn__1840.invoke(swank_fuzzy.clj:310)
> >  7: swank.commands.contrib.swank_fuzzy$call_with_timeout__1703.invoke
> > (swank_fuzzy.clj:127)
> >  8: swank.commands.contrib.swank_fuzzy
> > $fuzzy_completion_set__1838.invoke(swank_fuzzy.clj:309)
> >  9: swank.commands.contrib.swank_fuzzy
> > $eval__1849$fuzzy_completions__1851.invoke(swank_fuzzy.clj:323)
> >  10: clojure.lang.Var.invoke(Var.java:385)
> >  11: user$eval__2042.invoke(NO_SOURCE_FILE)
> >  12: clojure.lang.Compiler.eval(Compiler.java:5256)
> >  13: clojure.lang.Compiler.eval(Compiler.java:5224)
> >  14: clojure.core$eval__4688.invoke(core.clj:2036)
> >  15: swank.core$eval_in_emacs_package__399.invoke(core.clj:58)
> >  16: swank.core$eval_for_emacs__468.invoke(core.clj:126)
> >  17: clojure.lang.Var.invoke(Var.java:373)
> >  18: clojure.lang.AFn.applyToHelper(AFn.java:182)
> >  19: clojure.lang.Var.applyTo(Var.java:482)
> >  20: clojure.core$apply__4058.invoke(core.clj:437)
> >  21: swank.core$eval_from_control__401.invoke(core.clj:65)
> >  22: swank.core$eval_loop__403.invoke(core.clj:70)
> >  23: swank.core$spawn_repl_thread__526$fn__557$fn__559.invoke(core.clj:
> > 179)
> >  24: clojure.lang.AFn.applyToHelper(AFn.java:172)
> >  25: clojure.lang.AFn.applyTo(AFn.java:164)
> >  26: clojure.core$apply__4058.invoke(core.clj:437)
> >  27: swank.core$spawn_repl_thread__526$fn__557.doInvoke(core.clj:176)
> >  28: clojure.lang.RestFn.invoke(RestFn.java:398)
> >  29: clojure.lang.AFn.run(AFn.java:37)
> >  30: java.lang.Thread.run(Thread.java:613)
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with
> > your first post.
> > To unsubscribe from 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


Possible BUG: NPE

2009-12-07 Thread Feng
Hi,

After git pull on new branch

commit 1da63ad10d2531264e86eb705a10b3cebc9b1067
Author: Rich Hickey 
Date:   Mon Dec 7 16:44:41 2009 -0500

init CLEAR_SITES

Got NPE in slime

java.lang.RuntimeException: java.lang.RuntimeException:
java.lang.RuntimeException: java.lang.RuntimeException:
java.lang.NullPointerException
  [Thrown class java.lang.RuntimeException]

Backtrace:
  0: clojure.lang.LazySeq.sval(LazySeq.java:47)
  1: clojure.lang.LazySeq.seq(LazySeq.java:56)
  2: clojure.lang.RT.seq(RT.java:440)
  3: clojure.core$seq__3970.invoke(core.clj:105)
  4: clojure.core$sort__4671.invoke(core.clj:1994)
  5: swank.commands.contrib.swank_fuzzy
$fuzzy_generate_matchings__1781.invoke(swank_fuzzy.clj:256)
  6: swank.commands.contrib.swank_fuzzy
$fuzzy_completion_set__1838$fn__1840.invoke(swank_fuzzy.clj:310)
  7: swank.commands.contrib.swank_fuzzy$call_with_timeout__1703.invoke
(swank_fuzzy.clj:127)
  8: swank.commands.contrib.swank_fuzzy
$fuzzy_completion_set__1838.invoke(swank_fuzzy.clj:309)
  9: swank.commands.contrib.swank_fuzzy
$eval__1849$fuzzy_completions__1851.invoke(swank_fuzzy.clj:323)
 10: clojure.lang.Var.invoke(Var.java:385)
 11: user$eval__2042.invoke(NO_SOURCE_FILE)
 12: clojure.lang.Compiler.eval(Compiler.java:5256)
 13: clojure.lang.Compiler.eval(Compiler.java:5224)
 14: clojure.core$eval__4688.invoke(core.clj:2036)
 15: swank.core$eval_in_emacs_package__399.invoke(core.clj:58)
 16: swank.core$eval_for_emacs__468.invoke(core.clj:126)
 17: clojure.lang.Var.invoke(Var.java:373)
 18: clojure.lang.AFn.applyToHelper(AFn.java:182)
 19: clojure.lang.Var.applyTo(Var.java:482)
 20: clojure.core$apply__4058.invoke(core.clj:437)
 21: swank.core$eval_from_control__401.invoke(core.clj:65)
 22: swank.core$eval_loop__403.invoke(core.clj:70)
 23: swank.core$spawn_repl_thread__526$fn__557$fn__559.invoke(core.clj:
179)
 24: clojure.lang.AFn.applyToHelper(AFn.java:172)
 25: clojure.lang.AFn.applyTo(AFn.java:164)
 26: clojure.core$apply__4058.invoke(core.clj:437)
 27: swank.core$spawn_repl_thread__526$fn__557.doInvoke(core.clj:176)
 28: clojure.lang.RestFn.invoke(RestFn.java:398)
 29: clojure.lang.AFn.run(AFn.java:37)
 30: java.lang.Thread.run(Thread.java:613)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 deftype usage

2009-05-25 Thread Feng



On May 25, 6:47 am, Konrad Hinsen  wrote:
> On 24.05.2009, at 07:01, Feng wrote:
>
> > clojure.contrib.types/deftype assumes data to tag are created fresh
> > with no meta data. Would it be useful to have it update meta data if
> > data are already initialized with meta data, e.g. from file or db with
> > other meta data, but :type ::constructor are too program specific to
> > be stored in there?
>
> I considered this, but decided to postpone any action until the  
> problem actually occurs. The reason why I prefer the current approach  
> wherever it is applicable (i.e. for any values that don't need  
> metadata other than for type identification is the associated overhead.
>
> My current implementation creates a single metadata map per type that  
> is then attached to each data item. The memory overhead is  
> negligible, and the CPU time overhead is just one call to with-meta  
> per object creation. The modification that you propose (as well as  
> the variant I had considered, using vary-meta) creates a metadata map  
> per object, resulting in potentially lots of metadata maps, even  
> though many could be identical, and requiring map operations of non-
> negligible cost for each object creation.
>
> Several solutions are envisageble:
>
> 1) Check if the object has metadata, and put on a predefined map if  
> not. This leads to an increased CPU overhead for each object  
> creation, to to a memory overhead only for types that actually  
> require it.
>
> 2) Make the metadata handling an option specified by a parameter to  
> deftype.
>
> 3) Delegate metadata handling to the constructor, at least optionally.
>
> It's hard to choose among these solutions without having some real-
> life use cases.
>

Thanks for your feedbacks, Konrad. I'll do some experiment with option
1.

> Konrad.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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 deftype usage

2009-05-23 Thread Feng



On May 24, 1:01 am, Feng  wrote:
> Hi,
>
> clojure.contrib.types/deftype assumes data to tag are created fresh
> with no meta data. Would it be useful to have it update meta data if
> data are already initialized with meta data, e.g. from file or db with
> other meta data, but :type ::constructor are too program specific to
> be stored in there?
>
> A usage like following. x is read from database.
>
> user=> (meta x)
> {:last-updated #}
> user=> (deftype ::person person)
> #
> user=> (meta (person x))
> {:type :user/person, :clojure.contrib.types/constructor user/
> person, :last-updated #}
>
> Here is a simple patch. It merges deftype meta into original meta
> data, and it overrides existing deftype meta if they already exist
> (this is just to keep things simple. I haven't thought it much. Just
> assuming user knows new type should be compatible with old type in
> some context).
>
> Index: src/clojure/contrib/types.clj
> ===
> --- src/clojure/contrib/types.clj       (revision 840)
> +++ src/clojure/contrib/types.clj       (working copy)
> @@ -80,9 +80,9 @@
>                         ::constructor
>                             (quote ~(qualified-symbol constructor-
> name))}]
>          (def ~constructor-name
> -             (comp (fn [~'x] (with-meta ~'x meta-map#))
> ~constructor))
> +             (comp (fn [~'x] (with-meta ~'x (merge (meta ~'x) meta-
> map#))) ~constructor))
>          (defmethod deconstruct ~type-tag [~'x]
> -          (~deconstructor (with-meta ~'x {})))
> +          (~deconstructor (with-meta ~'x (dissoc (meta ~'x)
> {:type ::constructor}
sorry, should be
:type ::constructor
>
>  (defmacro deftype-
>    "Same as deftype but the constructor is private."
>
> Regards,
> - Feng
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



question about deftype usage

2009-05-23 Thread Feng

Hi,

clojure.contrib.types/deftype assumes data to tag are created fresh
with no meta data. Would it be useful to have it update meta data if
data are already initialized with meta data, e.g. from file or db with
other meta data, but :type ::constructor are too program specific to
be stored in there?

A usage like following. x is read from database.

user=> (meta x)
{:last-updated #}
user=> (deftype ::person person)
#
user=> (meta (person x))
{:type :user/person, :clojure.contrib.types/constructor user/
person, :last-updated #}

Here is a simple patch. It merges deftype meta into original meta
data, and it overrides existing deftype meta if they already exist
(this is just to keep things simple. I haven't thought it much. Just
assuming user knows new type should be compatible with old type in
some context).

Index: src/clojure/contrib/types.clj
===
--- src/clojure/contrib/types.clj   (revision 840)
+++ src/clojure/contrib/types.clj   (working copy)
@@ -80,9 +80,9 @@
::constructor
(quote ~(qualified-symbol constructor-
name))}]
 (def ~constructor-name
- (comp (fn [~'x] (with-meta ~'x meta-map#))
~constructor))
+ (comp (fn [~'x] (with-meta ~'x (merge (meta ~'x) meta-
map#))) ~constructor))
 (defmethod deconstruct ~type-tag [~'x]
-  (~deconstructor (with-meta ~'x {})))
+  (~deconstructor (with-meta ~'x (dissoc (meta ~'x)
{:type ::constructor}

 (defmacro deftype-
   "Same as deftype but the constructor is private."

Regards,
- Feng

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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 building modular code in Clojure

2009-05-18 Thread Feng
ould
> accomplish the same thing by using a class with static methods to
> represent a "module" of code.  I've recently been reading the Scala
> book, and it seems like they've taken the idea of singleton objects as
> modules one step further, along with traits to handle mixins of
> partial implementations, in order to address a lot of these issues
> even better than vanilla Java.
>
> And what about functional languages?  Well, I'm pretty sure that PLT
> Scheme has a sophisticated modular mechanism called Units which handle
> these sorts of issues.   And I think that ML can parameterize modules
> in the form of functors (or is that only a parameterization over
> types?).
>
> So please, I'd love to hear more ideas about how to write my Clojure
> code in a more modular way, making it easier to explore and maintain
> variations, and dynamically link the sets of modules I want to use to
> solve a given problem.
>
> Thanks!

Hi Mark,

You might find "Lexical contexts; or, Lambda, the Ultimate Module?"
post by Scott Burson inspiring.

http://groups.google.com/group/comp.lang.lisp/browse_thread/thread/ef3b989e8dabad62/a6ceac2011b8b66c?hl=en&#a6ceac2011b8b66c

It does not use CL package and dynamic variables (similar to clojure
ns and vars) to achieve modularity, rather criticize them as wrong
constructs for modularity. Instead, It builds a semi-module system
using CL lexical constructs (let, lables, macrolet, symbol-macrolet) +
macro.

Source code is available here.

http://common-lisp.net/cgi-bin/viewcvs.cgi/devel/src/?root=misc-extensions

The implementation is very short. However, it's beyond my skill to
tell whether it can be ported to clojure or not.

Cheers,
- Feng



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



clojure.contrib.pprint.PrettyWriter ClassNotFoundException

2009-05-09 Thread Aaron Feng
When I tried to import PrettyWriter from clojure-contrib I'm getting
java.lang.ClassNotFoundException.  Am I missing something?
Thanks,

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
To unsubscribe from 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: Is Clojure production ready?

2009-04-17 Thread Aaron Feng

Thanks to all of you for the input.  It sounds like most people are
comfortable with the current state of clojure.  That is great to hear!
 I know there has been a lot of talk to "1.0fy" clojure yesterday.
Going 1.0 will definitely help us make the jump (maybe others too?).
I understand 1.0 is only a perception, but unfortunately it's an
important one for us.

If anyone is interested in possibly working on a large scale
concurrent financial project in clojure, and don't mind living in
Philadelphia, feel free to drop me an email with resume.

Thanks again,

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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Is Clojure production ready?

2009-04-15 Thread Aaron Feng

Hi,

I work for a large financial software company, and we are interested
in using Clojure for our new project.  Due to the concurrent nature of
the project, we are evaluating three possible languages: Erlang,
Scala, and Clojure.  This project will be a hosted solution, but
availability and performance is very important to us.  We want to
deploy the project within 6 to 12 months, but the project will
continue to build out the rest of the functionality for the next 2 to
4 years. We guesstimate that it will receive around 1M hits daily
initially, and it will continue to grow on a monthly basis.

Due to the nature of the project, I'm only allowed to give high level
overview of the project at this time.

We have a bias toward Scala and Clojure because they run on top of
JVM.  The richness of existing 3rd party and open source libraries are
also attractive for us.

The fundamental question for us is:  Is Clojure worth our investment
in the current state?  What are the possible risks?

Also, if anyone has any thoughts on hiring Clojure people, it would be
greatly appreciated.

Thanks,

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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



What's this?

2009-02-20 Thread Feng

Exception java.lang.StackOverflowError:
  [1] clojure.lang.PersistentHashMap$LeafNode.nodeSeq
(PersistentHashMap.java:567), pc = 2
  [2] clojure.lang.PersistentHashMap$BitmapIndexedNode$Seq.create
(PersistentHashMap.java:503), pc = 21
  [3] clojure.lang.PersistentHashMap$BitmapIndexedNode.nodeSeq
(PersistentHashMap.java:478), pc = 2
  [4] clojure.lang.PersistentHashMap$FullNode$Seq.create
(PersistentHashMap.java:345), pc = 21
  [5] clojure.lang.PersistentHashMap$FullNode$Seq.next
(PersistentHashMap.java:356), pc = 41
  [6] clojure.lang.ASeq.more (ASeq.java:115), pc = 1
  [7] clojure.lang.RT.more (RT.java:590), pc = 11
  [8] clojure.core$rest__3032.invoke (core.clj:61), pc = 3
  [9] clojure.core$concat__3174$cat__3188$fn__3189.invoke (core.clj:
445), pc = 71
  [10] clojure.lang.LazySeq.seq (LazySeq.java:36), pc = 12
  [11] clojure.lang.RT.seqFrom (RT.java:481), pc = 11
  [12] clojure.lang.RT.seq (RT.java:451), pc = 19
  [13] clojure.core$seq__3046.invoke (core.clj:107), pc = 3
  [14] clojure.core$filter__3749$step__3751.invoke (core.clj:1518), pc
= 10
  [15] clojure.core$filter__3749$fn__3755.invoke (core.clj:1522), pc =
30
  [16] clojure.lang.LazySeq.seq (LazySeq.java:36), pc = 12
  [17] clojure.lang.RT.seqFrom (RT.java:481), pc = 11
  [18] clojure.lang.RT.seq (RT.java:451), pc = 19
  [19] clojure.core$seq__3046.invoke (core.clj:107), pc = 3
  [20] clojure.core$map__3719$fn__3721.invoke (core.clj:1485), pc = 13
  [21] clojure.lang.LazySeq.seq (LazySeq.java:36), pc = 12
  [22] clojure.lang.Cons.next (Cons.java:37), pc = 4
  [23] clojure.lang.RT.next (RT.java:581), pc = 11
  [24] clojure.core$next__3030.invoke (core.clj:54), pc = 3
  [25] clojure.core$concat__3174$cat__3188$fn__3189.invoke (core.clj:
447), pc = 163
  [26] clojure.lang.LazySeq.seq (LazySeq.java:36), pc = 12
  [27] clojure.lang.RT.seqFrom (RT.java:481), pc = 11
  [28] clojure.lang.RT.seq (RT.java:451), pc = 19

  thousands of [26] [27] [28] ...

  [11159] clojure.lang.LazySeq.seq (LazySeq.java:36), pc = 15
  [11160] clojure.lang.RT.seqFrom (RT.java:481), pc = 11
  [11161] clojure.lang.RT.seq (RT.java:451), pc = 19
  [11162] clojure.core$seq__3046.invoke (core.clj:107), pc = 3
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Fully lazy sequences are coming - feedback wanted!

2009-02-15 Thread Feng



On Feb 15, 11:46 pm, Feng  wrote:
> I tried to migrate swank-clojure to lazy branch rev1282. Here are
> steps I did.
>
> 1) search and replace rest to next
> 2) search and replace seq? to sequence?
> 3) change lazy-cons to lazy-seq following the recipe
> 4) fixed if LazySeq exceptions
>
> see attached diff at the end.
>
> Code loads fine. However, I got below error as soon as emacs slime-
> connect to swank server.
> The failing code occurred in eval form read from emacs connection. In
> jswat debugger, I can see form.toString() in
> clojure.lang.Compiler.eval frame as "(#'swank.commands.contrib/swank-
> require (quote (:swank-repl ...)))". I even cut & pasted it to plain
> repl and it ran fine.

However, browsing object shows form.more() is a clojure.core$map_xxx
$fn_xxx, which looks like a lazy-seq closure.

Correction, form.more() is a clojure.lang.Cons object. Its _first and
_more are two objects of class clojure.core$map__3637$fn__3639.

>
> What could be wrong here?
>
> clojure.lang.PersistentList
>   [Thrown class java.lang.ClassCastException]
>
> Restarts:
>  0: [ABORT] Return to SLIME's top level.
>
> Backtrace:
>   0: swank.commands.contrib$eval__1128.(Unknown Source)
>   1: sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
>   2: sun.reflect.NativeConstructorAccessorImpl.newInstance
> (NativeConstructorAccessorImpl.java:39)
>   3: sun.reflect.DelegatingConstructorAccessorImpl.newInstance
> (DelegatingConstructorAccessorImpl.java:27)
>   4: java.lang.reflect.Constructor.newInstance(Constructor.java:494)
>   5: java.lang.Class.newInstance0(Class.java:350)
>   6: java.lang.Class.newInstance(Class.java:303)
>   7: clojure.lang.Compiler$FnExpr.eval(Compiler.java:3263)
>   8: clojure.lang.Compiler.eval(Compiler.java:4209)
>   9: clojure.core$eval__3811.invoke(core.clj:1695)
>  10: swank.core$eval_in_emacs_package__272.invoke(core.clj:55)
>  11: swank.core$eval_for_emacs__346.invoke(core.clj:123)
>  12: clojure.lang.Var.invoke(Var.java:344)
>  13: clojure.lang.AFn.applyToHelper(AFn.java:179)
>  14: clojure.lang.Var.applyTo(Var.java:453)
>  15: clojure.core$apply__3084.doInvoke(core.clj:410)
>  16: clojure.lang.RestFn.invoke(RestFn.java:428)
>  17: swank.core$eval_from_control__275.invoke(core.clj:62)
>  18: swank.core$spawn_worker_thread__369$fn__397$fn__399.invoke
> (core.clj:157)
>  19: clojure.lang.AFn.applyToHelper(AFn.java:171)
>  20: clojure.lang.AFn.applyTo(AFn.java:164)
>  21: clojure.core$apply__3084.doInvoke(core.clj:410)
>  22: clojure.lang.RestFn.invoke(RestFn.java:428)
>  23: swank.core$spawn_worker_thread__369$fn__397.doInvoke(core.clj:
> 153)
>  24: clojure.lang.RestFn.invoke(RestFn.java:402)
>  25: clojure.lang.AFn.run(AFn.java:37)
>  26: java.lang.Thread.run(Thread.java:613)
>
> thanks,
> - Feng
>
> diff --git a/swank/commands/basic.clj b/swank/commands/basic.clj
> index 79d4354..8072d5b 100644
> --- a/swank/commands/basic.clj
> +++ b/swank/commands/basic.clj
> @@ -98,8 +98,9 @@
>               :short-message ~(.toString t)))
>
>  (defn- exception-causes [#^Throwable t]
> -  (lazy-cons t (when-let [cause (.getCause t)]
> -                 (exception-causes cause
> +  (lazy-seq
> +   (cons t (when-let [cause (.getCause t)]
> +              (exception-causes cause)
>
>  (defn- compile-file-for-emacs*
>    "Compiles a file for emacs. Because clojure doesn't compile, this
> is
> diff --git a/swank/commands/contrib.clj b/swank/commands/contrib.clj
> index 6c0ed07..2185efd 100644
> --- a/swank/commands/contrib.clj
> +++ b/swank/commands/contrib.clj
> @@ -3,7 +3,7 @@
>
>  (defslimefn swank-require [keys]
>    (binding [*ns* (find-ns 'swank.commands.contrib)]
> -    (doseq [k (if (seq? keys) keys (list keys))]
> +    (doseq [k (if (sequence? keys) keys (list keys))]
>        (try
>         (require (symbol (str "swank.commands.contrib." (name k
> -       (catch java.io.FileNotFoundException fne nil)
> \ No newline at end of file
> +       (catch java.io.FileNotFoundException fne nil)
> diff --git a/swank/commands/contrib/swank_arglists.clj b/swank/
> commands/contrib/swank_arglists.clj
> index 4a87d89..e7a6cd9 100644
> --- a/swank/commands/contrib/swank_arglists.clj
> +++ b/swank/commands/contrib/swank_arglists.clj
> @@ -9,8 +9,8 @@
>                  print-lines]} (apply hash-map options)]
>      ;; Yeah, I'm lazy -- I'll flesh this out later
>      (if (and raw-specs
> -             (seq? raw-specs)
> -             (seq? (first raw-specs)))
> +             (sequence? raw-specs)
> +             (sequence? (first raw-specs)))
>        ((slime-fn 'operat

Re: Fully lazy sequences are coming - feedback wanted!

2009-02-15 Thread Feng

I tried to migrate swank-clojure to lazy branch rev1282. Here are
steps I did.

1) search and replace rest to next
2) search and replace seq? to sequence?
3) change lazy-cons to lazy-seq following the recipe
4) fixed if LazySeq exceptions

see attached diff at the end.

Code loads fine. However, I got below error as soon as emacs slime-
connect to swank server.
The failing code occurred in eval form read from emacs connection. In
jswat debugger, I can see form.toString() in
clojure.lang.Compiler.eval frame as "(#'swank.commands.contrib/swank-
require (quote (:swank-repl ...)))". I even cut & pasted it to plain
repl and it ran fine. However, browsing object shows form.more() is a
clojure.core$map_xxx$fn_xxx, which looks like a lazy-seq closure.

What could be wrong here?

clojure.lang.PersistentList
  [Thrown class java.lang.ClassCastException]

Restarts:
 0: [ABORT] Return to SLIME's top level.

Backtrace:
  0: swank.commands.contrib$eval__1128.(Unknown Source)
  1: sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
  2: sun.reflect.NativeConstructorAccessorImpl.newInstance
(NativeConstructorAccessorImpl.java:39)
  3: sun.reflect.DelegatingConstructorAccessorImpl.newInstance
(DelegatingConstructorAccessorImpl.java:27)
  4: java.lang.reflect.Constructor.newInstance(Constructor.java:494)
  5: java.lang.Class.newInstance0(Class.java:350)
  6: java.lang.Class.newInstance(Class.java:303)
  7: clojure.lang.Compiler$FnExpr.eval(Compiler.java:3263)
  8: clojure.lang.Compiler.eval(Compiler.java:4209)
  9: clojure.core$eval__3811.invoke(core.clj:1695)
 10: swank.core$eval_in_emacs_package__272.invoke(core.clj:55)
 11: swank.core$eval_for_emacs__346.invoke(core.clj:123)
 12: clojure.lang.Var.invoke(Var.java:344)
 13: clojure.lang.AFn.applyToHelper(AFn.java:179)
 14: clojure.lang.Var.applyTo(Var.java:453)
 15: clojure.core$apply__3084.doInvoke(core.clj:410)
 16: clojure.lang.RestFn.invoke(RestFn.java:428)
 17: swank.core$eval_from_control__275.invoke(core.clj:62)
 18: swank.core$spawn_worker_thread__369$fn__397$fn__399.invoke
(core.clj:157)
 19: clojure.lang.AFn.applyToHelper(AFn.java:171)
 20: clojure.lang.AFn.applyTo(AFn.java:164)
 21: clojure.core$apply__3084.doInvoke(core.clj:410)
 22: clojure.lang.RestFn.invoke(RestFn.java:428)
 23: swank.core$spawn_worker_thread__369$fn__397.doInvoke(core.clj:
153)
 24: clojure.lang.RestFn.invoke(RestFn.java:402)
 25: clojure.lang.AFn.run(AFn.java:37)
 26: java.lang.Thread.run(Thread.java:613)

thanks,
- Feng

diff --git a/swank/commands/basic.clj b/swank/commands/basic.clj
index 79d4354..8072d5b 100644
--- a/swank/commands/basic.clj
+++ b/swank/commands/basic.clj
@@ -98,8 +98,9 @@
  :short-message ~(.toString t)))

 (defn- exception-causes [#^Throwable t]
-  (lazy-cons t (when-let [cause (.getCause t)]
- (exception-causes cause
+  (lazy-seq
+   (cons t (when-let [cause (.getCause t)]
+  (exception-causes cause)

 (defn- compile-file-for-emacs*
   "Compiles a file for emacs. Because clojure doesn't compile, this
is
diff --git a/swank/commands/contrib.clj b/swank/commands/contrib.clj
index 6c0ed07..2185efd 100644
--- a/swank/commands/contrib.clj
+++ b/swank/commands/contrib.clj
@@ -3,7 +3,7 @@

 (defslimefn swank-require [keys]
   (binding [*ns* (find-ns 'swank.commands.contrib)]
-(doseq [k (if (seq? keys) keys (list keys))]
+(doseq [k (if (sequence? keys) keys (list keys))]
   (try
(require (symbol (str "swank.commands.contrib." (name k
-   (catch java.io.FileNotFoundException fne nil)
\ No newline at end of file
+   (catch java.io.FileNotFoundException fne nil)
diff --git a/swank/commands/contrib/swank_arglists.clj b/swank/
commands/contrib/swank_arglists.clj
index 4a87d89..e7a6cd9 100644
--- a/swank/commands/contrib/swank_arglists.clj
+++ b/swank/commands/contrib/swank_arglists.clj
@@ -9,8 +9,8 @@
 print-lines]} (apply hash-map options)]
 ;; Yeah, I'm lazy -- I'll flesh this out later
 (if (and raw-specs
- (seq? raw-specs)
- (seq? (first raw-specs)))
+ (sequence? raw-specs)
+ (sequence? (first raw-specs)))
   ((slime-fn 'operator-arglist) (ffirst raw-specs) *current-
package*)
   nil)))

diff --git a/swank/commands/indent.clj b/swank/commands/indent.clj
index 6248399..af58ce3 100644
--- a/swank/commands/indent.clj
+++ b/swank/commands/indent.clj
@@ -33,10 +33,7 @@
(filter (comp var? val) (mapcat ns-map nss)

 (defn- every-other [coll]
-  (when coll
-(lazy-cons
- (first coll)
- (every-other (drop 2 coll)
+  (take-nth 2 coll))

 (defn- update-indentation-delta
   "Update the cache and return the changes in a (symbol '. indent)
list.
@@ -53,15 +50,15 @@
 (let [vars (filter (comp var? val) (mapcat ns-map
nss))]
   (mapcat in-cache? vars)))]

Initialize java.util.TreeSet/TreeMap using clojure set/map value

2008-12-15 Thread Feng

Hi,

Because clojure set, vector and map all implements
java.util.Comparator (indirectly via AFn), they interact with
java.util.TreeSet/TreeMap in surprising way due to overloaded ctor
(java.util.Comparator).

user=> (def s (java.util.TreeSet. [1 2 3 3]))
#'user/s
user=> s
#=(java.util.TreeSet. #{})
user=> (.add s 3)
true
user=> s
#=(java.util.TreeSet. #{3})
user=> (.add s 3)
java.lang.RuntimeException: java.lang.IllegalArgumentException: Wrong
number of args passed to: PersistentVector (NO_SOURCE_FILE:0)
user=> (def m (java.util.TreeMap. {:a 1 :b 2 }))
#'user/m
user=> m
#=(java.util.TreeMap. {})
user=> (.put m :a 2)
nil
user=> m
#=(java.util.TreeMap. {:a 2})
user=> (.put m :c 3)
java.lang.RuntimeException: java.lang.ClassCastException:
clojure.lang.Keyword (NO_SOURCE_FILE:0)

Is this an oversight or a compromise by design?

regards,

- Feng



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Patch: precompiling Clojure core sources in Ant build script

2008-12-14 Thread Feng

This is due to the change in clojure svn 1158. (.method ClassName ...)
syntax has been changed to call java.lang.Class method for ClassName,
not static field/method any more. Use namespace syntax instead.

diff --git a/swank/commands/basic.clj b/swank/commands/basic.clj
index ac0736f..4705cd5 100644
--- a/swank/commands/basic.clj
+++ b/swank/commands/basic.clj
@@ -273,7 +273,7 @@
 (when-let [meta (and sym-var (meta sym-var))]
   (if-let [path (or (slime-find-file-in-paths (:file meta) (slime-
search-paths))
(slime-find-file-in-paths (str (namespace-to-
path (:ns meta))
-  (.separator
File)
+  File/separator
   (:file meta))
(slime-search-paths))
 `((~(str "(defn " (:name meta) ")")
(:location
diff --git a/swank/util/io.clj b/swank/util/io.clj
index 56b037e..48fd5b8 100644
--- a/swank/util/io.clj
+++ b/swank/util/io.clj
@@ -28,7 +28,7 @@
(dothread
  (thread-set-name "Call-on-write Stream")
  (continuously
-   (.sleep Thread 200)
+   (Thread/sleep 200)
(when-not @closed?
  (.flush stream




On Dec 14, 4:41 pm, kunnar  wrote:
> Hi,
>
> Looks like patch is already applied, but i now i get following error
> after "M-."
>
> java.lang.IllegalArgumentException: No matching field found: separator
> for class java.lang.Class (NO_SOURCE_FILE:0)
>   [Thrown class clojure.lang.Compiler$CompilerException]
>
> I updated everything clojure related - clojure itself, swank-clojure,
> clojure-mode, slime, clojure-contrib, but i still get that error.
> Before update "M-." did work.
>
> Kunnar
>
> On Dec 11, 7:04 am, "Bill Clementson"  wrote:
>
> > Hi Matt,
>
> > FYI - Jeffrey Chu just sent me an email and the patch has now been
> > applied to swank-clojure.
>
> > - Bill
>
> > On Wed, Dec 10, 2008 at 1:09 PM, Bill Clementson  wrote:
> > > Hi Matt,
>
> > > On Wed, Dec 10, 2008 at 12:47 PM, MattyDub  wrote:
>
> > >> I can confirm that that patch fixed my problem - I can now M-. to
> > >> render-place.  Thanks, Bill!
>
> > > Good to hear that the patch fixes the issue for you.
>
> > >>   What paths doesslime-edit-definitionsearch for the definitions?
> > >> It's not finding the clojure macros/functions (like defn, dosync,
> > >> etc.), so I must not have that path configured correctly.
> > >> -Matt
>
> > > Basically, it searches a bunch of standard Java locations plus the
> > > locations you specified in your classpath. If you want to see what
> > > will be searched, enter the following 2 statements in your Clojure
> > > REPL:
> > > (in-ns 'swank.commands.basic)
> > > (slime-search-paths)
>
> > > Note: the function "slime-search-paths" isn't public
>
> > > If M-. isn't working on standard Clojure symbols, it could be for a
> > > number of reasons:
> > > 1. You're using an old version of Clojure
> > > 2. You've built Clojure excluding source from the jar file
> > > 3. The Clojure source isn't in your classpath (only necessary if #2 is 
> > > true)
>
> > > - Bill
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Possible bug? StringIndexOutOfBoundException

2008-11-20 Thread Feng

I start getting StringIndexOutOfBoundException since svn rev 1113 (use
source name in smap). Though I'm not sure if this a bug in clojure or
in user code, it appears that SOURCE var always have a root bound
"NO_SOURCE_FILE". Shouldn't below code check against that, instead of
just null?

Index: src/jvm/clojure/lang/Compiler.java
===
--- src/jvm/clojure/lang/Compiler.java  (revision 1118)
+++ src/jvm/clojure/lang/Compiler.java  (working copy)

@@ -2993,7 +2993,7 @@

int lineBefore = (Integer) LINE_BEFORE.get();
int lineAfter = (Integer) LINE_AFTER.get() + 1;

-   if(source != null && SOURCE_PATH.get() != null)
+   if(source != null && !source.equals("NO_SOURCE_FILE") &&
SOURCE_PATH.get() != null)
{
//cv.visitSource(source, null);
String smap = "SMAP\n" +
   source.substring(0,source.lastIndexOf
('.')) + ".java\n" +

regards,
- Feng
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Patch: precompiling Clojure core sources in Ant build script

2008-11-14 Thread Feng



On Nov 14, 4:09 pm, "Graham Fawcett" <[EMAIL PROTECTED]> wrote:
> On Fri, Nov 14, 2008 at 4:01 PM, Stephen C. Gilardi <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Nov 14, 2008, at 3:38 PM, Graham Fawcett wrote:
>
> > I'm sure there's a work-around, of course. The meta information is still
> > there:
>
> > This appears to be because the sources are no longer included in
> > clojure.jar. I added "/src/clj" to my
> > classpath and now it works.
>
> Thanks, Steve -- an easy fix!
>
> Best,
> Graham
>
> > --Steve

M-. will jump to wrong place if defs are not in namespace master .clj.
I already reported it to swank-clojure owner. I guess the fix should
be in git repo soon.

This should fix it.

(defn- namespace-to-path [ns]
  (let [ns-str (name (ns-name ns))]
(-> ns-str
(.substring 0 (.lastIndexOf ns-str "."))
(.replace \- \_)
(.replace \. \/

(defslimefn find-definitions-for-emacs [name]
  (let [sym-name (read-from-string name)
sym-var (ns-resolve (maybe-ns *current-package*) sym-name)]
(when-let [meta (and sym-var (meta sym-var))]
(if-let [path (or (slime-find-file-in-paths (str (namespace-to-
path (:ns meta))
 (.separator
File)
 (:file meta))
(slime-search-paths))
;; This is OK for namespace master .clj, but not for help files.
;  (slime-find-file-in-paths (str (namespace-
to-path (:ns meta)) ".clj")
;(slime-search-
paths))
  (slime-find-file-in-paths (:file meta)
(slime-search-paths)))]
`((~(str "(defn " (:name meta) ")")
   (:location
    ~path
(:line ~(:line meta))
nil)))
`((~(str (:name meta))
   (:error "Source definition not found.")))

regards,

- Feng
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A question about ns-resolve

2008-09-16 Thread Feng



On Sep 16, 7:41 am, Rich Hickey <[EMAIL PROTECTED]> wrote:
> On Sep 16, 12:26 am, Feng <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > It appears that ns-resolve only resolves alias qualified symbol in
> > current clojure/*ns*, but not in the namespace passed as argument.
>
> Fixed - thanks for the report.
>
> > I tried to make some change in Compiler.java
>
> Please send in a CA before submitting any patches - thanks.
>

I'll do that when I'm capable to contribute patches formally.

thanks for the fix.

- Feng

> Rich
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Should meta :file include namespace/package path?

2008-09-01 Thread Feng

Hi,

With recent unified namespace and package, should meta :file include
package path as well?

user=> (require '(clojure.contrib sql))
nil
user=> (def src (:file ^#'clojure.contrib.sql/with-connection))
#'user/src
user=> src
"sql.clj"
user=> (.getResource (clojure.lang.RT/baseLoader) src)
nil
user=> (.getResource (clojure.lang.RT/baseLoader) "clojure/contrib/sql/
sql.clj")
file:/Users/fenghou/lib/clojure/contrib/src/clojure/contrib/sql/
sql.clj
user=>

regards,
Feng
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---