Re: Jesus, how the heck to do anything?

2011-03-24 Thread Laurent PETIT
2011/3/24 ultranewb pineapple.l...@yahoo.com

 On Mar 24, 7:26 am, Armando Blancas armando_blan...@yahoo.com 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.


Frankly, I'm not aware of any real poll trying to get this kind of figure
out of the community following this ml.
It's clear does not have to hate langage A to start loving langage B. That's
kind of a surprising reasoning twist to think white/black like this.

The world is always bigger than we think it is, and I would not be surprised
that a great number of people not being active on this mailing list are both
java + clojure + ... polyglots, because they work in/for enterprise and they
need to adapt to their environment.

Cheers,

-- 
Laurent

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
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 Tassilo Horn
mmwaikar mmwai...@gmail.com 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 ulises.cerv...@gmail.com 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 your file'. 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 path/to/clojure.jar 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 pineapple.l...@yahoo.com 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 pineapple.l...@yahoo.com 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 seancorfi...@gmail.com 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 b.gh...@gmail.com 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 m...@kotka.de 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 jules.gosn...@gmail.com 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 dependencies section of the XML file generated with lein 
pom in my little Leiningen project:

  dependencies
dependency
  groupIdorg.clojure/groupId
  artifactIdclojure/artifactId
  version1.3.0-alpha5/version
/dependency
  /dependencies


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 HashMapString,String has 
the same type in the bytecode as any other HashMap.  The String,String 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
http://www.rabbitmq.com/java-client.html

On Thu, Mar 24, 2011 at 11:15 AM, Max Weber weber.maximil...@googlemail.com
 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 t...@freenet.de 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 t...@freenet.de 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 ListString from 
one returning ListInteger. (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 andy.finger...@gmail.com 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 HashMapString,String has 
 the same type in the bytecode as any other HashMap.  The String,String 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 alessiosta...@gmail.com 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 ListString from
 one returning ListInteger.

I think you mean, you can't tell a ListString from a ListInteger
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 tass...@member.fsf.org wrote:
 mmwaikar mmwai...@gmail.com 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 mark.rathw...@gmail.com 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
 weber.maximil...@googlemail.com 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 mark.rathw...@gmail.com 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
 weber.maximil...@googlemail.com 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 a...@malloys.org wrote:
 On Mar 24, 9:47 am, Alessio Stalla alessiosta...@gmail.com 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 ListString from
  one returning ListInteger.

 I think you mean, you can't tell a ListString from a ListInteger
 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
ListString, where the superclass is ListT and defines T get(int).
But if you have class FooT with a method T bar(), you can't tell via
reflection the distinction between new FooString().bar() and new
FooInteger().bar() - they're the same method of the same class at
runtime. Similarly if you have a method T ListT 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 t...@freenet.de 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 m...@kotka.de 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: 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 seancorfi...@gmail.com 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