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

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

Re: Wrapper function for slime

2009-04-22 Thread Craig McDaniel
Thanks Phil. I'll try it out. It's about time I started learning about Maven anyway. --~--~-~--~~~---~--~~ You 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 u

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

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 compi

Re: generated class with overloaded methods

2009-02-13 Thread Craig McDaniel
OK, I understand. When you want separate Clojure functions that execute different code for same arity/different signature case, you must use the method demonstrated by Christophe. The code I showed was only useful when you don't care about the type. You could use the multi-arity function and manua

Re: generated class with overloaded methods

2009-02-13 Thread Craig McDaniel
I guess I don't understand. In the Clojure code below, the double arity method does in fact override all three of the methods from the superclass (two of which have the same name and same arity). Isn't that what you're looking for? Try it out. |-- build.xml |-- go.clj |-- src | `-- expmeth |

Re: generated class with overloaded methods

2009-02-13 Thread Craig McDaniel
Both my method (multi-arity) and Christophe's method (overridden method names contain arguments) do work. I tested them both with the code posted. -Craig --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" grou

Re: generated class with overloaded methods

2009-02-13 Thread Craig McDaniel
On Feb 13, 9:59 am, Laurent PETIT 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. -C

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

Re: generated class with overloaded methods

2009-02-13 Thread Craig McDaniel
I just tried it out to be sure. Overloaded methods with the same arity work as expected. Clojure picks the right method to call via reflection. package expmeth; public class ClassA { public void hello() { System.err.println("hello from Java!"); } public void hello(int x) {

Re: A stupid beginners question about Compile

2009-02-12 Thread Craig McDaniel
Have a look at how the clojure-contrib project is compiled. The build.xml file will help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com

generated class with overloaded methods

2009-02-12 Thread Craig McDaniel
For the benefit of others, since this took me a while to understand... When using gen-class to extend or implement a superclass with overloaded methods, use a single multi-arity function to override the overloaded methods in the superclass: expmeth/ClassA.java: package expmeth; public class Clas

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

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 inc

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 gro

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 unsubscr

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

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

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

Re: Another socket repl

2009-01-19 Thread Craig McDaniel
On Jan 19, 11:45 am, Phil Hagelberg 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

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

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 G

Re: Another socket repl

2009-01-19 Thread Craig McDaniel
On Jan 19, 9:55 am, "Stephen C. Gilardi" 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 t

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 t

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

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/

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 rece

Re: New Tracing Library

2008-12-05 Thread Craig McDaniel
Correction: http://paste.lisp.org/display/71656 --~--~-~--~~~---~--~~ You 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 emai

New Tracing Library

2008-12-05 Thread Craig McDaniel
I'd like to submit a new tracing library to clojure.contrib. Please try it out and let me know if it is suitable. The existing clojure.contrib.trace macros allow you to explicitly trace any expression or redefine a function with deftrace so that it is traced. But deftrace doesn't work with functi

Re: Classpath issue using new main method from jar?

2008-12-03 Thread Craig McDaniel
o 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

Classpath issue using new main method from jar?

2008-12-03 Thread Craig McDaniel
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/tru

Re: Embedding Clojure/swank into existing Java system

2008-12-01 Thread Craig McDaniel
Never mind about my unloaded/reloading servlets comment. Checking for a swank exception as in the original example would work fine. -Craig --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to

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

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 con

Re: Use of "/" to call static method in generated classes

2008-11-21 Thread Craig McDaniel
Thanks for the explanation. I just wanted to report it in case it might be a bug. --~--~-~--~~~---~--~~ You 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 unsu

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

Re: clojure.jar/classpath for SVN version

2008-11-09 Thread Craig McDaniel
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

Re: clojure.jar/classpath for SVN version

2008-11-09 Thread Craig McDaniel
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 >

clojure.jar/classpath for SVN version

2008-11-09 Thread Craig McDaniel
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

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

Re: offtopic - where are you come from? (poll)

2008-10-17 Thread Craig McDaniel
also from Atlanta, Georgia --~--~-~--~~~---~--~~ You 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

Re: Good Introductory materials to the Java ecosystem.

2008-10-05 Thread Craig McDaniel
This site provides a nice search index for those Java API docs: http://gotapi.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 unsub

Re: For socket repl: request redirectable *err* var

2008-09-29 Thread Craig McDaniel
Yes, I'd like to see *err* added too. I did my own *err* for a custom REPL and was surprised it wasn't already part of the environment just like *out*. On Sep 29, 9:24 am, Thorsen Eric <[EMAIL PROTECTED]> wrote: > I would love to see this change as well. > > Eric > > On Sep 28, 2008, at 1:28 PM,

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 forgive

Re: gen-class for jar file

2008-08-27 Thread Craig McDaniel
The "Hello Servlet" post from yesterday does that. On Aug 27, 4:56 pm, "Kevin Downey" <[EMAIL PROTECTED]> wrote: > I am interested in using the gen-class related stuff to generate a > class file to load and run my clojure code from a jar file. Does > anyone have any example code for this they can

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