Re: Emacs with Lisp and Clojure.

2011-03-24 Thread Tassilo Horn
mmwaikar  writes:

> But the same enter key works properly when I am using Lisp, so why
> shouldn't it be the default in Clojure as well?

What's considered "properly" for RET is purely subjective. :-)

But I have to admit that I was wrong.  When paredit-mode is enabled, RET
is indeed bound to `paredit-newline', which does indentation
automatically.  For me that does the trick for Clojure, Elisp, and CL
buffers...

> Also, after removing clojure-mode, when I try to install swank-
> clojure, it again installs the clojure-mode, but fails to install
> itself?

Do you get some error messages?

Using emacs 24 from bzr, I only added

  (add-to-list 'package-archives
   '("technomancy" . "http://repo.technomancy.us/emacs/";) t)

to get the most recent packages from technomancy listed in M-x
package-list-packages, and there I installed these ones:

  clojure-mode  1.8.0   installed  Major mode for Clojure code
  slime 20100404.1  installed  Superior Lisp Interaction Mode for 
Emacs
  slime-repl20100404installed  Read-Eval-Print Loop written in 
Emacs Lisp
  swank-clojure 1.1.0   installed  Slime adapter for clojure

Bye,
Tassilo

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


Re: gen-class and state...

2011-03-24 Thread Jules
Guys,

Thanks for your replies - I'm glad I posted as this is exactly what I was 
looking for. I wish I had found Stuart's article when he wrote it. I had an 
inkling that my gen-class struggles were out of date - now I can go and 
rework all that code :-)

Problem solved.

Thanks again,

Jules

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

Re: gen-class and state...

2011-03-24 Thread Ulises
Sorry for hijacking but I wouldn't mind some clarification on the subject.

Right now I can get java classes and interfaces with defprotocol and
defrecord and the world is good.

Can somebody please educate me in the uses/needs for :gen-class and friends?

Keep in mind that I haven't really done much Java interop so my
question may indeed be a silly one.

Cheers!

U

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


Re: gen-class and state...

2011-03-24 Thread Meikel Brandmeyer
Hi,

On 24 Mrz., 10:40, Ulises  wrote:

> Can somebody please educate me in the uses/needs for :gen-class and friends?

You need gen-class when you want (or have to) derive from another
class. defrecord/deftype/reify don't allow that, while gen-class/proxy
do.

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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: gen-class and state...

2011-03-24 Thread Ulises
> You need gen-class when you want (or have to) derive from another
> class. defrecord/deftype/reify don't allow that, while gen-class/proxy
> do.

I suppose this is for when you want to add fields to an already
existing class? (I'm assuming that adding methods could be done with
extend/extend-protocol?)

U

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


http://build.clojure.org/releases - no alpha5 alpha6.. ?

2011-03-24 Thread Jules
is this:

http://build.clojure.org/releases/org/clojure/clojure/

no longer the place to point my maven :-(

I'd love to give the latest alpha's a try, but the thought of manually 
d/l-ing them and then installing them into my local repo is just too much !!

should I point somewhere else, or will this release dir be updated soon ?

thanks

Jules

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

Re: Jesus, how the heck to do anything?

2011-03-24 Thread Matthias Diehn Ingesman
Hi,

You can write some lines of Clojure code in a file, and then execute
it with the command 'clj '. I'm sitting on a linux box
where the script to start Clojure is called 'clj', but if you don't
have such or simply downloaded the zip from clojure.org, you can use
this line to execute a script called test.clj:

java -cp  clojure.main test.clj

Which on my linux system would be

java -cp /usr/share/clojure/clojure.jar clojure.main test.clj

The '-cp' after java means "add this file to the classpath", and
basically tells java where to find libraries and classes you use in
your code. Don't worry about it if you use a build tool like leiningen
(see end of this post).

Now for a Clojure script that simply calculates the 5th fibonacci
number and prints it:

(defn fib [n]
  (if (< n 2) 1
  (+ (fib (- n 2))
  (fib (- n 1)

(println (fib 5))

You can simply copy that to a file test.clj and use the above command
to run it - should produce 8 as output. This procedure should work
with every script you throw after clojure.

For larger (non-script) projects I would recommend using the
'leiningen' build tool (https://github.com/technomancy/leiningen), the
README should explain how to use it. Basically it can handle your
project dependencies for you, provide a way to package your
application in a JAR file for execution with java, and many other nice
features.

I hope this helps,
  /Matthias

On Mar 23, 8:50 am, ultranewb  wrote:
> Short version:  How do I just open an editor, type in some Clojure
> code, save it in a file, and then run it?
>
> Long version:  Okay, I'm very new to Clojure.  But I'm not a Java
> programmer (don't want to be).  I'm not used to all this complexity
> just to do something simple.  What I want to do is the "normal
> programming" that I do with every other environment and language I
> work with, i.e. I edit some source code on screen, save it in a file,
> and either compile/run, or interpret it or whatever.  But I haven't
> figured out how to do that yet, and don't know if it's possible.
>
> I downloaded Netbeans and Enclojure.  It runs fine.  I can get a REPL,
> blah blah.  But have no idea how to do anything "real" i.e. execute a
> program saved in a file.  Again, I want to edit some code with the
> very nice editor, save it, and hit some button that says "execute" or
> perhaps "compile and execute" or perhaps "build and execute" or
> whatever.  But apparently there is a heck of a lot more to it than
> that.  I understand that you have to build a "project" or whatever.
> Fine - I did that.  Still, I have no idea which directory out of that
> huge structure I'm supposed to put code in, I have no idea how to set
> up all these "dependencies" or whatever.  I did try some random stuff,
> i.e. saving a file in various directories and hitting "build" but that
> didn't work.  I also tried editing various files that were already
> there, hoping one of them was the "main" file I was supposed to be
> dumping source code into, but that didn't work either.
>
> So I downloaded Clojure Box.  It installs and runs fine.  Again, I get
> a REPL no problem.  But there's only so much coding I can do in a
> REPL.  Again, I'd like to do more.
>
> I spent a long time trying to find some help online (googling, etc),
> but everything I've found assumes I know too much, i.e. how to set up
> all these projects and dependencies.
>
> Actually, I'm not interested in fooling with all the boilerplate and
> crap AT ALL.  So if I HAVE to do that, I'm outta here.  But something
> tells me I may not have to, i.e. there may be some automated tool
> somewhere, or some "template" files I can just use over and over, or
> some "trick" to use like "just name your program 'main' and stick it
> in such-and-such directory."
>
> Any 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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Java Interop - Generics - Hmmm...

2011-03-24 Thread Jules
Guys,

I have a hybrid Java/Clojure project.

The Java side contains a number of interfaces/classes that make use of 
generics.

Implementing the interfaces Clojure-side is no problem - I just forget about 
type and get on with it :-)

I am slowly migrating more and more code into Clojure and there will come a 
point when I'd like to take some of these interfaces over...

So now to my confusion:

My understanding is that generics are a compile-time, NOT a run-time 
abstraction.

This implies that metadata about generics would not be present at runtime 
and therefore [probably] not in bytecode ?

So, I would expect to be able to replace my interfaces with defprotocols - 
however, I would expect this to confuse Java implementations of these 
interfaces, since they somehow have access to their interfaces 
generics-oriented metadata...

So maybe I have answered my question - I guess that there must actually be 
some generics metadata present in the bytecode to allow inter-jar generics 
compilation to work, but then at runtime this would be ignored [probably].

So this leads me to conclude that I would 

1. have to port my classes that implement generic interfaces to Clojure 
before the interfaces themselves.
2. give up the ability to write further generic implementations of these 
interfaces in Java

:-(

can anyone who really knows what the situation is confirm my suspicions ?

thanks for your time,

Jules

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

Re: Jesus, how the heck to do anything?

2011-03-24 Thread Baishampayan Ghose
On Thu, Mar 24, 2011 at 8:34 AM, ultranewb  wrote:
>> That's quite alright. Nine out of ten people here hate java;
>
> Actually, I didn't know that.  I imagined that 9 out of 10 people here
> would be java-ites.  It's good to know that I'm in good company.

Clojure won't have existed if the people here were satisfied with Java.

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.com

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


Re: Jesus, how the heck to do anything?

2011-03-24 Thread ultranewb
On Mar 24, 10:19 am, Sean Corfield  wrote:
> Heh, even as a long-time Java developer (since '97), I'm here because
> I want something _better_ than Java. It's why I learned Groovy in 2008
> (sort of "Java-lite" - fixes most of Java's problems but suffers from
> performance issues compared to Java), Scala in 2009 (sort of "Java++"
> - fixes most of Java's problems but suffers from a split personality
> since it's a hybrid OO/FP language and has a frightening type system -
> for the people I need to work with), and then Clojure in 2010.

Since we are mentioning other languages (I'm sure it's a little off-
topic, but what the hey), if you really want to fry your brain and
blow your mind, check out APL, or its modern successor, J.  APL is
ancient, but so is LISP, so that shouldn't put off any LISP-ites.  I
am not exaggerating when I say that for most little problems you want
to solve, you can do it in one line.  I wrote an electronic real-time
trading platform in J.  Would have taken God knows how many pages of
code in any other language.  With J I did it in just a few pages max.

One area I'd say Clojure is ahead of something like J would be
concurrency.  It's always fun to know new languages.  Heck, I guess I
know over 20 at this juncture.

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


Re: Extra params for a handler inside Ring's wrap-params

2011-03-24 Thread Thorsten Wilms

On 03/23/2011 02:32 PM, Thorsten Wilms wrote:

Hi!

Routing, using ring.middleware.params and net.cgrand.moustache:

(def tlog-app-handler
(app ["admin" &]
{:get (app ...snip...)
:post (app wrap-params [[path not-empty] &] submit-article)}


Thanks to wrap-params, I can destructure request params within
submit-article. However, I also want to have "path". Without
wrap-params, it would simply be:

(app [[path not-empty] &] (submit-article path))



(app wrap-params [[path not-empty] &] (partial submit-article path))

results in "nth not supported on this type: PersistentHashMap"


Should have been:

(app [[path not-empty] &] (wrap-params (partial submit-article path)))

Which works, then.

Thanks to the fine folks in #clojure, I have another solution:

(app [[path not-empty] &] (wrap-params
   (fn [req] (submit-article req path



--
Thorsten Wilms

thorwil's design for free software:
http://thorwil.wordpress.com/

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


Re: Jesus, how the heck to do anything?

2011-03-24 Thread Meikel Brandmeyer
Hi,

On 24 Mrz., 13:09, Baishampayan Ghose  wrote:

> Clojure won't have existed if the people here were satisfied with Java.

I think, there is a difference between "hate" and "dissatisfaction."

IMHO the Java bashing is overrated. Coming from a polyglot-but-non-
java background, I didn't have much trouble getting things running. Is
the CLASSPATH really so much different to the PYTHONPATH,
LD_LIBRARY_PATH or even the plain old PATH itself? When you work with
the JVM (or the CLR; for that matter) you need some knowledge about
it. And then stop fighting the system but adapt to it.

"Heck, why do I have to refuel my car every other week? I even have to
know which type of gasoline or - *gasp* - Diesel to use." No one
seriously says such things. Why do we do it with the JVM?

That does not mean, that Java and/or the JVM is perfect, but neither
is Clojure. Things can - and should - be improved.

Disclaimer: I'm not a professional.

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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Jesus, how the heck to do anything?

2011-03-24 Thread Timothy Baldridge
> I didn't have much trouble getting things running. Is
> the CLASSPATH really so much different to the PYTHONPATH,
> LD_LIBRARY_PATH or even the plain old PATH itself?

No, it's not that much different, except python is a bit more smart
about how things are setup. For instance, if you startup script.py
python will not only search PYTHONPATH, but also search the directory
where the python executable lives, as well as the current path.

On top of that, python (unlike lein, and I guess java as well) prefers
that all modules be installed in the python home directory. So the end
effect is I have been able to write python projects for years, and
only once have had to set the PYTHONPATH variable.

The same goes for LD_LIBRARY_PATH. The only time I've had to set that
variable is when I'm doing something funky like writing a plugin.

But the issue is, all these IDEs out there don't follow any of these
methods. So if you want to launch clojure with penumbra, not only do
you have to set the CLASSPATH, but you also have to set the -D
variable to point to the native libs. Even when I finally knew how to
set all this up, it still took me about 3 hours to get La Clojure to
recognize it all. And that was after trying and giving up on
Enclojure.

And don't even try to compare all this to the CLR...the gac, Visual
Studio, and the way the CLR links assemblies means that I've
never...ever...had to set a CLR path. And I program C# for a living.

Timothy

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


Re: Jesus, how the heck to do anything?

2011-03-24 Thread Baishampayan Ghose
On Thu, Mar 24, 2011 at 6:52 PM, Meikel Brandmeyer  wrote:
>> Clojure won't have existed if the people here were satisfied with Java.
>
> I think, there is a difference between "hate" and "dissatisfaction."

I agree. That's precisely why I used the word "satisfied" and not any
variation of love/hate.

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.com

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


Re: Java Interop - Generics - Hmmm...

2011-03-24 Thread Armando Blancas
For interop I write interfaces in Java. This way I can provide type-
specific signatures, constants, javadocs and generics; then implement
them all in Clojure. I also write exception classes in Java for use in
Clojure since I find it simpler and cleaner than gen-class. You don't
have to give up anyting for the sake of interop, but perhaps you won't
write 100% Clojure.

On Mar 24, 4:58 am, Jules  wrote:
> Guys,
>
> I have a hybrid Java/Clojure project.
>
> The Java side contains a number of interfaces/classes that make use of
> generics.
>
> Implementing the interfaces Clojure-side is no problem - I just forget about
> type and get on with it :-)
>
> I am slowly migrating more and more code into Clojure and there will come a
> point when I'd like to take some of these interfaces over...
>
> So now to my confusion:
>
> My understanding is that generics are a compile-time, NOT a run-time
> abstraction.
>
> This implies that metadata about generics would not be present at runtime
> and therefore [probably] not in bytecode ?
>
> So, I would expect to be able to replace my interfaces with defprotocols -
> however, I would expect this to confuse Java implementations of these
> interfaces, since they somehow have access to their interfaces
> generics-oriented metadata...
>
> So maybe I have answered my question - I guess that there must actually be
> some generics metadata present in the bytecode to allow inter-jar generics
> compilation to work, but then at runtime this would be ignored [probably].
>
> So this leads me to conclude that I would
>
> 1. have to port my classes that implement generic interfaces to Clojure
> before the interfaces themselves.
> 2. give up the ability to write further generic implementations of these
> interfaces in Java
>
> :-(
>
> can anyone who really knows what the situation is confirm my suspicions ?
>
> thanks for your time,
>
> Jules

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


Re: http://build.clojure.org/releases - no alpha5 alpha6.. ?

2011-03-24 Thread Andy Fingerhut
I've been using a project.clj file like this in Leiningen to get 1.3 alpha1 
through alpha6:

(defproject clj-1.3.0-alpha5 "1.0.0-SNAPSHOT"
  :description "FIXME: write"
  :dependencies [[org.clojure/clojure "1.3.0-alpha5"]])

Leiningen uses Maven under the hood, so if you have any Maven pom.xml file that 
works for any release of 1.3.0-alpha*, just change the * and try again.  If 
not, here is the  section of the XML file generated with "lein 
pom" in my little Leiningen project:

  

  org.clojure
  clojure
  1.3.0-alpha5

  


Andy

On Mar 24, 2011, at 3:53 AM, Jules wrote:

> is this:
> 
> http://build.clojure.org/releases/org/clojure/clojure/
> 
> no longer the place to point my maven :-(
> 
> I'd love to give the latest alpha's a try, but the thought of manually 
> d/l-ing them and then installing them into my local repo is just too much !!
> 
> should I point somewhere else, or will this release dir be updated soon ?
> 
> thanks
> 
> Jules

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


Re: Java Interop - Generics - Hmmm...

2011-03-24 Thread Jules
Thanks for the reply Armando,

This is pretty much where i was until I was asked to write a dot.net client 
library for my server.

I then looked at all my Java code and figured I could write a second copy in 
C# and then keep the two in sync for ever after, or port it all to Clojure 
and let ClojureCLR do the work...

I guess I can't have my cake and eat it.

In a perfect world, I would be able to sprinkle some extra metadata around 
my defprotocol to give Java classes implementing it whatever generics 
goodness they require - but I can understand this being low on Clojure's 
TODO list :-)

Jules

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

RabbitMQ

2011-03-24 Thread Max Weber
What is the best Clojure library to work with RabbitMQ?

Best regards

Max

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


Implicit unpacking of a map

2011-03-24 Thread Thorsten Wilms

Hi!

The following simplified code works:

(defn save-article
  [path form-params timestamp]
  (ds/save! (Article. path (form-params "title") (form-params "body")
 timestamp


But I would like to not handle the content of form-params explicitly.

My naive attempt that shows that I still have troubles with the 
evaluation model:


(ds/save! (flatten `(Article. path ~(vals form-params) timestamp)))

Fails with: "java.lang.IllegalArgumentException: No implementation of 
method: :get-entity-object of protocol: 
#'appengine-magic.services.datastore/EntityProtocol found for class: 
clojure.lang.Symbol"


I take that I created a list that looks like the function call that I 
need, but that is not evaluated as such. Throwing in eval doesn't help.

Can you shed some light on this?

How can I accomplish not having to make the content of form-params 
explicitly? (Not to save on typing, more for my understanding.)



--
Thorsten Wilms

thorwil's design for free software:
http://thorwil.wordpress.com/

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


Re: Java Interop - Generics - Hmmm...

2011-03-24 Thread Andy Fingerhut
I'm not an expert on this, but I believe that whenever you have generics in 
Java, they have no effect on the bytecode, e.g. a HashMap has 
the same type in the bytecode as any other HashMap.  The  part 
is only used in some checks made by the Java compiler when compiling Java 
source code, and in helping avoid some casting.  As evidence I have used 
reflection to examine the fields and method signatures of some Java classes 
that have generics, and there was nothing in the types except that which was 
specified outside the < ... >.

Andy

On Mar 24, 2011, at 8:04 AM, Jules wrote:

> Thanks for the reply Armando,
> 
> This is pretty much where i was until I was asked to write a dot.net client 
> library for my server.
> 
> I then looked at all my Java code and figured I could write a second copy in 
> C# and then keep the two in sync for ever after, or port it all to Clojure 
> and let ClojureCLR do the work...
> 
> I guess I can't have my cake and eat it.
> 
> In a perfect world, I would be able to sprinkle some extra metadata around my 
> defprotocol to give Java classes implementing it whatever generics goodness 
> they require - but I can understand this being low on Clojure's TODO list :-)
> 
> Jules
> 
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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

Re: http://build.clojure.org/releases - no alpha5 alpha6.. ?

2011-03-24 Thread Jules
Aha !

OK - so maven is pulling alpha5/6 in from somewhere, but not from the repo 
that I expected - and unfortunately, I am not finding 
clojure.contrib.logging for these releases - maybe contrib is not being 
released to the same repo ? or maybe it has changed its name ? I'll have to 
investigate.

Thanks for pointing me in the right direction.

Jules

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

Re: RabbitMQ

2011-03-24 Thread Mark Rathwell
I just wrapped their java client library:

http://www.rabbitmq.com/java-client.html


On Thu, Mar 24, 2011 at 11:15 AM, Max Weber  wrote:

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

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

Re: http://build.clojure.org/releases - no alpha5 alpha6.. ?

2011-03-24 Thread Chas Emerick
Jules,

All new Clojure artifacts are being released to maven central now, which is 
always checked by maven (and therefore lein):

http://mavencentral.sonatype.com/#search|ga|1|org.clojure

I think all existing prior releases of Clojure and clojure-contrib are there 
now as well.  Unless you're locked onto an old SNAPSHOT build (which can 
disappear at any time, since they're SNAPSHOTs), there's no longer any reason 
to have build.clojure.org set up as a repo in your pom.xml/project.clj.

- Chas

On Mar 24, 2011, at 11:13 AM, Jules wrote:

> Aha !
> 
> OK - so maven is pulling alpha5/6 in from somewhere, but not from the repo 
> that I expected - and unfortunately, I am not finding clojure.contrib.logging 
> for these releases - maybe contrib is not being released to the same repo ? 
> or maybe it has changed its name ? I'll have to investigate.
> 
> Thanks for pointing me in the right direction.
> 
> Jules
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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

Re: Implicit unpacking of a map

2011-03-24 Thread Tassilo Horn
Thorsten Wilms  writes:

Hi Thorsten,

> The following simplified code works:
> 
> (defn save-article
>   [path form-params timestamp]
>   (ds/save! (Article. path (form-params "title") (form-params "body")
>  timestamp
> 
>
> But I would like to not handle the content of form-params explicitly.

Probably, you want to use destructuring.

--8<---cut here---start->8---
(defn save-article
  [path {t "title", b "body" & rest :as m} timestamp]
  (println "path:" path
   ", title:" t
   ", body:" b
   ", timestamp:" timestamp
   ", m:" m))
--8<---cut here---end--->8---

Bye,
Tassilo

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


Re: Implicit unpacking of a map

2011-03-24 Thread Meikel Brandmeyer
Hi,

On 24 Mrz., 16:16, Thorsten Wilms  wrote:

> 
> (defn save-article
>    [path form-params timestamp]
>    (ds/save! (Article. path (form-params "title") (form-params "body")
>       timestamp
> 

The problem is the constructor call. With plain old clojure
functions you could use apply, but Java method and constructor
calls must be hard-wired in the bytecode (and hence at
compilation time) (if I understood this correctly).

So there will be now way around explicitly specifying the map
keys. Although you can relieve the pain a little with
destructuring as Tassilo already showed. It can be shorted a
bit using :strs.

(defn save-article
  [path {:strs [title body]} timestamp]
  (ds/save! (Article. path title body timestamp)))

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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Java Interop - Generics - Hmmm...

2011-03-24 Thread Alessio Stalla
On Thursday, March 24, 2011 5:29:56 PM UTC+1, Jules wrote:
>
> Thanks Andy,
>
> I agree that there is no practical remnant of generics in the runtime as I 
> have poked around with reflection as well, but I think there might be in the 
> bytecode, otherwise if I compiled a generic interface, stuck it into a jar 
> and gave it to you to link against, the compiler would know nothing about 
> the genericness of my interface ? Surely this can't be right as generics DO 
> exist at compile time, so I think that there is compile-time generics info 
> stashed somewhere in the bytecode that is not loaded at runtime.
>

Reflection is aware of generic type variables: 
http://download.oracle.com/javase/6/docs/api/java/lang/reflect/GenericDeclaration.html

What is lost at runtime is information about *instantiation* of those 
variables: e.g. you can't distinguish a method returning List from 
one returning List. (Actually, not even all instantiations of 
generic type variables are lost at runtime, see 
http://gafter.blogspot.com/2006/12/super-type-tokens.html for an example). 

hth,
Alessio

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

Re: Java Interop - Generics - Hmmm...

2011-03-24 Thread Alan
This is only half-true. The data exists somewhere, as Jules says, so
that javac can enforce proper use of generics when calling compiled
library code. Eg, rt.jar contains only classes, yet j.u.List still
manages to have generics, which are treated correctly by the compiler.
The *use* of generic code is compiled into just a bunch of Objects and
casting, but the .class file does contain some annotations to declare
the generics. It's just rather hard to find.

On Mar 24, 8:19 am, Andy Fingerhut  wrote:
> I'm not an expert on this, but I believe that whenever you have generics in 
> Java, they have no effect on the bytecode, e.g. a HashMap has 
> the same type in the bytecode as any other HashMap.  The  part 
> is only used in some checks made by the Java compiler when compiling Java 
> source code, and in helping avoid some casting.  As evidence I have used 
> reflection to examine the fields and method signatures of some Java classes 
> that have generics, and there was nothing in the types except that which was 
> specified outside the < ... >.
>
> Andy
>
> On Mar 24, 2011, at 8:04 AM, Jules wrote:
>
>
>
>
>
>
>
> > Thanks for the reply Armando,
>
> > This is pretty much where i was until I was asked to write a dot.net client 
> > library for my server.
>
> > I then looked at all my Java code and figured I could write a second copy 
> > in C# and then keep the two in sync for ever after, or port it all to 
> > Clojure and let ClojureCLR do the work...
>
> > I guess I can't have my cake and eat it.
>
> > In a perfect world, I would be able to sprinkle some extra metadata around 
> > my defprotocol to give Java classes implementing it whatever generics 
> > goodness they require - but I can understand this being low on Clojure's 
> > TODO list :-)
>
> > Jules
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with 
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en

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


Re: Java Interop - Generics - Hmmm...

2011-03-24 Thread Jules
Thanks Andy,

I agree that there is no practical remnant of generics in the runtime as I 
have poked around with reflection as well, but I think there might be in the 
bytecode, otherwise if I compiled a generic interface, stuck it into a jar 
and gave it to you to link against, the compiler would know nothing about 
the genericness of my interface ? Surely this can't be right as generics DO 
exist at compile time, so I think that there is compile-time generics info 
stashed somewhere in the bytecode that is not loaded at runtime.

What do you reckon ? I don't see how else it could work - but this is all 
supposition - I'd be interested in hearing from someone in the know.

Jules

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

Re: http://build.clojure.org/releases - no alpha5 alpha6.. ?

2011-03-24 Thread Jules
Aha! Thanks.

Looking at the link you have posted the latest version of Clojure is alpha6, 
but contrib is reporting 1.2 - that must be the root of my problem.

i have been using http://build.clojure.org/releases/org/clojure/clojure/because 
up until alpha4 it was serving both in sync.

Do you know if there are plans to ship contrib 1.3alphas from maven central 
as well ?

thanks

Jules

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

Re: Java Interop - Generics - Hmmm...

2011-03-24 Thread Alan
On Mar 24, 9:47 am, Alessio Stalla  wrote:
> Reflection is aware of generic type 
> variables:http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Generi...
>
> What is lost at runtime is information about *instantiation* of those
> variables: e.g. you can't distinguish a method returning List from
> one returning List.

I think you mean, you can't tell a List from a List
once it's been returned. As you demonstrated, telling which kind of
list a particular method will return can be done via reflection.

> (Actually, not even all instantiations of
> generic type variables are lost at runtime, 
> seehttp://gafter.blogspot.com/2006/12/super-type-tokens.htmlfor an example).

That's really nifty. Thanks for the link.

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


Re: gen-class and state...

2011-03-24 Thread Jules
Stuart,

I still think in a very OO way - which is probably why I am having 
difficulty with this :-)

A common OO pattern is to encapsulate complex resource acquisition/release 
within a class.

I can do this with gen-class - since I control ctor args and the instances 
initial state, as well as having post-init for when some part of my 
initialisation requires a reference to itself.

I'm guessing that I can't do this with deftype/reify - so this might be 
another reason to fall back on gen-class ?

[although I could leave space for an atom in my state and provide ctor/dtor 
fns which read/wrote this atom... - so I suppose this would be one way 
around the problem,,,]

Would you mind clarifying ?

Thanks

Jules

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

Re: http://build.clojure.org/releases - no alpha5 alpha6.. ?

2011-03-24 Thread Andy Fingerhut
There was a recent discussion on clojure-dev about this question.  I don't 
understand the details myself, so I'll point you at the thread.  The relevant 
part starts about 2/3 of the way through this 51-message thread, around March 
19, between Sean Corfield and Stuart Sierra (sorry, I don't know if there is a 
way to provide a URL that starts at a specific message within a long thread):

http://groups.google.com/group/clojure-dev/browse_thread/thread/f1b1fbfd2a6c1a9f

Then a new thread was created specifically on this topic here:

http://groups.google.com/group/clojure-dev/browse_thread/thread/6791b2971fc8739f

Andy

On Mar 24, 2011, at 9:34 AM, Jules wrote:

> Aha! Thanks.
> 
> Looking at the link you have posted the latest version of Clojure is alpha6, 
> but contrib is reporting 1.2 - that must be the root of my problem.
> 
> i have been using http://build.clojure.org/releases/org/clojure/clojure/ 
> because up until alpha4 it was serving both in sync.
> 
> Do you know if there are plans to ship contrib 1.3alphas from maven central 
> as well ?
> 
> thanks
> 
> Jules

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

Re: Java Interop - Generics - Hmmm...

2011-03-24 Thread Jules
cool :-)

I had a feeling that there was some vestige of generics left at runtime - 
now I know exactly what it is.

thanks guys,

Jules

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

Re: Emacs with Lisp and Clojure.

2011-03-24 Thread MarisO
swank-clojure is deprecated, don't use it.  Instead start swank from
leiningen.

I found these instructions how to install clojure support in emacs
http://riddell.us/ClojureSwankLeiningenWithEmacsOnLinux.html

No need to use elpa with broken packages or starter-kit.

Maris

On Mar 24, 8:14 am, Tassilo Horn  wrote:
> mmwaikar  writes:
> > But the same enter key works properly when I am using Lisp, so why
> > shouldn't it be the default in Clojure as well?
>
> What's considered "properly" for RET is purely subjective. :-)
>
> But I have to admit that I was wrong.  When paredit-mode is enabled, RET
> is indeed bound to `paredit-newline', which does indentation
> automatically.  For me that does the trick for Clojure, Elisp, and CL
> buffers...
>
> > Also, after removing clojure-mode, when I try to install swank-
> > clojure, it again installs the clojure-mode, but fails to install
> > itself?
>
> Do you get some error messages?
>
> Using emacs 24 from bzr, I only added
>
>   (add-to-list 'package-archives
>                '("technomancy" . "http://repo.technomancy.us/emacs/";) t)
>
> to get the most recent packages from technomancy listed in M-x
> package-list-packages, and there I installed these ones:
>
>   clojure-mode      1.8.0       installed  Major mode for Clojure code
>   slime             20100404.1  installed  Superior Lisp Interaction Mode for 
> Emacs
>   slime-repl        20100404    installed  Read-Eval-Print Loop written in 
> Emacs Lisp
>   swank-clojure     1.1.0       installed  Slime adapter for clojure
>
> Bye,
> Tassilo

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


Re: RabbitMQ

2011-03-24 Thread Alex Robbins
According to http://www.clojure-toolbox.com/

https://github.com/mefesto/wabbitmq

But I'm pretty new to clojure and don't know if it is good.

On Thu, Mar 24, 2011 at 10:30 AM, Mark Rathwell  wrote:
>
> I just wrapped their java client library:
> http://www.rabbitmq.com/java-client.html
>
> On Thu, Mar 24, 2011 at 11:15 AM, Max Weber
>  wrote:
>>
>> What is the best Clojure library to work with RabbitMQ?
>>
>> Best regards
>>
>> Max
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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


Re: RabbitMQ

2011-03-24 Thread Dennis
We did the same

On Thu, Mar 24, 2011 at 10:30 AM, Mark Rathwell  wrote:
>
> I just wrapped their java client library:
> http://www.rabbitmq.com/java-client.html
>
> On Thu, Mar 24, 2011 at 11:15 AM, Max Weber
>  wrote:
>>
>> What is the best Clojure library to work with RabbitMQ?
>>
>> Best regards
>>
>> Max
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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


Re: Java Interop - Generics - Hmmm...

2011-03-24 Thread Alessio Stalla
On 24 Mar, 17:54, Alan  wrote:
> On Mar 24, 9:47 am, Alessio Stalla  wrote:
>
> > Reflection is aware of generic type 
> > variables:http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Generi...
>
> > What is lost at runtime is information about *instantiation* of those
> > variables: e.g. you can't distinguish a method returning List from
> > one returning List.
>
> I think you mean, you can't tell a List from a List
> once it's been returned. As you demonstrated, telling which kind of
> list a particular method will return can be done via reflection.

Only if the method is defined in a class that instantiates a type
variable, e.g. String get(int) in class MyList implements
List, where the superclass is List and defines T get(int).
But if you have class Foo with a method T bar(), you can't tell via
reflection the distinction between new Foo().bar() and new
Foo().bar() - they're the same method of the same class at
runtime. Similarly if you have a method  List foo(...) you can't
know about the different instantiations of T for calls to foo().

> > (Actually, not even all instantiations of
> > generic type variables are lost at runtime, 
> > seehttp://gafter.blogspot.com/2006/12/super-type-tokens.htmlforan example).
>
> That's really nifty. Thanks for the link.

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


Re: Implicit unpacking of a map

2011-03-24 Thread Thorsten Wilms

On 03/24/2011 05:40 PM, Meikel Brandmeyer wrote:


The problem is the constructor call. With plain old clojure
functions you could use apply, but Java method and constructor
calls must be hard-wired in the bytecode (and hence at
compilation time) (if I understood this correctly).


Guess that's why a macro, which I tried out of sheer curiosity, doesn't 
work, either.



So there will be now way around explicitly specifying the map
keys. Although you can relieve the pain a little with
destructuring as Tassilo already showed. It can be shorted a
bit using :strs.

(defn save-article
   [path {:strs [title body]} timestamp]
   (ds/save! (Article. path title body timestamp)))


I had been using destructuring, just not in the example, where I had to 
have a whole form-params. :strs makes that quite a bit nicer, thanks!


Looking for a bit more info, I found:
http://groups.google.com/group/clojure/browse_thread/thread/a9504c4c9b1a4d9b
explaining :strs, :keys and :syms.


--
Thorsten Wilms

thorwil's design for free software:
http://thorwil.wordpress.com/

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


Re: Implicit unpacking of a map

2011-03-24 Thread Alan
A macro should work fine if you use ~@ instead of just ~.

(defmacro save-article
   [path form-params timestamp]
   `(ds/save! (Article. ~path ~@(vals form-params) ~timestamp)))

On Mar 24, 1:28 pm, Thorsten Wilms  wrote:
> On 03/24/2011 05:40 PM, Meikel Brandmeyer wrote:
>
> > The problem is the constructor call. With plain old clojure
> > functions you could use apply, but Java method and constructor
> > calls must be hard-wired in the bytecode (and hence at
> > compilation time) (if I understood this correctly).
>
> Guess that's why a macro, which I tried out of sheer curiosity, doesn't
> work, either.

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


Re: http://build.clojure.org/releases - no alpha5 alpha6.. ?

2011-03-24 Thread Stuart Sierra
Short summary:

Clojure 1.3.0-alpha5 and -alpha6 have been released to Maven Central, which 
is the default repo for all Maven-based tools, including Leiningen.

"New" clojure-contrib libraries are also being released to Maven Central.  
See http://dev.clojure.org/display/design/Contrib+Projects for a list.

"Old" clojure-contrib has not had a release since 1.3.0-alpha4.  New 
releases, to anywhere, are a low priority.  -alpha4 is source-compatible 
with Clojure 1.3.0-alpha6.

-Stuart Sierra
clojure.com

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

Re: gen-class and state...

2011-03-24 Thread Stuart Sierra
 A typical pattern for resource management is a function or macro like 
`with-open-file`.

-S

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

Re: Implicit unpacking of a map

2011-03-24 Thread Meikel Brandmeyer
Hi,

Am 24.03.2011 um 21:38 schrieb Alan:

> A macro should work fine if you use ~@ instead of just ~.
> 
> (defmacro save-article
>   [path form-params timestamp]
>   `(ds/save! (Article. ~path ~@(vals form-params) ~timestamp)))

A macro works only with literal maps.

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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Implicit unpacking of a map

2011-03-24 Thread Alan
I find it easier to write web apps if my users provide me with their
inputs at compile time anyway.

On Mar 24, 1:45 pm, Meikel Brandmeyer  wrote:
> Hi,
>
> Am 24.03.2011 um 21:38 schrieb Alan:
>
> > A macro should work fine if you use ~@ instead of just ~.
>
> > (defmacro save-article
> >   [path form-params timestamp]
> >   `(ds/save! (Article. ~path ~@(vals form-params) ~timestamp)))
>
> A macro works only with literal maps.
>
> 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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Implicit unpacking of a map

2011-03-24 Thread Thorsten Wilms

On 03/24/2011 09:38 PM, Alan wrote:

A macro should work fine if you use ~@ instead of just ~.

(defmacro save-article
[path form-params timestamp]
`(ds/save! (Article. ~path ~@(vals form-params) ~timestamp)))


Thanks for the suggestion, but:

Unknown location:
error: java.lang.IllegalArgumentException: Don't know how to create ISeq 
from: clojure.lang.Symbol



(I doubt I managed to introduce a mistake, as it looks alright with 
macroexpand.)



--
Thorsten Wilms

thorwil's design for free software:
http://thorwil.wordpress.com/

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


Re: Implicit unpacking of a map

2011-03-24 Thread Ken Wesson
What about this? First, use :title and :body keywords instead of
"title" and "body" strings as keys in form-params. Then define this
utility function:

(defn get-seq [m & kws]
  ((apply juxt kws) m))

which takes a map and one or more keywords (cannot be other types of
key) and returns a seq (actually a vector) of the corresponding
values, in order; do this

(defn new-article [path timestamp title body]
  (Article. path title body timestamp))

so you can use apply. And then this:

(defn save-article
  [path form-params timestamp]
  (ds/save!
(apply new-article path timestamp
  (get-seq form-params :title :body

is neat and tidy and easily extensible to added form-params later (add
them to the end of new-article's arg list and to the get-seq keyword
list in the same order; pass them to the amended Article constructor
appropriately).

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


Re: http://build.clojure.org/releases - no alpha5 alpha6.. ?

2011-03-24 Thread Sean Corfield
Yeah, the confusion around what's where led me to create this dynamic
page on my site:

http://corfield.org/clj/index.cfm

As pointed out on clojure-dev, yes, you can use the Maven search for
"clojure" but that didn't get me what I really wanted. Hopefully that
page is useful to others...

On Thu, Mar 24, 2011 at 9:34 AM, Jules  wrote:
> Aha! Thanks.
>
> Looking at the link you have posted the latest version of Clojure is alpha6,
> but contrib is reporting 1.2 - that must be the root of my problem.
>
> i have been using http://build.clojure.org/releases/org/clojure/clojure/
> because up until alpha4 it was serving both in sync.
>
> Do you know if there are plans to ship contrib 1.3alphas from maven central
> 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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Jesus, how the heck to do anything?

2011-03-24 Thread Sean Corfield
On Thu, Mar 24, 2011 at 3:37 AM, ultranewb  wrote:
> Since we are mentioning other languages (I'm sure it's a little off-
> topic, but what the hey), if you really want to fry your brain and
> blow your mind, check out APL, or its modern successor, J.

My final year project at university was to write an APL interpreter
(in Pascal, back in '83). APL is a fun language. I haven't looked at J
(yet).
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/

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

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


Re: http://build.clojure.org/releases - no alpha5 alpha6.. ?

2011-03-24 Thread Aaron Bedra

On 03/24/2011 11:13 AM, Jules wrote:

Aha !

OK - so maven is pulling alpha5/6 in from somewhere, but not from the 
repo that I expected - and unfortunately, I am not finding 
clojure.contrib.logging for these releases - maybe contrib is not 
being released to the same repo ? or maybe it has changed its name ? 
I'll have to investigate.
Logging has been pulled into the new contrib style under the project 
tools.logging.  Take a look at the following leiningen example:


(defproject example "1.0.0-SNAPSHOT"
  :description "FIXME: write"
  :dependencies [[org.clojure/clojure "1.3.0-alpha6"]
   [org.clojure/tools.logging "0.1.2"]])

This is the same library that was in contrib, and it will be the place 
for further development.



--
Cheers,

Aaron Bedra
--
Clojure/core
http://clojure.com

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


Re: Jesus, how the heck to do anything?

2011-03-24 Thread ultranewb
On Mar 25, 8:58 am, Sean Corfield  wrote:
> My final year project at university was to write an APL interpreter
> (in Pascal, back in '83). APL is a fun language. I haven't looked at J
> (yet).

Awesome!

J is APL, but totally "modernized."  Everything you would expect in a
functional language (currying, first class functions, anonymous
functions, composition, etc) and even more things, like hooks, trains,
forks, not needing to refer to variables explicitly, etc.  Sort of
scary, when you think of what you could do with ancient APL.

One other difference with APL is that they removed the old complaint
of "special characters and keyboards" by changing it to pure standard
ascii characters.  Thing is, I don't particularly like this aspect.  I
much prefer old APL symbols to the new string of plain ascii
characters which I find ugly.  The irony in all of this is that
Iverson was before his time in creating a language with special
symbols - some people didn't "get it," you needed special equipment
and character sets and fonts, etc.  So they removed this old complaint
with J... just with the advent of unicode, which actually allows for
such things quite easily.  In other words, the language was ahead of
its time, and devolved a step backwards to address complaints just as
the times caught up, heh.

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


Re: RabbitMQ

2011-03-24 Thread isaac praveen
On Thu, Mar 24, 2011 at 8:45 PM, Max Weber
 wrote:
> What is the best Clojure library to work with RabbitMQ?
>

Give bunny a try. Might not be the best rabbitmq-client library :)

https://github.com/icylisper/bunny

example:

(use 'bunny.publisher)
(with-mq conn
   (publish "This is a message"))

where conn is a connection map.
-- 
isaac
http://icylisper.in

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


Re: Jesus, how the heck to do anything?

2011-03-24 Thread Ken Wesson
On Fri, Mar 25, 2011 at 12:36 AM, ultranewb  wrote:
> On Mar 25, 8:58 am, Sean Corfield  wrote:
>> My final year project at university was to write an APL interpreter
>> (in Pascal, back in '83). APL is a fun language. I haven't looked at J
>> (yet).
>
> Awesome!
>
> J is APL, but totally "modernized."  Everything you would expect in a
> functional language (currying, first class functions, anonymous
> functions, composition, etc) and even more things, like hooks, trains,
> forks, not needing to refer to variables explicitly, etc.  Sort of
> scary, when you think of what you could do with ancient APL.
>
> One other difference with APL is that they removed the old complaint
> of "special characters and keyboards" by changing it to pure standard
> ascii characters.  Thing is, I don't particularly like this aspect.  I
> much prefer old APL symbols to the new string of plain ascii
> characters which I find ugly.  The irony in all of this is that
> Iverson was before his time in creating a language with special
> symbols - some people didn't "get it," you needed special equipment
> and character sets and fonts, etc.  So they removed this old complaint
> with J... just with the advent of unicode, which actually allows for
> such things quite easily.

Er ... not exactly. It may allow representing the special characters
in disk files and network traffic in a manner that will survive being
passed through tool chains and among web users, but I'm aware of no
magic Unicode floppy disc I can stick into my machine, run "make
install" (or "setup.exe") off, and wind up able to *type* the special
characters by simply looking down at my keyboard, finding one of them,
and pushing it. :)

So it'd mean a lot of annoying alt+numpad foolery, copy-paste, or
memorizing arcane emacs-style chords.

Maybe in another ten years keyboards will have become multitouch
screens that can serve various other purposes, and when used as
keyboards can have the glyphs changed in software; then maybe you can
just task switch to your J IDE and watch your keyboard F-key and
numpad symbols change as determined by the keymaps defined for the
application with the input focus, or something; and this won't all
cost a ridiculous amount of money.

But that day has not yet arrived. And besides, a touch-screen keyboard
can't be typed on by feel, unless they add software-controlled shape
shifting or something. I think there are experimental display devices
for the blind that could be put under a flexible oled touchscreen to
make a fully programmable keyboard that actually had keys you could
feel and push down, but that's even longer to make practical and
inexpensive.

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