A problem with using enumeration-seq with java.util.jar.JarFile.

2011-10-19 Thread mmwaikar
Hi, I want to read the contents of one of the files in a jar file. Here's the documentation - http://download.oracle.com/javase/6/docs/api/java/util/jar/JarFile.html Now, the doc. of entries method specifies it returns an EnumerationJarEntry, whereas - (map #(class %) (enumeration-seq

Re: A problem with using enumeration-seq with java.util.jar.JarFile.

2011-10-19 Thread Alan Malloy
JarEntries are ZipEntries - there is no problem here. user= (supers java.util.jar.JarFile$JarFileEntry) #{java.util.zip.ZipEntry java.util.zip.ZipConstants java.lang.Object java.util.jar.JarEntry java.lang.Cloneable} user= (isa? java.util.jar.JarFile$JarFileEntry java.util.jar.JarEntry) true On

Re: A problem with using enumeration-seq with java.util.jar.JarFile.

2011-10-19 Thread mmwaikar
But then why does this fail - (slurp (.getInputStream (first (enumeration-seq (.entries f) with - No matching field found: getInputStream for class java.util.jar.JarFile$JarFileEntry. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to

Re: A problem with using enumeration-seq with java.util.jar.JarFile.

2011-10-19 Thread mmwaikar
Oops. Sorry, my bad. I am not using the JarFile object for the call. -- 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

Re: Clojure 1.3 treatment of integers and longs

2011-10-19 Thread Stuart Halloway
Thanks. I read through that and it didn't quite answer my question. To me it seems more logical that: 1. Clojure defaults to longs when you create a new number (with a literal 0, 1, etc) 2. You can create ints by doing (int 0) 3. Clojure never changes the types of things you're using I

Re: Unexpected behavior with satisfies?

2011-10-19 Thread Eric in San Diego
You're right, I may have re-compiled buffers in the wrong order. I will be more mindful of that in the future. Thanks! On Oct 15, 12:31 pm, Alan Malloy a...@malloys.org wrote: The most common cause of issues like this is if you reload ns1 after loading ns2, then T2 will be implementing an old

Re: Can't eval locals problem

2011-10-19 Thread Razvan Rotaru
Thanks for your suggestion. I finally decided to find a way around the problem. :) This is cutting too deep for me to handle with my current clojure knowledge. I also talked to Constantine Vetoshev (the author of appengine-magic) and he anknowledged it as an issue which could have a solution by

shortcut for anonymous function literal and syntax quote

2011-10-19 Thread Razvan Rotaru
Hi, I'm just wondering is there a nicer way to write this: (defmacro my-macro [ body] (map (fn[x] `(my-fun ~x)) body)) I'd like to use the anonymous function literall #(), but this won't work: (defmacro my-macro [ body] (map #(`(my-fun ~%)) body)) So if you have some suggestion, I'd

Re: shortcut for anonymous function literal and syntax quote

2011-10-19 Thread Alan Malloy
Not really. In _Let Over Lambda_'s section on reader macros, he creates a reader macro #`(foo bar a1 a2) that expands to (lambda (a1 a2) `(foo bar ,a1 ,a2)), but this is not possible in Clojure. A nice example of something you can do with reader macros, in case Clojure ever gets them. And you

Re: Will clojurescript get in-ns and load?

2011-10-19 Thread Stuart Sierra
It's not likely, because namespaces do not exist at runtime in ClojureScript. What would `load` do in a browser? -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

Re: Clojure 1.3 treatment of integers and longs

2011-10-19 Thread nathanmarz
Here's a code example illustrating the problem I'm having: https://gist.github.com/1300034 I've simplified it to the bare minimum necessary to illustrate the problem. Agree 100% that ints and longs are broken in Java. The hashcode/ equality stuff is messed up. Clojure can try really hard to hide

Re: Clojure 1.3 treatment of integers and longs

2011-10-19 Thread Kevin Downey
On Wed, Oct 19, 2011 at 5:14 PM, nathanmarz nathan.m...@gmail.com wrote: Here's a code example illustrating the problem I'm having: https://gist.github.com/1300034 I've simplified it to the bare minimum necessary to illustrate the problem. Agree 100% that ints and longs are broken in Java.

Re: Macro not working - newbie question

2011-10-19 Thread Dusan
That's much simpler indeed, but it doesn't give the key-value pairs, just the values. On Oct 18, 10:15 pm, Alan Malloy a...@malloys.org wrote: Simpler to just use the field names which are already bound, rather than constructing keywords out of them and calling them with juxt: (defmacro

Re: Macro not working - newbie question

2011-10-19 Thread Dusan
Thank you for claridying this. I thought it was much simpler, that the macro output is the text which is the input of the function at compile time. I will definitely need some time to understrand how the reader works. Btw. your version of macro doesn't give the key-value pairs, just the values...

Suggestion for changing some documentation

2011-10-19 Thread tjb
While exploring clojure I got stuck because I didn't understand what tail position meant (as in the case of recur). My question was answered on stack overflow (link below). I think it might help other beginners if the documentation for recur was changed slightly from: ...recur is functional and

Newbie help in pitching in

2011-10-19 Thread Rett Kent
Hi all, Now that I have my shiny new, clojure-dev membership, I'd like to pitch in. I took a look at the pages describing how to contribute. http://clojure.org/contributing http://clojure.org/patches The process for contributing is pretty clear, but I'm finding it hard to find anything

Re: Who will be at QCon SF?

2011-10-19 Thread Abbas
Look forward to your talk. Cheers, Abbas On Oct 18, 5:19 pm, Aaron Bedra aaron.be...@gmail.com wrote: I will be there and am giving a talk in the functional web track http://qconsf.com/sf2011/presentation/One+%28%29+to+Rule+them+All See you on the coast. Cheers, Aaron Bedra --

Re: Newbie help in pitching in

2011-10-19 Thread Bob Shock
I would recommend adding examples to clojuredocs.org and adding new problems to 4clojure.com. On Oct 19, 4:32 pm, Rett Kent rett.k...@gmail.com wrote: Hi all, Now that I have my shiny new, clojure-dev membership, I'd like to pitch in.  I took a look at the pages describing how to contribute.

Re: Newbie help in pitching in

2011-10-19 Thread Stuart Halloway
Hi all, Now that I have my shiny new, clojure-dev membership, I'd like to pitch in. I took a look at the pages describing how to contribute. http://clojure.org/contributing http://clojure.org/patches The process for contributing is pretty clear, but I'm finding it hard to find

Re: Type hints and records

2011-10-19 Thread Alan Malloy
You can't really fix that, because (:foo bar) means call function :foo on bar, and in general the function :foo returns Object. (.foo bar) says look at the Java object bar, and give me its foo member. Because there is a typehint on that, Clojure can know what return type to expect. On Oct 19,

Re: Macro not working - newbie question

2011-10-19 Thread Alan Malloy
The compiler, and the macro system, work with data structures like lists and vectors, which have already been parsed from characters by the reader. If you want the field names as well, it's not hard to change my original answer: (defmacro defrecord-withstr [name include? columns fields] (let

About metadat and #^ macro.

2011-10-19 Thread mmwaikar
Hi, I read in Clojure in Action book by Amit Rathore, that #^ associates metadata for the next form. He also mentions that it is deprecated. So what is the current way of doing it? Also, in code like this - (defn filenames-in-jar Returns a sequence of Strings naming the non-directory entries

Re: About metadat and #^ macro.

2011-10-19 Thread Ben Smith-Mannschott
The current syntax is just ^ (defn filenames-in-jar [^JarFile jar-file] ...) On Thu, Oct 20, 2011 at 07:03, mmwaikar mmwai...@gmail.com wrote: Hi, I read in Clojure in Action book by Amit Rathore, that #^ associates metadata for the next form. He also mentions that it is deprecated. So what

Re: About metadat and #^ macro.

2011-10-19 Thread Baishampayan Ghose
Sunil, I read in Clojure in Action book by Amit Rathore, that #^ associates metadata for the next form. He also mentions that it is deprecated. So what is the current way of doing it? Also, in code like this - (defn filenames-in-jar Returns a sequence of Strings naming the non-directory

Clojure jar files.

2011-10-19 Thread mmwaikar
Hi, Is it mandatory that a clojure jar file, no matter packaged using whichever tool (other than leiningen, for ex.), should have a project.clj file? Thanks, Manoj. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: A problem with using enumeration-seq with java.util.jar.JarFile.

2011-10-19 Thread Ben Smith-Mannschott
I've been hacking around with jars in clojure recently. You might find some ideas here: https://gist.github.com/1300472 // Ben On Wed, Oct 19, 2011 at 14:34, mmwaikar mmwai...@gmail.com wrote: But then why does this fail - (slurp (.getInputStream (first (enumeration-seq (.entries f)

Re: Clojure jar files.

2011-10-19 Thread Alan Malloy
Do whatever you want. Look inside clojure.jar - do you see a project.clj file? That said, I think it's polite to provide them if you're using lein or cake yourself, so that other users can read a config file that's not a POM. On Oct 19, 10:07 pm, mmwaikar mmwai...@gmail.com wrote: Hi, Is it

Re: About metadat and #^ macro.

2011-10-19 Thread Luc Prefontaine
Just use ^ for type hints. http://clojure.org/java_interop#Java%20Interop-Type%20Hints Type hints are used to eliminate reflection calls, the compiler can use the exact type of the parameter to eliminate the runtime cost of finding if methods/fields exist before calling/accessing them. user=

Re: About metadat and #^ macro.

2011-10-19 Thread Alan Malloy
I agree with the general sentiment: add typehints later, and only if you need performance in this particular part of the code. I object to the characterization as a small loss of performance, though. A reflective method call takes about five hundred times as long as a hinted method call in the