Re: Best practices for Slime with Clojure

2009-05-17 Thread Craig McDaniel

Hi Glen, Everybody seems to have their own approach. I use a run-slime
wrapper emacs function discussed here:
http://groups.google.com/group/clojure/browse_thread/thread/855804aa6fdd74a1/0969640bc5637bd7)

Here is the emacs code I use:

(defun reset-swank ()
  Because changing swank-clojure-extra-classpaths is not enough
to force a new instance of slime to use it.
  (interactive)
  (setq slime-lisp-implementations
(assq-delete-all 'clojure slime-lisp-implementations))
  (add-to-list 'slime-lisp-implementations
   `(clojure ,(swank-clojure-cmd) :init swank-clojure-
init) t))

(defun run-slime (dir)
  (interactive DProject directory: )
  (cd dir)
  (when (not (file-directory-p classes))
(make-directory classes))
  (setq swank-clojure-extra-classpaths '(src classes lib/*))
  (reset-swank)
  (slime))

Good Luck,
Craig
--~--~-~--~~~---~--~~
You 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
-~--~~~~--~~--~--~---



Adding dependent jars without restarting your repl

2009-04-22 Thread Craig McDaniel

Phil, that's useful advice about unpacking jar files to a project's
dependency directory versus dropping jar files in there. That would be
a good candidate for a FAQ regarding how to add dependent jars during
development without restarting your REPL. And it decreases questions
about the deprecated add-classpath function.

-Craig

--~--~-~--~~~---~--~~
You 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: Wrapper function for slime

2009-04-21 Thread Craig McDaniel

Correction:

(defun reset-swank ()
  Because changing swank-clojure-extra-classpaths is not enough
to force a new instance of slime to use it.
  (interactive)
  (setq slime-lisp-implementations
(assq-delete-all 'clojure slime-lisp-implementations))
  (add-to-list 'slime-lisp-implementations
   `(clojure ,(swank-clojure-cmd) :init swank-clojure-
init) t))

(defun run-slime (dir)
  (interactive DProject directory: )
  (cd dir)
  (when (not (file-directory-p classes))
(make-directory classes))
  (setq swank-clojure-extra-classpaths '(src classes lib/*))
  (reset-swank)
  (slime))

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



Wrapper function for slime

2009-04-20 Thread Craig McDaniel

Using something like this run-slime wrapper to start slime may be
useful to others. It helps me avoid some issues when moving from
project to project without restarting emacs. Assuming jar files reside
in each separate project's own lib directory, Clojure source in its
src directory, and compiled classes in its classes directory, run-
slime does the following:

- changes the classpath used by swank-clojure for each project. This
was tricky because simply setting swank-clojure-extra-classpaths and
restarting slime won't do it. The contents of the slime-lisp-
implementations list must be changed.

- makes sure AOT compiling works by creating the classes directory
and setting the classpath to include both the src and classes
directories. Even if you specify the classes dir in the classpath,
it won't work unless the directory exists in advance of starting
slime.

- also sets the classpath to include all files in the lib
subdirectory. (Note that the lib/* classpath syntax won't work on Java
5.)

(defun reset-swank ()
  Because changing swank-clojure-extra-classpaths is not enough
to force a new instance of slime to use it.
  (interactive)
  (assq-delete-all 'clojure slime-lisp-implementations)
  (add-to-list 'slime-lisp-implementations
   `(clojure ,(swank-clojure-cmd) :init swank-clojure-
init) t))

(defun run-slime (dir)
  (interactive DProject directory: )
  (cd dir)
  (when (not (file-directory-p classes))
(make-directory classes))
  (setq swank-clojure-extra-classpaths '(src classes lib/*))
  (reset-swank)
  (slime))


--~--~-~--~~~---~--~~
You 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: generated class with overloaded methods

2009-02-13 Thread Craig McDaniel

Christophe, you're right. I tried it and that method also works. I
didn't know about that secret feature.

(ns expmeth.TestMe
  (:gen-class
   :extends expmeth.ClassA
   :exposes-methods {hello helloSuper}))

(defn -hello [this]
 (.helloSuper this)
 (println hello from clojure!))

(defn -hello-String [this x]
  (.helloSuper this x)
  (println hello-String from clojure x))

(defn -hello-int [this x]
  (.helloSuper this x)
  (println hello-int from clojure... 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
To unsubscribe from 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: generated class with overloaded methods

2009-02-13 Thread Craig McDaniel

On Feb 13, 9:59 am, Laurent PETIT laurent.pe...@gmail.com wrote:
 Your example code below is not complete (where's helloSuper definition ?),

Yes, it is complete. See :exposes-methods under (doc gen-class).
helloSuper is the exposed name for the hello method in the
superclass. Clojure creates that method for you.

-Craig

--~--~-~--~~~---~--~~
You 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: My SLIME installation diary

2009-02-04 Thread Craig McDaniel

Thanks Stuart. Since the clojure-contrib.jar you built in step 3 does
include both clj and class files, I think you can reduce

 (setq swank-clojure-extra-classpaths
   (list /Users/stuart/Projects/clj/contrib/src
 /Users/stuart/Projects/clj/contrib/classes))

to

 (setq swank-clojure-extra-classpaths
   (list /Users/stuart/Projects/clj/contrib/clojure-
contrib.jar))

-Craig

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



Symbol to Namespace Qualified y

2009-02-01 Thread Craig McDaniel



git://github.com/kreg/traceme.git
--~--~-~--~~~---~--~~
You 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
-~--~~~~--~~--~--~---



Symbol to Namespace Qualified Symbol

2009-02-01 Thread Craig McDaniel

Anyone have a better method to go from a symbol to a namespace
qualified symbol? I'm using this ugly kludge now:

(symbol (.substring (.toString (resolve sym)) 2))

I'm keeping a map of currently traced functions and the key is the
namespaced-qualified symbol of the function. See 
git://github.com/kreg/traceme.git

Thanks for any suggestions.

-Craig


--~--~-~--~~~---~--~~
You 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: Symbol to Namespace Qualified Symbol

2009-02-01 Thread Craig McDaniel

Make that http://github.com/kreg/traceme/tree/master to just view the
project.
--~--~-~--~~~---~--~~
You 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: Symbol to Namespace Qualified Symbol

2009-02-01 Thread Craig McDaniel

Thanks Steve. I'm going with your suggestion to use the var itself
rather than the symbol as the key. It simplifies things.

-Craig

--~--~-~--~~~---~--~~
You 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: Got a Clojure library?

2009-02-01 Thread Craig McDaniel

Name: clojure.contrib.server-socket.clj
URL:http://code.google.com/p/clojure-contrib/
Author: Craig McDaniel
Category: net
License: ECL
Description: An enhancement of Rich's original socket-server example
that keeps track of client connections, closing them when the go away.
It also includes a socket REPL as an example server socket.

Name: traceme
URL: http://github.com/kreg/traceme/tree
Author: Craig McDaniel
Category: REPL tool
Licence: ECL
Description: Tracing of functions can be enabled/disabled through a
simple toggle function.


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

2009-01-21 Thread Craig McDaniel

 I wonder if it wouldn't be a good idea to move the call to binding 
 fromsocket-replinto accept-fn. It seems like a reasonable default to rebind
 *in* and *out* for the duration of the accepting function; the example
 uses this as does my application.

I'm not sure that rebinding *in* and *out* is something that every
socket server app would want to do. And couldn't it interfere with
debugging? You may not want that println you put in there for
debugging to go out the socket to the other side.
--~--~-~--~~~---~--~~
You 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
-~--~~~~--~~--~--~---



Another socket repl

2009-01-19 Thread Craig McDaniel

In case this is of use to anybody else, I thought I'd share my version
of a socket REPL: http://clojure.googlegroups.com/web/socket-repl.clj

Unlike the socket repl on the Wiki Example page, it does the
following:

- uses the repl from clojure.main
- keeps track of connections, closing the sockets when they go away
- redirects exception messages (*err*) to the socket stream
--~--~-~--~~~---~--~~
You 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: Another socket repl

2009-01-19 Thread Craig McDaniel

Correction: http://clojure.googlegroups.com/web/socket-repl+(2).clj

--~--~-~--~~~---~--~~
You 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: Another socket repl

2009-01-19 Thread Craig McDaniel

On Jan 19, 9:55 am, Stephen C. Gilardi squee...@mac.com wrote:

 Would you be up for including this in clojure-contrib? If so, and if  
 we hear no objection here, could you please put on the appropriate EPL  
 license header and your copyright notice (see other contribs for  
 examples) and I'll be happy to check it in.


Sure, I posted an updated version that includes the EPL license
header: http://clojure.googlegroups.com/web/socket-repl.clj

Thanks,
Craig

--~--~-~--~~~---~--~~
You 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: Another socket repl

2009-01-19 Thread Craig McDaniel

Well, somehow that link points to an old version. I guess the delete
and rename functions in Google groups do some strange things. Just
look for the file in the Files section.
--~--~-~--~~~---~--~~
You 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: Another socket repl

2009-01-19 Thread Craig McDaniel

I am a registered contributor...even though I haven't contributed
anything so far. I opened an issue on clojure-contrib and attached the
file. Let me know if that is not the correct procedure.

-Craig

--~--~-~--~~~---~--~~
You 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: Another socket repl

2009-01-19 Thread Craig McDaniel

On Jan 19, 11:45 am, Phil Hagelberg p...@hagelb.org wrote:
 I noticed that very little of this code is specific to the REPL; the
 bulk of it is just dealing with creating and doing things with server
 sockets. Perhaps it could be included in clojure-contrib as a
 generalized server-sockets library if instead of calling (repl) it could
 take an optional argument for a different function to use?

Thanks, that's a good point. I'm posting a new file server-socket.clj
that is more generic and includes the REPL as an example case.

-Craig
--~--~-~--~~~---~--~~
You 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: File organization bootstrapping

2009-01-07 Thread Craig McDaniel

Getting back to Phil Hagelberg's comment that maintaining a project's
classpath in both a SLIME config and shell script for each project/
application is a Don't Repeat Yourself violation, there is a way to
avoid that:

Don't bother with swank-clojure-extra-classpaths. Instead, include /
path/to/swank-clojure in the classpath of each of your project's
startup shell scripts. Each project starts up a swank server using
something like the following in its initialization code, using a
unique port for each project:

(require 'swank.swank)
(swank.swank/ignore-protocol-version 2009-01-01)
(swank.swank/start-server /dev/null :port  :encoding iso-
latin-1-unix)

Connect to your running app from emacs by using M-x slime-connect
rather than M-x slime. When you're done, use M-x slime-
disconnect (or from the REPL, , then disconnect) to leave your
process running. In addtion, including swank in your running
production app is a real benefit since you can connect to it from
emacs at any later time for diagnosis, debugging, etc...

-Craig

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



Trace Tools

2008-12-15 Thread Craig McDaniel
Here is a minor update to what I posted previously (but this time as
an attachment). This is just a small library that allows you turn on
tracing for all functions in a namespace all at once, or toggle
tracing for individual functions.

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



trace2.clj
Description: Binary data


Re: Classpath issue using new main method from jar?

2008-12-03 Thread Craig McDaniel

Hmm... I must have missed that. The comment in build.xml regarding how
to start Clojure should probably be changed to use clojure.main
instead of -jar clojure.jar.

On Dec 3, 10:09 am, Mark Volkmann [EMAIL PROTECTED] wrote:
 Right. Rich pointed out a week or so ago that you can't use -jar
 together with -cp. That means you can't get around specifying the name
 of the main class you want to run.



 On Wed, Dec 3, 2008 at 9:05 AM, Craig McDaniel [EMAIL PROTECTED] wrote:

  The classpath specified on the command line seems to be ignored for
  case #3 (using SVN Rev 1142):

  1. Using clojure.lang.Repl

  java -cp /home/kreg/src/clojure/trunk/clojure.jar:/another/class/path
  clojure.lang.Repl

  Clojure
  user= (.getProperty System java.class.path)
  /home/kreg/src/clojure/trunk/clojure.jar:/another/class/path
  user=

  2. Using clojure.main explicitly

  java -cp /home/kreg/src/clojure/trunk/clojure.jar:/another/class/path
  clojure.main -e '(.getProperty System
  java.class.path)'

  /home/kreg/src/clojure/trunk/clojure.jar:/another/class/path

  3. Using clojure.main via Main-Class in jar file...ignores classpath
  on command line

  java -cp /another/class/path -jar /home/kreg/src/clojure/trunk/
  clojure.jar -e '(.getProperty System
  java.class.path)'

  /home/kreg/src/clojure/trunk/clojure.jar

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



Re: Embedding Clojure/swank into existing Java system

2008-12-01 Thread Craig McDaniel

Since release 1127, you can now do this instead:

$ cat src/mypkg/HelloServlet.clj
(ns myapp.HelloServlet
  (:gen-class
   :extends javax.servlet.http.HttpServlet)
  (:import (java.io PrintWriter)
   (java.util.logging Logger Level))
  (:require swank clojure.main))

(defn- -init [this config]
  (clojure.main/with-bindings
   (swank/ignore-protocol-version 2008-11-23)
   (swank/start-server /dev/null :port 4006 :encoding iso-latin-1-
unix)))

(defn- -doGet [this request response]
  (.severe (Logger/getLogger hello) logging this thang)
  (.setContentType response text/html)
  (let [out (PrintWriter. (.getWriter response))]
(doto out
  (.println html)
  (.println head)
  (.println titleHello World!/title)
  (.println /head)
  (.println body)
  (.println h1Hello Bizarro World...from Clojure!/h1)
  (.println (str 17 + 33 =  (+ 17 33)))
  (.println /body)
  (.println /html

It doesn't handle the unloading/reloading of servlets well, so it
could be improved by:

1. Letting swank pick which port to listen on, and writing the port
number to a temporary file.
2. On unload, closing the swank socket and deleting the temporary
file.

I posted the whole project (build.xml, etc...) here: 
http://paste.lisp.org/display/71326

I'm also going to try installing a Compojure-built servlet into
Tomcat. I'll post that later if I can make that work.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: slime+clojure problem

2008-12-01 Thread Craig McDaniel

Make sure you're using the latest versions of clojure (SVN version,
not dated release), and swank-clojure as well.

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



Use of / to call static method in generated classes

2008-11-21 Thread Craig McDaniel

Testing the new (ns ... :genclass ...), I copied Rich's example from
http://paste.lisp.org/display/70665:

(ns my.hello
  (:gen-class
   :extends javax.swing.DefaultCellEditor
   :constructors {[Integer] [javax.swing.JCheckBox]}
   :factory makeone
   :methods [[mymax [int] int]]
   :init init
   :main true
   :state myint
   :exposes {clickCountToStart {:get get-c-count :set set-c-count}})
  )

(defn- -main [foo]
  (println Hello foo World!)
  (let [x (my.hello. 42)]
(prn (.mymax x 21

(defn- -init [myint]
  [[(javax.swing.JCheckBox.)] myint])

(defn- -mymax [this i]
  (max i (.myint this)))

(defn- -getCellEditorValue [this]
  (prn :getCellEditorValue)
  nil)

I can compile and run the example, but it doesn't work with the /
syntax for main, even though main is a static method:

user (.getProperty System java.class.path)
/home/kreg/src/clojure/trunk/clojure.jar:/home/kreg/src/junk
user (binding [*compile-path* /home/kreg/src/junk] (compile
'my.hello))
#{my.hello swank ...}
user (.main my.hello (into-array [Bizarro]))
Hello Bizarro World!
42
nil
user (my.hello/main (into-array [Bizarro]))

java.lang.Exception: No such var: my.hello/main

Works from command line ok:

[EMAIL PROTECTED] ~/src/junk
$ java -cp .:/home/kreg/src/clojure/trunk/clojure.jar my.hello
Bizarro
Hello Bizarro World!
42
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: clojure.jar/classpath for SVN version

2008-11-09 Thread Craig McDaniel

Thanks very much. I'll read these change logs for the SVN versions
from now on!

The README for the swank-clojure project recommends using the SVN
version of Clojure, otherwise I'd stick with the regular releases. The
README should probably be modified to point to release 1088.

On Nov 9, 7:31 pm, Chouser [EMAIL PROTECTED] wrote:
 On Sun, Nov 9, 2008 at 7:21 PM, Craig McDaniel [EMAIL PROTECTED] wrote:

  Without including gen in the classpath, the following exception is
  reported:

 This may have something to do with the last few checkins.
 I'd recommend you use SVN version 1088 instead.

 Here are the last few change log comments for your reference:

 SVN 1092:
 Author: rhickey [EMAIL PROTECTED]
 Date:   Sat Nov 8 19:06:14 2008 +

     Interim checkin - DO NOT USE!!
     Unless you are interested in helping test:
     deleted set/xml etc dirs
     Moved clojure ns to clojure.core, moved set/xml etc up out of dirs
     New binding syntax (breaking change) for:
       doseq
       dotimes
       with-open
       when-first
       if-let
       when-let
     plus:
     new print-dup functionality for replica generation of compilation 
 constants
     new *print-dup* flag, prints duplicators
     back to simplified readably printing for repl
     readable fns, as long as they are not closures

 SVN 1091:
 Author: rhickey [EMAIL PROTECTED]
 Date:   Sat Nov 8 18:53:02 2008 +

     Interim checkin - DO NOT USE!!
     Unless you are interested in helping test:
     Moved clojure ns to clojure.core, moved set/xml etc up out of dirs
     New binding syntax (breaking change) for:
       doseq
       dotimes
       with-open
       when-first
       if-let
       when-let
     plus:
     new print-dup functionality for replica generation of compilation 
 constants
     new *print-dup* flag, prints duplicators
     back to simplified readably printing for repl
     readable fns, as long as they are not closures

 SVN 1090:
 Author: rhickey [EMAIL PROTECTED]
 Date:   Sat Nov 8 15:09:22 2008 +

     Interim checkin - DO NOT USE!!
     Unless you are interested in helping test:
     New binding syntax (breaking change) for:
       doseq
       dotimes
       with-open
       when-first
       if-let
       when-let
     plus:
     new print-dup functionality for replica generation of compilation 
 constants
     new *print-dup* flag, prints duplicators
     back to simplified readably printing for repl
     readable fns, as long as they are not closures

 SVN 1089:
 Author: rhickey [EMAIL PROTECTED]
 Date:   Sat Nov 8 01:06:34 2008 +

     Interim checkin - DO NOT USE!!
     Unless you are interested in helping test:
     new print-dup functionality for replica generation of compilation 
 constants
     new *print-dup* flag, prints duplicators
     back to simplified readably printing for repl
     readable fns, as long as they are not closures

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



Re: clojure.jar/classpath for SVN version

2008-11-09 Thread Craig McDaniel

Without including gen in the classpath, the following exception is
reported:

$ java -cp clojure.jar clojure.lang.Repl
Exception in thread main java.lang.ExceptionInInitializerError
at clojure.lang.Repl.clinit(Repl.java:23)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException:
java.lang.ClassNotFoundException:
clojure.core$eval__1 (core.clj:
0)
at clojure.lang.RT.clinit(RT.java:325)
... 1 more
Caused by: java.lang.RuntimeException:
java.lang.ClassNotFoundException: clojure.core$eval__1 (core.c
lj:
0)
at clojure.lang.Compiler.eval(Compiler.java:4131)
at clojure.lang.Compiler.load(Compiler.java:4447)
at clojure.lang.RT.loadResourceScript(RT.java:366)
at clojure.lang.RT.loadResourceScript(RT.java:357)
at clojure.lang.RT.doInit(RT.java:380)
at clojure.lang.RT.clinit(RT.java:321)
... 1 more

On Nov 9, 1:45 pm, Craig McDaniel [EMAIL PROTECTED] wrote:
 Previously, I could run clojure with:

 java -cp clojure.jar clojure.lang.Repl

 After building clojure.jar from a more recent SVN version (1092) that
 includes AOT and generated classes, it looks like I have to now
 include the generated classes in the classpath (running from trunk
 directory):

 java -cp clojure.jar:gen clojure.lang.Repl

 ...and that only works on the second attempt, after the files in the
 gen directory have been created.

 Shouldn't the build.xml file be modified to include these gen files in
 clojure.jar?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: problems with slime and emacs

2008-10-31 Thread Craig McDaniel

This works for me:

(add-to-list 'load-path (expand-file-name ~/src/slime))
(require 'slime)

(add-to-list 'load-path (expand-file-name ~/src/clojure-mode))
(require 'clojure-auto)

(add-to-list 'load-path (expand-file-name ~/src/swank-clojure))
(setq swank-clojure-jar-path (expand-file-name ~/clojure_20080916/
clojure.jar))
(setq swank-clojure-extra-classpaths (list (file-truename ~/share/
java/*)))
(setq swank-clojure-library-paths (list (file-truename ~/lib)))
(require 'swank-clojure-autoload)

On Oct 31, 11:59 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Hello all,

 I'm struggling to get slime and emacs to work together.  I copied the
 code from the readme included with swank-clojure, but am running into
 an error.  I'm sure it's something trivial that I'm missing.  Here is
 what I have in my .emacs copied from the various readme files.

 ;; clojure mode
 (add-to-list 'load-path ~/.emacs.d/clojure-mode)

 (require 'clojure-auto)
 ;; or if you use paredit, uncomment the following
 ;; (require 'clojure-paredit)

 ;; swank clojure
 (add-to-list 'load-path /Users/clk/.emacs.d/swank-clojure)

 (require 'swank-clojure-autoload)
 (swank-clojure-config
  (setq swank-clojure-jar-path /Users/clk/Documents/Development/
 Languages/lisp/clojure_20080916/clojure.jar)
  (setq swank-clojure-extra-classpaths (list /Users/clk/.emacs.d/
 clojure-extra)))

 ;; Add sbcl back in
 (add-to-list 'slime-lisp-implementations '(sbcl (sbcl)))

 That results in the following error:

 ad-Orig-error: Error: You must specify a swank-clojure-jar-path.
 Please see README of swank-clojure.

 I copied the code above from the readme.  And yes, the path to the
 clojure.jar is correct.

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



Re: Clojure Poll 09/2008

2008-09-13 Thread Craig McDaniel

 What are you doing with Clojure?

I work in a fairly conservative environment where they probably
wouldn't approve of my using a language in an alpha state, much less a
variant of Lisp! But since I love the language and the interactive
environment with Emacs, I decided it's easier to beg forgiveness than
ask permission.

1. Wrote a Clojure service that runs on remote thin clients. It
receives Clojure forms that instruct it to download and cache PDF
templates, dynamically fill in form data, overlay logos, etc.., then
print the resulting PDF.
2. I also use it for prototyping and experimentation.

 What 3 features would you most like to see added next?

1. I agree that better stack trace/error information would be nice.

Not really features, but...

2. More thorough documentation and examples: For instance: how to
profile your code and decide where you should use type hints.
3. Can't think of #3.

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



Hello Clojure Servlet

2008-08-26 Thread Craig McDaniel

Here is a simple hello world servlet project that runs under
Tomcat. It may be useful to others. Note: This code works with the
20080612 Clojure release, but doesn't seem to find the doGet method
when using the current SVN release.

*** Instructions ***

1. Edit build.properties in user home to specify Tomcat parameters
catalina.home, manager.username, and manager.password.

2. Edit build.properties in project home to specify where clojure.jar
and genclass.clj reside.

3. ant install

4. Go to http://localhost:8080/hello-clojure/hello

*** File List ***

./src/mypkg/HelloServlet.clj
./build.properties
./build.xml
./gen-classes.clj
./web/WEB-INF/web.xml

*** gen-classes.clj ***

(def genclass-file (first *command-line-args*))
(def build-dir (second  *command-line-args*))
(load-file genclass-file)
(clojure/gen-and-save-class build-dir
'mypkg.HelloServlet
:extends javax.servlet.http.HttpServlet)

*** HelloServlet.clj ***

(clojure/in-ns 'mypkg.HelloServlet)
(clojure/refer 'clojure)

(import '(java.io PrintWriter))

(defn doGet [this request response]
  (.setContentType response text/html)
  (let [out (PrintWriter. (.getWriter response))]
(doto out
  (println html)
  (println head)
  (println titleHello World!/title)
  (println /head)
  (println body)
  (println h1Hello World...from Clojure!/h1)
  (println (str 17 + 3 =  (+ 17 3)))
  (println /body)
  (println /html


*** build.properties ***

clojure.jar=${user.home}/clojure/clojure.jar
genclass.clj=${user.home}/clojure/src/genclass.clj

*** web.xml ***

?xml version=1.0 encoding=ISO-8859-1?
web-app xmlns=http://java.sun.com/xml/ns/j2ee;
 xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
 xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd;
 version=2.4

  display-nameHello, World Clojure Application/display-name
  description
This is a simple web application with a source code organization
based on the recommendations of the Application Developer's Guide.
  /description

  servlet
servlet-nameHelloClojure/servlet-name
servlet-classmypkg.HelloServlet/servlet-class
  /servlet

  servlet-mapping
servlet-nameHelloClojure/servlet-name
url-pattern/hello/url-pattern
  /servlet-mapping

/web-app

*** build.xml ***

project name=servlet-test default=clojure.gen basedir=.

  !--
   include the following in your build.properties file:
   * clojure.jar - full path of clojure.jar
   * genclass.clj - full path of genclass.clj
  --
  property file=build.properties/

  !--
   include the following in your ~/build.properties file:
   * catalina.home
   * manager.username
   * manager.password
  --
  property file=${user.home}/build.properties/

  property name=app.name  value=hello-clojure/
  property name=app.path  value=/${app.name}/
  property name=app.version   value=0.1-dev/
  property name=build.homevalue=${basedir}/build/
  property name=dist.home value=${basedir}/dist/
  property name=docs.home value=${basedir}/docs/
  property name=manager.url   value=http://localhost:8080/manager/

  property name=src.home  value=${basedir}/src/
  property name=web.home  value=${basedir}/web/


  path id=compile.classpath
!-- the main clojure jar  --
pathelement location=${clojure.jar}/
!-- Include all elements that Tomcat exposes to applications --
fileset dir=${catalina.home}/bin
  include name=*.jar/
/fileset
pathelement location=${catalina.home}/lib/
fileset dir=${catalina.home}/lib
  include name=*.jar/
/fileset
  /path

  !-- custom ant tasks --
  taskdef resource=org/apache/catalina/ant/catalina.tasks
   classpathref=compile.classpath/

  !--
  The prepare target is used to create the build destination
  directory, and copy the static contents of your web application
  to it.  If you need to copy static files from external
  dependencies, you can customize the contents of this task.

  Normally, this task is executed indirectly when needed.
  --
  target name=prepare
tstamp/
!-- Create build directories as needed --
mkdir dir=${build.home}/
mkdir dir=${build.home}/WEB-INF/
mkdir dir=${build.home}/WEB-INF/classes/mypkg/test/
!-- Copy static content of this web application --
copy todir=${build.home}
  fileset dir=${web.home}/
/copy
!-- Copy external dependencies as required --
mkdir dir=${build.home}/WEB-INF/lib/
copy todir=${build.home}/WEB-INF/lib file=${clojure.jar}/
  /target

  !--
  The clojure.gen target generates class files from *.clj files
  --
  target name=clojure.gen depends=prepare
!-- Generate java class from clj file --
mkdir dir=${build.home}/WEB-INF/classes/
java classname=clojure.lang.Script
classpathref=compile.classpath
  arg value=gen-classes.clj/
  arg value=--/