Re: Actors not good for concurrency model

2010-05-17 Thread Peter Schuller
> Actors in Erlang DO have mutable state, you're just discouraged from > using it. ;) No really, erl -man get and set. Sometimes you're forced > to use this despite the best of intentions. I don't think anyone is trying to claim that it is impossible to mutate shared in state in an erlang actor. T

Re: convert this to loop/recur?

2010-05-17 Thread Jarkko Oranen
On May 18, 2:23 am, Base wrote: > (defn lazy-date-seq [d1 d2] >   (let [start (-> d1 >                 (.dayOfMonth) >                 (.withMinimumValue))] >      (lazy-seq >        (cons start >          (if (joda/before? start d2) >            (lazy-date-seq (.plusMonths start 1) d2)) >

Re: convert this to loop/recur?

2010-05-17 Thread Meikel Brandmeyer
Hi, On May 18, 1:23 am, Base wrote: > (defn lazy-date-seq [d1 d2] >   (let [start (-> d1 >                 (.dayOfMonth) >                 (.withMinimumValue))] >      (lazy-seq >        (cons start >          (if (joda/before? start d2) >            (lazy-date-seq (.plusMonths start 1) d2))

Re: swank-clojure and GNU Emacs 23 - package.el install issues

2010-05-17 Thread Justin Kramer
Per Phil Hagelberg's suggestion on IRC, I downloaded and used his package.el, which fixed the issue for me: http://github.com/technomancy/package.el/raw/master/package.el Phil said the bug hasn't been patched upstream. Justin On May 17, 4:18 pm, Terrence Brannon wrote: > Hello, I wanted to try

Re: convert this to loop/recur?

2010-05-17 Thread Adrian Cuthbertson
Hi Base, It's useful to think of the "pattern" of loop/recur and then apply it to your problem. I.e (loop [-- initial bindings --] (if --- terminating condition --- ---return result---; otherwise... (do-stuff with bindings (recur ---with new bindings--- A simple examp

Re: Actors not good for concurrency model

2010-05-17 Thread patrickdlogan
> i don't expect it would be hard to write an Erlang program with 2 > actors that would deadlock. Of course it wouldn't. > as far as i know, people use timeouts on > message handling to sweep it under the carpet. Most people probably use the OTP library with well-defined "behaviors" is what they

Re: Error when tried to compile with C-c C-k in emacs.

2010-05-17 Thread Hugo Duncan
On Mon, 17 May 2010 10:38:43 -0400, grav wrote: clojure-mode 1.7.1 slime 20100404 slime-repl 20100404 swank-clojure 1.1.0 You'll need swank-clojure 1.2.1 to work with that version of slime. -- Hugo Duncan -- You received this message because you are subscribed to the Google Groups "Clojure"

Does emacs suppress output from thread ?

2010-05-17 Thread Preecha P
I tried to play around with thread with these lines of code. It should print the value of variable but it doesn't.. In emacs. user> (def x 5) #'user/x user> x 5 user> (import [java.lang Thread]) java.lang.Thread user> (.start (Thread. (fn [] (print x nil or with agent user> (def foo (agent 0

Re: swank-clojure and GNU Emacs 23 - package.el install issues

2010-05-17 Thread Paul Hobbs
Seconded, I'm having troubles with both swank-clojure and clojure. -- Paul Hobbs On Mon, May 17, 2010 at 1:18 PM, Terrence Brannon wrote: > Hello, I wanted to try out Clojure. It was my understanding that > swank-clojure was a package GNU Emacs that would download clojure > automatically. But th

Re: Actors not good for concurrency model

2010-05-17 Thread Dave Fayram
Actors in Erlang DO have mutable state, you're just discouraged from using it. ;) No really, erl -man get and set. Sometimes you're forced to use this despite the best of intentions. But I really have to ask, how composable were monads again? - dlf On Mon, May 17, 2010 at 3:04 AM, Peter Schuller

Re: labrepl - Enclojure/Maven integration

2010-05-17 Thread Pratik Patel
> How does labrepl integrate with Enclojure, and does anyone manage to > use an IDE effectively with lein/maven? I use CCW in Eclipse, but I used Netbeans + Enclojure + labrepl in the past. I fired NB up again and did the following and it seemed to work OK. This is with Netbeans 6.8 with enclojure

Re: Error when tried to compile with C-c C-k in emacs.

2010-05-17 Thread Robbie Vanbrabant
I am seeing the same issue, also with ELPA. Has anyone been able to resolve this issue? Used the emacs starter kit (http://github.com/technomancy/emacs- starter-kit) and then installed swank-clojure using ELPA. All the other functionality seems to be working just fine. Thanks Robbie On May 17, 4:

Re: convert this to loop/recur?

2010-05-17 Thread Dave Fayram
Note that your recur call is wrapped in a cons. It is *not* in the tail position. (def date-seq (fn [d1 d2] (loop [b (-> d1 (.dayOfMonth) (.withMinimumValue)) e d2] (cons b (if (time/before? b e) (recur (.plusMonths b 1) e)) ;; Inside

Re: Style preference: (:key map) or (map :key)?

2010-05-17 Thread Michael Gardner
On May 17, 2010, at 10:10 AM, Sean Devlin wrote: > From the in progress Clojure library standards[1] page: > > * Use keyword-first syntax to access properties on objects: > > (:property object-like-map) > > * Use collection-first syntax to extract values from a collection (or > use get if the c

Re: convert this to loop/recur?

2010-05-17 Thread Base
Thanks Mike - So I was doing a little more digging on this and came across an interesting blog posting: http://formpluslogic.blogspot.com/2009/07/clojure-lazy-seq-and-recursion.html discussing the use of recursion vs lazy sequences. To mimic Brent from his posting I created 2 fn's: (defn date-

Re: convert this to loop/recur?

2010-05-17 Thread Mike Meyer
On Mon, 17 May 2010 14:36:23 -0700 (PDT) Base wrote: > Hi All - > > I am trying convert a function to use loop/recur and am getting the > dreded > > "java.lang.UnsupportedOperationException: Can only recur from tail > position (repl-1:414)" error > > (at least dreded for newbies...) The "tail

Re: swank-clojure and GNU Emacs 23 - package.el install issues

2010-05-17 Thread David Nolen
I'm running into this issue as well. On Mon, May 17, 2010 at 4:18 PM, Terrence Brannon wrote: > Hello, I wanted to try out Clojure. It was my understanding that > swank-clojure was a package GNU Emacs that would download clojure > automatically. But the docs for it no longer say that. > > Anyway,

convert this to loop/recur?

2010-05-17 Thread Base
Hi All - I am trying convert a function to use loop/recur and am getting the dreded "java.lang.UnsupportedOperationException: Can only recur from tail position (repl-1:414)" error (at least dreded for newbies...) The function takes 2 joda dates and returns a sequence of dates starting at the f

Re: a default value for get-in?

2010-05-17 Thread Jay Fields
+1. I'd also like to see a default value in select-keys. On Mon, May 17, 2010 at 3:34 PM, braver wrote: > If get-in is to be consistent with get, it better allow to specify a > default value: > > (get-in nested-structure [k1 k2 ... kN] :default something) > > -- would it make sense to add that

When is *err* used?

2010-05-17 Thread alux
Hi, I reset *out* in a test program, and it worked fine. But when I try to do the same with *err*, I found no change, still. All Errors I produced seem to go directly to Java's System.err, not using my new *err*. Can anybody point me to a situation, when *err* is used? Thank you, and kind regard

swank-clojure and GNU Emacs 23 - package.el install issues

2010-05-17 Thread Terrence Brannon
Hello, I wanted to try out Clojure. It was my understanding that swank-clojure was a package GNU Emacs that would download clojure automatically. But the docs for it no longer say that. Anyway, I successfully installed slime and slime-repl using package.el under a manually built GNU Emacs 23 with

Re: Clojure 1.2: Readsyntax for meta information

2010-05-17 Thread Laurent PETIT
2010/5/17 Stefan Kamphausen : > Salut, > > On 17 Mai, 18:12, Laurent PETIT wrote: >> 2010/5/17 Meikel Brandmeyer : >> >> > Hi, >> >> > On Mon, May 17, 2010 at 08:21:39AM -0700, Stefan Kamphausen wrote: >> >> >> is it correct to assume that the usual read-syntax for 1.2 will be ^ >> >> instead of #

a default value for get-in?

2010-05-17 Thread braver
If get-in is to be consistent with get, it better allow to specify a default value: (get-in nested-structure [k1 k2 ... kN] :default something) -- would it make sense to add that to the standard get-in? Cheers, Alexy -- You received this message because you are subscribed to the Google Groups

Re: Which git version for cells?

2010-05-17 Thread Steven Devijver
On 17 mei, 19:25, "Eric Schulte" wrote: > Hi Steven, > > I recently put together a propagator/cell system using Clojure's > actors/watchers.  The code for implementing a concurrent propagator > system actually came out to a little less than a single page.  Take a > look at the following for the

Re: Actors not good for concurrency model

2010-05-17 Thread Peter Schuller
> i don't expect it would be hard to write an Erlang program with 2 > actors that would deadlock. as far as i know, people use timeouts on > message handling to sweep it under the carpet. > > e.g. (just a quick google search turns this up) > http://mue.tideland.biz/avoiding-erlang-deadlocks So yes

Re: Which git version for cells?

2010-05-17 Thread Eric Schulte
Hi Steven, I recently put together a propagator/cell system using Clojure's actors/watchers. The code for implementing a concurrent propagator system actually came out to a little less than a single page. Take a look at the following for the full implementation. http://gist.github.com/403987 H

Re: Actors not good for concurrency model

2010-05-17 Thread Raoul Duke
On Mon, May 17, 2010 at 3:04 AM, Peter Schuller wrote: > Deadlock in a message passing system is still possible if you limit > the mailbox size (unless some other means are used to prevent it). My > understanding is that mailbox size is not limited in erlang, and that > there is no other means to

Re: how do I clojurize this java ?

2010-05-17 Thread Brian Wolf
hmm, whats weird is that that works for me too that way, starting the repl with the jar files in the lib directory of the lein project yet when I cd up into the project root directory : user=> (import 'twitter4j.TwitterStreamFactory) twitter4j.TwitterStreamFactory user=> (.getInstance (TwitterS

Re: Clojure 1.2: Readsyntax for meta information

2010-05-17 Thread Stefan Kamphausen
Salut, On 17 Mai, 18:12, Laurent PETIT wrote: > 2010/5/17 Meikel Brandmeyer : > > > Hi, > > > On Mon, May 17, 2010 at 08:21:39AM -0700, Stefan Kamphausen wrote: > > >> is it correct to assume that the usual read-syntax for 1.2 will be ^ > >> instead of #^?  Will all printers emit that? Will #^ be

Re: Dynamic use of protocols

2010-05-17 Thread Sean Devlin
You could create a local instance of clojure.lang.MultiFn in a let binding, and access it directly. You can see the definition of the object here: http://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lang/MultiFn.java The very good reason you DO NOT DO THIS is that this object is MUT

Re: Clojure 1.2: Readsyntax for meta information

2010-05-17 Thread Meikel Brandmeyer
Hi, On Mon, May 17, 2010 at 09:18:15AM -0700, ataggart wrote: > Not quite. Wow. I'm really disconnected from 1.2. :( Please ignore me concerning 1.2 questions. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group,

Re: setting vars with macro

2010-05-17 Thread islon
Thanks for the answers. I realized the macro wasn't a good idea and I will keep using atoms to manage state, just found the reset! function =) Islon On May 17, 10:28 am, Michael Gardner wrote: > On May 15, 2010, at 4:56 PM, islon wrote: > > > I'm working in a simple single-thread console-based r

Re: Atoms/Concurrency - usage pattern

2010-05-17 Thread Jules
Thanks for your replies - Meikel and Alex, I considered using refs, but perhaps wrongly, came to the conclusion that they were for coordinating multiple changes atomically within an STM ? I figured that I only had one shared piece of state - current- state (input and output are both effectively th

Re: Clojure 1.2: Readsyntax for meta information

2010-05-17 Thread ataggart
Not quite. Syntax Before: meta: ^ type-hint: #^ Syntax After: meta: none, use meta type-hint: ^ It's already in place on 1.2: user=> (set! *warn-on-reflection* true) true user=> (defn foo [x] (.longValue x)) Reflection warning, NO_SOURCE_PATH:6 - reference to field longValue can't be resolved

Re: Clojure 1.2: Readsyntax for meta information

2010-05-17 Thread Laurent PETIT
2010/5/17 Meikel Brandmeyer : > Hi, > > On Mon, May 17, 2010 at 08:21:39AM -0700, Stefan Kamphausen wrote: > >> is it correct to assume that the usual read-syntax for 1.2 will be ^ >> instead of #^?  Will all printers emit that? Will #^ become >> deprecated? > > No. They are not equivalent and ^ is

Re: Atoms/Concurrency - usage pattern

2010-05-17 Thread ataggart
If you are not concerned about coordination, then why not just grab the value beforehand and use compare-and-set: (let [old @my-atom new (my-fn arg)] (compare-and-set! my-atom old new) (do-stuff old new)) On the other hand, if you are concerned about coordination between multiple thread

Re: ANN: try clojure

2010-05-17 Thread Rayne
Thanks for reporting that. I'll fix that in the next version. As soon as I finish at least a few pages of the tutorial, I'll have Heinz deploy it on his server. On May 17, 7:51 am, Daniel Werner wrote: > Having a web-based zero-deployment-effort REPL is pretty nifty, > especially for newcomers. T

Re: Atoms/Concurrency - usage pattern

2010-05-17 Thread Meikel Brandmeyer
Hi, On Mon, May 17, 2010 at 08:49:35AM -0700, Jules wrote: > The problem occurs in stateful objects when you receive an input and > need to both modify your state and generate and deliver some output. > > I store my internal state in an atom and use swap! to update it, > passing in the input and

Re: Clojure 1.2: Readsyntax for meta information

2010-05-17 Thread Meikel Brandmeyer
Hi, On Mon, May 17, 2010 at 08:21:39AM -0700, Stefan Kamphausen wrote: > is it correct to assume that the usual read-syntax for 1.2 will be ^ > instead of #^? Will all printers emit that? Will #^ become > deprecated? No. They are not equivalent and ^ is deprecated. #^ will remain doing what it

Atoms/Concurrency - usage pattern

2010-05-17 Thread Jules
Guys, I have a hybrid Java/Clojure project. I'm finding myself moving more and more of the concurrent code from Java to Clojure - because it is so much simpler to code in Clojure :-)... ... but I am also finding that I have a recurring problem for which Clojure only seems to have a partial solut

Clojure 1.2: Readsyntax for meta information

2010-05-17 Thread Stefan Kamphausen
Hi, is it correct to assume that the usual read-syntax for 1.2 will be ^ instead of #^? Will all printers emit that? Will #^ become deprecated? Unfortunately I didn't find a enlightening ticket on assembla and no information on the devel list, just the commit message ("^ does what #^ does, reade

Re: Dynamic use of protocols

2010-05-17 Thread Laurent PETIT
2010/5/17 Mikhail Kryshen : > On 17 май, 12:07, Laurent PETIT wrote: >> Yes, >> >> as David wrote, >> >> What you're describing is not single-dispatch-based polymorphism (e.g. >> like in java), it's double dispatch (because you want to dispatch to >> the implementation of the protocol function bas

Re: Style preference: (:key map) or (map :key)?

2010-05-17 Thread Sean Devlin
>From the in progress Clojure library standards[1] page: * Use keyword-first syntax to access properties on objects: (:property object-like-map) * Use collection-first syntax to extract values from a collection (or use get if the collection might be nil). (collection-like-map key) (get collecti

Re: Style preference: (:key map) or (map :key)?

2010-05-17 Thread Mike DeLaurentis
I don't know if it's more common or not, but I tend to use (:key map) most of the time, because it's a visual cue that I'm getting some key from a map. Whenever you see (:key something), you know that you're getting the :key field from something. When you see (something :key), you have to be more

Re: Error when tried to compile with C-c C-k in emacs.

2010-05-17 Thread grav
> You'll notice 90% of the "I'm having trouble with Emacs" posts have > one thing in common: they all start with "I'm trying to install > without ELPA". I have this exact problem, and I have installed everything using ELPA. clojure-mode 1.7.1 slime 20100404 slime-repl 20100404 swank-clojure 1.1.0

Style preference: (:key map) or (map :key)?

2010-05-17 Thread Michael Gardner
It appears the (:key map) style is more common than (map :key) among Clojurians. Is this true? So far I'm doing (map :key) because it's more familiar, and because it doesn't make me change styles when using something besides keywords as keys (admittedly rare so far). But I'd like to hear other

Re: Dynamic use of protocols

2010-05-17 Thread Mikhail Kryshen
On 17 май, 12:07, Laurent PETIT wrote: > Yes, > > as David wrote, > > What you're describing is not single-dispatch-based polymorphism (e.g. > like in java), it's double dispatch (because you want to dispatch to > the implementation of the protocol function based on both the type and > another par

Re: how do I clojurize this java ?

2010-05-17 Thread Sean Devlin
"Clojurize" just got added to my custom dictionary :) You'll want to use the standard . syntax for creating a new object. You wrote this (new TwitterStreamFactory) It's standard to write (TwitterStreamFactory. ) So your form would look like this: (.getInstance (TwitterStreamFactory. ) "someth

Re: Clojure web app + js libraries - any suggestions?

2010-05-17 Thread Matt
If Saul's approach is really what you want to do, then you may want to look at Conjure, which has everything Saul mentions in one web framework. Check it out at: http://github.com/macourtney/Conjure A tutorial can be found at: http://wiki.github.com/macourtney/Conjure/hello-world-tutorial-2 To

Re: setting vars with macro

2010-05-17 Thread Michael Gardner
On May 15, 2010, at 4:56 PM, islon wrote: > I'm working in a simple single-thread console-based rpg game in > clojure (a port from my own scala version) > and didn't want to use any concurrency structure because the game is > single threaded. > I was thinking about a macro like > > (defmacro set!

Re: ANN: try clojure

2010-05-17 Thread Daniel Werner
Having a web-based zero-deployment-effort REPL is pretty nifty, especially for newcomers. Thanks Rayne/Heinz/etc.! Already found a small bug: HTML entities are apparently quoted twice and appear in the output. Clojure> "blah" "blah" Clojure> filter #

Re: Actors not good for concurrency model

2010-05-17 Thread Peter Schuller
> far as i know..actors share a mutable queue.. so there's good possibility > for dead-locks Actors as they work in erlang don't have mutable state (not intrinsically anyway, though of course you can implement an actor that does poke on shared data since it's your code). The 'state' in an erlang a

labrepl - Enclojure/Maven integration

2010-05-17 Thread Rick Moynihan
Hi all, I ran a clojure dojo last week in Dundee, Scotland and thought we'd be able to start on a simple group project making use of a couple of libraries. I figured the most idiomatic approach to this would be to adopt leiningen, but it appears that Enclojure (used by the majority of the group -

Re: Dynamic use of protocols

2010-05-17 Thread Laurent PETIT
Yes, as David wrote, What you're describing is not single-dispatch-based polymorphism (e.g. like in java), it's double dispatch (because you want to dispatch to the implementation of the protocol function based on both the type and another parameter which may be totally dynamic, or materialized -

Re: new Clojure Compiler...

2010-05-17 Thread Steven Devijver
On 17 mei, 08:48, Fabio Kaminski wrote: > first that dinamic languages are better for developers, but you loose some > performance compared to typed languages.. and jvm was created with types in > mind.. so right now clojure data structures are implemented in java and > typed, when you get it in

Re: setting vars with macro

2010-05-17 Thread Laurent PETIT
2010/5/15 islon : > I'm working in a simple single-thread console-based rpg game in > clojure (a port from my own scala version) > and didn't want to use any concurrency structure because the game is > single threaded. > I was thinking about a macro like > > (defmacro set!! [s val] >  `(def ~s ~val

Re: congomongo memory leak?

2010-05-17 Thread Andrew Boekhoff
Hi. Congomongo is a fairly thin wrapper around the MongoDB java driver. All fetch requests are proxied through the driver which handles all opening and closing of connections automatically. Its main utility is providing a smooth(er) interface between Clojure's immutable types and the mutable t

Re: Artificial Intelligence in Clojure

2010-05-17 Thread Fabio Kaminski
i think MIT - church http://projects.csail.mit.edu/church/wiki/Church would be a good candidate AI lib for porting to clojure On Sat, May 15, 2010 at 5:02 PM, Miki wrote: > You can use Weka (java). > > On May 14, 10:56 pm, nathaniel wrote: > >

Re: Actors not good for concurrency model

2010-05-17 Thread Fabio Kaminski
far as i know..actors share a mutable queue.. so there's good possibility for dead-locks for scala theres an akka framework , that you can solve that with its actors .. that let me see.. uses a STM.. and its actors are pretty the same as .. clojures agents i think clojure are making disciples in