Re: Nested Multimethods

2008-10-14 Thread Rich Hickey

On Mon, Oct 13, 2008 at 11:14 PM, Stuart Halloway
<[EMAIL PROTECTED]> wrote:
>
> Hi Patrick,
>
> How about:
>
> (defmulti length (fn [x]
>  (if (= :stateMachine  (:class x))
>(:state x)
>(:class x
>
> (defmethod length :yardstick [x] 36)
> (defmethod length :walking [x] "short")
> (defmethod length :running [x] "long")
>
> user=> (length {:class :yardstick})
> 36
> user=> (length {:class :stateMachine :state :walking})
> "short"
> user=> (length {:class :stateMachine :state :running})
> "long"
>
> It would probably be better to have the fn return a vector so you
> don't have to worry about :state and :class values with colliding
> names, but that's the basic idea.
>

In general, if you have a conditional or other enumeration of things
in your dispatch method it is a warning sign that you might not be
getting the leverage out of multimethods - their prime reason to exist
is to provide open, extensible case logic.

Never say never, but in this case it's better to use two multimethods.

Rich

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



Re: Clojure Eclipse plugin progress (clojure-dev)

2008-10-14 Thread mac

I use eclipse daily at work so I'm pretty used to it, would be very
nice with a clojure plugin.
Are you taking feature requests?
If you are, here is mine:

I like a good IDE as much as anyone but so far I have been using emacs
with Jeffrey Chu's clojure-mode (http://clojure.codestuffs.com/).
Coming from a VS/eclipse background I feel comfortable with a full IDE
but I have discovered something about most IDE's when I have been
using emacs.
While they do a good job of integrating stuff, their editors actually
suck, at least in their default configurations.

So I humbly submit a request to you to try to make the editor have the
same features as the clojure paredit mode, at least as an option one
can enable. What I really like about it is that it is sexp-aware, it
will help you balance parens and brackets by inserting pairs
automatically and prevent you from deleting non empty expressions.
There are also keyboard commands for "expanding" or "shrinking" an
expression to include/exclude symbols or expressions around it/inside
it while automatically preserving correct indentation. Plus of course
the standard stuff like keyboard commands for eval last expr, eval
buffer, eval region (selection) etc. that really helps with
interactive development.

As much as I like the whole IDE idea, I am starting to get so used to
the fantastic editor that emacs is when properly configured that I get
a little annoyed writing java in eclipse at work because it doesn't
really offer much more than syntax highlightning and inserting some
brackets (yes code completion is great and all but not really an
editor feature in the sense I mean here).

To sum up a very wordy post: if you could make the editor as good as
the emacs mode, that would be awesome!

/Markus

On Oct 14, 4:49 am, Casey Marshall <[EMAIL PROTECTED]> wrote:
> Hi,
> I humbly present my first steps toward an Clojure Eclipse plugin
> (http://code.google.com/p/clojure-dev/).  So far, here's where its at:
>
> * Clojure nature, project type and builder (which doesn't do much
> yet).
> * Added a Clojure REPL to the console.  You can open it with the "New
> Console" button on the console view.
> * When editing a *.clj file, you can run the current file, which will
> get loaded into the REPL console.
>
> The REPL console has direct access to the Eclipse runtime and should
> be able to manipulate the workbench.  That's right.. its an Eclipse
> minibuffer!
>
> Some background on clojure-dev... for some reason, I had to add a
> Class.forName("clojure.lang.RT") in my Clojure OSGi bundle's start().
> Otherwise I was not able to run Clojure within Equinox -- I believe it
> was a Compiler.loadFile issue on the core Clojure files.  I originally
> tried basing my plugin on the DLTK without much luck -- the DLTK does
> not seem very relevant to targeting the JVM, its more like something
> you'd use for an out-of-process scripting language environment.  I'm
> going to go my own way and hook into the JDT where I have to.  I'm
> looking at CUSP, PyDev, and Scala SDT for inspiration.
>
> My next steps are to focus on Clojure language support and better JDT
> integration (classpath, etc.).  Deployment and tooling is a big deal
> to me, I think they're essential to being productive with the Java
> platform -- even if the Clojure language is more productive, the Java
> batteries included still require a lot of typing!
>
> I know the Eclipse platform pretty well but from an Equinox & RCP
> background.  I'm new to IDE development, so this is quite a learning
> experience!
>
> Cheers,
> Casey
--~--~-~--~~~---~--~~
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: Nested Multimethods

2008-10-14 Thread Randall R Schulz

On Tuesday 14 October 2008 07:48, CuppoJava wrote:
> That's a very elegant solution Rich. I'm so obvious when someone
> tells you how to do it.
>
> Clojure amazes me more every day. All the painfully accumulated
> knowledge of Java design patterns are so trivial in Clojure. It
> doesn't even seem like there's any need for design "patterns" at all
> anymore cause everything is handled elegantly by the base language.

I have heard it claimed (on one of the Scala lists, I think) that 
patterns themselves are an anti-pattern...


Randall Schulz

--~--~-~--~~~---~--~~
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 Eclipse plugin progress (clojure-dev)

2008-10-14 Thread JumpingJupiter

> I humbly present my first steps toward an Clojure Eclipse plugin
> (http://code.google.com/p/clojure-dev/).

It seems your writing your plug-in in java. I don't know anything
about Eclipse plug-ins; it should be possible (maybe not desirable) to
write the plug-in in clojure right? what are your reasons for using
java?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
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: Nested Multimethods

2008-10-14 Thread CuppoJava

That's a very elegant solution Rich. I'm so obvious when someone tells
you how to do it.

Clojure amazes me more every day. All the painfully accumulated
knowledge of Java design patterns are so trivial in Clojure. It
doesn't even seem like there's any need for design "patterns" at all
anymore cause everything is handled elegantly by the base language.
--~--~-~--~~~---~--~~
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: packaging App (cross-platform) without scripts, only jar

2008-10-14 Thread Asbjørn Bjørnstad



On Oct 2, 10:23 pm, Pascal <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> for Michael Beauregard,
>
> > Is there a reason why setting the "Main-Class" field in the jar's manifest
> > doesn't work.
>
> It work, and since the manifest had to be edited to set the Class-Path
> why not set correctly the Main-Class ? maybe if my main class would
> be called "Main" instead of "Launcher" it will be automatic.
> But still, the Class-Path is needed so I changed the manifest.
>
> > I'm surprised that any code has to be written at all for this work.
> > ...
> > I've used this before and I think that the launcher (in Windows at least)
> > would execute: java -jar %f
>
> Exactly and it work! but to be able to click on a "jar"
> you must *have* a jar, something that was not by default in Clojure
> since you cannot compile ahead into a jar.

So it is not possible to put the clj files into the jar so that no
unzipping
is neccessary? I tried, but my java/jar knowledge is basically zero.
--
 -asbjxrn

--~--~-~--~~~---~--~~
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 Eclipse plugin progress (clojure-dev)

2008-10-14 Thread Stefan Liebig

Great, this sounds really nice. I will have a look at it.

I created a clojure library bundle from the clojure.jar and a
second bundle that depends on the first. The seconds bundle
activator calls two clojure functions for start and stop of the
bundle passing the BundleContext to the clojure functions.
These two functions currently just print that they had been
started and stopped. Well, that is not that much, I know.
However, there was no need to work with reflection.

Tschüß,
Stefan

On Oct 14, 4:49 am, Casey Marshall <[EMAIL PROTECTED]> wrote:
> Hi,
> I humbly present my first steps toward an Clojure Eclipse plugin
> (http://code.google.com/p/clojure-dev/).  So far, here's where its at:
>
> * Clojure nature, project type and builder (which doesn't do much
> yet).
> * Added a Clojure REPL to the console.  You can open it with the "New
> Console" button on the console view.
> * When editing a *.clj file, you can run the current file, which will
> get loaded into the REPL console.
>
> The REPL console has direct access to the Eclipse runtime and should
> be able to manipulate the workbench.  That's right.. its an Eclipse
> minibuffer!
>
> Some background on clojure-dev... for some reason, I had to add a
> Class.forName("clojure.lang.RT") in my Clojure OSGi bundle's start().
> Otherwise I was not able to run Clojure within Equinox -- I believe it
> was a Compiler.loadFile issue on the core Clojure files.  I originally
> tried basing my plugin on the DLTK without much luck -- the DLTK does
> not seem very relevant to targeting the JVM, its more like something
> you'd use for an out-of-process scripting language environment.  I'm
> going to go my own way and hook into the JDT where I have to.  I'm
> looking at CUSP, PyDev, and Scala SDT for inspiration.
>
> My next steps are to focus on Clojure language support and better JDT
> integration (classpath, etc.).  Deployment and tooling is a big deal
> to me, I think they're essential to being productive with the Java
> platform -- even if the Clojure language is more productive, the Java
> batteries included still require a lot of typing!
>
> I know the Eclipse platform pretty well but from an Equinox & RCP
> background.  I'm new to IDE development, so this is quite a learning
> experience!
>
> Cheers,
> Casey

--~--~-~--~~~---~--~~
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: Casting java arguments...

2008-10-14 Thread Luc Prefontaine
The SQL library in clojure-contrib already does this just for that sole
purpose:

(defmacro with-connection
  "Evaluates body in the context of a new connection to a database then
  closes it. db-spec is a map containing string values for these
required
  keys:
:classname the jdbc driver class name
:subprotocol   the jdbc subprotocol
:subname   the jdbc subname
  db-spec may contain additional key-value pairs that are passed along
to
  the driver as properties such as :user, :password, etc."
  [db-spec & body]
  `(do
 (clojure.lang.RT/classForName (:classname ~db-spec))
 (with-open con#

...

I defined the database with a definition like this:

(def dbmaster {
  :classname "com.mysql.jdbc.Driver"
  :subprotocol "mysql"
...

but I was always ending up with an exception saying it could not find
the driver.

As far as I can see the class name is right. The call to classForName
did not trigger any exceptions.
The classForName call should trigger execution of the static code in the
MySql driver class.

So for now it works with my workaround (registering the driver directly)
but I'll try to get to the bottom of this eventually.

Thank you all for the suggestions.

Luc


Now I still did not understand why it was not working when I was calling
the library 
On Fri, 2008-10-10 at 02:45 -0700, mritun wrote:

> 
> 
> On Oct 10, 1:46 am, Luc Prefontaine <[EMAIL PROTECTED]>
> wrote:
> > I found a workaround...
> >
> > I was able to register the driver using
> > -Djdbc.drivers=com.mysql.jdbc.Driver on the java command line.
> > Looks like loading the class is not enough, adding the above does work:
> >
> > user=> (enumeration-seq (. java.sql.DriverManager getDrivers))
> > ([EMAIL PROTECTED] [EMAIL PROTECTED])
> >
> > The mysql jdbc driver code says that it registers itself (static block)
> > but something is wrong.
> > Eventually I will find why but now I have other pressing needs to full
> > fill than debugging that code.
> 
> Static blocks don't execute until the class is loaded, so just
> specifying a class in classpath is not enough.
> 
> In Java the idiomatic way to let the driver initialize itself, is to
> add the following line somewhere in your initialization code before
> requesting connection:
> 
> Class.forName("com.mysql.jdbc.Driver");
> 
> This loads the class, and its static block registers the driver. You'd
> have to do an equivalent in clojure too.
> 
> - Akhilesh
> > 
> 

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



"Invalid this class index..." exception

2008-10-14 Thread Paul Stadig
I'm getting the following error message when trying to load a 12MB clojure
file that is basically just a big hashmap of fundamental types (i.e.
strings, numbers, keywords, etc.).

java -cp
/home/pstadig/.emacs.d/clojure/target/clojure-lang-1.0-SNAPSHOT.jar:./gen
clojure.lang.Script db.clj
Exception in thread "main" java.lang.ClassFormatError: Invalid this class
index 3171 in constant pool in class file clojure/eval__2459 (db.clj:0)
at clojure.lang.Compiler.eval(Compiler.java:4116)
at clojure.lang.Compiler.load(Compiler.java:4432)
at clojure.lang.Compiler.loadFile(Compiler.java:4399)
at clojure.lang.Script.main(Script.java:65)
Caused by: java.lang.ClassFormatError: Invalid this class index 3171 in
constant pool in class file clojure/eval__2459
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at clojure.lang.RT.classForName(RT.java:1509)
at clojure.lang.Compiler$FnExpr.getCompiledClass(Compiler.java:3180)
at clojure.lang.Compiler$FnExpr.eval(Compiler.java:3190)
at clojure.lang.Compiler.eval(Compiler.java:4104)
... 3 more

I'm using revision 1068 with Sun Java 1.6.0, as indicated below. I've also
gotten this error with earlier revisions of Clojure.  I forget the revision
(around 2008-10-06), but I think it was before AOT. I'm not sure what the
issue is. I can send along the file if needed.

svn info
Path: .
URL: https://clojure.svn.sourceforge.net/svnroot/clojure/trunk
Repository Root: https://clojure.svn.sourceforge.net/svnroot/clojure
Repository UUID: b4165764-bd0f-0410-b771-ab16a44d2305
Revision: 1068
Node Kind: directory
Schedule: normal
Last Changed Author: rhickey
Last Changed Rev: 1068
Last Changed Date: 2008-10-13 19:57:11 -0400 (Mon, 13 Oct 2008)

java -version
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Server VM (build 1.6.0-b105, mixed mode)


Paul

--~--~-~--~~~---~--~~
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 Eclipse plugin progress (clojure-dev)

2008-10-14 Thread Casey Marshall

Thanks Markus,
I agree, awareness of sexps will be very important.  Sounds like I
have some research to do with clojure-mode.

Casey

On Oct 14, 8:27 am, mac <[EMAIL PROTECTED]> wrote:
> I use eclipse daily at work so I'm pretty used to it, would be very
> nice with a clojure plugin.
> Are you taking feature requests?
> If you are, here is mine:
>
> I like a good IDE as much as anyone but so far I have been using emacs
> with Jeffrey Chu's clojure-mode (http://clojure.codestuffs.com/).
> Coming from a VS/eclipse background I feel comfortable with a full IDE
> but I have discovered something about most IDE's when I have been
> using emacs.
> While they do a good job of integrating stuff, their editors actually
> suck, at least in their default configurations.
>
> So I humbly submit a request to you to try to make the editor have the
> same features as the clojure paredit mode, at least as an option one
> can enable. What I really like about it is that it is sexp-aware, it
> will help you balance parens and brackets by inserting pairs
> automatically and prevent you from deleting non empty expressions.
> There are also keyboard commands for "expanding" or "shrinking" an
> expression to include/exclude symbols or expressions around it/inside
> it while automatically preserving correct indentation. Plus of course
> the standard stuff like keyboard commands for eval last expr, eval
> buffer, eval region (selection) etc. that really helps with
> interactive development.
>
> As much as I like the whole IDE idea, I am starting to get so used to
> the fantastic editor that emacs is when properly configured that I get
> a little annoyed writing java in eclipse at work because it doesn't
> really offer much more than syntax highlightning and inserting some
> brackets (yes code completion is great and all but not really an
> editor feature in the sense I mean here).
>
> To sum up a very wordy post: if you could make the editor as good as
> the emacs mode, that would be awesome!
>
> /Markus
>
> On Oct 14, 4:49 am, Casey Marshall <[EMAIL PROTECTED]> wrote:
>
> > Hi,
> > I humbly present my first steps toward an Clojure Eclipse plugin
> > (http://code.google.com/p/clojure-dev/).  So far, here's where its at:
>
> > * Clojure nature, project type and builder (which doesn't do much
> > yet).
> > * Added a Clojure REPL to the console.  You can open it with the "New
> > Console" button on the console view.
> > * When editing a *.clj file, you can run the current file, which will
> > get loaded into the REPL console.
>
> > The REPL console has direct access to the Eclipse runtime and should
> > be able to manipulate the workbench.  That's right.. its an Eclipse
> > minibuffer!
>
> > Some background on clojure-dev... for some reason, I had to add a
> > Class.forName("clojure.lang.RT") in my Clojure OSGi bundle's start().
> > Otherwise I was not able to run Clojure within Equinox -- I believe it
> > was a Compiler.loadFile issue on the core Clojure files.  I originally
> > tried basing my plugin on the DLTK without much luck -- the DLTK does
> > not seem very relevant to targeting the JVM, its more like something
> > you'd use for an out-of-process scripting language environment.  I'm
> > going to go my own way and hook into the JDT where I have to.  I'm
> > looking at CUSP, PyDev, and Scala SDT for inspiration.
>
> > My next steps are to focus on Clojure language support and better JDT
> > integration (classpath, etc.).  Deployment and tooling is a big deal
> > to me, I think they're essential to being productive with the Java
> > platform -- even if the Clojure language is more productive, the Java
> > batteries included still require a lot of typing!
>
> > I know the Eclipse platform pretty well but from an Equinox & RCP
> > background.  I'm new to IDE development, so this is quite a learning
> > experience!
>
> > Cheers,
> > Casey
--~--~-~--~~~---~--~~
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: "Invalid this class index..." exception

2008-10-14 Thread Rich Hickey



On Oct 14, 1:55 pm, "Paul Stadig" <[EMAIL PROTECTED]> wrote:
> I'm getting the following error message when trying to load a 12MB clojure
> file that is basically just a big hashmap of fundamental types (i.e.
> strings, numbers, keywords, etc.).
>
> java -cp
> /home/pstadig/.emacs.d/clojure/target/clojure-lang-1.0-SNAPSHOT.jar:./gen
> clojure.lang.Script db.clj
> Exception in thread "main" java.lang.ClassFormatError: Invalid this class
> index 3171 in constant pool in class file clojure/eval__2459 (db.clj:0)

> I'm using revision 1068 with Sun Java 1.6.0, as indicated below. I've also
> gotten this error with earlier revisions of Clojure.  I forget the revision
> (around 2008-10-06), but I think it was before AOT. I'm not sure what the
> issue is. I can send along the file if needed.
>

Looks like you might be using Clojure data structures literals as a
data format. That's great, and fine, but you probably want to read
that file rather than load it. Loading it will force the compiler to
treat it as code, and, now, as needed by the AOT support, try to put
the data structure into a classfile, where it won't fit. Reading it
will work.

Rich

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



Re: "Invalid this class index..." exception

2008-10-14 Thread Paul Stadig
Thanks, Rich. Reading made the difference. I was confused because I was able
to load smaller data structure literal files, but it would choke on the 12MB
file. That's why I thought there was something about the way the larger file
was being loaded.

I think I avoided using read because it needed a PushbackReader and
load-file was just so easy to pass a path to. Anyway, sorry about the dumb
question, and thanks for the response.


Paul

Looks like you might be using Clojure data structures literals as a
> data format. That's great, and fine, but you probably want to read
> that file rather than load it. Loading it will force the compiler to
> treat it as code, and, now, as needed by the AOT support, try to put
> the data structure into a classfile, where it won't fit. Reading it
> will work.
>
> Rich
>
>

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



Re: Clojure Eclipse plugin progress (clojure-dev)

2008-10-14 Thread Casey Marshall

Writing Eclipse plugins in Clojure is very interesting is a long term
goal.  In order to pull that off, I would need to extend/implement
Eclipse platform classes and interfaces in Clojure, and export these
classes in an Eclipse plugin, which is an OSGi bundle.

Scala rewrote their Eclipse plugin in Scala at a certain point -- but
Scala is easier as it compiles to *.class files.  Clojure will be more
challenging as I'll need to hook up clojure.lang.Compiler to the
classloader directly, and expose dynamically compiled bytecode.
However, the potential could be huge.  Not only could Clojure be used
for Eclipse PDE development, but Clojure-OSGi bundles would
interoperate with other OSGi solutions (Glassfish, Apache ServiceMix,
etc.).  OSGi would give Clojure apps some nice deployment options and
a new devious way to sneak Clojure into the enterprise :)

In the meantime, I'm ok with developing in Java now with the
possibility of rewriting in Clojure later.  This ugly Java code will
at least serve as a blueprint for what's to come.

Casey

On Oct 14, 10:00 am, JumpingJupiter <[EMAIL PROTECTED]>
wrote:
> > I humbly present my first steps toward an Clojure Eclipse plugin
> > (http://code.google.com/p/clojure-dev/).
>
> It seems your writing your plug-in in java. I don't know anything
> about Eclipse plug-ins; it should be possible (maybe not desirable) to
> write the plug-in in clojure right? what are your reasons for using
> java?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
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: Nested Multimethods

2008-10-14 Thread Rich Hickey



On Oct 13, 11:01 pm, CuppoJava <[EMAIL PROTECTED]> wrote:
> Is there anyway to do the following with the existing multi-method
> facilities?
>
> There is a general multi-method length(object) that splits off to
> different methods depending on the :class of the object.
>
> And then specifically for objects with :class = :stateMachine, I want
> to define it's method to split off further depending on the :state of
> the object.
>
> (defmulti length :class)
> (defmethod-multi length :stateMachine :state)
>
> (defmethod length :stateMachine :walking
>   (println "Short distance"))
>
> (defmethod length :stateMachine :running
>   (println "Long distance"))
>

The answer is right in your title - use more than one multimethod and
nest them:

(defmulti length :class)
(defmulti sm-length :state)

(defmethod length :stateMachine [x]
  (sm-length x))

(defmethod sm-length :walking [_]
  (println "Short distance"))

(defmethod sm-length :running [_]
  (println "Long distance"))

(length {:class :stateMachine :state :running})
-> Long distance

Rich

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



Re: Suggest changing update-in to accept additional args for "f"

2008-10-14 Thread Alexander Kjeldaas


I'm also not completely happy with the usefulness of update-in.
However I don't see how this improves things a lot.

(update-in m [:a :b] + 2) can be written as:
(update-in m [:a :b] (partial + 2)) or
(update-in m [:a :b] #(+ 2 %))

both of which are more readable and more self-documenting IMO.

An extension I have been using is this one:

(update-map m {:a {:b #(+ 2 %)}})

user=> (update-map {:a {:b 3}
   :c {:d 3}}
  {:a #(+ 2 %)
   :c #(conj % {:e 4}})
{:a {:b 5}, :c {:e 4, :d 3}}

in this case any values can be updated by providing a pattern-map
which works like this.  If an element in the pattern-map implements
IFn, it is used to transform the corresponding value in m.
update-map can be used in a reduce when you want to keep state in a
structured fashion in a map. Example:
user=> (reduce (fn [state data]
 (update-map state {:stddev {:sumofsumsum #(+
(* data data))
  :sumofsum
#(+ % data)}}))
   {:stddev {:sumofsumsum 0.0 :sumofsum 0.0}}
   '(1 2 3))
Unlike loop, the above reduce function can be composed easily as long
as the composed functions use different parts of the map
user=> (reduce #(comp update1 update2)
   {... some initial state}
   '(1 2 3 ))
Or without initial state:
user=>(reduce  (fn [state data]
(update-map state {:stddev {:sumofsumsum #(+
(or % 0) (* data data))
 :sumofsum
#(+ (or % 0) data)}})
   '(1 2 3))

Implementation (not really tested):
(defn update-map
  [m fn-pattern]
  (loop [m m
 [k & ks] (keys fn-pattern)]
(if k
  (let [k-pat (get fn-pattern k)]
(cond
 (associative? k-pat)
 (recur (assoc m k (update-map (get m k) k-pat))
ks)
 (fn? k-pat)
 (recur (assoc m k (k-pat (get m k)))
ks)
 :else
 (recur (assoc m k k-pat)
ks)))
  m)))

Alexander

On Oct 13, 6:35 pm, mb <[EMAIL PROTECTED]> wrote:
> Hello,
>
> On 13 Okt., 17:02, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote:
>
> >         user=> (update-in m [:a :b] + 2) ; new
> >         {:a {:b 3}}
>
> I think this is a good idea. This would also be in-line with things
> like
> alter and commute.
>
> Sincerely
> Meikel
--~--~-~--~~~---~--~~
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: "Invalid this class index..." exception

2008-10-14 Thread Matthew D. Swank



On Oct 14, 1:09 pm, Rich Hickey <[EMAIL PROTECTED]> wrote:
> On Oct 14, 1:55 pm, "Paul Stadig" <[EMAIL PROTECTED]> wrote:
>
> > I'm getting the following error message when trying to load a 12MB clojure
> > file that is basically just a big hashmap of fundamental types (i.e.
> > strings, numbers, keywords, etc.).
>
> > java -cp
> > /home/pstadig/.emacs.d/clojure/target/clojure-lang-1.0-SNAPSHOT.jar:./gen
> > clojure.lang.Script db.clj
> > Exception in thread "main" java.lang.ClassFormatError: Invalid this class
> > index 3171 in constant pool in class file clojure/eval__2459 (db.clj:0)
> > I'm using revision 1068 with Sun Java 1.6.0, as indicated below. I've also
> > gotten this error with earlier revisions of Clojure.  I forget the revision
> > (around 2008-10-06), but I think it was before AOT. I'm not sure what the
> > issue is. I can send along the file if needed.
>
> Looks like you might be using Clojure data structures literals as a
> data format. That's great, and fine, but you probably want to read
> that file rather than load it. Loading it will force the compiler to
> treat it as code, and, now, as needed by the AOT support, try to put
> the data structure into a classfile, where it won't fit. Reading it
> will work.
>
> Rich

Has anyone gotten swank-clojure to work with this change?
Thanks,

Matt
--~--~-~--~~~---~--~~
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: "Invalid this class index..." exception

2008-10-14 Thread Paul Stadig
I have. I just had to add "/home/pstadig/gen" to
swank-clojure-extra-classpaths. When I start emacs (from my Application
menu) it starts in my home directory. If you started emacs in a different
directory, then I guess you would just have to add "[THAT DIR]/gen" to the
classpath.


Paul

On Tue, Oct 14, 2008 at 3:40 PM, Matthew D. Swank <
[EMAIL PROTECTED]> wrote:

>
>
>
> On Oct 14, 1:09 pm, Rich Hickey <[EMAIL PROTECTED]> wrote:
> > On Oct 14, 1:55 pm, "Paul Stadig" <[EMAIL PROTECTED]> wrote:
> >
> > > I'm getting the following error message when trying to load a 12MB
> clojure
> > > file that is basically just a big hashmap of fundamental types (i.e.
> > > strings, numbers, keywords, etc.).
> >
> > > java -cp
> > >
> /home/pstadig/.emacs.d/clojure/target/clojure-lang-1.0-SNAPSHOT.jar:./gen
> > > clojure.lang.Script db.clj
> > > Exception in thread "main" java.lang.ClassFormatError: Invalid this
> class
> > > index 3171 in constant pool in class file clojure/eval__2459 (db.clj:0)
> > > I'm using revision 1068 with Sun Java 1.6.0, as indicated below. I've
> also
> > > gotten this error with earlier revisions of Clojure.  I forget the
> revision
> > > (around 2008-10-06), but I think it was before AOT. I'm not sure what
> the
> > > issue is. I can send along the file if needed.
> >
> > Looks like you might be using Clojure data structures literals as a
> > data format. That's great, and fine, but you probably want to read
> > that file rather than load it. Loading it will force the compiler to
> > treat it as code, and, now, as needed by the AOT support, try to put
> > the data structure into a classfile, where it won't fit. Reading it
> > will work.
> >
> > Rich
>
> Has anyone gotten swank-clojure to work with this change?
> Thanks,
>
> Matt
> >
>

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



emacs-cvs and swank-clojure under os-x 10.4

2008-10-14 Thread Matthew D. Swank

swank-clojure seems to work fine; it just seems that java is ignoring
'swank-clojure-extra-classpaths.

in slime:

user> (require 'clojure.contrib.zip-filter)
java.io.FileNotFoundException: Could not locate Clojure resource on
classpath: clojure/contrib/zip_filter/zip_filter.clj (NO_SOURCE_FILE:
0)


at a shell:

java -cp /sw/local/src/clojure/target/clojure-lang-1.0-SNAPSHOT.jar:/
Users//.clojure/clojure-contrib.jar clojure.lang.Repl
Clojure
user=> (require 'clojure.contrib.zip-filter)
nil
user=>

Anyone using clojure on a mac?

Matt

--~--~-~--~~~---~--~~
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: emacs-cvs and swank-clojure under os-x 10.4

2008-10-14 Thread Jeffrey Chu

Hi Matt,

I don't have a Mac easily available, so unfortunately I can't run
tests on my own.

Could you tell me what you have set in:
  C-h v swank-clojure-extra-classpaths

And also the output of evaluating:
  M-: (swank-clojure-cmd)

Thanks,
- Jeff

On Oct 14, 12:49 pm, "Matthew D. Swank" <[EMAIL PROTECTED]>
wrote:
> swank-clojure seems to work fine; it just seems that java is ignoring
> 'swank-clojure-extra-classpaths.
>
> in slime:
>
> user> (require 'clojure.contrib.zip-filter)
> java.io.FileNotFoundException: Could not locate Clojure resource on
> classpath: clojure/contrib/zip_filter/zip_filter.clj (NO_SOURCE_FILE:
> 0)
>
> at a shell:
>
> java -cp /sw/local/src/clojure/target/clojure-lang-1.0-SNAPSHOT.jar:/
> Users//.clojure/clojure-contrib.jar clojure.lang.Repl
> Clojure
> user=> (require 'clojure.contrib.zip-filter)
> nil
> user=>
>
> Anyone using clojure on a mac?
>
> Matt

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



Making a living on Clojure

2008-10-14 Thread Fogus

I am attempting to work Clojure (at least partially) into my job, but
in doing so I wonder how many of you here use it at your own jobs as
opposed to relegating it to hobby.

-m

--~--~-~--~~~---~--~~
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: emacs-cvs and swank-clojure under os-x 10.4

2008-10-14 Thread Stephen C. Gilardi

On Oct 14, 2008, at 3:49 PM, Matthew D. Swank wrote:

> Anyone using clojure on a mac?

I am. I specify which clojure slime should run using "Swank Clojure  
Binary" (in customize). In my shell script, I specify my classpath  
using a "-cp $DIRS" command line argument and also specify a place to  
look for jars via a "-Djava.ext.dirs=$JAVAEXTDIR" argument.

The path to the "gen" folder is currently "./gen"--it's relative to  
the current working directory. When I updated my launch script to  
include that in classpath, it works for me both at the command line  
and under emacs using slime/swank.

--Steve


--~--~-~--~~~---~--~~
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: help a journalist: why Clojure?

2008-10-14 Thread Esther Schindler

Wow -- I didn't know about that one! I'd have included it for-sure if  
I had.

There were a few that hit the editing room floor, including a  
keyboard shaped waffle iron.

On Oct 14, 2008, at 7:51 AM, Michel Salim wrote:

> On Mon, Oct 13, 2008 at 6:13 PM, estherschindler
> <[EMAIL PROTECTED]> wrote:
>> 7 Cool, Weird and Useful Computer Keyboards
>> Not every computer keyboard or input device is a boring hunk of
>> plastic. We look at several ergonomic, wireless, high-tech and just
>> plain fun keyboards to brighten your day and give joy to your
>> fingertips.
>> http://www.cio.com/special/slideshows/cool_keyboards/index
>
> If there's ever a part 2 to the cool keyboards slideshow, it would be
> nice to see a review of the Happy Hacking Keyboard :)


--~--~-~--~~~---~--~~
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: Making a living on Clojure

2008-10-14 Thread Luc Prefontaine
Hi,

Presently writing the logic of an application message bus product using
Clojure, mainly because:

a) lack of time to writer 1000xlines of Java code.
b) need to reuse some existing java code & Spring stuff.
c) heavy need for parallelism.
d) heavy need for fast releases to improve the product, dynamic language
is a must.
e) lot funnier to mix tools in a project, it breaks the monotony and
gives the opportunity to people to lean different things and where they
should be used.
f) Java sucks after a number of years (8 in my case) and all these
frameworks reinventing the wheel or themselves, Cobol would be as funny
to use today
with a few wizards. Just reading java doc (most of it being poor
documentation of the code behavior) gets me stomach pains.
g) some of my earlier product prototypes where in Common Lisp but now
being able to reuse Java libraries means the prototype can now be
designed to become
eventually the V1.0 of the product. There will always be a twist to
extend the product relying if needed on existing Java code. Not true
with Common Lisp.
Getting  a product release becomes a new project by itself. There's
always some bits missing and you end up writing extra code.

But:

a) I am my own boss so I make the decisions about the design and the
appropriate tools.
My partners either follow or die in the process :)) Some are left
around so it's probably not
so hard...

b) I sell closed systems on standalone boxes. no endless and painful
discussions with the customer
anarchitects about the implementation with discussions:  we would
like this part to be rewritten in (choose your option here),
why not use that latest gizmo  framework that pop out from nowhere 3
weeks ago, we just decided to standardize on that a month ago,...
bablebable...
No endless meeting anymore...

c) My projects are schedule driven most of the time so sticking to a
tool for the principle
of keeping stuff mono-language/framework is cumbersome and useless.
My customers want their stuff running as fast as possible,
since we maintain what we deliver, they do not care about what's
under the hood.

In our product, the configuration GUI part is done in Ruby on Rails
(faster delivery, GUI code is dull to write) and deployed on JRuby,
many basic components come from the prototype that was created primarily
in Java with Spring. On top of that the bus logic runs in Clojure.
Java lies where it should, at the same spot where assembly languages
used to sit in the 70s/80s/90s years, at the bottom.
You know it's there but you do want to deal with it directly as much as
possible however it's always possible to write some specialized code
or use existing librairies.

Use the tool were it is the best fitted but that cannot be sold to
many organizations, at least here in Canada.
They want the single tool that will allow them to build a complete house
including the plumbing and the electricity.
Of course that tool does not exists yet so they stick with Java and a
whole bunch of code assistants to spit out huge piles of java code.

Why not build the house from bare molecules... nice genetic engineering
project but not very efficient if you want to deliver
a project of 1000 houses in a three years time line. :

We are working with Clojure and some other not yet mainstream
technologies, at least in Canada on a daily basis now.

I call that a competitive advantage

Our first implementation will be in production by the end of November
2008, other sites to follow in first half of 2009.

The count is now 3 (me and my two partners). Who else ?

Luc


On Tue, 2008-10-14 at 13:13 -0700, Fogus wrote:

> I am attempting to work Clojure (at least partially) into my job, but
> in doing so I wonder how many of you here use it at your own jobs as
> opposed to relegating it to hobby.
> 
> -m
> 
> > 
> 

--~--~-~--~~~---~--~~
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: packaging App (cross-platform) without scripts, only jar

2008-10-14 Thread R. P. Dillon

On Oct 14, 10:04 am, Asbjørn  Bjørnstad <[EMAIL PROTECTED]> wrote:
> On Oct 2, 10:23 pm, Pascal <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi all,
>
> > for Michael Beauregard,
>
> > > Is there a reason why setting the "Main-Class" field in the jar's manifest
> > > doesn't work.
>
> > It work, and since the manifest had to be edited to set the Class-Path
> > why not set correctly the Main-Class ? maybe if my main class would
> > be called "Main" instead of "Launcher" it will be automatic.
> > But still, the Class-Path is needed so I changed the manifest.
>
> > > I'm surprised that any code has to be written at all for this work.
> > > ...
> > > I've used this before and I think that the launcher (in Windows at least)
> > > would execute: java -jar %f
>
> > Exactly and it work! but to be able to click on a "jar"
> > you must *have* a jar, something that was not by default in Clojure
> > since you cannot compile ahead into a jar.
>
> So it is not possible to put the clj files into the jar so that no
> unzipping
> is neccessary? I tried, but my java/jar knowledge is basically zero.
> --
>  -asbjxrn

I put together an quick tutorial of how I made an executable jar for
an example "Hello World" app in Clojure.  Suggestions welcome.

http://rpdillon.googlepages.com/creatingexecutablejarswithclojure

Cheers,
Rick
--~--~-~--~~~---~--~~
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: Refs and ensure

2008-10-14 Thread Rich Hickey

On Oct 13, 9:51 pm, jim <[EMAIL PROTECTED]> wrote:
> Rich,
>
> I've been working with refs tonight and I appreciate the validate-fn
> addition.  Makes my life a lot easier.
>
> From reading the docs, 'ensure' keeps a ref from changing inside a
> dosync.  But if accesses to refs are contained in function calls that
> are called during the transaction, the programmer might overlook them
> when writing the dosync.
>
> A hack I came up with to deal with this is to bind a new value to
> 'deref' that saves the ref to a list before calling the normal deref
> function.  Then as a final step in the transaction, to go through the
> list of deref'd refs and call 'ensure' on each one.
>
> Do you have any thoughts on how to handle the situation better?
>

Yes - don't do it!

First, let me explain ensure a bit more. When running in a
transaction, you will see the ref world as-of a point in time,
entirely consistent. Refs never change inside a dosync unless you
change them. This is known as snapshot isolation, and, under MVCC, is
an efficient and robust way to do things. Reads don't need to be
tracked, and consistency is good. In most cases, you only care that
the refs you are writing to haven't changed before you commit - this
is done automatically by the transaction.

ensure is there to, well, ensure that a ref >that you've only read< is
no different when your transaction commits. When would you want to do
this? - when your business rule has an invariant on read data. Failing
to lock down the invariant read items in this case risks what is
called a write skew. A classic example is a financial program that
lets you have two accounts, at most one of which can run a negative
balance. Any debit to an account will change only that account, but
read and rely upon the value in the other account not changing. In
some MVCC systems you'd have to issue a dummy write to the other
account in order to get it to participate in the transaction. ensure
is just a cleaner, clearer way to do this.

Why wouldn't we want to ensure all reads? For two reasons - one, it's
terribly inefficient, and two, that's not the way the concurrent world
works. In the real world we make an observation, make a decision, and
act, and the world doesn't stop in the meantime. Physics keeps actions
from conflicting, and, similarly, MVCC transactions prevent write
conflicts.

You're seeing more and more assaults on transactional DBMS systems not
being able to scale, people accepting eventual or partial consistency
etc. I think some of these problems stem from a stop-the-world
approach, one that we have to question in our in-memory designs as
well.

Many STMs do read tracking and ensure that nothing you've read has
changed during the transaction. They also may keep track of each ref
only from the point in time you first read it, offering no whole-world
consistency at all. I think MVCC is a better approach.

As an example, consider a program like one that needs to give all
salespeople that have made their quota a bonus. The program will need
to read the quotas and sales, and will change their paycheck. By doing
so in a Clojure transaction, it is making decisions based upon
consistent data. There's no reason to stop people from selling in the
meantime, concurrently, i.e. you don't care if, at the end of issuing
bonuses, more sales have occurred.

It will be possible for me to add an optional ensure-all mode to the
transactions if there is sufficient demand, but I encourage you to
first understand and rely upon the substantial consistency guarantees
and efficiencies offered by Clojure's MVCC snapshot isolation, using
ensure only when you have a true read invariant/write skew situation.

Rich


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



Asking for Permission

2008-10-14 Thread [EMAIL PROTECTED]

hello,rich,

i'm from china,  i found content  in  your Clojure  web is  thoughtful
and attractive, i wanna translate it to chinese,

it will be helpful for  learning Clojure by myself, also for other
chinese interested in Clojure language and generic softwares design,
but i can't find license of your web content but Clojure software.





regards,


gerry






--~--~-~--~~~---~--~~
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: packaging App (cross-platform) without scripts, only jar

2008-10-14 Thread [EMAIL PROTECTED]



On Oct 14, 10:04 am, Asbjørn  Bjørnstad <[EMAIL PROTECTED]> wrote:
>
[..snip..]
> So it is not possible to put the clj files into the jar so that no
> unzipping
> is neccessary? I tried, but my java/jar knowledge is basically zero.
> --
>  -asbjxrn

it is definitely possible.  To make a jar that doesn't need clojure in
the classpath you need to unpack the clojure jar and repack those
files inside the new jar with your own clojure files.

I have a make-class.clj for a project using what I think maybe
deprecated syntax these days:

(in-ns 'TFC)
(clojure/refer 'clojure)
(load-file "/media/windows/clojure/src/genclass.clj")
(load-file "TFC.clj")
(clojure/gen-and-save-class (first *command-line-args*) 'TFC :main
true)

this makes a class file named TFC.class from the TFC namespace with a
"main" function.  The "main" function in the TFC namespace looks like:
(defn main [& strings] ...)
dunno if the [& strings] is required, but it seems like the closest
clojure mapping to java's "main" method signature.

to build the standalone jar file:

1) run make-class.clj which gives me TFC.class from TFC.clj
2) extract clojure.jar into the same directory as TFC.class and
TFC.clj
3) create the jar file specifying "TFC" as the "application entry
point". the exact command line is:
 jar cevf TFC tcp-flow.jar *

the resulting is tcp-flow.jar is standalone in the sense that it does
not need a separate clojure.jar in the classpath and all .clj files
are inside the jar
this is a very simple app so there is only one clojure source file. I
am not sure how this would work out with multiple files and such.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Preliminary AOT support and swank-clojure startup times

2008-10-14 Thread Matthew D. Swank

Just a data-point:
OS: Windows-XP
CPU: Pentium-IV 2.8 Ghz
Mem: 504 MB

JDK:1.6u10rc

Startup time of swank-clojure rev. 1064: 6 s.
Startup time of swank-clojure rev. 1068: 120 s!

When I get home, I can see if the difference is as dramatic in Linux
x68_64 and OS-X PPC32.
--~--~-~--~~~---~--~~
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: Nested Multimethods

2008-10-14 Thread mb

Hello,

On 14 Okt., 16:58, Randall R Schulz <[EMAIL PROTECTED]> wrote:
> I have heard it claimed (on one of the Scala lists, I think)
> that patterns themselves are an anti-pattern...

I think there are always patterns. They are just different. In
Clojure there is maybe the "Driver Function" pattern: Instead
of writing a huge macro, put the logic in a driver function,
package up the arguments in (fn [] ...) closures and pass
them to the driver.

Sincerely
Meikel


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



using libraries

2008-10-14 Thread Paul Drummond

Hi all,

After a short break from hacking in Clojure I am back and eager to try
out all the new features but I am having trouble getting familiar with
the new lib/namespace feature.

I want to use the zip-filter library so at the REPL I tried this:

(require 'clojure.contrib.zip-filter :as zf)

which failed with:

java.lang.Exception: Unable to resolve symbol: zf in this context

The docs say :as takes a symbol as its argument so this should work,
right?

Apologies if I've made a silly syntax error - it's been a while!

Is require even the right function to be calling?  I notice the docs
for "require" say:

"Use :require in the ns macro in preference to calling this directly."

Maybe I should be using ns but I assumed it was for library modules
only - I am at the REPL and I don't really want to create a new
namespace, or do I ?!

Anyway, it's good to be back - looks like Clojure has been gathering
soon momentum recently and what's this I hear about a book from the
Pragmatic Programmers?!!!  Exciting times! :)

Cheers,
Paul.

--~--~-~--~~~---~--~~
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 Eclipse plugin progress (clojure-dev)

2008-10-14 Thread Casey Marshall

Well, there's also gen-class...  I'm still getting to know clojure...

On Oct 14, 1:35 pm, Casey Marshall <[EMAIL PROTECTED]> wrote:
> Writing Eclipse plugins in Clojure is very interesting is a long term
> goal.  In order to pull that off, I would need to extend/implement
> Eclipse platform classes and interfaces in Clojure, and export these
> classes in an Eclipse plugin, which is an OSGi bundle.
>
> Scala rewrote their Eclipse plugin in Scala at a certain point -- but
> Scala is easier as it compiles to *.class files.  Clojure will be more
> challenging as I'll need to hook up clojure.lang.Compiler to the
> classloader directly, and expose dynamically compiled bytecode.
> However, the potential could be huge.  Not only could Clojure be used
> for Eclipse PDE development, but Clojure-OSGi bundles would
> interoperate with other OSGi solutions (Glassfish, Apache ServiceMix,
> etc.).  OSGi would give Clojure apps some nice deployment options and
> a new devious way to sneak Clojure into the enterprise :)
>
> In the meantime, I'm ok with developing in Java now with the
> possibility of rewriting in Clojure later.  This ugly Java code will
> at least serve as a blueprint for what's to come.
>
> Casey
>
> On Oct 14, 10:00 am, JumpingJupiter <[EMAIL PROTECTED]>
> wrote:
>
> > > I humbly present my first steps toward an Clojure Eclipse plugin
> > > (http://code.google.com/p/clojure-dev/).
>
> > It seems your writing your plug-in in java. I don't know anything
> > about Eclipse plug-ins; it should be possible (maybe not desirable) to
> > write the plug-in in clojure right? what are your reasons for using
> > java?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
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: using libraries

2008-10-14 Thread Stephen C. Gilardi

On Oct 14, 2008, at 5:24 PM, Paul Drummond wrote:

> I want to use the zip-filter library so at the REPL I tried this:
>
> (require 'clojure.contrib.zip-filter :as zf)
>
> which failed with:
>
> java.lang.Exception: Unable to resolve symbol: zf in this context

The zf needs a quote as well as 'clojure.contrib.zip-filter (which is  
also a (quoted) symbol). Without the quote, Clojure is trying to  
evaluate zf to know what to pass as the last argument of require.

Lists and symbols evaluate to something other than themselves.

--Steve


--~--~-~--~~~---~--~~
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: Preliminary AOT support and swank-clojure startup times

2008-10-14 Thread Randall R Schulz

On Tuesday 14 October 2008 14:17, Matthew D. Swank wrote:
> Just a data-point:
> OS: Windows-XP
> CPU: Pentium-IV 2.8 Ghz
> Mem: 504 MB
>
> JDK:1.6u10rc
>
> Startup time of swank-clojure rev. 1064: 6 s.
> Startup time of swank-clojure rev. 1068: 120 s!

You managed to slow it down by a factor of 20??

I dare say, I could top that...


> When I get home, I can see if the difference is as dramatic in Linux
> x68_64 and OS-X PPC32.


RRS

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



Clojure Eclipse plugin progress (clojure-dev)

2008-10-14 Thread Casey Marshall

Hi,
I humbly present my first steps toward an Clojure Eclipse plugin
(http://code.google.com/p/clojure-dev/).  So far, here's where its at:

* Clojure nature, project type and builder (which doesn't do much
yet).
* Added a Clojure REPL to the console.  You can open it with the "New
Console" button on the console view.
* When editing a *.clj file, you can run the current file, which will
get loaded into the REPL console.

The REPL console has direct access to the Eclipse runtime and should
be able to manipulate the workbench.  That's right.. its an Eclipse
minibuffer!

Some background on clojure-dev... for some reason, I had to add a
Class.forName("clojure.lang.RT") in my Clojure OSGi bundle's start().
Otherwise I was not able to run Clojure within Equinox -- I believe it
was a Compiler.loadFile issue on the core Clojure files.  I originally
tried basing my plugin on the DLTK without much luck -- the DLTK does
not seem very relevant to targeting the JVM, its more like something
you'd use for an out-of-process scripting language environment.  I'm
going to go my own way and hook into the JDT where I have to.  I'm
looking at CUSP, PyDev, and Scala SDT for inspiration.

My next steps are to focus on Clojure language support and better JDT
integration (classpath, etc.).  Deployment and tooling is a big deal
to me, I think they're essential to being productive with the Java
platform -- even if the Clojure language is more productive, the Java
batteries included still require a lot of typing!

I know the Eclipse platform pretty well but from an Equinox & RCP
background.  I'm new to IDE development, so this is quite a learning
experience!

Cheers,
Casey

--~--~-~--~~~---~--~~
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: help a journalist: why Clojure?

2008-10-14 Thread Michel Salim
On Mon, Oct 13, 2008 at 6:13 PM, estherschindler
<[EMAIL PROTECTED]> wrote:
> 7 Cool, Weird and Useful Computer Keyboards
> Not every computer keyboard or input device is a boring hunk of
> plastic. We look at several ergonomic, wireless, high-tech and just
> plain fun keyboards to brighten your day and give joy to your
> fingertips.
> http://www.cio.com/special/slideshows/cool_keyboards/index

If there's ever a part 2 to the cool keyboards slideshow, it would be
nice to see a review of the Happy Hacking Keyboard :)

Regards,

-- 
miʃel salim  •  http://hircus.jaiku.com/
IUCS •  [EMAIL PROTECTED]
Fedora   •  [EMAIL PROTECTED]
MacPorts •  [EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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: GUIs in Clojure

2008-10-14 Thread V.Quixote

It sounds like all we really need is a single clojure thread which
handles all access to Swing/AWT/Whatever. Since an additional
complaint is that Swing is too imperative, it sounds like both
problems could easily be solved at once.
I'd personally like for the declarations to be done using Clojure data
structures.

--~--~-~--~~~---~--~~
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: Making a living on Clojure

2008-10-14 Thread mb

Hi,

On 14 Okt., 22:13, Fogus <[EMAIL PROTECTED]> wrote:
> I am attempting to work Clojure (at least partially) into my job,
> but in doing so I wonder how many of you here use it at your own
> jobs as opposed to relegating it to hobby.

I'm using Clojure at my job, but mainly to make my life easier.
It's something which doesn't show up in HR files and my boss doesn't
care as long as it gets the job done. So maybe not what you are
interested in. How did Rich put it? "I know of some companies, who
use it as their secret weapon."

Nevertheless: Although it's not a big project I see the savings
in time and code, which were already stated by others. I planned
to give the GUI to a student worker to implement it in Java, so
that I can focus on the bussiness logic in the backend. But I'm
about to change my mind and go for full Clojure. Maybe I can infect
him with the Clojuritis but I have little hope...

In any case: if it has to run on the JVM and no one cares how
it looks like under the hood, I would go for Clojure. Although one
has to bring the patience to adapt to the development. (I had
several changes while tracking the development of
clojure.contrib.lib to clojure/ns.)

Take this with a grain of salt. I'm not a software developer.
Just my two cents.

Sincerely
Meikel

--~--~-~--~~~---~--~~
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: Refs and ensure

2008-10-14 Thread jim

Thanks for the response, Rich.

I really wanted to eliminate the possibility that the user of my
library would accidentally overlook a ref that needed to be invariant
during a transaction.  That solution felt hackish, which is why I
asked.  At this point, I'll shift the burden to the programmer to
ensure that all refs that need to be invariant, are.

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



Re: Preliminary AOT support and swank-clojure startup times

2008-10-14 Thread Matthew D. Swank



On Oct 14, 4:48 pm, Randall R Schulz <[EMAIL PROTECTED]> wrote:
> On Tuesday 14 October 2008 14:17, Matthew D. Swank wrote:
>
> > Just a data-point:
> > OS: Windows-XP
> > CPU: Pentium-IV 2.8 Ghz
> > Mem: 504 MB
>
> > JDK:1.6u10rc
>
> > Startup time of swank-clojure rev. 1064: 6 s.
> > Startup time of swank-clojure rev. 1068: 120 s!
>
> You managed to slow it down by a factor of 20??
>
> I dare say, I could top that...
>

Well, for the time being the difference seems limited to windows and
1.6u10rc.  I won't be able to test another windows vm till
tomorrow...curious.

Matt
--~--~-~--~~~---~--~~
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: Preliminary AOT support and swank-clojure startup times

2008-10-14 Thread Randall R Schulz

On Tuesday 14 October 2008 16:35, Matthew D. Swank wrote:
> On Oct 14, 4:48 pm, Randall R Schulz <[EMAIL PROTECTED]> wrote:
> > On Tuesday 14 October 2008 14:17, Matthew D. Swank wrote:
> > > ...
> > >
> > > Startup time of swank-clojure rev. 1064: 6 s.
> > > Startup time of swank-clojure rev. 1068: 120 s!
> >
> > You managed to slow it down by a factor of 20??
> >
> > I dare say, I could top that...
>
> Well, for the time being the difference seems limited to windows and
> 1.6u10rc.  I won't be able to test another windows vm till
> tomorrow...curious.

Actually, I figured it was a typo. You meant to write "120 ms" or 
something... Either way, the exclamation point would be justified...


> Matt


Randall Schulz

--~--~-~--~~~---~--~~
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: Making a living on Clojure

2008-10-14 Thread Josh Daghlian

I'm one of about a dozen developers on a 250 kloc Java codebase that
has a DSL of sorts in it: boolean predicate trees representing
targeting for ad campaigns. I write, among other things, tree-
rewriting compilers that turn those trees into SQL where clauses,
scheduling buckets, floating point numbers for forecasts, functors for
figuring out ad request eligibility, etc.  The "compiler" layer has
tons of special cases built into it which had proven very annoying to
test properly, and what I really wanted was a syntax for these
predicate trees.

Clojure to the rescue! In particular, the Clojure reader to the
rescue. I wrote an sexp-to-real-object parser (in about a dozen lines
of not-very-lispy code), which allowed me to write very dense (one-
line) test cases.  Several hundred lines of sexp's later, the code was
comprehensively tested. I shoved the whole thing into a Junit test
(with Clojure code in Strings, in this case) and haven't heard from
the compiler layer since.  Good times.

There are two or three other portions of the code that I'd like to
replace with Clojure, especially Spring and its horrible XML
"language" for configuring things, and perhaps Hibernate and its
horrible XML "language" for describing O/R mappings. The Clojure STM
would make a bunch of state management easier elsewhere in the app (by
forcing it to be explicit), but that's a much larger task for another
time.

At any rate, the point is that because it's ultimately just a jar file
in our maven repository, using Clojure for something else is now
ridiculously easy. There's no integration work to do, the build system
already supports it, and the operations guys don't have to learn a new
language. Clojure is just kind of there.

On Oct 14, 4:13 pm, Fogus <[EMAIL PROTECTED]> wrote:
> I am attempting to work Clojure (at least partially) into my job, but
> in doing so I wonder how many of you here use it at your own jobs as
> opposed to relegating it to hobby.
>
> -m

On Oct 14, 4:13 pm, Fogus <[EMAIL PROTECTED]> wrote:
> I am attempting to work Clojure (at least partially) into my job, but
> in doing so I wonder how many of you here use it at your own jobs as
> opposed to relegating it to hobby.
>
> -m
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



is clojure known to work on any phones with javame?

2008-10-14 Thread Kevin Downey

I am in the market for a phone and it would be so cool to have clojure
on it. Has anyone tried this yet?

-- 
The Mafia way is that we pursue larger goals under the guise of
personal relationships.
Fisheye

--~--~-~--~~~---~--~~
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: using libraries

2008-10-14 Thread Paul Drummond

Of course.  Hmmm.  And I thought I knew this stuff! :)

I think I was getting all confused because I was playing with ns and
it doesn't require quoting (because it's a macro).  It makes sense now
- thanks.

Regarding the use of require, am I right in thinking that ns is for
library modules and require, use, etc. are appropriate for just
bringing in library functions to the REPL?  I'm pretty sure this is
the case - I just wanted to check as the documentation made me doubt
myself a little.

Paul.

On Oct 14, 10:47 pm, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote:
> On Oct 14, 2008, at 5:24 PM, Paul Drummond wrote:
>
> > I want to use the zip-filter library so at the REPL I tried this:
>
> > (require 'clojure.contrib.zip-filter :as zf)
>
> > which failed with:
>
> > java.lang.Exception: Unable to resolve symbol: zf in this context
>
> The zf needs a quote as well as 'clojure.contrib.zip-filter (which is  
> also a (quoted) symbol). Without the quote, Clojure is trying to  
> evaluate zf to know what to pass as the last argument of require.
>
> Lists and symbols evaluate to something other than themselves.
>
> --Steve
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---