is it possible to check if a promise has been delivered to without blocking?

2010-09-14 Thread Sunil S Nandihalli
Hello Everybody, Let us say I have something like (def s (promise)) . . . . now can I check if the promise hase been delivered .. Thanks Sunil. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: is it possible to check if a promise has been delivered to without blocking?

2010-09-14 Thread Laurent PETIT
Nope. here's the source: Clojure classpath initialized by cljr. user= (source promise) (defn promise Alpha - subject to change. Returns a promise object that can be read with deref/@, and set, once only, with deliver. Calls to deref/@ prior to delivery will block. All subsequent derefs

Re: is it possible to check if a promise has been delivered to without blocking?

2010-09-14 Thread Meikel Brandmeyer
See also here: http://groups.google.com/group/clojure-dev/browse_thread/thread/bbf34a823f3081d6 -- 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

Re: is it possible to check if a promise has been delivered to without blocking?

2010-09-14 Thread Hubert Iwaniuk
Hi Sunil, Before it gets to clojure.core you could use it like that: http://github.com/neotyk/http.async.client/blob/master/src/http/async/client/util.clj#L21 Cheers, Hubert. On Tue, Sep 14, 2010 at 8:51 AM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hello Everybody,  Let us say I

Re: Clojure 1.2 Release

2010-09-14 Thread Mark Derricutt
I got tripped up on permissions on oss.sonatype.org as my account doesn't give me access to deploy org.clojure. You don't have org.clojure permissions, so the staging artifacts went into default 'Central Bundles' profile, artifacts in which need to be reviewed and released by us. I've not (yet -

can merge-with return a map with duplicate keys?

2010-09-14 Thread kovas boguta
I'm running a large hadoop job in which merge-with is called millions of times to aggregate values among about 1000 keys. Basically we are counting the number of times the keys occur among all entries and using merge-with as the reduce function. In the output, the keys are often duplicated (I've

Re: is it possible to check if a promise has been delivered to without blocking?

2010-09-14 Thread Hubert Iwaniuk
Glad I could help, Hubert. On Tue, Sep 14, 2010 at 9:39 AM, Sunil S Nandihalli su...@gridpro.com wrote: Thanks Hubert,  That is exactly what I was looking for. Sunil. On Tue, Sep 14, 2010 at 12:54 PM, Hubert Iwaniuk neo...@kungfoo.pl wrote: Hi Sunil, Before it gets to clojure.core you

Re: is it possible to check if a promise has been delivered to without blocking?

2010-09-14 Thread Sunil S Nandihalli
Thanks Hubert, That is exactly what I was looking for. Sunil. On Tue, Sep 14, 2010 at 12:54 PM, Hubert Iwaniuk neo...@kungfoo.pl wrote: Hi Sunil, Before it gets to clojure.core you could use it like that:

Re: Talk at QCon SP

2010-09-14 Thread Amsterda Technology
Very good presentation! But it's only the begin. Let's motivate the community to participate in those meetings. Clojure, LISP , Distributed Systems and Machine Learning are great topics in conputer world. We must cooperate to do this job better and better. Nice regards, On Sep 13, 7:49 pm,

var args

2010-09-14 Thread Michael Ossareh
Hi, I don't fully understand how to make real use of varargs and destructuring. c.c.sql/create-table is defined as follows: (create-table name specs) Called as follows: (c.c.sql/create-table :tblname [:cola :text NOT NULL PRIMARY KEY] [:colb :number NOT NULL] [:colc :blob NOT NULL)] I

Re: var args

2010-09-14 Thread CuppoJava
Hi mike, Your problem is about to calling a function with a list of arguments, which is independent of varargs. Take a look at the apply function. It does what you're looking for. Cheers -Patrick On Sep 14, 2:47 am, Michael Ossareh ossa...@gmail.com wrote: Hi, I don't fully understand how to

Re: clojure-test-mode elpa version still out of date?

2010-09-14 Thread alux
Just if any one is gets the same problem: I updated slime and slime- repl to the 20100404 version, and everything works again. Regards, alux PS.: For completeness: swank-clojure version 1.1.0 On 11 Sep., 12:40, alux alu...@googlemail.com wrote: Hello Bruce, would you please provide the

Re: possible bug

2010-09-14 Thread doc
That works. Thanks! take care, Mike On Sep 14, 1:38 am, Meikel Brandmeyer m...@kotka.de wrote: Hi, I can reproduce it with 1.2 and 1.3.0-master-20100911.130147-5. And I think I know, what the problem is: You must not recur out of a binding. The binding implicitely contains a try with

practical clojure

2010-09-14 Thread faenvie
i just emerged from a whirlwind read through 'practical clojure'. i like this book very much. it's a very well structured, carefully written book. kind of a minimalistic approach but minimalistic in the positive sense clojure itself is. so now 'students' have really good choices among 4 high

why doesn't a function have a type ?

2010-09-14 Thread Belun
why isn't the type of a function : clojure.lang.IFn ? it's this instead : user= (type #(str wonder what this is)) user$eval7$fn__8 would love if you would answer here : http://stackoverflow.com/questions/3708516/what-type-is-a-function thanks, alex -- You received this message because you

Re: why doesn't a function have a type ?

2010-09-14 Thread Nicolas Oury
On Tue, Sep 14, 2010 at 2:35 PM, Belun alexandrurep...@gmail.com wrote: why isn't the type of a function : clojure.lang.IFn ? Actually you assume the existence of an unique type. In most OO-language, and Clojure inherits that from its host, an object has multiple types. Indeed an object can be

Re: java interop problem

2010-09-14 Thread Alan
That would be very awkward: user= (- (range) (filter even?) (drop 10) (take 5)) LazySeq user= (- (range) (filter even?) (drop 10) (take 5) first) 20 user= (- (range) (filter even?) (drop 10) (take 5) second) 22 ... On Sep 14, 5:20 am, Ranjit rjcha...@gmail.com wrote: Thanks for clearing

Re: java interop problem

2010-09-14 Thread Alan
Also, if you want the behavior you describe, it's easy to get it in the current approach, whereas if the REPL didn't consume lazy sequences it would be very hard to get it to. Try: (def myvar (filter even? (range))) ; prints the Var object (nth myvar 1) ; realizes the first 10,000 items in

simplest graphics?

2010-09-14 Thread Lee Spector
I'm looking for a way to do simple colored-lines-and-shapes graphics in a window that requires: - No libraries beyond what is built into java, clojure 1.2, and clojure-contrib (which is what one gets automatically in a new Eclipse/Counterclockwise project). - As little additional code as

Re: var args

2010-09-14 Thread Alan
First, you could use destructuring to make your map function cleaner. The following is exactly identical to your definition. It declares that it will be passed one argument; because that argument is [...], it will be a seq; it asks that the seq be split into y, the first element, and z, a seq of

logging

2010-09-14 Thread Jeff Rose
Hi, I've been using my own wrapper for Java's built-in logging so far, but today I took a look at clojure.contrib.logging because I would like to start using spy. It really seems like Clojure should have some simple logging out of the box, but this is not the case yet. Can we make it a bit

ClassCastException: class to interface

2010-09-14 Thread JonnyB
I try to spare you all the details. I want to call a java function: foo (String str, BarInterface bar) with an argument bar of class Bar that implements BarInterface. The call works fine from Java. But Clojure throws a ClassCastException. I never met an error like this and have no idea where to

Re: ClassCastException: class to interface

2010-09-14 Thread Alan
This is working fine from Clojure. I don't see how you can get help without providing some information about the code you have that isn't working. user (definterface Printable (print [])) user.Printable user (definterface User (use [^user.Printable p])) user.User user (def p (reify Printable

Re: simplest graphics?

2010-09-14 Thread Miki
Maybe the ants demo will help - http://tinyurl.com/29rqe5r On Sep 14, 9:55 am, Lee Spector lspec...@hampshire.edu wrote: I'm looking for a way to do simple colored-lines-and-shapes graphics in a window that requires: - No libraries beyond what is built into java, clojure 1.2, and

Clojure ensure

2010-09-14 Thread peter veentjer
I have got a question about the Clojure ensure and how it actually works and the documentation doesn't provide enough information. I see a few different solutions: 1) An optimistic approach: Once a ref is 'ensured' it is included in the conflict detection set. This means that the approach is

Re: Clojure ensure

2010-09-14 Thread Daniel Gagnon
The first one is correct. On Tue, Sep 14, 2010 at 3:22 PM, peter veentjer alarmnum...@gmail.comwrote: I have got a question about the Clojure ensure and how it actually works and the documentation doesn't provide enough information. I see a few different solutions: 1) An optimistic

Re: Clojure ensure

2010-09-14 Thread Stuart Halloway
Actually, the second one is basically it. (Except that I don't know the Oracle reference, so can't speak to that.) Stu The first one is correct. On Tue, Sep 14, 2010 at 3:22 PM, peter veentjer alarmnum...@gmail.com wrote: I have got a question about the Clojure ensure and how it actually

Re: var args

2010-09-14 Thread Michael Ossareh
Alan and Patrick, thank you so much! I've come across apply in JS and it really should have clicked for me! So I have the following, and it works very well: (defn make-tables [connection schema] (sql/with-connection connection (doseq [[name specs] schema] (try

Re: can merge-with return a map with duplicate keys?

2010-09-14 Thread kovas boguta
Interesting possibility, hard for me to test for directly. But following that idea, I changed the keys to strings and the problem went away, so I'm happy :) Thanks! On Tue, Sep 14, 2010 at 4:45 AM, Stuart Halloway stuart.hallo...@gmail.com wrote: Can you look at the class of these keys and see

Re: can merge-with return a map with duplicate keys?

2010-09-14 Thread Stuart Halloway
Could you try the numeric keys against the master branch? The num/prim/equiv changes should help with this. Stu Interesting possibility, hard for me to test for directly. But following that idea, I changed the keys to strings and the problem went away, so I'm happy :) Thanks! On Tue,

Re: Clojure 1.2 Release

2010-09-14 Thread Mark Derricutt
So clojure 1.2.0 is now in maven central: dependency groupIdorg.clojure/groupId artifactIdclojure/artifactId version1.2.0/version /dependency I got sidetracked with phonecalls from parents last night and didn't get clojure-contrib submitted for central but will do that today. Now I

Re: Clojure ensure

2010-09-14 Thread peter veentjer
Ok, I have a 1 and 2 :) So is it pessimistic or optimistic? So encounter time ensure or commit time ensure? On Sep 14, 9:36 pm, Stuart Halloway stuart.hallo...@gmail.com wrote: Actually, the second one is basically it. (Except that I don't know the Oracle reference, so can't speak to that.)

Re: simplest graphics?

2010-09-14 Thread Lee Spector
On Sep 14, 2010, at 2:13 PM, Miki wrote: Maybe the ants demo will help - http://tinyurl.com/29rqe5r Thanks Miki -- I've seen that code, and the video of Rich discussing it, and I've been toying with some of the elements that it uses (JFrames etc.). But that is in a more elaborate context

Re: Clojure ensure

2010-09-14 Thread peter veentjer
I had a quick peek at the stm paper of mark volkmann This function takes a Ref. It prevents other transactions from setting an in-transaction value for the Ref, which also prevents them from committing a new value. This can be used to avoid write skew. It also helps avoid retries due to write

Re: simplest graphics?

2010-09-14 Thread Alan
I think you could just keep a vector of (color,shape) pairs as an atom, and reify a subclass of JPanel whose paint() method closes around that atom, calling (.draw shape color). Then as long as you call repaint every time you modify the atom, you should be done. Seems like it's hard to see a

Re: var args

2010-09-14 Thread Alan
Great. Looks shiny and idiomatic to me. On Sep 14, 12:06 pm, Michael Ossareh ossa...@gmail.com wrote: Alan and Patrick, thank you so much! I've come across apply in JS and it really should have clicked for me! So I have the following, and it works very well: (defn make-tables   [connection

Re: var args

2010-09-14 Thread Meikel Brandmeyer
Hi, Am 14.09.2010 um 23:01 schrieb Alan: (defn make-tables [connection schema] (sql/with-connection connection (doseq [[name specs] schema] (try (apply sql/create-table name specs) (catch Exception e (prn e)) You actually don't

Re: logging

2010-09-14 Thread ataggart
First, c.c.logging was intended as a wrapper around some java logging lib. There's a plethora of them, so I saw no reason to add another. As for simple out of the box logging, it's there (sort of) via java.util.logging, and it defaults writing to stdout at INFO level. That said, I'm inclined to