Re: clojure shell window?

2009-09-15 Thread ddyer
Thanks, that looks promising. Presumably I'll have to figure out how to compile that into a proper class file, and feed it some root object in the environment that calls instantiates it. --~--~-~--~~~---~--~~ You received this message because you are subscribed

Re: Ensure and STM: find the bug...

2009-09-15 Thread Christophe Grand
On Wed, Sep 16, 2009 at 6:13 AM, Krukow wrote: > On Sep 15, 10:23 pm, Mark Volkmann wrote: > > I think the problem is that you only ensure one of the Refs. If you > > want to make sure that a condition between multiple Refs isn't > > violated, you need to sure all of them. Otherwise other transa

Re: Ensure and STM: find the bug...

2009-09-15 Thread Krukow
On Sep 16, 12:32 am, Timothy Pratley wrote: > I ran program #1 and #2 on Clojure 1.1.0-alpha-SNAPSHOT from git > -> program #1 output skew > -> program #2 no output > > What version are you using? Could be something that's been fixed > recently. I was running a fairly recent, but not the lates

Re: Ensure and STM: find the bug...

2009-09-15 Thread Krukow
On Sep 15, 10:23 pm, Mark Volkmann wrote: > I think the problem is that you only ensure one of the Refs. If you > want to make sure that a condition between multiple Refs isn't > violated, you need to sure all of them. Otherwise other transactions > will be free to modify the Refs that aren't e

Re: Modeling Data Associations in Clojure?

2009-09-15 Thread Brenton
Thank you all for your input. I think I will follow Stuart's advice and go with something like the following, again using the example data above. (use 'clojure.set) (def policies (ref #{{:id 3 :name "x" :holder 7 :vehicle 11} {:id 4 :name "y" :holder 2 :vehicle 12}}

Re: Modeling Data Associations in Clojure?

2009-09-15 Thread Stuart Sierra
On Sep 15, 6:54 am, Dragan Djuric wrote: > Ha, ha, some object-oriented lessons are being rediscovered :))) Precisely! Just because the language doesn't enforce information hiding doesn't mean you can't do it. -SS --~--~-~--~~~---~--~~ You received this message

Re: Unwind-protect?

2009-09-15 Thread Stuart Sierra
unwind-protect is indeed a Common Lisp form, not Clojure. It ensures that a given piece of code is always executed, even when an error or some other condition causes the code to exit early. In Clojure (and Java), the nearest equivalent is the try-catch-finally block. It looks like this: (try

Re: Ensure and STM: find the bug...

2009-09-15 Thread Timothy Pratley
I ran program #1 and #2 on Clojure 1.1.0-alpha-SNAPSHOT from git -> program #1 output skew -> program #2 no output What version are you using? Could be something that's been fixed recently. On Sep 16, 6:14 am, Krukow wrote: > After a discussion in dcug about the write-skew anomaly, I wanted t

Re: Unwind-protect?

2009-09-15 Thread Michael Wood
2009/9/15 Gorsal : > > Ah, I thought there was a contrib out there for unwind-protect . I > guess its so trivial that no one wrote it. lol. There's error-kit: http://richhickey.github.com/clojure-contrib/error-kit-api.html Not sure how much that is or is not like unwind-protect. -- Michael Woo

Re: Method combination (as in CL)?

2009-09-15 Thread Richard Newman
> I'm visiting from the Common Lisp world and I'm wondering if Clojure's > multimethods support method combination? (Please forgive me if this > has already been asked and just direct me to the relevant > documentation.) Discussed previously: http://groups.google.com/group/clojure/browse_thread/

Re: clojure shell window?

2009-09-15 Thread kyle smith
repl.clj in the files section of the group is exactly what you want. --~--~-~--~~~---~--~~ 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 n

Method combination (as in CL)?

2009-09-15 Thread Elliott Slaughter
Hi, I'm visiting from the Common Lisp world and I'm wondering if Clojure's multimethods support method combination? (Please forgive me if this has already been asked and just direct me to the relevant documentation.) Here's a contrived example. B derives from A and both have methods defined for

clojure shell window?

2009-09-15 Thread ddyer
I've been looking for a Clojure REPL loop in a java window, the general idea is to use it as an ad-hoc inspector for existing java programs. Does this already exist? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "

Re: Ensure and STM: find the bug...

2009-09-15 Thread Mark Volkmann
On Tue, Sep 15, 2009 at 3:23 PM, Mark Volkmann wrote: > I think the problem is that you only ensure one of the Refs. If you > want to make sure that a condition between multiple Refs isn't > violated, you need to sure I meant "ensure" instead of "sure". > all of them. Otherwise other transactio

Re: Ensure and STM: find the bug...

2009-09-15 Thread Mark Volkmann
I think the problem is that you only ensure one of the Refs. If you want to make sure that a condition between multiple Refs isn't violated, you need to sure all of them. Otherwise other transactions will be free to modify the Refs that aren't ensured. On Tue, Sep 15, 2009 at 3:14 PM, Krukow wro

Re: Clojure for game programming?

2009-09-15 Thread Elliott Slaughter
On Sep 15, 9:27 am, CuppoJava wrote: > Yes. I haven't personally run into any problems (since I handle my own > threading), but it's explicitly stated that you shouldn't put mutable > data into Clojure's immutable data structures. It's possible that I > misunderstood what is meant by this. It wou

Ensure and STM: find the bug...

2009-09-15 Thread Krukow
After a discussion in dcug about the write-skew anomaly, I wanted to write a program exhibiting the anomaly, together with a similar program using ensure to eliminate it. My program doesn't work: it exhibits the anomaly, but ensure doesn't fix it, and neither does adding a validator to the refs.

Re: Conjure 0.2 released.

2009-09-15 Thread Matt
I'll make a note on the wiki to chmod the scripts in Unix. I'm not sure what else I can do. I swear I tested all of this on my Mac. -Matt On Sep 15, 10:17 am, Stuart Halloway wrote: > The bigger problem here is that the ant jar task loses file   > permissions, so after Conjure expands the file

Re: What happened to the set operations?

2009-09-15 Thread B Smith-Mannschott
On Tue, Sep 15, 2009 at 21:47, Brian Hurt wrote: > > The API documentation: > http://clojure.org/data_structures#toc22 > > mentions the existence of the basic set operations of union, intersection, > and difference.  But these functions don't seem to exist anymore (including > in the version of c

Re: Unwind-protect?

2009-09-15 Thread Gorsal
Ah, I thought there was a contrib out there for unwind-protect . I guess its so trivial that no one wrote it. lol. On Sep 15, 12:25 pm, Joost wrote: > On 15 sep, 18:19, Jarkko Oranen wrote: > > > Unwind-protect? Isn't that a Common Lisp thing? Sounds like you got > > the wrong mailing list :) >

Re: What happened to the set operations?

2009-09-15 Thread Richard Newman
> The API documentation: > http://clojure.org/data_structures#toc22 > > mentions the existence of the basic set operations of union, > intersection, and difference. But these functions don't seem to > exist anymore (including in the version of clojure I pulled from > github about five minut

What happened to the set operations?

2009-09-15 Thread Brian Hurt
The API documentation: http://clojure.org/data_structures#toc22 mentions the existence of the basic set operations of union, intersection, and difference. But these functions don't seem to exist anymore (including in the version of clojure I pulled from github about five minutes ago). I was just

Re: Accessing a protected final method of the superclass

2009-09-15 Thread Chouser
On Tue, Sep 15, 2009 at 2:08 PM, Sir Diddymus wrote: > > Dear all, > > I've successfully extended a Java class (:gen-class and :extends) and > all is working as expected, until I was forced to call a protected > final method of the superclass from within my derived class. I don't > seem find a wa

Accessing a protected final method of the superclass

2009-09-15 Thread Sir Diddymus
Dear all, I've successfully extended a Java class (:gen-class and :extends) and all is working as expected, until I was forced to call a protected final method of the superclass from within my derived class. I don't seem find a way to do this (:exposes-methods really is only for overridden method

Re: A problem with compilation Clojure files

2009-09-15 Thread Richard Newman
> Although I still don't understand why the current working directory > can cause such problems (shouldn't Java be able to make proper use of > the classpath?), my problem has been solved. Because the compilation of Clojure files produces files in *compile- path* ("classes" by default), which is

Re: Unwind-protect?

2009-09-15 Thread Joost
On 15 sep, 18:19, Jarkko Oranen wrote: > Unwind-protect? Isn't that a Common Lisp thing? Sounds like you got > the wrong mailing list :) You may be right :) > It's true though that Clojure has no return, break or continue... They > are imperative constructs, and Clojure is mostly functional. As

Re: A problem with compilation Clojure files

2009-09-15 Thread TPJ
On 14 Wrz, 20:06, Richard Newman wrote: > > Nope, it's not that easy. I changed "clojure.example.hello" to > > "clojure.examples.hello" in the hello.clj file, and the message was > > still the same. (Hard to believe, isn't it?) > > What's the value of *compile-path*? Is it in your classpath? In

Re: A problem with compilation Clojure files

2009-09-15 Thread TPJ
On 14 Wrz, 19:51, Michael Wood wrote: > (...) > What does your "runclojure" script look like? Yes, that's the point. If the problem isn't in the Clojure itself, nor in the source file, and the files are placed exactly where they should be, the only possibility is the script used to run Clojure.

Re: Clojure for game programming?

2009-09-15 Thread CuppoJava
Yes. I haven't personally run into any problems (since I handle my own threading), but it's explicitly stated that you shouldn't put mutable data into Clojure's immutable data structures. It's possible that I misunderstood what is meant by this. It would be best to ask someone who's familiar with

Re: Unwind-protect?

2009-09-15 Thread Jarkko Oranen
On Sep 15, 6:54 pm, Gorsal wrote: > I was just wondering about the unwind-protect form, I've heard that it > doesn't protect against certain types of exits, but what exactly are > these exits? I've heard return, break, and continue statements said > but i can't seem to find these statements in c

Unwind-protect?

2009-09-15 Thread Gorsal
I was just wondering about the unwind-protect form, I've heard that it doesn't protect against certain types of exits, but what exactly are these exits? I've heard return, break, and continue statements said but i can't seem to find these statements in clojure. Any examples? --~--~-~--~---

Re: finding paths in clojure with Floyd-Warshall - ugly code

2009-09-15 Thread Timothy Pratley
Out of curiosity I implemented an option for parallel processing single thread: "Elapsed time: 39.275432 msecs" parallel: "Elapsed time: 271.072837 msecs" Ouch! I guess all that merging was a bad idea :) Obviously mutating in place would get around that, I could use an unprotected java array as th

Re: Conjure 0.2 released.

2009-09-15 Thread Stuart Halloway
The bigger problem here is that the ant jar task loses file permissions, so after Conjure expands the file structure to create a project Unix users will have to chmod u+x any files that are scripts. I looked at it for about 10 seconds and decided it wasn't easily fixable without going away

Re: Conjure 0.2 released.

2009-09-15 Thread Matt
Fixed in the main branch. Stu made the change on his fork, and I merged it in. -Matt On Sep 14, 2:52 pm, Jim Menard wrote: > Matt, > > There's a missing double quote on line 11 of lancet.sh. After adding > that, I had no problem compiling Conjure. Looking forward to trying > it. > > Jim --~--~

Re: Conjure 0.2 released.

2009-09-15 Thread Matt
That's my plan for the next release. Unfortunately, the change to test- is came out right before I finished the release. After reviewing what it would take to update, I decided to wait. If you make the changes on your fork, I'll be happy to merge them in. -Matt On Sep 14, 11:31 am, Stuart Hallo

Re: Mutating state in java super classes

2009-09-15 Thread Chouser
On Tue, Sep 15, 2009 at 7:15 AM, Rick Moynihan wrote: > > Hi all, > > I'm looking at extending a java class in clojure, however I can't find > any mention of how to access or change state within my super class > object e.g. given a java class like this: > > public class Foo { >   protected int fo

Re: finding paths in clojure with Floyd-Warshall - ugly code

2009-09-15 Thread Timothy Pratley
I thought it would be interesting to make a version which spits out the paths: http://github.com/timothypratley/strive/blob/master/clj/sandpit/fw.clj shortest-path 7 2: ({:node 7, :step-cost 0, :remaining-cost 6} {:node 8, :step-cost 1, :remaining-cost 5} {:node 6, :step-cost 1, :remaining-cost

Re: finding paths in clojure with Floyd-Warshall - ugly code

2009-09-15 Thread ajuc
> [snip] > > You are "accumulating" a result, which hints us at 'reduce. > And 'for provides the nested enumeration: > > (defn floyd-warshall2 [{:keys [nodes distances]}] >   (reduce (fn [[distances prevs] [k x y]] >             (let [d (+ (distances [x k] Double/POSITIVE_INFINITY) >              

Mutating state in java super classes

2009-09-15 Thread Rick Moynihan
Hi all, I'm looking at extending a java class in clojure, however I can't find any mention of how to access or change state within my super class object e.g. given a java class like this: public class Foo { protected int foo = 10; // ... } How can I write the equivalent of this in clojure

Re: Modeling Data Associations in Clojure?

2009-09-15 Thread Dragan Djuric
Ha, ha, some object-oriented lessons are being rediscovered :))) > For example, you would have an opaque "Person" object, perhaps in a > Ref, and functions like get-name, set-name, get-policy, etc.  The > underlying storage model can be whatever you want -- sets, SQL, > files,  You just have