Re: a denilling macro

2009-07-27 Thread Meikel Brandmeyer
Hi, as David has said, your macro works only for literal values, which doesn't make much sense.. I would implement i-let as follows: (defmacro let-default [bindings & body] `(let ~(vec (mapcat (fn [[sym value default]] `(value# ~value ~sym

Re: source locations in error messages from macros

2009-07-27 Thread Mike Hinchey
I think only code lists have the line and source metadata attached, so that's all that's available. The compiler can't attached such metadata to non-code vectors because, I think, that would potentially conflict with user's metadata. It can't put metadata on objects like Strings that don't suppor

Problem with gen-class

2009-07-27 Thread Laurent PETIT
Hello, I'm trying to make clojure and Eclipse play well together for writing Eclipse plugins. I have played with (proxy) but I encountered classloader problems that are currently beyond my knowledge (and I want to get something up and running quickly so I didn't take the time to broaden my knowle

Re: a denilling macro

2009-07-27 Thread Laurent PETIT
2009/7/28 David Miller > > (let [ x (or nil 4) >y (or 2 6) >z (or nil 10)] > (+ x y z)) > > => 16 > > This use of 'or' is fairly idiomatic, and not just in Lispish. Less > typing than 'if'. And you can use it or not, unlike i-let, which > forces you to put in a default for all

Re: Newbish question. Does anyone have any example code for playing a wav sound file?

2009-07-27 Thread verec
Here's a simple translation of my java production code (tested on OSX/ Vista/XP, java 1.5 & 6) The gotcha is to forget the line listener and never dispose the resources. When I first tried without it, it worked perfectly on OS X but stacked sound threads upon sound threads on XP. This very same

Re: Clojure performance tests and clojure a little slower than Java

2009-07-27 Thread ataggart
On Jul 27, 10:06 am, BerlinBrown wrote: > So far I have found that clojure is about > 5-10 times as slow as comparable code in Clojure. I infer you mean clojure execution times are about 5-10 times longer than in java. It depends on what you're doing, but that sounds plausible. Here's are so

Re: Basic hadoop example in clojure.

2009-07-27 Thread RD
Hi Emeka, thanks for the reply, I know the old code had some bugs. But taking the suggestion by Stuart i.e instead of using maxtemperature directly I tried using (Class/forName "maxtemperature") and this worked. So I'm not sure if I was referring to different class-paths in my code. regards, RD

Re: gen-class & bytecode for method implementation

2009-07-27 Thread Mark Addleman
I'm not familiar with declaring inline functions, though I've seen (definline) in the docs (I think it's still marked experimental). If it does what I think it does, it's still not going to solve the problem, though. It looks like all defined methods are just stubs that delegate to functions hel

Re: Logging functions delegated to java logging systems

2009-07-27 Thread ataggart
Ok the patch file has been languishing on assembla for a few days, so I've uploaded it to the files section here if anyone wants to use the latest version. logging.clj at http://groups.google.com/group/clojure/files http://groups.google.com/group/clojure/files On Jul 23, 11:20 am, ataggart

Re: a denilling macro

2009-07-27 Thread David Miller
(let [ x (or nil 4) y (or 2 6) z (or nil 10)] (+ x y z)) => 16 This use of 'or' is fairly idiomatic, and not just in Lispish. Less typing than 'if'. And you can use it or not, unlike i-let, which forces you to put in a default for all bindings. Regarding the implementation of

Re: Newbish question. Does anyone have any example code for playing a wav sound file?

2009-07-27 Thread _hrrld
On Jul 27, 7:00 pm, Rayne wrote: > All I'm trying to do is play a simple .wav sound file once. > > I'll appreciate any examples! I'm hesitant to even share this, since I consider myself a rank Clojure and Java neophyte, but I think it is what you're asking for: http://github.com/harold/clj-sound

source locations in error messages from macros

2009-07-27 Thread Rob
Hi, I'm curious if there is a documented/accepted way to give source code locations with error messages from macros. I noticed that some of the objects passed to a macro have meta data that contains a line number, but other objects, like symbols, do not. And I don't see any filenames. I was i

Re: Clojure performance tests and clojure a little slower than Java

2009-07-27 Thread Isaac Gouy
On Jul 27, 2:26 pm, AndyF wrote: -snip- > I thought it was interesting that even the Haskell entry to the k- > nucleotide benchmark uses a *mutable* hash table (at least, I think > they are from the discussion on the Wiki page linked below -- my > Haskell knowledge isn't extensive enough to und

Newbish question. Does anyone have any example code for playing a wav sound file?

2009-07-27 Thread Rayne
I've googled around, and found several ways to do this in Java, but I've not been successful in translating the less-complex examples. I'm wondering, how would an experienced Clojurian go about doing this in Clojure? All I'm trying to do is play a simple .wav sound file once. I'll appreciate any

Re: gen-class & bytecode for method implementation

2009-07-27 Thread John Harrop
On Mon, Jul 27, 2009 at 3:37 PM, Mark Addleman wrote: > > I have written some Clojure code to implement java.lang.CharSequence > that is constructed with a length and an ISeq of strings. I need this > because I want to pass the resulting CharSequence into Java's regex > library. I got the thing

a denilling macro

2009-07-27 Thread nchubrich
I've been learning Clojure. I just wrote a macro to be used like so: (i-let [x nil 4 y 2 6 z nil 10] (+ x y z)) => 16 I.E. if the first value in the triple is nil, bind it to the second value in the triple. This is useful when you want to let something that might be nil and

Re: gen-class & bytecode for method implementation

2009-07-27 Thread John Newman
Clojure! Not *'clothier.'* :) On Tue, Jul 28, 2009 at 5:05 AM, wlr wrote: > > On Jul 27, 8:25 pm, John Newman wrote: > > I'm new to Clojure so bare with me, > > Sorry, can't resist... you must be seeking the naked truth. :-) > > > -- John --~--~-~--~~~---~--~--

Re: gen-class & bytecode for method implementation

2009-07-27 Thread wlr
On Jul 27, 8:25 pm, John Newman wrote: > I'm new to Clojure so bare with me, Sorry, can't resist... you must be seeking the naked truth. :-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to

Re: gen-class & bytecode for method implementation

2009-07-27 Thread John Newman
I'm new to Clojure so bare with me, but I'm trying to figure out what it does... Is it doing something like this: user=> (apply pr (.split #"\n" (str "hello\n" "world\n"))) "hello" "world"nil Or do you want those concatenated? Or is that too slow? On Tue, Jul 28, 2009 at 12:07 AM, Mark Addlema

Re: Details of send vs. send-off

2009-07-27 Thread Garth Sheldon-Coulson
Never mind, RTFgooglegroup: http://groups.google.com/group/clojure/browse_thread/thread/80ae6ff3f2da8919 On Mon, Jul 27, 2009 at 5:46 PM, Garth Sheldon-Coulson wrote: > Hi, > > I'm updating the documentation for Clojuratica and want to make sure I have > the difference between send and send-off

Details of send vs. send-off

2009-07-27 Thread Garth Sheldon-Coulson
Hi, I'm updating the documentation for Clojuratica and want to make sure I have the difference between send and send-off right. Could someone in the know tell me if the following is accurate and complete? "Send" updates its agent using a thread from a limited thread pool. The > threads are recyc

Re: Clojure performance tests and clojure a little slower than Java

2009-07-27 Thread AndyF
Berlin: I've got a start at programs for solving two of the problems solved in many other languages on "The Computer Language Benchmarks Game" web site: http://shootout.alioth.debian.org In particular, the k-nucleotide problem has as a significant part of its computation time a similar task to

Re: Clojure knows what is a pure function?

2009-07-27 Thread J. McConnell
No, this is not currently possible. One problem is that in a call like (foo bar), it is not possible at compile time to determine bar's type and it may very well be an impure function. Regards, - J. On Mon, Jul 27, 2009 at 10:30 AM, André wrote: > > Hi to everyone, it's my first post here on t

Re: Basic hadoop example in clojure.

2009-07-27 Thread Emeka
RD,I don't know about the gen-class, to be sincere with you I have not used. But clojure follows a standard and natural sequence if you look closely. What you used in your former code were referring to different class path and the paths were not even defined. The below is from clojure.org A stand-

Re: Thread local data structures

2009-07-27 Thread Aaron Cohen
Well, I was thinking smaller to start with. Hotspot identifies places where classes don't escape a method for instance and can use that to elide locks and inline field references without calling a constructor for instance. So it would be great to do this at the fn level in clojure as well, you kn

Re: when should functions "seq" their arguments?

2009-07-27 Thread Sean Devlin
I'm not sure if it should change. I think this depend on the distinction between "seq" and "collection". For example, I personally consider a string a seq, but not a collection. Is this a proper distinction? On Jul 27, 5:36 pm, eyeris wrote: > The docstring should also be changed by replacing

Re: when should functions "seq" their arguments?

2009-07-27 Thread eyeris
The docstring should also be changed by replacing "seq" with "collection". On Jul 27, 12:39 pm, Mark Engelberg wrote: > Yeah, but this case is different because nth is much faster if the > input is a vector, and calling seq on the input will actually degrade > the performance for vector inputs.

Clojure knows what is a pure function?

2009-07-27 Thread André
Hi to everyone, it's my first post here on the group, I'm brazilian (english's not my mother tongue -- sorry if I'm assassinating it), I'm a Java programmer starting to drink the clojure kool-aid. That said, after reading about clojure I think I quite understand what pure functions are, but I did

gen-class & bytecode for method implementation

2009-07-27 Thread Mark Addleman
I have written some Clojure code to implement java.lang.CharSequence that is constructed with a length and an ISeq of strings. I need this because I want to pass the resulting CharSequence into Java's regex library. I got the thing working (thanks to the docs and some good examples that I found

Re: Confusion with namespaces and SLIME

2009-07-27 Thread Phil Hagelberg
Tom Emerson writes: > When I switch back to the clojure file and modify or add a function > that refers to another symbol defined in that namespace, and attempt > to evaluate the sexp with C-c C-e then the SLIME repl throws an > exception saying that the symbols cannot be resolved (even though I

Re: Thread local data structures

2009-07-27 Thread Stuart Sierra
That sounds really, really hard. Because even if the structure is used in only one thread, you have to check that there's never a reference to an older version. You could theoretically re-implement the Persistent List/Map/Set interfaces with mutable implementations, but I don't know where to go

Re: when should functions "seq" their arguments?

2009-07-27 Thread Laurent PETIT
> To make this concrete, should the following function from > clojure.contrib.seq-utils call seq on its arg? As written, you cannot > call it with an associative collection unless you remember to wrap it > in a seq: > > (defn rand-elt > "Return a random element of this seq" > [s] > (nth s (ra

Confusion with namespaces and SLIME

2009-07-27 Thread Tom Emerson
Hi all, I'm working with a Clojure file that creates a namespace to include all of its functions: (ns foobar) I load slime and then compile/load the file (C-c C-k), then switch the slime REPL to use the 'foobar' namespace. So far, so good: symbols in that namespace are accessible in the repl wi

Re: Clojure performance tests and clojure a little slower than Java

2009-07-27 Thread Berlin Brown
On Jul 27, 2:15 pm, Aaron Cohen wrote: > http://groups.google.com/group/clojure/browse_thread/thread/7ab7c1e62... > http://groups.google.com/group/clojure/browse_thread/thread/6cd78dea8... > >

Re: Java based DocDB

2009-07-27 Thread Shantanu Kumar
Can you take a look at MongoDB? It is written in C++ but you can connect to it using Java, and several other languages. http://www.mongodb.org/display/DOCS/Home Regards, Shantanu On Jul 27, 7:46 pm, Sean Devlin wrote: > Howdy everyone, > I've got a project that needs a Doc DB.  It will need to

Re: Clojure performance tests and clojure a little slower than Java

2009-07-27 Thread Aaron Cohen
http://groups.google.com/group/clojure/browse_thread/thread/7ab7c1e62c468d7c/37678e50ca75be06?q=group:clojure+performance+rich#37678e50ca75be06 http://gr

Re: Clojure performance tests and clojure a little slower than Java

2009-07-27 Thread Berlin Brown
On Jul 27, 1:57 pm, Berlin Brown wrote: > "One thing you need to do is define what you mean exactly when you say > "Java > vs Clojure." " > > Like I said, I didn't want to get too focused on this particular > example. Is there code where I could run in Clojure and where I could > run in Java t

Re: Clojure performance tests and clojure a little slower than Java

2009-07-27 Thread Berlin Brown
"One thing you need to do is define what you mean exactly when you say "Java vs Clojure." " Like I said, I didn't want to get too focused on this particular example. Is there code where I could run in Clojure and where I could run in Java that would end up with the same result. And then I could

REQUEST: Add seqable? to core

2009-07-27 Thread Sean Devlin
Rich, There have been a few times in this thread that people have tried to determine if a function was seqable, and used the following code (seq? a-collection) While this code is great for determining if a-collection is a sequence, it is sometimes not what people want. Often the following code

Re: when should functions "seq" their arguments?

2009-07-27 Thread Mark Engelberg
Yeah, but this case is different because nth is much faster if the input is a vector, and calling seq on the input will actually degrade the performance for vector inputs. Maybe you could test for vectorness, and call seq otherwise. --~--~-~--~~~---~--~~ You recei

Thread local data structures

2009-07-27 Thread Aaron Cohen
What kind of infrastructure would it take to do something like Escape Analysis in the clojure compiler? It seems to me that it should be possible for "something" (the clojure compiler?, a new JIT of some sort?) to notice that a data structure is being used in a thread-local manner, and use that kno

Re: when should functions "seq" their arguments?

2009-07-27 Thread Sean Devlin
This is a cop out, but... A function should seq the argument when it is appropriate. I've written some functions that depends on the input NOT being a map (SQL IN clause generation, for example), and I wouldn't want this to work for a map. I think the way you documented rand-elt gives you an an

Re: Clojure performance tests and clojure a little slower than Java

2009-07-27 Thread Aaron Cohen
One thing you need to do is define what you mean exactly when you say "Java vs Clojure." In your example you are comparing clojure code vs java code but you are also comparing clojure data structures (PersistentMap) with traditional Java data structures (HashMap). I'm not sure you meant to conflat

Clojure performance tests and clojure a little slower than Java

2009-07-27 Thread BerlinBrown
I was coming up with some performance tests for Clojure, going back and forth between different JVM languages (JRuby, Scala) and mainly looking at pure Java code. So far I have found that clojure is about 5-10 times as slow as comparable code in Clojure. Of course this is before any optimization

Re: Basic hadoop example in clojure.

2009-07-27 Thread RD
Hi Stuart, Thanks for the link Relating to the hadoop code I posted above, I got it to compile by putting the code under a namespace and changing the class names appropriately , but still I have no clue as to why the code didn't work without the namespace. I'll defenitely check the link tho

when should functions "seq" their arguments?

2009-07-27 Thread Stuart Halloway
Coming from the Ruby and JavaScript worlds, I am used to having functions that normalize their arguments, such as the "$" function in various JavaScript libraries. Other library functions tend to automatically call "$" for you, so you don't have to remember whether to do it or not. One an

Re: Basic hadoop example in clojure.

2009-07-27 Thread Stuart Sierra
Hi rdsr, The problem is that you're trying to use the "maxtemperature" as a class name before it's finished compiling. To work around that, use (Class/forName "maxtemperature") instead. You can also see my (very task-specific) Hadoop/Clojure integration at and

Re: Java based DocDB

2009-07-27 Thread Stuart Sierra
It's not exactly a document database, but I have used Solr to store & retrieve text documents. It's pure Java, runs either embedded in your app or as a standalone HTTP service. Using the Java API from Clojure is easy. It's stable, but you should keep a backup copy of your files in case the inde

Java based DocDB

2009-07-27 Thread Sean Devlin
Howdy everyone, I've got a project that needs a Doc DB. It will need to run on windows (and probably OS X), so I am looking for something that works with Java. I thought I'd ask for some help here before I re-invent the wheel. 1. Has anyone here worked with a Java based doc DB? 2. Does anyone

speaking in Boston Aug 15

2009-07-27 Thread Stuart Halloway
Hi all, I will be speaking at Developer Day in Boston August 15 (http://developer-day.com/events/2009-boston.html ). The talk is not specifically about Clojure, but more about "how to code rightly." So ... it turns out that it *is* mostly about Clojure. :-) Stu --~--~-~--~~-

defmethod

2009-07-27 Thread Timothy Pratley
I picked up a tip from a post from Meikel about specifying the function name for multi-methods for debugging purposes. It got me thinking, wouldn't this make sense as default behaviour? I guess it looses some flexibility to have the name automatically defined but gains some conciseness: (defmacro

Re: ANN: Clojuratica -- A seamless interface to Mathematica for fast numerics and more

2009-07-27 Thread Jan Rychter
Garth Sheldon-Coulson writes: > I would like to announce *Clojuratica ,* a > high-performance, seamless Clojure interface to Wolfram > Mathematica. Wow! This is exactly what I needed. I've been looking for interfaces to

ANN: Clojuratica -- A seamless interface to Mathematica for fast numerics and more

2009-07-27 Thread Garth Sheldon-Coulson
Dear Clojurians, I would like to announce *Clojuratica ,* a high-performance, seamless Clojure interface to Wolfram Mathematica. Mathematica will be familiar to many on this list already. It is probably the world's most

Re: Website down?

2009-07-27 Thread John Newman
Yea, false alarm. I guess my network at work is just jacked up. On Mon, Jul 27, 2009 at 2:21 PM, Glen Stampoultzis wrote: > Seems to be up. > http://downforeveryoneorjustme.com/clojure.org > > > 2009/7/27 John Newman > >> I've been trying to get

Re: Clojure Workshop in London next Monday

2009-07-27 Thread Alex Scordellis
@Andrew, glad you enjoyed it :-) @Jim, sorry you missed it :-( There was quite a lot of interest in organising something to follow on from last Monday's event, so I've created a mailing list for London Clojure activity [1]. The next TW geek night is a pairing workshop [2] on September 8. [1] h

Re: Why do Enlive template functions return a seq instead of a str?

2009-07-27 Thread Christophe Grand
Hi Cody ! On Wed, Jul 15, 2009 at 5:41 PM, cody koeninger wrote: > > On Jul 11, 12:31 pm, Jarkko Oranen wrote > > Forcing them into a single string at the end would wasteful in case > > the user intends to write the output into a stream (which can be done > > a fragment at a time.) Thus, leavin

Nightlies of clojure-lang/clojure-contrib in a maven repo?

2009-07-27 Thread Mark Derricutt
'lo all, Is anyone running any maven repositories of nightly builds of clojure and clojure-contrib at all? Seems Howards http://tapestry.formos.com/maven-snapshot-repository repository lags quite a bit (clojure-lang 1.1.0 snapshot has no clojure.test namespace). Mark -- Discouragement is a dis

Re: Website down?

2009-07-27 Thread Glen Stampoultzis
Seems to be up. http://downforeveryoneorjustme.com/clojure.org 2009/7/27 John Newman > I've been trying to get to Clojure.org for a few days > now and I can't get to it from my military network, nor my civilian > satellite con

Website down?

2009-07-27 Thread John Newman
I've been trying to get to Clojure.org for a few days now and I can't get to it from my military network, nor my civilian satellite connection (I'm deployed). I can't ping it though (resolves to 75.126.104.177). Is anyone else having the same problem? -- John --~--~---

Basic hadoop example in clojure.

2009-07-27 Thread RD
Hi all, I'm having trouble converting the basic hadoop example to clojure. Here's my code. (ns maxtemperature (:gen-class) (:import [org.apache.hadoop.io IntWritable Text] [org.apache.hadoop.mapred JobConf JobClient FileInputFormat FileOutputFormat