- and type hints

2009-04-29 Thread Christophe Grand

Hello,

Currently when you have a reflection warning in a - form, you have to 
split it:

clojure.core=  (- hello world (.split  ) second (.split o) seq)
Reflection warning, line: 1269 - call to split can't be resolved.
(w rld)

I propose to modify the - macro to make it preserve type hints, hence 
you could write:

clojure.core= (- hello world (.split  ) #^String second (.split 
o) seq)
(w rld)

Here is the patched macro:

(defmacro -
  Threads the expr through the forms. Inserts x as the
  second item in the first form, making a list of it if it is not a
  list already. If there are more forms, inserts the first form as the
  second item in second form, etc.
  ([x] x)
  ([x form] (with-meta
  (if (seq? form)
`(~(first form) ~x ~@(next form))
(list form x)) (meta form)))
  ([x form  more] `(- (- ~x ~form) ~...@more)))

-- 
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.blogspot.com/ (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
To unsubscribe from 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: - and type hints

2009-04-29 Thread Christophe Grand

Bad example:
  (- hello world (.split  ) #^String second (.split o) seq) ; 
actually works
but not:
  (- hello world (.split  ) #^String (second) (.split o) seq) ; 
works only with the patched -

Christophe Grand a écrit :
 Hello,

 Currently when you have a reflection warning in a - form, you have to 
 split it:

 clojure.core=  (- hello world (.split  ) second (.split o) seq)
 Reflection warning, line: 1269 - call to split can't be resolved.
 (w rld)

 I propose to modify the - macro to make it preserve type hints, hence 
 you could write:

 clojure.core= (- hello world (.split  ) #^String second (.split 
 o) seq)
 (w rld)

 Here is the patched macro:

 (defmacro -
   Threads the expr through the forms. Inserts x as the
   second item in the first form, making a list of it if it is not a
   list already. If there are more forms, inserts the first form as the
   second item in second form, etc.
   ([x] x)
   ([x form] (with-meta
   (if (seq? form)
 `(~(first form) ~x ~@(next form))
 (list form x)) (meta form)))
   ([x form  more] `(- (- ~x ~form) ~...@more)))

   


-- 
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.blogspot.com/ (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
To unsubscribe from 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: - and type hints

2009-04-29 Thread Christophe Grand

Christophe Grand a écrit :
 Bad example:
   (- hello world (.split  ) #^String second (.split o) seq) ; 
 actually works
 but not:
   (- hello world (.split  ) #^String (second) (.split o) seq) ; 
 works only with the patched -
   

Or I should put up and write
  (- hello world (.split  ) (#^String second) (.split o) seq)

Sorry for the noise.

Christophe

-- 
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.blogspot.com/ (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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Feature Request: Easily Embeddable Console

2009-04-29 Thread ianp

IMHO it would be good if there were an easy (i.e. 1-line) way of
embedding Clojure in an existing Swing app. most of the docs out there
cover embedding it in a console application, or using Swank to connect
over a socket.

Ideally, either:

JPanel panel = ...;
panel.add(new ClojureConsole());

or

JTextPane textpane = ...;
ClojureConsole.installIntoTextPane(textpane);

or something like that.

What do people think would be the minimum requirements here? And if I
were to write something like this would people be interested in seeing
it added (to clojure or, maybe more appropriately, clojure-contrib) ?
--~--~-~--~~~---~--~~
You 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: Git with Google Code

2009-04-29 Thread dysinger

Or you can just point github.com at the svn repo.

Stuart Sierra wrote:
 FYI, for those interested in using Git for Clojure sources, here's
 Google's advice on how to use Git with Google Code:

 http://google-opensource.blogspot.com/2008/05/develop-with-git-on-google-code-project.html

 -SS
--~--~-~--~~~---~--~~
You 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: cannot use swig native shared libraries

2009-04-29 Thread Tony Hursh


On Apr 27, 2009, at 8:45 PM, jim wrote:


 Hey Antonio,

 I'm getting a similar error. I wanted to call setuid from Clojure, so
 I followed this link's example:
 http://www2.sys-con.com/itsg/virtualcd/Java/archives/0510/Silverman/index.html

 to build a java class and a shared library. I added the class to my
 classpath and was able to import my UID class. But when I tried to
 call the UID.setuid method, it gave me that UnsatisfiedLinkError. Did
 you find a solution to your problem?

 Jim

 On Apr 22, 8:41 am, Antonio, Fabio Di Narzo
 antonio.fa...@gmail.com wrote:
 Hi all.
 I'm having problems with using swig-generated wrappers with Clojure.
 I'm running ubuntu-8.04-i386, gcc-4.2.4, swig-1.3.33, openjdk-1.6.0,
 latest clojure release.

 I've cut down a minimal reproducible example.


(snip)


Not a direct solution for whatever's going wrong with The Horror That  
Is SWIG, but have you guys tried using JNA instead?

IIRC, the JRuby folks managed to get the entire POSIX library working  
through JNA, and I think I've seen mention of a similar success with  
the Win32API.








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



Example Server in Clojure

2009-04-29 Thread Chris McClellen


I wanted to write an example server in clojure to show some folks at
the office what a full from the ground up application might look like
in clojure.  I wanted a non-trivial example, but not one so complex
that a new clojure user wouldn't understand it.  I had ported some
decent algorithms we used over to clojure and was impressed at the
expressiveness (moving something that took 500+ lines to express in a
more popular language down to 71 sloc).  However, that effort was not
an application, just a set of functions running against test data.

I ended up writing a chat server in clojure, thats weighs in at about
189 lines of code (not counting comments and blank lines).  I am
fairly new to clojure so I was hoping people could take a look at it
and give constructive comments about what I did right and what I did
wrong.

The server implements users, chat rooms, private messaging and so
forth.  It also uses the concurrency built in so I could attempt to
show off the concurrent nature of clojure to my colleagues.

Some things to note:

* I am new to clojure.  I have about 4 weeks of experience now, about
half of it spent reading up on clojure so I could write this thing.  I
am sure  the code will show that off :(
* I realize there is a specification for IRC.  I wanted something
simpler.
* This server is just an example, and it is built around people using
telnet to connect to it.  It is not robust.  Simple things like a
client not reading its input will eventually hang a user thread.
* Lots of IO, so unfortunately, quite a bit of side effects.

I'll probably add features over time.  But please, look at it and give
me feedback so I can get better at clojure.

Here's the link

http://github.com/cmcclellen/crm.chat-server/tree/master


--~--~-~--~~~---~--~~
You 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: cannot use swig native shared libraries

2009-04-29 Thread Antonio, Fabio Di Narzo

2009/4/29 Tony Hursh tony.hu...@gmail.com:


 On Apr 27, 2009, at 8:45 PM, jim wrote:


 Hey Antonio,

 I'm getting a similar error. I wanted to call setuid from Clojure, so
 I followed this link's example:
 http://www2.sys-con.com/itsg/virtualcd/Java/archives/0510/Silverman/index.html

 to build a java class and a shared library. I added the class to my
 classpath and was able to import my UID class. But when I tried to
 call the UID.setuid method, it gave me that UnsatisfiedLinkError. Did
 you find a solution to your problem?

 Jim

 On Apr 22, 8:41 am, Antonio, Fabio Di Narzo
 antonio.fa...@gmail.com wrote:
 Hi all.
 I'm having problems with using swig-generated wrappers with Clojure.
 I'm running ubuntu-8.04-i386, gcc-4.2.4, swig-1.3.33, openjdk-1.6.0,
 latest clojure release.

 I've cut down a minimal reproducible example.


 (snip)


 Not a direct solution for whatever's going wrong with The Horror That
 Is SWIG,
Sure, the SWIG C file is unreadable, and very far from an hypothetical
handwritten C wrapper. However, I would underline that it works
smoothly in the Java language, and only gives problems with Clojure.

I'm also wondering now if the problem is restricted to my linux
platform, or is more general (win, mac, different JDKs, etc.).

but have you guys tried using JNA instead?
I'm working with already existent (SWIG-based) libraries. I'll
consider JNA for the future. Tnx for the tip.

a.


 IIRC, the JRuby folks managed to get the entire POSIX library working
 through JNA, and I think I've seen mention of a similar success with
 the Win32API.








 




-- 
Antonio, Fabio Di Narzo
Ph.D. student at
Department of Statistical Sciences
University of Bologna, Italy

--~--~-~--~~~---~--~~
You 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: Git with Google Code

2009-04-29 Thread Luke Amdor

I believe git-svn doesn't work under msysgit. When I did have use git
under windows, I used cygwin's git. It did everything that the *nix
git could do.

Luke

On Apr 29, 4:03 am, Marko Kocić marko.ko...@gmail.com wrote:
 (defn on-windows [x]
   (use http://code.google.com/p/msysgit;)
   'success)

 On 29 апр, 10:55, dysinger dysin...@gmail.com wrote:

  Let me abstract that out a little for you :P

  (defn on-windows [x]
    (format %s sucks on windows! x))

  On Apr 28, 1:36 pm, Rayne disciplera...@gmail.com wrote:

   Git still sucks on windows :\

   On Apr 28, 11:04 am, Stuart Sierra the.stuart.sie...@gmail.com
   wrote:

FYI, for those interested in using Git for Clojure sources, here's
Google's advice on how to use Git with Google Code:

   http://google-opensource.blogspot.com/2008/05/develop-with-git-on-goo...

-SS


--~--~-~--~~~---~--~~
You 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: UTF-8

2009-04-29 Thread Stephen C. Gilardi


On Apr 29, 2009, at 7:30 AM, David Powell wrote:

So, I'd like to see the constants in RT.java changed to not specify  
UTF-8, but for the encoding used by

the compiler to continue to specify UTF-8.

Anyone have any opinions?


I think your explanation, reasoning, and conclusions are all exactly  
correct and Clojure should change as you described.


--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: Git with Google Code

2009-04-29 Thread Christophe Grand

git-svn has been reenabled in msysgit since one or two releases and 
works well.

Luke Amdor a écrit :
 I believe git-svn doesn't work under msysgit. When I did have use git
 under windows, I used cygwin's git. It did everything that the *nix
 git could do.

 Luke

 On Apr 29, 4:03 am, Marko Kocić marko.ko...@gmail.com wrote:
   
 (defn on-windows [x]
   (use http://code.google.com/p/msysgit;)
   'success)

 On 29 апр, 10:55, dysinger dysin...@gmail.com wrote:

 
 Let me abstract that out a little for you :P
   
 (defn on-windows [x]
   (format %s sucks on windows! x))
   
 On Apr 28, 1:36 pm, Rayne disciplera...@gmail.com wrote:
   
 Git still sucks on windows :\
 
 On Apr 28, 11:04 am, Stuart Sierra the.stuart.sie...@gmail.com
 wrote:
 
 FYI, for those interested in using Git for Clojure sources, here's
 Google's advice on how to use Git with Google Code:
   
 http://google-opensource.blogspot.com/2008/05/develop-with-git-on-goo...
   
 -SS
   
 
 

   


-- 
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.blogspot.com/ (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
To unsubscribe from 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: UTF-8

2009-04-29 Thread Toralf

On Apr 29, 1:30 pm, David Powell djpow...@djpowell.net wrote:
 So, I'd like to see the constants in RT.java changed to not specify UTF-8, 
 but for the encoding used by
 the compiler to continue to specify UTF-8.

+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
To unsubscribe from 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: UTF-8

2009-04-29 Thread Laurent PETIT

Yes, not fixing it before 1.0 would be the kind of thing that people
willing to make FUD on clojure would exploit really easily with great
success:

clojure does not even handle encoding problems well

:'(

2009/4/29 Toralf toralf.witt...@gmail.com:

 On Apr 29, 1:30 pm, David Powell djpow...@djpowell.net wrote:
 So, I'd like to see the constants in RT.java changed to not specify UTF-8, 
 but for the encoding used by
 the compiler to continue to specify UTF-8.

 +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
To unsubscribe from 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: Git with Google Code

2009-04-29 Thread Vincent Foley

http://article.gmane.org/gmane.comp.version-control.git/117039

On Apr 29, 1:01 am, Dan redalas...@gmail.com wrote:
 On Tue, Apr 28, 2009 at 4:36 PM, Rayne disciplera...@gmail.com wrote:

  Git still sucks on windows :\

 On which grounds?

 Or as wikipedia would put it [citation needed]
--~--~-~--~~~---~--~~
You 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
-~--~~~~--~~--~--~---



java enum problem

2009-04-29 Thread brus

Hello to community.
I'm trying to convert this jMonkey Engine java's code to Clojure:
.
public class TestSimpleGame extends SimpleGame {

  public static void main(String[] args) {
TestSimpleGame app = new TestSimpleGame();
app.setConfigShowMode(ConfigShowMode.AlwaysShow);
app.start();
  }

  protected void simpleInitGame() {
display.setTitle(A Simple Test);
Box box = new Box(my box, new Vector3f(0, 0, 0), 2, 2, 2);
box.setModelBound(new BoundingSphere());
box.updateModelBound();
rootNode.attachChild(box);
  }
}
..
ConfigShowMode is enum type:

public abstract class AbstractGame {
private static final Logger logger = Logger.getLogger
(AbstractGame.class
.getName());

public enum ConfigShowMode {
NeverShow,
AlwaysShow,
ShowIfNoConfig;
}
..
so my failure attempt was:
..
(ns jME-hello
  (:import (com.jme.app SimpleGame AbstractGame)
  (com.jme.math Vector3f)
  (com.jme.scene.shape Box)))

(def b (Box. My box (Vector3f. 0 0 0)(Vector3f. 1 1 1)))

(def AShow (proxy [Enum] [AlwaysShow 1]))

(defn main []
(let [app (proxy [SimpleGame] []
   (.simpleInitGame []
   (. (proxy-super rootNoode) attachChild b)))]
   (.setConfigShowMode app AShow)
   (.start app)))

(main)
..
java.lang.ClassCastException: clojure.proxy.java.lang.Enum cannot be
cast to com.jme.app.AbstractGame$ConfigShowMode (NO_SOURCE_FILE:0)
  [Thrown class clojure.lang.Compiler$CompilerException]


Obviously this is newbie problem,
and I made enum type according to previous mails.


--~--~-~--~~~---~--~~
You 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: how do I create a runnable clojure program

2009-04-29 Thread Stuart Sierra

Hi Santanu,
Unfortunately, this is not a well-documented area, but it is
possible.  Here's the high-level view, but don't expect these
instructions to be sufficient:

1. Put (:gen-class) in the (ns...) declaration in your .clj file.

2. Add a -main function like:  (defn -main [ args] ...)

3. Compile your namespace with (compile...)  This generates .class
files.

4. Run your class with java your.namespace.name

5. (Optional)  Use jar or ant to create a .jar file with a manifest
that specifies your class as the Main-Class.

No, this is not easy.  You need to know Java pretty thoroughly to have
any hope of success.  At some point I hope to write an article with
more details.  In the mean time, search the list to learn about gen-
class and compile.

-Stuart Sierra



On Apr 29, 7:04 am, Santanu thisissant...@gmail.com wrote:
 Hi Everybody,

 I wanted to compile a .clj clojure file into a .jar/.class file so
 that I could run it using java. (I don't know what is the actual way
 to run clojure file. So far, I have only been trying it from within
 emacs/slime).

 But I don't know how to create the .class/.jar file. I also don't know
 how to use ant (is that required?). I know javac can be applied on
 a .java file to get a .class file... but I dunno what applies to
 a .clj file?

 Kindly suggest how do I do this. Any pointer(s) to a suitable online
 article would be great.

 Thanks in advance for your help.

 Reards,
 Santanu Chatterjee
--~--~-~--~~~---~--~~
You 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: how do I create a runnable clojure program

2009-04-29 Thread tmountain

There was a very recent thread on the list related to the same
question:

http://groups.google.com/group/clojure/browse_thread/thread/750e5795141cff35#

HTH,
Travis

On Apr 29, 7:04 am, Santanu thisissant...@gmail.com wrote:
 Hi Everybody,

 I wanted to compile a .clj clojure file into a .jar/.class file so
 that I could run it using java. (I don't know what is the actual way
 to run clojure file. So far, I have only been trying it from within
 emacs/slime).

 But I don't know how to create the .class/.jar file. I also don't know
 how to use ant (is that required?). I know javac can be applied on
 a .java file to get a .class file... but I dunno what applies to
 a .clj file?

 Kindly suggest how do I do this. Any pointer(s) to a suitable online
 article would be great.

 Thanks in advance for your help.

 Reards,
 Santanu Chatterjee
--~--~-~--~~~---~--~~
You 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: how do I create a runnable clojure program

2009-04-29 Thread rb



On Apr 29, 1:04 pm, Santanu thisissant...@gmail.com wrote:
 Hi Everybody,

 I wanted to compile a .clj clojure file into a .jar/.class file so
 that I could run it using java. (I don't know what is the actual way
 to run clojure file. So far, I have only been trying it from within
 emacs/slime).

 But I don't know how to create the .class/.jar file. I also don't know
 how to use ant (is that required?). I know javac can be applied on
 a .java file to get a .class file... but I dunno what applies to
 a .clj file?

 Kindly suggest how do I do this. Any pointer(s) to a suitable online
 article would be great.

I remember this helped me:
http://clojure.org/compilation

Cheers

Raphaël


 Thanks in advance for your help.

 Reards,
 Santanu Chatterjee
--~--~-~--~~~---~--~~
You 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: Example Server in Clojure

2009-04-29 Thread tmountain

I'm new to Clojure as well and am also writing a server. Side effects
are hard to avoid when doing things like I/O, so I wouldn't feel too
bad about it. From the looks of your code, you've done a nice job
separating things like network communication from the business logic
of your chat server. I had a look at server-socket in clojure.contrib
when I started my project, but it appeared to create a thread per
connection, so I opted against it. I'm no expert, but I think you
might get better scalability using something like ThreadPoolExecutor
to manage your threads. It probably doesn't matter in your case as
you've said it was a proof of concept, but I'm just throwing that out
there. To test the basics of my server, I setup something in ruby to
make thousands of concurrent connections and see how Clojure would
scale. Somewhere in the 3000-4000 simultaneous connection range, the
ruby script crashed with an error of too many files open. Meanwhile
the Clojure program had 15 threads open and was chugging along
nicely ;-). Of course, this was with Ruby 1.8.x, so things might be
better in the 1.9 branch.

Travis

On Apr 28, 7:27 pm, Chris McClellen chris.mcclel...@gmail.com wrote:
 I wanted to write an example server in clojure to show some folks at
 the office what a full from the ground up application might look like
 in clojure.  I wanted a non-trivial example, but not one so complex
 that a new clojure user wouldn't understand it.  I had ported some
 decent algorithms we used over to clojure and was impressed at the
 expressiveness (moving something that took 500+ lines to express in a
 more popular language down to 71 sloc).  However, that effort was not
 an application, just a set of functions running against test data.

 I ended up writing a chat server in clojure, thats weighs in at about
 189 lines of code (not counting comments and blank lines).  I am
 fairly new to clojure so I was hoping people could take a look at it
 and give constructive comments about what I did right and what I did
 wrong.

 The server implements users, chat rooms, private messaging and so
 forth.  It also uses the concurrency built in so I could attempt to
 show off the concurrent nature of clojure to my colleagues.

 Some things to note:

 * I am new to clojure.  I have about 4 weeks of experience now, about
 half of it spent reading up on clojure so I could write this thing.  I
 am sure  the code will show that off :(
 * I realize there is a specification for IRC.  I wanted something
 simpler.
 * This server is just an example, and it is built around people using
 telnet to connect to it.  It is not robust.  Simple things like a
 client not reading its input will eventually hang a user thread.
 * Lots of IO, so unfortunately, quite a bit of side effects.

 I'll probably add features over time.  But please, look at it and give
 me feedback so I can get better at clojure.

 Here's the link

 http://github.com/cmcclellen/crm.chat-server/tree/master
--~--~-~--~~~---~--~~
You 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: java enum problem

2009-04-29 Thread Stuart Sierra

On Apr 29, 10:14 am, brus emil.bru...@gmail.com wrote:
 (def AShow (proxy [Enum] [AlwaysShow 1]))

I don't think you can proxy an enumeration.  You can use gen-class,
but even that doesn't work perfectly.  You may need to break down and
write some Java.

-Stuart Sierra
--~--~-~--~~~---~--~~
You 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: Example Server in Clojure

2009-04-29 Thread Laurent PETIT

Hi,

Not a thourough analysis of your code, but still one remark at least :

For each of your files that are part of a namespace but the main file,
you should consider placing an (in-ns 'name.of.the.loading.ns) call at
the top of the file.

This will help IDEs, and also you when you just want to reload that
particular file

HTH,

-- 
Laurent

2009/4/29 Chris McClellen chris.mcclel...@gmail.com:


 I wanted to write an example server in clojure to show some folks at
 the office what a full from the ground up application might look like
 in clojure.  I wanted a non-trivial example, but not one so complex
 that a new clojure user wouldn't understand it.  I had ported some
 decent algorithms we used over to clojure and was impressed at the
 expressiveness (moving something that took 500+ lines to express in a
 more popular language down to 71 sloc).  However, that effort was not
 an application, just a set of functions running against test data.

 I ended up writing a chat server in clojure, thats weighs in at about
 189 lines of code (not counting comments and blank lines).  I am
 fairly new to clojure so I was hoping people could take a look at it
 and give constructive comments about what I did right and what I did
 wrong.

 The server implements users, chat rooms, private messaging and so
 forth.  It also uses the concurrency built in so I could attempt to
 show off the concurrent nature of clojure to my colleagues.

 Some things to note:

 * I am new to clojure.  I have about 4 weeks of experience now, about
 half of it spent reading up on clojure so I could write this thing.  I
 am sure  the code will show that off :(
 * I realize there is a specification for IRC.  I wanted something
 simpler.
 * This server is just an example, and it is built around people using
 telnet to connect to it.  It is not robust.  Simple things like a
 client not reading its input will eventually hang a user thread.
 * Lots of IO, so unfortunately, quite a bit of side effects.

 I'll probably add features over time.  But please, look at it and give
 me feedback so I can get better at clojure.

 Here's the link

 http://github.com/cmcclellen/crm.chat-server/tree/master


 


--~--~-~--~~~---~--~~
You 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: learning clojure, converting a sequence with repetitions to a multi-map

2009-04-29 Thread Boris Mizhen

Thanks Christophe,
 Using a default return value, you can rewrite the (if-let...) as (conj
 (amap key ()) item).
A good point, getting clojure and clojure :)

(defn seq-to-multimap
  takes a sequence s of possibly repeating elements
   and converts it to a map, where keys are obtained
   by applying key-fn to elements of s and values are
   sequences of all elements of s with a given key
  [s key-fn]
  (reduce
   (fn [m el]
 (let [key (key-fn el)]
   (assoc m key (conj (m key []) el
   {} s))

Boris

On Apr 28, 5:31 pm, Christophe Grand christo...@cgrand.net wrote:
 Hi Boris,

 Boris Mizhen a écrit :



  I am starting to learn clojure. I would appreciate comments on the
  utility function below.
  Coding style, idiomatic Clojure, comment style, efficiency, naming
  conventions, indentations (used slime) ... anything I should
  improve :)

  (defn seq-to-multimap [s key-fn]
    takes a sequence s of possibly repeating elements
     and converts it to a map, where keys are obtained by applying key-
  fn
     to elements of s and values are sequence of all elements of s with
  the
     particular key
    (reduce
     (fn [amap item]
       (let [key (key-fn item)]
         (assoc amap key
           (if-let [it (amap key)]
             (conj it item)
             (list item)
     {} s))

 First, you misplaced the docstring: it comes before the args vector.
 Using a default return value, you can rewrite the (if-let...) as (conj
 (amap key ()) item).

  user (seq-to-multimap [1 :key :key 2 3 3 nil] #(identity %1))
  {nil (nil), 3 (3 3), 2 (2), :key (:key :key), 1 (1)}

 Here you don't need to write #(identity %1), identity suffices.

  Would it be better to have this function to create a list of lists
  using an equality op instead?

 I think it's a better choice to have it return a map because, to compute
 the result, you need to efficiently index by key.

 --
 Professional:http://cgrand.net/(fr)
 On Clojure:http://clj-me.blogspot.com/(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
To unsubscribe from 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: java enum problem

2009-04-29 Thread brus


On 29 tra, 17:00, Stuart Sierra the.stuart.sie...@gmail.com wrote:
 On Apr 29, 10:14 am, brus emil.bru...@gmail.com wrote:

  (def AShow (proxy [Enum] [AlwaysShow 1]))

 I don't think you can proxy an enumeration.  You can use gen-class,
 but even that doesn't work perfectly.  You may need to break down and
 write some Java.

 -Stuart Sierra

Actually that enum is not needed for display test,
but sooner or later others could be.

Thanks for suggestion Stuart.

Emil
--~--~-~--~~~---~--~~
You 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 talk in NYC May 12

2009-04-29 Thread Stuart Sierra

Hi, Clojurians,
I'll be talking about my work with Clojure at LispNYC on Tuesday, May
12.  Time (evening)  location to be announced.  Slides and
(hopefully) video available after.

Possible topics:
 * Clojure with Java libraries like Hadoop  Solr
 * Deploying a web server with Clojure  Restlet
 * Clojure libs I've written, like test-is

-Stuart Sierra
--~--~-~--~~~---~--~~
You 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: Clojure talk in NYC May 12

2009-04-29 Thread Rich Hickey



On Apr 29, 11:16 am, Stuart Sierra the.stuart.sie...@gmail.com
wrote:
 Hi, Clojurians,
 I'll be talking about my work with Clojure at LispNYC on Tuesday, May
 12.  Time (evening)  location to be announced.  Slides and
 (hopefully) video available after.

 Possible topics:
  * Clojure with Java libraries like Hadoop  Solr
  * Deploying a web server with Clojure  Restlet
  * Clojure libs I've written, like test-is


I'll be there - looking forward to it!

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



Re: Clojure talk in NYC May 12

2009-04-29 Thread Laurent PETIT

2009/4/29 Stuart Sierra the.stuart.sie...@gmail.com:

 Hi, Clojurians,
 I'll be talking about my work with Clojure at LispNYC on Tuesday, May
 12.  Time (evening)  location to be announced.  Slides and
 (hopefully) video available after.

Excellent, keep us informed when the video are available!

Have a nice talk,

-- 
Laurent

--~--~-~--~~~---~--~~
You 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: learning clojure, converting a sequence with repetitions to a multi-map

2009-04-29 Thread Boris Mizhen

Thanks Jason.

merge-with seems to be made to support a function like this, I wonder
where is the slowdown coming from? Is apply slow?

I named your version seq-to-multimap2. The timing results are below:

user (def a (reverse (take 10 (iterate (fn [x] (rand-int 100))
1
#'user/a

user (time (def b (seq-to-multimap2 a identity)))
Elapsed time: 443.774747 msecs
#'user/b

user (time (def b (seq-to-multimap a identity)))
Elapsed time: 146.814412 msecs
#'user/b


user (def a (reverse (take 10 (iterate (fn [x] (rand-int 10))
1
#'user/a

user (time (def b (seq-to-multimap a identity)))
Elapsed time: 70.812128 msecs
#'user/b

user (time (def b (seq-to-multimap2 a identity)))
Elapsed time: 284.089358 msecs
#'user/b


user (def a (reverse (take 10 (iterate (fn [x] (rand-int 1))
1
#'user/a

user (time (def b (seq-to-multimap2 a identity)))
Elapsed time: 530.553921 msecs
#'user/b

user (time (def b (seq-to-multimap a identity)))
Elapsed time: 240.03259 msecs
#'user/b

Regards,
Boris

On Apr 28, 7:28 pm, Jason Wolfe jawo...@berkeley.edu wrote:
 (defn seq-to-multimap
   takes a sequence s of possibly repeating elements
    and converts it to a map, where keys are obtained by applying key-
 fn
    to elements of s and values are sequence of all elements of s with
    the particular key
   [s key-fn]
   (apply merge-with concat
      (map (fn [x] {(key-fn x) [x]}) s)))

 Here's a more concise, but probably significantly slower version 

 -Jason
--~--~-~--~~~---~--~~
You 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: Clojure talk in NYC May 12

2009-04-29 Thread Stuart Sierra

On Apr 29, 11:21 am, Rich Hickey richhic...@gmail.com wrote:
 I'll be there - looking forward to it!

Ooh, pressure. Guess I gotta make it good.
-SS
--~--~-~--~~~---~--~~
You 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: learning clojure, converting a sequence with repetitions to a multi-map

2009-04-29 Thread Christophe Grand

IMHO, the slowdown comes from allocation:
with
  (apply merge-with concat (map (fn [x] {(key-fn x) [x]}) s))

you build a map containing a vector, plus a seq (merge-with calls seq on each 
argument) for each item before performing a reduction which calls assoc and 
concat.
In seq-to-multimap you only perform a reduction which calls assoc and conj.

Plus in seq-to-multimap2, the values of the returned map are unrealized lazy 
seqs.



Boris Mizhen a écrit :
 Thanks Jason.

 merge-with seems to be made to support a function like this, I wonder
 where is the slowdown coming from? Is apply slow?

 I named your version seq-to-multimap2. The timing results are below:
 
 user (def a (reverse (take 10 (iterate (fn [x] (rand-int 100))
 1
 #'user/a

 user (time (def b (seq-to-multimap2 a identity)))
 Elapsed time: 443.774747 msecs
 #'user/b

 user (time (def b (seq-to-multimap a identity)))
 Elapsed time: 146.814412 msecs
 #'user/b

 
 user (def a (reverse (take 10 (iterate (fn [x] (rand-int 10))
 1
 #'user/a

 user (time (def b (seq-to-multimap a identity)))
 Elapsed time: 70.812128 msecs
 #'user/b

 user (time (def b (seq-to-multimap2 a identity)))
 Elapsed time: 284.089358 msecs
 #'user/b

 
 user (def a (reverse (take 10 (iterate (fn [x] (rand-int 1))
 1
 #'user/a

 user (time (def b (seq-to-multimap2 a identity)))
 Elapsed time: 530.553921 msecs
 #'user/b

 user (time (def b (seq-to-multimap a identity)))
 Elapsed time: 240.03259 msecs
 #'user/b

 Regards,
 Boris

 On Apr 28, 7:28 pm, Jason Wolfe jawo...@berkeley.edu wrote:
   
 (defn seq-to-multimap
   takes a sequence s of possibly repeating elements
and converts it to a map, where keys are obtained by applying key-
 fn
to elements of s and values are sequence of all elements of s with
the particular key
   [s key-fn]
   (apply merge-with concat
  (map (fn [x] {(key-fn x) [x]}) s)))

 Here's a more concise, but probably significantly slower version 

 -Jason
 
 

   


-- 
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.blogspot.com/ (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
To unsubscribe from 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: Example Server in Clojure

2009-04-29 Thread Phil Hagelberg

Chris McClellen chris.mcclel...@gmail.com writes:

 I ended up writing a chat server in clojure, thats weighs in at about
 189 lines of code (not counting comments and blank lines).  I am
 fairly new to clojure so I was hoping people could take a look at it
 and give constructive comments about what I did right and what I did
 wrong.

Cool.

I wrote a small multiplayer text adventure game to use as an example in
the PeepCode screencast. [1] But the code is small and pretty
understandable, so it might be interesting if you want to take a look at
a fairly similar project.

  http://github.com/technomancy/mire

I have it broken up into steps where each one builds on the last. Each
step is stored as a separate git branch, so you can walk through the
creation of the project as it occurred.

Hope it's useful!

Phil
http://technomancy.us

[1] - http://peepcode.com/products/functional-programming-with-clojure

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Feature Request: Easily Embeddable Console

2009-04-29 Thread kyle smith

See repl.clj in the files section.  I've embedded it in a few of my
apps, and it's quite nice.
--~--~-~--~~~---~--~~
You 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: Getting slime-edit-definition to work with Clojure

2009-04-29 Thread Christopher Wilson

Here's a .emacs snippet that works for me:

;; SLIME setup (clojure)
(add-to-list 'load-path ~/.emacs.d/slime/)  ; your SLIME directory
(add-to-list 'load-path ~/.emacs.d/) ; clojure-mode.el is here
(add-to-list 'load-path ~/.emacs.d/swank-clojure) ; swank-clojure directory
(setq swank-clojure-binary ~/bin/clojure) ; shell script that invokes clojure
(require 'clojure-mode)
(require 'swank-clojure-autoload)
(require 'slime)

(eval-after-load slime
  '(progn
 (add-to-list 'load-path ~/.emacs.d/slime/contrib)
 (slime-setup '(slime-fancy slime-banner))
 (setq slime-complete-symbol*-fancy t)
 (setq slime-complete-symbol-function 'slime-fuzzy-complete-symbol)))

You can of course remove the slime-fancy and the slime-banner if
you wish. I hope this helps

--Chris

On Tue, Apr 28, 2009 at 1:28 PM, Baishampayan Ghose
b.gh...@ocricket.com wrote:

 Phil,

 I suspect the problem might have to do with the fact that you're
 configuring slime for both SBCL and Clojure. I know it's possible to
 get this working, but it's a lot more complicated that way. I'd
 suggest having one file for clojure slime config and one for sbcl, and
 only load one of them per Emacs instance.

 I'm sure someone who's more familiar with SLIME and Common Lisp could
 figure out a solution, but this seems like simplest solution.

 My eyes lit up for a second! I removed all SBCL support from SLIME and
 it still doesn't work :(

 Can you kindly share your working dotfiles and enlighten me?

 My current .emacs has this:
 ;;;

 (require 'slime)
 (slime-setup '(slime-fancy slime-banner slime-mdot-fu))

 (defvar slime-net-coding-system
  (find-if 'slime-find-coding-system
           '(utf-8-unix iso-latin-1-unix iso-8859-1-unix binary)))

 ;;; Clojure specific
 (defvar clj-root (concat (expand-file-name ~) /clojure/))
 (setq load-path (append
                 (list (concat clj-root clojure-mode)
                       (concat clj-root swank-clojure))
                 load-path))

 (setq swank-clojure-binary clojure)

 (require 'swank-clojure-autoload)

 (add-to-list 'slime-lisp-implementations
             '(clojure (/home/ghoseb/bin/clojure) :init
 swank-clojure-init))

 (require 'clojure-mode)
 (eval-after-load 'clojure-mode '(clojure-slime-config))

 (autoload 'clojure-mode clojure-mode A major mode for Clojure t)
 (add-to-list 'auto-mode-alist '(\\.clj$ . clojure-mode))

 (defun lisp-enable-paredit-hook ()
  (paredit-mode 1))

 (add-hook 'clojure-mode-hook 'lisp-enable-paredit-hook)

 (defun clj ()
  Starts Clojure in Slime
  (interactive)
  (slime 'clojure))
 ;;;

 Regards,
 BG

 --
 Baishampayan Ghose b.gh...@ocricket.com
 oCricket.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
To unsubscribe from 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: UTF-8

2009-04-29 Thread Rich Hickey



On Apr 29, 9:25 am, Laurent PETIT laurent.pe...@gmail.com wrote:
 Yes, not fixing it before 1.0 would be the kind of thing that people
 willing to make FUD on clojure would exploit really easily with great
 success:

 clojure does not even handle encoding problems well


Ok - patch welcome ASAP (not singling out you Laurent :)

Thanks,

Rich


 2009/4/29 Toralf toralf.witt...@gmail.com:



  On Apr 29, 1:30 pm, David Powell djpow...@djpowell.net wrote:
  So, I'd like to see the constants in RT.java changed to not specify UTF-8, 
  but for the encoding used by
  the compiler to continue to specify UTF-8.

  +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
To unsubscribe from 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: more vimclojure

2009-04-29 Thread Meikel Brandmeyer

Hi,

Am 29.04.2009 um 04:42 schrieb Johan Berntsson:


I've been emailing directly to Meikel, but perhaps a issue tracker of
some kind would be good? It is of course up to Meikel, and VimClojure
is already good enough for me to use for all my Clojure hacking
(including some paid work).


As for bug reports there are several possible places:

- here (I feel a little uncomfortable with that, but as long as
  the I can't get SLIME to work thread show up, it's ok, I
  think)

- me (writing a personal mail is always possible)

- the issue tracker: http://bitbucket.org/kotarak/vimclojure/issues/
  Although I'd like to follow Rich's example and would like
  to request, that issues are discussed with me before a ticket
  is opened.

I'm glad to see that VimClojure has a growing user basis
and people have good experiences with it. :)

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: more vimclojure

2009-04-29 Thread Meikel Brandmeyer

Hi Adrian,

Am 29.04.2009 um 07:00 schrieb Adrian Cuthbertson:


In the absence of an issue tracker at this time, could I mention the
following relating to indenting;

(defn xxx
 Some stuff...

(defmacro xxx
 Some stuff...

(defroutes xxx
Some stuf...


This can be configured using the lispwords option of Vim.
Do a :setlocal lispwords+=defroutes and you should get the
desired behaviour.

This is a built-in functionality. Since I come from Scheme, I knew
this option. However this question arose several times now, so
I guess that people coming eg. from Java don't know this Vim
option. So my cultural assumption that Lisp hackers know this
is maybe true, but not really applicable here. I will extend the
documentation.


Thanks Meikel, great work!


Thanks for the feedback! :)

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: UTF-8

2009-04-29 Thread Stephen C. Gilardi


On Apr 29, 2009, at 12:54 PM, Rich Hickey wrote:


Ok - patch welcome ASAP (not singling out you Laurent :)



I've entered an issue and provided a patch:

http://code.google.com/p/clojure/issues/detail?id=112

Thanks,

--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: Clojure talk in NYC May 12

2009-04-29 Thread DiG

I will be there too.

On Apr 29, 11:16 am, Stuart Sierra the.stuart.sie...@gmail.com
wrote:
 Hi, Clojurians,
 I'll be talking about my work with Clojure at LispNYC on Tuesday, May
 12.  Time (evening)  location to be announced.  Slides and
 (hopefully) video available after.

 Possible topics:
  * Clojure with Java libraries like Hadoop  Solr
  * Deploying a web server with Clojure  Restlet
  * Clojure libs I've written, like test-is

 -Stuart Sierra
--~--~-~--~~~---~--~~
You 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: Getting slime-edit-definition to work with Clojure

2009-04-29 Thread Phil Hagelberg

Baishampayan Ghose b.gh...@ocricket.com writes:

 Can you kindly share your working dotfiles and enlighten me?

I use M-x clojure-install plus (clojure-slime-config), since I wrote
it. This this is _all_ you need for projects that don't have
dependencies on third-party jars.

For some other projects, I've been using maven to handle the
dependencies. For those, I use this function to start up SLIME:

(defun slime-project (path)
  Setup classpaths for a clojure project and starts a new SLIME session.

Kills existing SLIME session, if any.
  (interactive (list
(ido-read-directory-name
 Project root: 
 (locate-dominating-file default-directory pom.xml
  (when (get-buffer *inferior-lisp*)
(kill-buffer *inferior-lisp*))
  (setq swank-clojure-binary nil
swank-clojure-jar-path (expand-file-name target/dependency/ path)
swank-clojure-extra-classpaths
(mapcar (lambda (d) (expand-file-name d path))
'(src/ target/classes/ test/))
swank-clojure-extra-vm-args
(list (format -Dclojure.compile.path=%s
  (expand-file-name target/classes/ path)))
slime-lisp-implementations
(cons `(clojure ,(swank-clojure-cmd) :init swank-clojure-init)
  (remove-if #'(lambda (x) (eq (car x) 'clojure))
 slime-lisp-implementations)))
  (save-window-excursion
(slime)))

The main difference is that the project is self-contained; it uses the
copy of clojure that Maven has placed in target/dependency, and all the
dependent jars are unpacked there too. It does require Emacs23 for the
call to locate-dominating-file.

 (setq swank-clojure-binary clojure)

 (add-to-list 'slime-lisp-implementations
  '(clojure (/home/ghoseb/bin/clojure) :init
 swank-clojure-init))

It looks like you're using a wrapper script rather than letting
swank-clojure construct a java command-line invocation. I'm not sure
why you're doing this; working with the defaults might fix it.

-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
To unsubscribe from 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: more vimclojure

2009-04-29 Thread Mitch

I'd like to add how great I think VimClojure is.  It's truly an
amazing environment and I don't think I'd be able to enjoy clojure as
much without it.  I'm too committed to vim to learn emacs for a new
language.  Thanks a lot Meikel!

On Apr 29, 10:13 am, Meikel Brandmeyer m...@kotka.de wrote:
 Hi Adrian,

 Am 29.04.2009 um 07:00 schrieb Adrian Cuthbertson:

  In the absence of an issue tracker at this time, could I mention the
  following relating to indenting;

  (defn xxx
   Some stuff...

  (defmacro xxx
   Some stuff...

  (defroutes xxx
                  Some stuf...

 This can be configured using the lispwords option of Vim.
 Do a :setlocal lispwords+=defroutes and you should get the
 desired behaviour.

 This is a built-in functionality. Since I come from Scheme, I knew
 this option. However this question arose several times now, so
 I guess that people coming eg. from Java don't know this Vim
 option. So my cultural assumption that Lisp hackers know this
 is maybe true, but not really applicable here. I will extend the
 documentation.

  Thanks Meikel, great work!

 Thanks for the feedback! :)

 Sincerely
 Meikel

  smime.p7s
 5KViewDownload
--~--~-~--~~~---~--~~
You 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: more vimclojure

2009-04-29 Thread Meikel Brandmeyer

Hi,

Am 29.04.2009 um 19:07 schrieb Meikel Brandmeyer:


- here (I feel a little uncomfortable with that, but as long as
 the I can't get SLIME to work thread show up, it's ok, I
 think)


A fourth place is now the VimClojure Google Group:
http://groups.google.com/group/vimclojure

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: how do I create a runnable clojure program

2009-04-29 Thread Santanu

Thanks everyone for your suggestions.
I somehow managed to compile my first clojure program, generating a
class file that I could run using java.
I started with the overview provided by Stuart Sierra, and read the
article pointed by Raphaël. Didn't work at first, but after some trial
and error, it worked somehow. The main problem is that I don't know
any Java yet (I just started reading Core Java vol.1 as suggested by
this group a few days ago).

Anyways, I am mentioning the process I used. Please suggest any better
(shorter/simpler) ways if you feel this is not the right way to do it.

1. I created a simple test2.clj file in my $HOME:
---
(ns test2
  (:gen-class))

(defn -main [ args]
  (println Hello, world of Clojure!))


2. I started a clojure REPL, from a terminal:

sant...@lenny:~$ java -cp /home/santanu/:/opt/clojure/clojure.jar
clojure.lang.Repl


3. Inside the REPL, I compiled my program using:

(binding [*compile-path* /home/santanu]
  (do
(load-file test2.clj)
(compile 'test2)))


4. Got out of the REPL, and ran the program using:

sant...@lenny:~$ java -cp ./:/opt/clojure/clojure.jar test2
Hello, world of Clojure!


One thing I noticed was that the above run takes an aweful amount of
time to run, much much more than a similar compiled java program:

-
sant...@lenny:~$ time java -cp /home/santanu/:/opt/clojure/clojure.jar
test2
Hello, world of Clojure!

real0m1.093s
user0m0.952s
sys 0m0.064s

sant...@lenny:~$ time java Test
Hello, World of Java!

real0m0.105s
user0m0.040s
sys 0m0.008s
-
I think I am definitely missing something here.

Regards,
Santanu Chatterjee
--~--~-~--~~~---~--~~
You 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: UTF-8

2009-04-29 Thread Rich Hickey



On Apr 29, 1:24 pm, Stephen C. Gilardi squee...@mac.com wrote:
 On Apr 29, 2009, at 12:54 PM, Rich Hickey wrote:

  Ok - patch welcome ASAP (not singling out you Laurent :)

 I've entered an issue and provided a patch:

http://code.google.com/p/clojure/issues/detail?id=112


Patch applied - rev 1360 - thanks!

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



The function of clojure.contrib.accumulators

2009-04-29 Thread samppi

Could someone give me a simple example of when
clojure.contrib.accumulators is useful? Its use seems to involve
collections (and numbers) that have the :clojure.contrib.accumulators/
accumulator type, and it has some general multimethods for adding and
combining, but what does it add that conj and concat do not provide?
contrib.monads/writer-m seems to suggest using accumulators, too...
--~--~-~--~~~---~--~~
You 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: UTF-8

2009-04-29 Thread Perry Trolard

For those on OS X -- who probably don't want the default MacRoman --
or anyone else who wants to override the system default, I wanted to
point out that setting the file.encoding system property when
invoking java (e.g. `java -Dfile.encoding=UTF-8 ... clojure.main`)
will set the encoding for in, out,  err. If you want to override
globally, this is easier than re-binding the vars.

Perry
--~--~-~--~~~---~--~~
You 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: UTF-8

2009-04-29 Thread Laurent PETIT

2009/4/29 Stephen C. Gilardi squee...@mac.com:

 On Apr 29, 2009, at 12:54 PM, Rich Hickey wrote:

 Ok - patch welcome ASAP (not singling out you Laurent :)


 I've entered an issue and provided a patch:

        http://code.google.com/p/clojure/issues/detail?id=112


That was quick ! :-)

--~--~-~--~~~---~--~~
You 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: Git with Google Code

2009-04-29 Thread Kevin O'Neill

no you have that the wrong way around. windows sucks :)

if you dont want to (or can't) use git-svn i maintain a mirror on git
hub (http://github.com/kevinoneill/clojure/tree/master).

-k.

On Wed, Apr 29, 2009 at 6:36 AM, Rayne disciplera...@gmail.com wrote:

 Git still sucks on windows :\

 On Apr 28, 11:04 am, Stuart Sierra the.stuart.sie...@gmail.com
 wrote:
 FYI, for those interested in using Git for Clojure sources, here's
 Google's advice on how to use Git with Google Code:

 http://google-opensource.blogspot.com/2008/05/develop-with-git-on-goo...

 -SS
 




-- 
email: ke...@oneill.id.au
web: http://kevin.oneill.id.au/

If you don't test then your code is only a collection of bugs which
apparently behave like a working program.

--~--~-~--~~~---~--~~
You 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: Git with Google Code

2009-04-29 Thread Cosmin Stejerean
On Wed, Apr 29, 2009 at 3:57 PM, Kevin O'Neill ke...@oneill.id.au wrote:


 no you have that the wrong way around. windows sucks :)

 if you dont want to (or can't) use git-svn i maintain a mirror on git
 hub (http://github.com/kevinoneill/clojure/tree/master).


Thanks for maintaining that, it's what I always use to check out Clojure.
I'm curious, how frequently is that updated from SVN? (Meaning, what is the
longest amount of time a commit can exist in SVN but not in your mirror?)
I've never had a problem, but I'd like to know for future reference.

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



Metadata for Any Object

2009-04-29 Thread Stu Hood
Hey gang,

Metadata support for pure Java objects is not currently supported, because
it requires a modification to the object. Additionally, only some Clojure
objects support metadata, due to the necessity of implementing the IMeta
interface. This can be confusing for new users, and eliminates some of the
utility.

Instead of attaching the metadata directly to the object, what if the
metadata was stored outside the object, in a global map of {object metadata,
...}? In order to handle garbage collection, something similar to Java's
WeakHashMap could be used, with the object itself as the key.

I know global state is Considered Harmful, but I think this would clarify
the usage of metadata, and remove duplication in the implementation of
Clojure.

Thoughts?
Stu

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



Monads tutorial Part 2

2009-04-29 Thread jim

I've just posted the second part of my monads tutorial at:

http://intensivesystems.net/tutorials/monads_201.html

I need to proof it further, so if you see problems with content,
grammar or spelling. Comment here or send me an email.

Jim
--~--~-~--~~~---~--~~
You 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
-~--~~~~--~~--~--~---



Dropping strings.

2009-04-29 Thread Nicolas Buduroi

Hi, I was wondering if there's a drop function somewhere in contrib
that work for strings. I didn't found any so I wrote my own:

(defn drop-str
  ([s] (drop-str 1 s))
  ([n s] (apply str (drop n (seq s)

This is not really fast, a better version would be something like
that:

(defn drop-str [n #^String s]
  (let [l (.length s)]
(.substring s (if ( n l) l n

Any suggestions?

- budu

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



update/update-in

2009-04-29 Thread mifrai

Hi,

I was wondering why there was no update to update-in? But there is
an assoc to assoc-in and a get to a get-in.

- 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
To unsubscribe from 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: update/update-in

2009-04-29 Thread David Nolen
Because update-in can use any function to do the update.

On Wed, Apr 29, 2009 at 6:54 PM, mifrai fraim...@gmail.com wrote:


 Hi,

 I was wondering why there was no update to update-in? But there is
 an assoc to assoc-in and a get to a get-in.

 - 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
To unsubscribe from 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: update/update-in

2009-04-29 Thread mifrai

Thanks for the quick reply and I understand that's the functionality
of it.

But just like get-in is the recursive form of get - I'm just wondering
why there's no singular form of update-in.

I know it's not much more work to go (update-in map [:single-key] conj
3) - but from experience there tends be really good reasons behind
these kinds of decisions and I'm just curious.

On Apr 29, 4:05 pm, David Nolen dnolen.li...@gmail.com wrote:
 Because update-in can use any function to do the update.

 On Wed, Apr 29, 2009 at 6:54 PM, mifrai fraim...@gmail.com wrote:

  Hi,

  I was wondering why there was no update to update-in? But there is
  an assoc to assoc-in and a get to a get-in.

  - 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
To unsubscribe from 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: Metadata for Any Object

2009-04-29 Thread Stuart Sierra

On Apr 29, 5:58 pm, Stu Hood stuh...@gmail.com wrote:
 Instead of attaching the metadata directly to the object, what if the
 metadata was stored outside the object, in a global map of {object metadata,
 ...}? In order to handle garbage collection, something similar to Java's
 WeakHashMap could be used, with the object itself as the key.

Interesting idea.

There might be performance penalities, depending on how often metadata
is used.  Metadata guarantees atomic updates (alter-meta!) so the
WeakHashMap might need to be wrapped in a synchronized map, at a
further penalty.

I've never needed metadata on non-Clojure types.  Do you have a use in
mind?

This could be a library, too, sort of like:

(defn my-meta [object]
  (if (instance? clojure.lang.IMeta object)
  (meta object)
  (*global-metadata* object)))

-SS
--~--~-~--~~~---~--~~
You 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
-~--~~~~--~~--~--~---



regex replace all?

2009-04-29 Thread Mark Derricutt
Does clojure come with a built-in regex replace method?  I see ones for
re-split, re-seq etc. but nothing for a simple replace, I've been using:

(defn replace-all
  [st reps]
  (reduce #(.replaceAll %1 (first %2) (second %2)) st reps))

but wondered if I was just missing some builtin?

-- 
Discouragement is a dissatisfaction with the past, a distaste for the
present, and a distrust of the future - Maree De Jong, Life Church New
Zealand.
http://www.talios.com

Sent from Auckland, Auk, New Zealand

--~--~-~--~~~---~--~~
You 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: Metadata for Any Object

2009-04-29 Thread Laurent PETIT

Hi,

2009/4/30 Stuart Sierra the.stuart.sie...@gmail.com:

 On Apr 29, 5:58 pm, Stu Hood stuh...@gmail.com wrote:
 Instead of attaching the metadata directly to the object, what if the
 metadata was stored outside the object, in a global map of {object metadata,
 ...}? In order to handle garbage collection, something similar to Java's
 WeakHashMap could be used, with the object itself as the key.

 Interesting idea.

 There might be performance penalities, depending on how often metadata
 is used.  Metadata guarantees atomic updates (alter-meta!) so the
 WeakHashMap might need to be wrapped in a synchronized map, at a
 further penalty.

I guess this would not be sufficient: WeakHashMap are not side-effect
free: they mutate every time one of their key is removed :
When a key has been discarded its entry is effectively removed from
the map, so this class behaves somewhat differently than other Map
implementations.

, making them improper to be used within STM transactions and such.

Regards,

-- 
Laurent



 I've never needed metadata on non-Clojure types.  Do you have a use in
 mind?

 This could be a library, too, sort of like:

 (defn my-meta [object]
  (if (instance? clojure.lang.IMeta object)
      (meta object)
      (*global-metadata* object)))

 -SS
 

--~--~-~--~~~---~--~~
You 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: regex replace all?

2009-04-29 Thread Baishampayan Ghose

Mark Derricutt wrote:
 Does clojure come with a built-in regex replace method?  I see ones for
 re-split, re-seq etc. but nothing for a simple replace, I've been using:
 
 (defn replace-all
   [st reps]
   (reduce #(.replaceAll %1 (first %2) (second %2)) st reps))

There is re-gsub in clojure-contrib.str-utils.

Regards,
BG

-- 
Baishampayan Ghose b.gh...@ocricket.com
oCricket.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
To unsubscribe from 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: update/update-in

2009-04-29 Thread David Nolen
I see what you mean, does seem like a useful addition:
(defn update [m k f  args]
  (assoc m k (apply f (k m) args)))

(update {:foo 0} :foo inc)

vs.

(assoc {:foo 0} :foo (inc (:foo {:foo 0})))

On Wed, Apr 29, 2009 at 7:13 PM, mifrai fraim...@gmail.com wrote:


 Thanks for the quick reply and I understand that's the functionality
 of it.

 But just like get-in is the recursive form of get - I'm just wondering
 why there's no singular form of update-in.

 I know it's not much more work to go (update-in map [:single-key] conj
 3) - but from experience there tends be really good reasons behind
 these kinds of decisions and I'm just curious.

 On Apr 29, 4:05 pm, David Nolen dnolen.li...@gmail.com wrote:
  Because update-in can use any function to do the update.
 
  On Wed, Apr 29, 2009 at 6:54 PM, mifrai fraim...@gmail.com wrote:
 
   Hi,
 
   I was wondering why there was no update to update-in? But there is
   an assoc to assoc-in and a get to a get-in.
 
   - 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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---