Re: puzzlement over lazy sequences

2011-09-13 Thread Michael Gardner
On Sep 12, 2011, at 11:28 PM, Ken Wesson wrote:

 But if, as you say, take, drop, etc. work for larger n, it should be
 easy to make nth work with larger n and non-random-access seqs, just
 by changing the non-random-access case to (first (drop n the-seq)).

I'd be rather surprised if nth suddenly started giving linear performance on 
arrays for large values of n. If nth can't be made to work in constant time on 
arrays for n  2**31, then I'd favor the IllegalArgumentException approach. One 
can always do (first (drop …)) manually if linear performance is acceptable.

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

2011-09-13 Thread Ken Wesson
On Tue, Sep 13, 2011 at 2:39 AM, Michael Gardner gardne...@gmail.com wrote:
 On Sep 12, 2011, at 11:28 PM, Ken Wesson wrote:

 But if, as you say, take, drop, etc. work for larger n, it should be
 easy to make nth work with larger n and non-random-access seqs, just
 by changing the non-random-access case to (first (drop n the-seq)).

 I'd be rather surprised if nth suddenly started giving linear performance on 
 arrays for large values of n. If nth can't be made to work in constant time 
 on arrays for n  2**31, then I'd favor the IllegalArgumentException 
 approach. One can always do (first (drop …)) manually if linear performance 
 is acceptable.

It already gives log32 rather than constant time performance on
vectors, I think. That would stay the same. It can be extended to
sorted-set and sorted-map with log2 time performance, again including
with large-n support. On actual java.util collections and Java arrays
it can just check if n exceeds 2^31 - 1, give not-found behavior if
so, and otherwise punt to Java. And on non-random-access stuff it can
use (first (drop n thingy)).

-- 
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

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

2011-09-13 Thread Stefan Kamphausen
Hi,

On Tuesday, September 13, 2011 6:28:01 AM UTC+2, Ken Wesson wrote:


 They're trees of arrays of 32 items, and the trees can in principle
 have arbitrary depth. So the 2^31 limit on Java arrays doesn't impact
 the Clojure collections, it seems.


are you sure?  As far as I understood things (reading PersistentVector.java 
and [1]), there can only be 6 levels of nodes, because of the 32bit which 
are used to store an integer and because of the bit-shifting which is used 
to find the correct level. 
That would lead to a limit of 32^6 which is half of the 2^31:

user= (= (Math/pow 2 31) (* 2 (Math/pow 32 6)))
true

:-)

Regards,
Stefan

[1] 
http://blog.higher-order.net/2009/02/01/understanding-clojures-persistentvector-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

good ways to deal with compiler errors in SLIME (emacs)

2011-09-13 Thread Sergey Didenko
Hi,

How can I see the error line number in SLIME? Or even somehow place editor
point on the place of the error?

For example when I load file in a lein repl, it prints:

java.lang.Exception: Unable to resolve symbol: dd in this context
(mytest.clj:447)

However when I load this file in the SLIME repl it just prints:

Unable to resolve symbol: dd in this context
...
0 [QUIT] Quit to the SLIME top level

and a long backtrace without error line information.

P.S. Sorry, if this is offtopic.

Regards, Sergey.

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

2011-09-13 Thread Ken Wesson
On Tue, Sep 13, 2011 at 4:18 AM, Stefan Kamphausen
ska2...@googlemail.com wrote:
 Hi,

 On Tuesday, September 13, 2011 6:28:01 AM UTC+2, Ken Wesson wrote:

 They're trees of arrays of 32 items, and the trees can in principle
 have arbitrary depth. So the 2^31 limit on Java arrays doesn't impact
 the Clojure collections, it seems.

 are you sure?  As far as I understood things (reading PersistentVector.java
 and [1]), there can only be 6 levels of nodes, because of the 32bit which
 are used to store an integer and because of the bit-shifting which is used
 to find the correct level.

I said the tree can *in principle* have arbitrary depth. Bit-shifting
can be done on BigIntegers, too.

-- 
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

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


ClojureScript for CouchDB

2011-09-13 Thread Pepijn de Vos
While reading about ClojureScript, I saw a couple of mentions of CouchDB as 
a use case for ClojureScript.

Would anyone care to elaborate? Is this anything more than an abstract idea? 
There is no CouchDB compile target AFAIK, and I can't see how any of the 
others would work out of the box.

The simplest approach would be to compile to a couch app, and let couchapp 
compile and upload the design doc.

To do this, no optimizations should be applied, as we need multiple files. 
But then either CommonJS requires or Couchapp macros will need to be 
generated. Or can this be made to work with Closure style requires as well?

The other option is to directly compile ClojureScript to a design doc. I 
have no idea how hard this is.

Pepijn

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

2011-09-13 Thread Herwig Hochleitner
Just a little remark: Keep in mind, that clutch
https://github.com/ashafa/clutch comes with a CouchDB view server that
can execute Clojure code.
So compiling to JS only seems desirable to me, when you can't
configure an additional view server on your CouchDB.
Performance wise, it should make no big difference, since JS views are
also executed on a separate view server.

regards

2011/9/13 Pepijn de Vos pepijnde...@gmail.com:
 While reading about ClojureScript, I saw a couple of mentions of CouchDB as
 a use case for ClojureScript.
 Would anyone care to elaborate? Is this anything more than an abstract idea?
 There is no CouchDB compile target AFAIK, and I can't see how any of the
 others would work out of the box.
 The simplest approach would be to compile to a couch app, and let couchapp
 compile and upload the design doc.
 To do this, no optimizations should be applied, as we need multiple files.
 But then either CommonJS requires or Couchapp macros will need to be
 generated. Or can this be made to work with Closure style requires as well?
 The other option is to directly compile ClojureScript to a design doc. I
 have no idea how hard this is.
 Pepijn

-- 
__
Herwig Hochleitner

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


heaps in clojure

2011-09-13 Thread Sunil S Nandihalli
Hi Everybody,
 I have a very large, but with finite size, collection. I would like to get
like first 10 elements in the sorted list . I would use a heap if I were in
c++ .. is there a inbuilt implementation of this in clojure? .. Is there
some other way to achieve this? some sort of lazy sort would be perfect. I
know I need the full collection to start with .. but that is fine.
Thanks,
Sunil.

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

2011-09-13 Thread Jonathan Fischer Friberg
There is the inbuilt sort function, also sort-by is useful.

In The joy of clojure, there were an example of a lazy sort.
It can be found here:
http://www.manning.com/fogus/
In the file q.clj in the source code.

Jonathan

On Tue, Sep 13, 2011 at 1:44 PM, Sunil S Nandihalli 
sunil.nandiha...@gmail.com wrote:

 Hi Everybody,
  I have a very large, but with finite size, collection. I would like to get
 like first 10 elements in the sorted list . I would use a heap if I were in
 c++ .. is there a inbuilt implementation of this in clojure? .. Is there
 some other way to achieve this? some sort of lazy sort would be perfect. I
 know I need the full collection to start with .. but that is fine.
 Thanks,
 Sunil.

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

2011-09-13 Thread Stuart Sierra
I've been spending a lot of time on the continuations aspect:
http://github.com/stuartsierra/cljque

-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: ClojureScript for CouchDB

2011-09-13 Thread Chas Emerick
First, what Herwig said. :-)

Second, it's not outside of the realm of possibility that clutch might 
eventually be able to take .cljs files (or clojure/cljs source inline via 
clutch macro), invoke the cljs compiler, and use its existing functionality to 
upload the resulting view functions' code to your couchdb instance.

It certainly would be pleasant to be able to write couch views in Clojure 
without messing with the view server setup (though clutch 0.2.5 simplifies this 
significantly).  Of course, you'd lose access to the wealth of Clojure (and 
Java) libraries available with the Clojure view server, so the tradeoffs are 
multivariate.

- Chas

On Sep 13, 2011, at 6:24 AM, Herwig Hochleitner wrote:

 Just a little remark: Keep in mind, that clutch
 https://github.com/ashafa/clutch comes with a CouchDB view server that
 can execute Clojure code.
 So compiling to JS only seems desirable to me, when you can't
 configure an additional view server on your CouchDB.
 Performance wise, it should make no big difference, since JS views are
 also executed on a separate view server.
 
 regards
 
 2011/9/13 Pepijn de Vos pepijnde...@gmail.com:
 While reading about ClojureScript, I saw a couple of mentions of CouchDB as
 a use case for ClojureScript.
 Would anyone care to elaborate? Is this anything more than an abstract idea?
 There is no CouchDB compile target AFAIK, and I can't see how any of the
 others would work out of the box.
 The simplest approach would be to compile to a couch app, and let couchapp
 compile and upload the design doc.
 To do this, no optimizations should be applied, as we need multiple files.
 But then either CommonJS requires or Couchapp macros will need to be
 generated. Or can this be made to work with Closure style requires as well?
 The other option is to directly compile ClojureScript to a design doc. I
 have no idea how hard this is.
 Pepijn
 
 -- 
 __
 Herwig Hochleitner
 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group 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: ClojureScript for CouchDB

2011-09-13 Thread Stuart Sierra
Just an idea at the moment. We need more people with knowledge of CouchDB to 
work on it.

-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

Problem with insert-values (clojure.contrib.sql)

2011-09-13 Thread finbeu
Houston, I have a problem:

(sql/with-connection db_spec
 (sql/insert-values MyTable [Number Name FloatValue]
[5, A, 2.0] [6 ,B, 3.0])

This works perfectly fine. 



Now I'm trying to do the following:

(def x [[5, A, 2.0] [6 ,B, 3.0]])
(sql/with-connection db_spec
 (sql/insert-values MyTable [Number Name FloatValue]
x))

I get the error: There are more columns in the INSERT statement than values 
specified in the VALUES clause.  The number of values in the VALUES clause 
must match the number of columns specified in the INSERT statement

How do I have to put  x in the insert-values function? I guess it needs to 
be expaned somehow. I tried a couple of things (doall, doseq,...) No 
success..

Thanks.

- Finn




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

Re: Problem with insert-values (clojure.contrib.sql)

2011-09-13 Thread Meikel Brandmeyer (kotarak)
Hi,

comparing the two calls, I suppose you need apply.


(def x [[5, A, 2.0] [6 ,B, 3.0]])
(sql/with-connection db_spec
  (apply sql/insert-values MyTable [Number Name FloatValue] x))


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

2011-09-13 Thread Pepijn de Vos
What needs to be done?

Pepijn

On Sep 13, 2011, at 2:30 PM, Stuart Sierra wrote:

 Just an idea at the moment. We need more people with knowledge of CouchDB to 
 work on it.
 
 -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

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

2011-09-13 Thread Chouser
On Tue, Sep 13, 2011 at 7:44 AM, Sunil S Nandihalli
sunil.nandiha...@gmail.com wrote:
 Hi Everybody,
  I have a very large, but with finite size, collection. I would like to get
 like first 10 elements in the sorted list . I would use a heap if I were in
 c++ .. is there a inbuilt implementation of this in clojure? .. Is there
 some other way to achieve this? some sort of lazy sort would be perfect. I
 know I need the full collection to start with .. but that is fine.

A seq on a sorted set should be pretty efficient.

(take 3 (sorted-set 8 2 1 4 6 9 7 3))
;= (1 2 3)

--Chouser

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


Re: Problem with insert-values (clojure.contrib.sql)

2011-09-13 Thread finbeu
oh yes. Now it works.  

Thanks for the quick response!

BTW: Does someone know how I can keep the connection always open? If I 
understand it right, with-connection does a connect and login to the db 
each time it gets called. Isn't this quite inefficient?

- Finn

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

[ANN] Clojure 1.3 RC0

2011-09-13 Thread Christopher Redinger
Clojure 1.3 RC0 is now available at http://clojure.org/downloads

Changes since Beta 3:

* Optimization should not demote BigInts (CLJ-836)
* Added Intrinsics
* fix nary-inline so *unchecked-math* works again

Please download it and let us know how it works for you. 1.3 is getting 
close.

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

Re: Problem with insert-values (clojure.contrib.sql)

2011-09-13 Thread Sean Corfield
On Tue, Sep 13, 2011 at 6:49 AM, finbeu info_pe...@t-online.de wrote:
 BTW: Does someone know how I can keep the connection always open? If I
 understand it right, with-connection does a connect and login to the db
 each time it gets called. Isn't this quite inefficient?

Take a look at 
https://github.com/clojure/java.jdbc/blob/master/doc/clojure/java/jdbc/ConnectionPooling.md

That's pretty much what we use at World Singles.
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/

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

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


Re: good ways to deal with compiler errors in SLIME (emacs)

2011-09-13 Thread Phil Hagelberg
On Tue, Sep 13, 2011 at 1:55 AM, Sergey Didenko
sergey.dide...@gmail.com wrote:
 How can I see the error line number in SLIME? Or even somehow place editor
 point on the place of the error?

 However when I load this file in the SLIME repl it just prints:

 Unable to resolve symbol: dd in this context

If you compile using C-c C-k (where it sends the filename instead of
the contents of the file) then it can determine line numbering.

-Phil

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


Re: [ANN] Clojure 1.3 RC0

2011-09-13 Thread Sean Corfield
On Tue, Sep 13, 2011 at 6:02 AM, Christopher Redinger
redin...@gmail.com wrote:
 Clojure 1.3 RC0 is now available at http://clojure.org/downloads
 Changes since Beta 3:
 * Optimization should not demote BigInts (CLJ-836)
 * Added Intrinsics

Could someone speak to this change since it didn't have an attached
JIRA ticket? It looks like an optimization to use direct bytecodes
rather than static method calls for a certain set of operations in
some contexts?

 * fix nary-inline so *unchecked-math* works again
 Please download it and let us know how it works for you. 1.3 is getting
 close.

We'll be running tests today on dev, CI and probably QA. We're looking
to take a new build of our platform into production this week, which
has a LOT more Clojure in it and, if RC0 works out, that'll be in our
production build too.
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/

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

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


Re: Clojure vs Scala - anecdote

2011-09-13 Thread Nathan Sorenson
I adore Clojure as well, but could this success not be partially due
to the reimplementing for the second time phenomenon? i.e. if you re-
wrote the entire thing in Scala again, perhaps you would see similar
gains in brevity etc?

On Sep 6, 10:32 pm, Sean Corfield seancorfi...@gmail.com wrote:
 I just wanted to share this experience from World Singles...

 Back in November 2009, we started developing with Scala. We needed a
 long-running process that published large volumes of changes from our
 member database as XML packets published to a custom search engine.
 The mapping from half a dozen tables in the database to a flat XML
 schema was pretty complex and the company had tried a number of
 solutions with mixed success in the past. I introduced Scala based on
 the promises of performance, concurrency and type safety - and
 conciseness (especially with XML being a native data type in Scala).

 We've been running the Scala publishing daemons in production for most
 of two years. Generally they work pretty well but, under stress, they
 tend to hit Out of Memory exceptions and, after a lot of poking
 around, we became fairly convinced it was due (at least in part) to
 the default actor implementation in Scala. Scala is going to fold in
 Akka soon and we had been considering migrating to Akka anyone...

 But having introduced Clojure this year (after experimenting with it
 since about May last year), we figured we'd have a short spike to
 create a Clojure version of the Scala code to see how it worked out.

 It took about 15 hours to recreate the publishing daemon in Clojure
 and get it to pass all our tests. Today we ran a soak test
 publishing nearly 300,000 profiles in one run. The Scala code would
 fail with OoM exceptions if we hit it with 50,000 profiles in one run
 (sometimes less). The Clojure code sailed thru and is still happily
 running - so we'll be replacing the Scala code during our next
 production build.

 The other aspect that's interesting is that the Scala code totaled
 about 1,000 lines (about 31k characters of code). The Clojure
 replacement is just under 260 lines (around 11.5k characters of code).
 Neither code base has much in the way of comments (*ahem* - I'm not
 proud of that, just pointing out that there's no noise offsetting
 the code comparison). That doesn't include unit tests either, it's
 just the raw production code. The form of the Clojure code mostly
 follows the form of the Scala code, most of the same functions - it
 was very functional Scala - with some refactoring to helper functions
 to make it more modular and more maintainable.

 The net result is (obviously) that we'll be taking the Clojure
 publishing daemon to production and we'll be dropping Scala
 completely.

 Kudos to Rich Hickey and the Clojure/core team for creating a great
 general purpose language that can solve big problems - thank you!
 --
 Sean A Corfield -- (904) 302-SEAN
 An Architect's View --http://corfield.org/
 World Singles, LLC. --http://worldsingles.com/
 Railo Technologies, Inc. --http://www.getrailo.com/

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

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


Re: Clojure vs Scala - anecdote

2011-09-13 Thread Laurent PETIT
Isn't it Brooks who said you will throw it away at least 3 times, or
something like this ? :)

2011/9/13 Nathan Sorenson n...@sfu.ca

 I adore Clojure as well, but could this success not be partially due
 to the reimplementing for the second time phenomenon? i.e. if you re-
 wrote the entire thing in Scala again, perhaps you would see similar
 gains in brevity etc?

 On Sep 6, 10:32 pm, Sean Corfield seancorfi...@gmail.com wrote:
  I just wanted to share this experience from World Singles...
 
  Back in November 2009, we started developing with Scala. We needed a
  long-running process that published large volumes of changes from our
  member database as XML packets published to a custom search engine.
  The mapping from half a dozen tables in the database to a flat XML
  schema was pretty complex and the company had tried a number of
  solutions with mixed success in the past. I introduced Scala based on
  the promises of performance, concurrency and type safety - and
  conciseness (especially with XML being a native data type in Scala).
 
  We've been running the Scala publishing daemons in production for most
  of two years. Generally they work pretty well but, under stress, they
  tend to hit Out of Memory exceptions and, after a lot of poking
  around, we became fairly convinced it was due (at least in part) to
  the default actor implementation in Scala. Scala is going to fold in
  Akka soon and we had been considering migrating to Akka anyone...
 
  But having introduced Clojure this year (after experimenting with it
  since about May last year), we figured we'd have a short spike to
  create a Clojure version of the Scala code to see how it worked out.
 
  It took about 15 hours to recreate the publishing daemon in Clojure
  and get it to pass all our tests. Today we ran a soak test
  publishing nearly 300,000 profiles in one run. The Scala code would
  fail with OoM exceptions if we hit it with 50,000 profiles in one run
  (sometimes less). The Clojure code sailed thru and is still happily
  running - so we'll be replacing the Scala code during our next
  production build.
 
  The other aspect that's interesting is that the Scala code totaled
  about 1,000 lines (about 31k characters of code). The Clojure
  replacement is just under 260 lines (around 11.5k characters of code).
  Neither code base has much in the way of comments (*ahem* - I'm not
  proud of that, just pointing out that there's no noise offsetting
  the code comparison). That doesn't include unit tests either, it's
  just the raw production code. The form of the Clojure code mostly
  follows the form of the Scala code, most of the same functions - it
  was very functional Scala - with some refactoring to helper functions
  to make it more modular and more maintainable.
 
  The net result is (obviously) that we'll be taking the Clojure
  publishing daemon to production and we'll be dropping Scala
  completely.
 
  Kudos to Rich Hickey and the Clojure/core team for creating a great
  general purpose language that can solve big problems - thank you!
  --
  Sean A Corfield -- (904) 302-SEAN
  An Architect's View --http://corfield.org/
  World Singles, LLC. --http://worldsingles.com/
  Railo Technologies, Inc. --http://www.getrailo.com/
 
  Perfection is the enemy of the good.
  -- Gustave Flaubert, French realist novelist (1821-1880)

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


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

Programmer Day

2011-09-13 Thread Wilker
(println (apply str (map char [72 97 112 112 121 32 80 114 111 103 114 97
109 109 101 114 32 68 97 121 33])))
---
Wilker Lúcio
http://about.me/wilkerlucio/bio
Kajabi Consultant
+55 81 82556600

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

2011-09-13 Thread Chouser
On Tue, Sep 13, 2011 at 12:31 PM, Wilker wilkerlu...@gmail.com wrote:
 (println (apply str (map char [72 97 112 112 121 32 80 114 111 103 114 97
 109 109 101 114 32 68 97 121 33])))

What kind of day is that, anyway?

(let [m map, c comp, p partial, s str]
  (m (c symbol (p apply s) (p m (c char dec int)) s)
 '[ibqqz qsphsbnnfs ebz]))

--Chouser

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

2011-09-13 Thread Jan Rychter
On Sep 13, 1:44 am, Stuart Sierra the.stuart.sie...@gmail.com wrote:
  Since the new, separated contrib libraries are supposed to be
  compatible with Clojure 1.2, you could perhaps also start migrating
  one lib at a time at your leisure.  This might even enable you to
  contribute to a migration document.

 Yes, this is what I am hoping people will do. Move to the new libraries
 first, then switch over to Clojure 1.3.

That is exactly our plan, except we probably won't start immediately,
as the word leisure in the paragraph above doesn't quite apply to
our current situation :-)

thanks,
--J.

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

2011-09-13 Thread Meikel Brandmeyer
“Plan to throw one away.”

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

2011-09-13 Thread Sean Corfield
On Tue, Sep 13, 2011 at 9:48 AM, Nathan Sorenson n...@sfu.ca wrote:
 I adore Clojure as well, but could this success not be partially due
 to the reimplementing for the second time phenomenon? i.e. if you re-
 wrote the entire thing in Scala again, perhaps you would see similar
 gains in brevity etc?

Well, the Scala world has moved on quite a bit since 2009 so I could
certainly make it somewhat more concise (I'd use the parallel
collections in 2.9 instead of actors and I hope there's a better SQL
abstraction by now so I could drop the ResultSet collection wrapper I
wrote). I doubt I could reduce it by a factor of three which is what
it would take to get close to the Clojure code.

I don't know who posted it on HN but I see it's also on DZone and so
it's generated a lot of noise out there and now I'm probably going to
do a more detailed comparison and analysis to post on my blog, to
answer some of the critical voices on HN... It was intended to be
purely anecdotal but that doesn't seem to satisfy anyone! :)
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/

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

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


Re: good ways to deal with compiler errors in SLIME (emacs)

2011-09-13 Thread Sergey Didenko
Thanks, Phil !

That's it. I was using slime-load-file instead of
slime-compile-and-load-file

If you compile using C-c C-k (where it sends the filename instead of
 the contents of the file) then it can determine line numbering.



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

2011-09-13 Thread Jason Wolfe
There is java.util.PriorityQueue, which is heap-based:

http://download.oracle.com/javase/1,5.0/docs/api/java/util/PriorityQueue.html

-Jason


On Sep 13, 4:44 am, Sunil S Nandihalli sunil.nandiha...@gmail.com
wrote:
 Hi Everybody,
  I have a very large, but with finite size, collection. I would like to get
 like first 10 elements in the sorted list . I would use a heap if I were in
 c++ .. is there a inbuilt implementation of this in clojure? .. Is there
 some other way to achieve this? some sort of lazy sort would be perfect. I
 know I need the full collection to start with .. but that is fine.
 Thanks,
 Sunil.

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

2011-09-13 Thread Laurent PETIT
Oh, it was just one, after all ?

Please, don't tell this to my boss :-D

2011/9/13 Meikel Brandmeyer m...@kotka.de

 “Plan to throw one away.”

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

Macros in ClojureScript

2011-09-13 Thread Timothy Baldridge
While working with ClojureScript I came across a interesting question.
When compiling cljs files, how does Clojure handle macros? Normally
macros are run at compile-time, but in this case the compile-time
platform is completely different than the run time platform. My guess
is that the compiler assumes that clojure.core.first (for instance)
functions exactly the same for both the JVM and the JS versions of
Clojure, but I could be wrong there. The only other possibility I can
see is if ClojureScript has some internal JS VM it uses only for macro
expanding.

So what is the situation here?

Thanks for your time,

Timothy

-- 
“One of the main causes of the fall of the Roman Empire was
that–lacking zero–they had no way to indicate successful termination
of their C programs.”
(Robert Firth)

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


N00b alert! - A question on immutable/mutable data structures...

2011-09-13 Thread Trevor
For the most part, I *believe* I understand why immutable data
structures with transactions are important to manage concurrent
operations to shared data, but I often wonder why it matters in some
cases...

For example, what if I have a hash-map that needs to handle concurrent
changes to the data structure, but never needs to have concurrent
changes to a given piece of data (i.e a key/value pair). Wouldn't
there be value in being able to modify the data in-place without
making a copy, or needing to endure the overhead associated with STM?

And if what I am suggesting is reasonable how can I create a mutable
hash-map in Clojure and still use (mostly) the same access functions.

Notes:
* Yes, I have watched Rich's video on identity and state, but it
hasn't helped my understand the above scenario.
* I am not suggesting a hash-map data structure should support mixed
operations.

Thanks,
Trevor



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

2011-09-13 Thread Laurent PETIT
Hi,

2011/9/14 Timothy Baldridge tbaldri...@gmail.com

 While working with ClojureScript I came across a interesting question.
 When compiling cljs files, how does Clojure handle macros? Normally
 macros are run at compile-time, but in this case the compile-time
 platform is completely different than the run time platform. My guess
 is that the compiler assumes that clojure.core.first (for instance)
 functions exactly the same for both the JVM and the JS versions of
 Clojure, but I could be wrong there. The only other possibility I can
 see is if ClojureScript has some internal JS VM it uses only for macro
 expanding.

 So what is the situation here?


My understanding is that ClojureScript macros are Clojure macros, taking
Clojure forms as their inputs. These clojure forms represent the literal
ClojureScript data passed in the macro call in the cljs code. The macro
plays with its input forms as usual, and gives back clojure forms which will
be seamlessly retrofitted to ClojureScripts forms in the right place, before
ClojureScript to Javascript 'compilation'.

HTH,

-- 
Laurent



 Thanks for your time,

 Timothy

 --
 “One of the main causes of the fall of the Roman Empire was
 that–lacking zero–they had no way to indicate successful termination
 of their C programs.”
 (Robert Firth)

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

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: N00b alert! - A question on immutable/mutable data structures...

2011-09-13 Thread Andy Fingerhut
To my knowledge, there are no built-in data structures that are mutable and
that use the same access functions.

There are built-in data structures called transients that are mutable, and
use almost the same hash functions.  Read the docs on transient,
persistent!, conj!, etc.  Transient data structures are restricted to be
modified from a single thread, to avoid concurrency issues.  Any attempt to
modify a transient data structure from multiple threads is detected as an
error at run time.

Note that even the immutable data structures do not make a copy of the
entire data structure.  If the data structure is large, most of the data is
shared between the old and new data structure.  See the tree example on this
Wikipedia page for a small example, but I know I've seen elsewhere pictures
of examples closer to Clojure's persistent data structure implementations:

http://en.wikipedia.org/wiki/Persistent_data_structure

Your scenario: What if I have a hash-map that needs to handle concurrent
changes to the data structure, but never needs to have concurrent changes to
a given piece of data (i.e. a key/value pair).

My question: How do you know, in advance, that it doesn't need to handle
such concurrent changes?

If it is because you have multiple threads that will always modify disjoint
subsets of the keys, then you could have a separate hash-map for each of
those sets of keys (perhaps a transient), and modify each one from its own
thread.  Readers of the hash map would then have to search for keys in
multiple tables, or if it was easy to calculate in advance which table the
key must be in, then only one table lookup is sufficient.

Andy


On Tue, Sep 13, 2011 at 4:00 PM, Trevor tcr1...@gmail.com wrote:

 For the most part, I *believe* I understand why immutable data
 structures with transactions are important to manage concurrent
 operations to shared data, but I often wonder why it matters in some
 cases...

 For example, what if I have a hash-map that needs to handle concurrent
 changes to the data structure, but never needs to have concurrent
 changes to a given piece of data (i.e a key/value pair). Wouldn't
 there be value in being able to modify the data in-place without
 making a copy, or needing to endure the overhead associated with STM?

 And if what I am suggesting is reasonable how can I create a mutable
 hash-map in Clojure and still use (mostly) the same access functions.

 Notes:
 * Yes, I have watched Rich's video on identity and state, but it
 hasn't helped my understand the above scenario.
 * I am not suggesting a hash-map data structure should support mixed
 operations.

 Thanks,
 Trevor



 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group 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: N00b alert! - A question on immutable/mutable data structures...

2011-09-13 Thread Stuart Halloway
 For example, what if I have a hash-map that needs to handle concurrent
 changes to the data structure, but never needs to have concurrent
 changes to a given piece of data (i.e a key/value pair). Wouldn't
 there be value in being able to modify the data in-place without
 making a copy, or needing to endure the overhead associated with STM?

Hi Trevor, 

You should endure the overhead of the STM if you need what the STM provides: 
coordination of activity across identities. But there are several things in 
Clojure that provide identities without STM.  In your example, you could place 
a map inside an atom, which provides atomic transitions between values, but no 
coordination.

Abandoning values entirely should be highly motivated by a specific need. If 
you're there, then Java's concurrent maps are good and appropriate.

Stuart Halloway
Clojure/core
http://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: Macros in ClojureScript

2011-09-13 Thread David Nolen
You can reference macros defined in *clojure* files that are on your
classpath like this:

(ns my.namespace
  (:require-macros [my.macros :as my])

The ClojureScript compiler will use these macros to expand your
ClojureScript source.

Works great.

David

On Tue, Sep 13, 2011 at 6:31 PM, Timothy Baldridge tbaldri...@gmail.comwrote:

 While working with ClojureScript I came across a interesting question.
 When compiling cljs files, how does Clojure handle macros? Normally
 macros are run at compile-time, but in this case the compile-time
 platform is completely different than the run time platform. My guess
 is that the compiler assumes that clojure.core.first (for instance)
 functions exactly the same for both the JVM and the JS versions of
 Clojure, but I could be wrong there. The only other possibility I can
 see is if ClojureScript has some internal JS VM it uses only for macro
 expanding.

 So what is the situation here?

 Thanks for your time,

 Timothy

 --
 “One of the main causes of the fall of the Roman Empire was
 that–lacking zero–they had no way to indicate successful termination
 of their C programs.”
 (Robert Firth)

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

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: N00b alert! - A question on immutable/mutable data structures...

2011-09-13 Thread Trevor
Thanks for the quick responses.

I'll try to answer Andy's question: How do you know, in advance, that
it doesn't need to handle such concurrent changes? ... and at the
same time I will try to provide this example to Stuart, hoping I can
see how using a map inside an atom might work:

Let's say my users log into a web page and each user has a queue that
does stuff for them. Since the users id is unique and each user can
only be logged in from one session, when I use the user id as a key
within a hash-map then I know *well-enough* there will not be any
concurrent changes to that key value pair, particularly since enqueing
means each change is actually an just addition to the stack. -- So I
am picking queue's to make a point... -- Queue's are chosen over lists
as they are both constant time and fast. Being atomic is great, but
wouldn't making a copy of a queue and re-assembling it defeat the
purpose of using it?

So let's try this:

 (def user-queues* (atom (hash-map)))
#'project/user-queues*

 (swap! user-queues* assoc user1 clojure.lang.PersistentQueue/EMPTY)
{user1 #PersistentQueue clojure.lang.PersistentQueue@0}

 (@user-queues* user1)
#PersistentQueue clojure.lang.PersistentQueue@0

I would like to add an item to the users queue, but it seems when
using an atom I can only swap in and out the value as opposed to
modifying the value in-place.

So let's start with just the basic atom'd queue:

 (def q (atom clojure.lang.PersistentQueue/EMPTY))
#'project/q

 (swap! q conj (seconds))
#PersistentQueue clojure.lang.PersistentQueue@d3232253

 (apply list (swap! q conj (seconds)))
(1315961557 1315961570)

awesome.

Now I want to store each users queue in the user-queues* hash-map. How
would I do that while maintaining a real queue? My initial attempts
always lead to reading the full queue into a list, then to conj and
item on that list, then I have to remake a queue to then be stored
back into the map via swapso it's at that point I might as well
not be using a queue - right?

Certainly hash-maps with queue's would be a reasonable idea - right?.

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


Calling a Java call with array from Clojure

2011-09-13 Thread ron peterson
I have a following API call that I need to make from Clojure:

class A

doSomething(java.lang.String arg1, String... args)

so I tried

(def a (new A))   ;this works

(.doSomething a abc efg hij)

;this doesn't work giving me no matching method found: doSomething for
class A

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

2011-09-13 Thread Luc Prefontaine
user= (class (into-array String [s a]))
[Ljava.lang.String;

Luc P.


On Tue, 13 Sep 2011 18:21:31 -0700 (PDT)
ron peterson peterson.ron...@gmail.com wrote:

 I have a following API call that I need to make from Clojure:
 
 class A
 
 doSomething(java.lang.String arg1, String... args)
 
 so I tried
 
 (def a (new A))   ;this works
 
 (.doSomething a abc efg hij)
 
 ;this doesn't work giving me no matching method found: doSomething for
 class A
 



-- 
Luc P.


The rabid Muppet

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

2011-09-13 Thread Luc Prefontaine
Oups I did read the code entirely... you defined a varg method ?


On Tue, 13 Sep 2011 21:34:33 -0400
Luc Prefontaine lprefonta...@softaddicts.ca wrote:

 user= (class (into-array String [s a]))
 [Ljava.lang.String;
 
 Luc P.
 
 
 On Tue, 13 Sep 2011 18:21:31 -0700 (PDT)
 ron peterson peterson.ron...@gmail.com wrote:
 
  I have a following API call that I need to make from Clojure:
  
  class A
  
  doSomething(java.lang.String arg1, String... args)
  
  so I tried
  
  (def a (new A))   ;this works
  
  (.doSomething a abc efg hij)
  
  ;this doesn't work giving me no matching method found: doSomething
  for class A
  
 
 
 



-- 
Luc P.


The rabid Muppet

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

2011-09-13 Thread Luc Prefontaine
My typos errors are horrible tonight, new laptop, new keyboard.

So if you defined a variable argument Java method the String array should work.
But I am not certain about the intent of ... in your code excerpt.

On Tue, 13 Sep 2011 21:43:03 -0400
Luc Prefontaine lprefonta...@softaddicts.ca wrote:

 Oups I did read the code entirely... you defined a varg method ?
 
 
 On Tue, 13 Sep 2011 21:34:33 -0400
 Luc Prefontaine lprefonta...@softaddicts.ca wrote:
 
  user= (class (into-array String [s a]))
  [Ljava.lang.String;
  
  Luc P.
  
  
  On Tue, 13 Sep 2011 18:21:31 -0700 (PDT)
  ron peterson peterson.ron...@gmail.com wrote:
  
   I have a following API call that I need to make from Clojure:
   
   class A
   
   doSomething(java.lang.String arg1, String... args)
   
   so I tried
   
   (def a (new A))   ;this works
   
   (.doSomething a abc efg hij)
   
   ;this doesn't work giving me no matching method found: doSomething
   for class A
   
  
  
  
 
 
 



-- 
Luc P.


The rabid Muppet

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


Rounding the edges of an Emacs beginner

2011-09-13 Thread Timothy Washington
Hey all,


So I'm still an avid vim user. But I see a lot of power in the swank slime
setup, and have been teaching myself emacs to try to leverage it. There are
still a few tricks I haven't got. Maybe my notes are just disorganised, but
I was hoping fellow Clojurians can chime in.



   - ? getting an error when I i) M-x slime-connect or ii) send a form (+1
   1) to swank ; this is after i) a lein swank then ii) in another window
   emacs M-x connect . ** Evaluating Slime forms seems to work after that


webkell@ubuntu:~/Projects/bkell$ lein swank

Listening for transport dt_socket at address: 36109

Connection opened on localhost port 4005.

exception in read loop

java.lang.Exception: Error reading swank message *# this happens when slime
tries to connect with M-x slime-connect *

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)

...

at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

...

at clojure.lang.Var.applyTo(Var.java:518)

at clojure.main.main(main.java:37)

exception in control loop

java.lang.InterruptedException

at
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:1961)

...

at swank.util.concurrent.mbox$receive.invoke(mbox.clj:28)

at swank.core$control_loop.invoke(core.clj:401)

...

at swank.swank$connection_serve$fn__1720.doInvoke(swank.clj:20)

...

at java.lang.Thread.run(Thread.java:619)




   - ? howto do Code completion (clojure, and elisp )
   - ? close a slime-repl connection
   - ? howto list modes engaged
   - ? Also need to increase my skills navigating the debugger. Is this still
   the reference http://georgejahad.com/clojure/swank-cdt.html to use
   -

   ? Can you use Emacs / Slime / CDT (debugging) with Ruby / Rails


As a VIM'er, I'm trying to do the following using emacs navigation, but seem
to have missed the levers to pull. I'm using a vim navigation
pluginhttp://gitorious.org/evil/pages/Home,
which helps a lot.


   - ? set line numbers
   - ? go to line 'n'
   - ? how to jump to matching parentheses
   - ? move down a chunk like in vim
   - ? yank 'n' lines - emacs yank puts back some 'killed' text ; HOWTO
   copy


Thanks
Tim

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

2011-09-13 Thread Alan Malloy
Varargs are a fiction of javac, and do not exist at the bytecode
level. In real life, this method takes two args, a String and a
String[]. Use into-array to create a string array, and pass that as
the second arg.

On Sep 13, 6:21 pm, ron peterson peterson.ron...@gmail.com wrote:
 I have a following API call that I need to make from Clojure:

 class A

 doSomething(java.lang.String arg1, String... args)

 so I tried

 (def a (new A))   ;this works

 (.doSomething a abc efg hij)

 ;this doesn't work giving me no matching method found: doSomething for
 class A

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

2011-09-13 Thread Phil Hagelberg
On Tue, Sep 13, 2011 at 7:13 PM, Timothy Washington twash...@gmail.com wrote:
 ? getting an error when I i) M-x slime-connect or ii) send a form (+1 1)
 to swank ; this is after i) a lein swank then ii) in another window
 emacs M-x connect . ** Evaluating Slime forms seems to work after that

Have you tried M-x clojure-jack-in? It will ensure that the correct
version of slime is loaded. I don't know what's causing your error,
but it could be a slime version mismatch.

 ? howto do Code completion (clojure, and elisp)

The emacs-starter-kit binds M-/ to hippie-expand which hooks into
slime inside the repl and clojure-mode buffers. It can be set up
manually too, but I couldn't tell you how off the top of my head. In
the repl just regular TAB works.

 ? close a slime-repl connection

M-x slime-disconnect

 ? howto list modes engaged

C-h m

 ? Also need to increase my skills navigating the debugger. Is this still the
 reference to use

I think that's right.

 ? Can you use Emacs / Slime / CDT (debugging) with Ruby / Rails

Ruby uses inf-ruby, which is pretty primitive compared to slime. But
it's better than raw irb.

 As a VIM'er, I'm trying to do the following using emacs navigation, but seem
 to have missed the levers to pull. I'm using a vim navigation plugin, which
 helps a lot.

 ? set line numbers

I think there's something called linum-mode for that, but I've never used it.

 ? go to line 'n'

M-g M-g

 ? how to jump to matching parentheses

C-M-b/f

 ? move down a chunk like in vim

Not sure what this means, but C-h t gives you most of the navigation commands.

 ? yank 'n' lines - emacs yank puts back some 'killed' text ; HOWTO copy

M-w

 Thanks

Sure.

-Phil

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

2011-09-13 Thread Timothy Washington
Oh nice one mate.


Yes, I tried M-x clojure-jack-in. The main feature I'm looking for is to be
able to run a jetty / compojure stack, then connect / jack-in to that.


But now that I think about it, I can probably just pass a run jetty / ring
form to swank to start it :) Let me know if I'm on the right path.


Wrt completion, I was looking at Sam Aaron's setuphttp://vimeo.com/25190186,
and thought that would be particularly useful. But your tip did get me a big
part of the way.



Don't want to be lost in a black box http://vimeo.com/21412267 :) Thanks a
bunch

Tim



On Tue, Sep 13, 2011 at 10:42 PM, Phil Hagelberg p...@hagelb.org wrote:

 On Tue, Sep 13, 2011 at 7:13 PM, Timothy Washington twash...@gmail.com
 wrote:
  ? getting an error when I i) M-x slime-connect or ii) send a form (+1
 1)
  to swank ; this is after i) a lein swank then ii) in another window
  emacs M-x connect . ** Evaluating Slime forms seems to work after that

 Have you tried M-x clojure-jack-in? It will ensure that the correct
 version of slime is loaded. I don't know what's causing your error,
 but it could be a slime version mismatch.

  ? howto do Code completion (clojure, and elisp)

 The emacs-starter-kit binds M-/ to hippie-expand which hooks into
 slime inside the repl and clojure-mode buffers. It can be set up
 manually too, but I couldn't tell you how off the top of my head. In
 the repl just regular TAB works.

  ? close a slime-repl connection

 M-x slime-disconnect

  ? howto list modes engaged

 C-h m

  ? Also need to increase my skills navigating the debugger. Is this still
 the
  reference to use

 I think that's right.

  ? Can you use Emacs / Slime / CDT (debugging) with Ruby / Rails

 Ruby uses inf-ruby, which is pretty primitive compared to slime. But
 it's better than raw irb.

  As a VIM'er, I'm trying to do the following using emacs navigation, but
 seem
  to have missed the levers to pull. I'm using a vim navigation plugin,
 which
  helps a lot.
 
  ? set line numbers

 I think there's something called linum-mode for that, but I've never used
 it.

  ? go to line 'n'

 M-g M-g

  ? how to jump to matching parentheses

 C-M-b/f

  ? move down a chunk like in vim

 Not sure what this means, but C-h t gives you most of the navigation
 commands.

  ? yank 'n' lines - emacs yank puts back some 'killed' text ; HOWTO copy

 M-w

  Thanks

 Sure.

 -Phil

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group 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: Calling a Java call with array from Clojure

2011-09-13 Thread ron peterson
Thank you very much. Your suggestions worked:

(.doSomething a abc (into-array String [efg hij]))

On Sep 13, 7:33 pm, Alan Malloy a...@malloys.org wrote:
 Varargs are a fiction of javac, and do not exist at the bytecode
 level. In real life, this method takes two args, a String and a
 String[]. Use into-array to create a string array, and pass that as
 the second arg.

 On Sep 13, 6:21 pm, ron peterson peterson.ron...@gmail.com wrote:







  I have a following API call that I need to make from Clojure:

  class A

  doSomething(java.lang.String arg1, String... args)

  so I tried

  (def a (new A))   ;this works

  (.doSomething a abc efg hij)

  ;this doesn't work giving me no matching method found: doSomething for
  class A

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


run clj file get user/counter-app error?

2011-09-13 Thread jayvandal
I am running a  swing tutorial clojure program file and when I run the
result is
++
user= (load-file c:/clojure-1.2.1/counter-app.clj)
#'user/counter-app
user=
++

What does this line mean?
#'user/counter-app

The name of my file is counter-app.clj
program listing on win Vista IS
--
(import '(javax.swing JLabel JButton JPanel JFrame))


(defn counter-app []
  (let [counter (atom 0)
label (JLabel. Counter: 0)
button (doto (JButton. Add 1)
 (on-action evnt  ;; evnt is not used
   (.setText label
  (str Counter:  (swap! counter inc)
panel (doto (JPanel.)
(.setOpaque true)
(.add label)
(.add button))]
(doto (JFrame. Counter App)
  (.setContentPane panel)
  (.setSize 300 100)
  (.setVisible true

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


Re: Problem with insert-values (clojure.contrib.sql)

2011-09-13 Thread finbeu
Sean, thx for the hint.

But how do I use the connectionpool now from clojure.java.jdbc? 

(defn db-update-or-insert
  Updates or inserts a fruit
  [record]
  (sql/with-connection db
(sql/update-or-insert-values
 :fruit
 [name=? (:name record)]
 record)))

In my scenario, I just have one technical user that writes some data into a 
table. I just want to keep tha connection open all the time.
 
Thx.

- Finn

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

Re: Problem with insert-values (clojure.contrib.sql)

2011-09-13 Thread Sean Corfield
On Tue, Sep 13, 2011 at 10:43 PM, finbeu info_pe...@t-online.de wrote:
 But how do I use the connectionpool now from clojure.java.jdbc?

Did you read that documentation? Does it not provide enough
information? Let me know so I can make it better.
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/

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

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