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 others languages too :)

but the greatest argument is the lack of composabillity and reuse that
side-effect functions suffer from...

the old divide-n-conquer..

On Sun, May 16, 2010 at 9:17 PM, patrickdlogan wrote:

> Nice diatribe against actors by someone who's apparently never...
> actually... used... actors. Clojure is really nice, but that doesn't
> mean I'm going to buy into weak arguments against features it doesn't
> have in its core.
>
>
> On May 16, 12:19 pm, Fabio Kaminski  wrote:
> > Sorry about using the list like twitter..
> >
> > but i thought this is a pretty good "article" about functional
> programming
> > side effects, and why actors are not very good design decision..
> >
> > Actors not good for concurrency model :
> http://pchiusano.blogspot.com/2010/01/actors-are-not-good-concurrency...
> >
> > just another prove that Rich thoughts are pretty concise ,
> > and that all are pretty well materialized in clojure's framework.
> >
> > what convinced me to embrace clojure, is that it choose to make the right
> > thing , instead of the popular one..
> >
> > as haskell community says wisely : "avoid success at all costs " :)
> >
> > --
> > 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
> your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group athttp://
> groups.google.com/group/clojure?hl=en
>
> --
> 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
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

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:
> > I saw a post about this from June 2009 or thereabouts, but it did not
> > get much follow-up.  I'm curious about AI libraries for Clojure,
> > partly since I imagine some Lisp AI code could be translated to
> > Clojure fairly easily.  I am doing some work on using Clojure with
> > applications including some AI-inspired techniques -- in particular,
> > for tracking usage patterns and user activity -- but I have not yet
> > really considered how to implement AI algorithms, such as neural
> > networks, in Clojure.  Any suggestions?
> >
> > --
> > 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
> your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group athttp://
> groups.google.com/group/clojure?hl=en
>
> --
> 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
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

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 types that the driver deals in. It also 
tries to unify various similar methods on collections into a few 
parameterizable functions.


It does tend to give the garbage collector a workout on large (for some 
value of large) reads and writes. That seems to have been the case with 
regards to the discussion from IRC that you mentioned.


Cheers,
Andy

A couple days ago, on IRC, I observed some folks talking about a
possible memory leak in the somnium congomongo clojure interface to
mongoDB.  The discussion suggested that each fetch opens the file
without closing it, and pretty soon you get an error.  Does anyone
know what happened with this?  Is it a real problem, and if so, is it
being addressed?

I'm about to start a project using clojure/mongoDB but don't want to
use it if there's a known problem without a known fix.

Thanks,

Mark

  


--
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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))
>
> so I can set my game state without using transactions, agents, etc.
> Any comments about it?

Hello,

It would be like programming C in java (in that you'll get stuff done,
but will not have learned a lot 'bout the language/platform you chose
for hosting your devs), but if you really want to take this road, then
you could use still not try to alter "the whole world" by re-defing
things (e.g. altering the root value of your vars).
So, you should take a look at:
  * binding
  * with-local-vars:
http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/with-local-vars
  * and for mutable effects local to your thread but not limited to
the dynamic scope (aka ThreadLocals in java): var-set:
http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/var-set

HTH,

-- 
Laurent

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 the clojure runtime its boxed already.
>
> theres some good approaches for dinamic languages like trace-jits(notably
> the new mozilla-javascript and luajit) .. but we are not there yet.. (JSR's
> was created as lazy sequences .. rsrs)
>

This is the typical confusion about "dynamic languages". Actually,
Clojure is not a dynamic language, it's a dynamically typed language.
Dynamic typing on the JVM generally doesn't suffer from a performance
impact, unless you're in the camp of people who believe reflection is
"slow".

Real dynamic languages like Ruby or Groovy do suffer from a gigantic
performance impact due to the feature that distinguish dynamic
languages from other languages: the meta protocol. In Ruby and Groovy
a method call is never really a method call, it's a message that's
sent through the meta protocol. It's this feature that gives you the
findByYourGrandMothersBirthDate() "dynamic" methods in Ruby on Rails
and Grails. These are not calls to methods at all, they are calls that
get parsed and converted into database query statements.

Clojure does not have a meta protocol and thus is not a dynamic
language, and thus does not have the associated performance impact.
You might have heard about Groovy++ which is branded as the new new
thing these days. Groovy++ is simply Groovy without the meta protocol,
hence fast Groovy.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 -when
serialized- by some key in the configuration - spring bean name,
etc.).

Protocols are based on a single dispatch mechanism, as classical
"class based" languages (e.g. Java) are.

When you write "kind of expandability almost free with well-designed
OO systems", I guess this design implies some kind of implementation
of the Strategy pattern, or more probably Delegation pattern.

So in your case, either you try to stay with Protocols and e.g. use
the Delegation pattern, either you switch to multimethods and have the
full power to centrally define the dispatch mechanism of your choice.

HTH,

-- 
Laurent

2010/5/16 David Nolen :
> On Saturday, May 15, 2010, Mikhail Kryshen
>> set of extenders and implementing functions. This state (what
>> types currently implement the protocol and how) is what I really
>> want to be able to manipulate. The way it is tied to the protocol
>> definition and changed by the extend function seems to cause the
>> problem.
>>
>
> Have you considered using multimethods instead?
>
> David
>
> --
> 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 your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 - though not me) doesn't support lein, though you can use
export to a maven pom.

Taking a look at the labrepl project, there is a clear integration
between the Maven build, and Enclojure... Specifically with Enclojure
providing a series of options to "start a project REPL", yet these
don't appear in my hand-cranked maven project, despite including the
maven-clojure-plugin.

I realise we can start the maven goal clojure:repl from within
Netbeans, however the REPL doesn't then seem to be as tightly
integrated with the editor.

How does labrepl integrate with Enclojure, and does anyone manage to
use an IDE effectively with lein/maven?

Thanks again,

R.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 actor is that of parameter(s) to an infinitely tail-recursive
function.

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 avoid deadlock, meaning that while you will
not deadlock in the message passing system you can cause memory
exhaustion.

Disclaimer: While I've played with erlang I'm not really that into it,
please correct me someone if I've misrepresented anything.

-- 
/ Peter Schuller

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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
#

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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!! [s val]
>  `(def ~s ~val))
> 
> so I can set my game state without using transactions, agents, etc.
> Any comments about it?

I wrote a Pong clone in Clojure just to stretch my mind a bit. Here's what I do:

The entire game world is a single struct-map (may become a record at some 
point), stored in a global ref. When my world-update timer fires, I deref the 
world and then pass it to my world-updater functions. These updaters return the 
new world state, which I then set via ref-set.

This is almost as simple as the usual global vars approach, and allowed me to 
trivially split the world-drawing code into another thread that runs on a 
different schedule. It also permits stuff like printing out or saving the 
entire world state very easily.

Actually, were it not for Swing, I wouldn't even be using mutable structures at 
all-- I'd be passing the world state from update to update using tail-recursion.

You might also be interested in these links:

http://nakkaya.com/2009/12/19/cloning-pong-part-1/ (I originally based my Pong 
game on this code)
http://jng.imagine27.com/articles/2009-09-12-122605_pong_in_clojure.html 
(cloning Pong is apparently pretty popular!)
http://briancarper.net/blog/making-an-rpg-in-clojure-part-one-of-many (site 
down at the moment)
http://prog21.dadgum.com/23.html (not Clojure, but interesting for functional 
games in general)

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 create your project download the jar and type: "java -jar conjure
". A directory will be created, named after your app.
Some basic views will be created for your and an H2 embedded database
ready to use. Just cd into the app directory and type "./run.bat
script/server.clj" to start a local server on port 8080.

-Matt


On May 16, 10:13 am, Base  wrote:
> Thanks much Saul.  This is exactly what I am looking for!  Let the
> webapps begin!
>
> On May 16, 7:15 am, Saul Hazledine  wrote:
>
>
>
> > On May 15, 5:23 pm, Base  wrote:
>
> > > So I would love to hear what others have done in the past to integrate
> > > clojure into a web app.  Any info would be most appreciated.
>
> > I use compojure 0.4 with hiccup to generate the HTML. It feels like a
> > very "old school" way of developing a web application because it isn't
> > a do everything web framework. However, things have gone smoothly and
> > I've had no problems with this approach. Despite being a clojure
> > newbie I have found my productivity is very good with slowdowns caused
> > by having to write things such as user management and form validation
> > myself.
>
> > I haven't integrated any javascript yet and the application is
> > responsive enough that I may only add minimal javascript as needed
> > after the first release. My intention is to use jquery and scriptjure:
>
> >http://arohner.blogspot.com/2010/04/writing-jquery-code-with-scriptju...
>
> > I'm using an embedded H2 database engine which is low latency (5 -> 10
> > ms to get query results back) and has made a big difference to how the
> > application feels.
>
> > Overall I would recommend this setup as (very) enjoyable and flexible
> > but if you're on a tight deadline then a full web framework may be
> > more appropriate.
>
> > Saul
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.To post to this group, send email 
> > tocloj...@googlegroups.com
> > Note that posts from new members are moderated - please be patient with 
> > your first post.
> > To unsubscribe from this group, send email 
> > toclojure+unsubscr...@googlegroups.com
> > For more options, visit this group 
> > athttp://groups.google.com/group/clojure?hl=en
>
> --
> 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 your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group 
> athttp://groups.google.com/group/clojure?hl=en

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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. ) "something" "other")

Sean

On May 16, 4:25 pm, Brian Wolf  wrote:
> Hi,
>
> I was wondering how to 'clojurize'
>
>   twitterStream = new TwitterStreamFactory().getInstance(args[0],
> args[1]);
>
> from the java code below,which is the  from the open source twitter4j
> java library (http://twitter4j.org/en/index.html)
>
> from the source, .getInstance(args[0], args[1])  is a "protected"
> method of TwitterStreamFactory, :
>
> so I think should be callable on the function (?),
>
> tried this and various permutations
>
> (.getInstance ( new TwitterStreamFactory) "something" "other")
>
> but the error says
>
> "cant call public method on non-public class
> : public java.lang.Object twitter4j.TwitterFactoryBase.getInstance
>
> or  twitterStream can to be instantiated using a public method using
> 'this' like below (if im following the java code right), but I
> understand the java concept of 'this' doesn't exist in clojure
>
> Thanks,
>
> Brian
>
> import twitter4j.Status;
> import twitter4j.StatusDeletionNotice;
> import twitter4j.StatusListener;
> import twitter4j.TwitterException;
> import twitter4j.TwitterStream;
> import twitter4j.TwitterStreamFactory;
>
> /**
>  * This is a code example of Twitter4J Streaming API - sample
> method support.
>  * Usage: java twitter4j.examples.PrintSampleStream
> [TwitterScreenName TwitterPassword]
>  * 
>  * @author Yusuke Yamamoto - yusuke at mac.com
>  */
> public final class PrintSampleStream implements StatusListener{
>     /**
>      * Main entry of this application.
>      * @param args String[] TwitterID TwitterPassword
>      */
>     public static void main(String[] args)throws TwitterException {
>         PrintSampleStream printSampleStream = new
> PrintSampleStream(args);
>         printSampleStream.startConsuming();
>     }
>
>     TwitterStream twitterStream;
>
>     PrintSampleStream(String[] args) {
>         try {
>             twitterStream = new
> TwitterStreamFactory(this).getInstance();
>         } catch (IllegalStateException is) {
>             // screen name / password combination is not in
> twitter4j.properties
>             if (args.length < 2) {
>                 System.out.println(
>                         "Usage: java
> twitter4j.examples.PrintSampleStream [ScreenName Password]");
>                 System.exit(-1);
>             }
>             twitterStream = new
> TwitterStreamFactory().getInstance(args[0], args[1]);
>         }
>     }
>
> --
> 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 your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group 
> athttp://groups.google.com/group/clojure?hl=en

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 parameter which may be totally dynamic, or materialized -when
> serialized- by some key in the configuration - spring bean name,
> etc.).

That makes sense. It looks like I was trying to avoid explicit
double-dispatch by manipulating the protocol at runtime. Is it abuse
of dynamic features of Clojure?

> Protocols are based on a single dispatch mechanism, as classical
> "class based" languages (e.g. Java) are.
>
> When you write "kind of expandability almost free with well-designed
> OO systems", I guess this design implies some kind of implementation
> of the Strategy pattern, or more probably Delegation pattern.

What I was actually talking about is the possibility to avoid global
state and being able to extend existing implementation to multiple
instances without much refactoring.

Protocols and multimethods both have global state. From what I saw in
Clojure source protocols are manipulated by changing root binding of
associated var, and multimethods are actually mutable functions
changed by defmethod (I see inconsistency here).

There is no standard way to create multimethod or protocol without
binding it to global var. Why is it possible to create non-global
function but not multimethod?

--
Mikhail

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 views before I get too set in my ways. 
Which style do you use, and why?

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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

Getting "Wrong number of args passed to: basic$eval--986$compile-file-
for-emacs" when using C-c C-k

Any advice?

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 aware of the context to know whether something is a map or some other
function.


On Mon, May 17, 2010 at 10:48 AM, Michael Gardner wrote:

> 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 views before I get too
> set in my ways. Which style do you use, and why?
>
> --
> 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
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

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 collection-like-map key)

Sean

[1] https://www.assembla.com/wiki/show/clojure/Clojure_Library_Coding_Standards

On May 17, 10:48 am, Michael Gardner  wrote:
> 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 views before I get too 
> set in my ways. Which style do you use, and why?
>
> --
> 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 your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group 
> athttp://groups.google.com/group/clojure?hl=en

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 based on both the type and
>> another parameter which may be totally dynamic, or materialized -when
>> serialized- by some key in the configuration - spring bean name,
>> etc.).
>
> That makes sense. It looks like I was trying to avoid explicit
> double-dispatch by manipulating the protocol at runtime. Is it abuse
> of dynamic features of Clojure?
>
>> Protocols are based on a single dispatch mechanism, as classical
>> "class based" languages (e.g. Java) are.
>>
>> When you write "kind of expandability almost free with well-designed
>> OO systems", I guess this design implies some kind of implementation
>> of the Strategy pattern, or more probably Delegation pattern.
>
> What I was actually talking about is the possibility to avoid global
> state and being able to extend existing implementation to multiple
> instances without much refactoring.

Not sure it's of interest for your particular case, but note that as
far as protocols are concerned, you can have a per-instance protocol
implementation (à la java anonymous classes) by using reify.

> Protocols and multimethods both have global state. From what I saw in
> Clojure source protocols are manipulated by changing root binding of
> associated var, and multimethods are actually mutable functions
> changed by defmethod (I see inconsistency here).
>
> There is no standard way to create multimethod or protocol without
> binding it to global var. Why is it possible to create non-global
> function but not multimethod?

I'll let people with more knowledge than me answer those ones :-)

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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, reader metadata").

Regards,
Stefan

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 solution.


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 a pure function which accepts the object's
current state and input and returns the object's new state.

The problem is that there is no clear mechanism for returning the
object's output from the same pure function.

At the moment, I am going with a solution whereby my object's state is
a variable length tuple e.g. [current-state & latest-output]. This
allows me to return both new state and output from the same swap! I
just have to agree with all other functions reading the state that
only e.g. current-state is relevant and latest-output can be ignored
by all except the caller of swap!, which actually processes/delivers
it, but this feels clumsy.

Am I missing something here or is there room for another member of the
swap! family which returns a tuple with a similar structure to mine,
but only uses the head of this tuple to reset the state of the
enclosing atom ?

Thanks for your time,


Jules

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 did up to now. ^ will go away w/o replacement.

Sincerely
Meikel

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 a pure function which accepts the object's
> current state and input and returns the object's new state.

I believe you need a ref for this, since you have to coordinate several
states: the object state and the input state.

(defn do-stuff
  [state input]
  (dosync
(let [[next-state output] (do-pure-stuff @state input)]
  (ref-set state next-state)
  output)))

or you combine both states in one, which might also make sense: the
current-state with the next input is a snapshot of your system from
which you can replay things.

(defn do-stuff
  [state input]
  (:output (swap! state do-pure-stuff input)))

Which is basically what you describe.

Sincerely
Meikel

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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. 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
> #
>
> --
> 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 your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group 
> athttp://groups.google.com/group/clojure?hl=en

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 threads changing the state, then don't use atoms; use refs.



On May 17, 8:49 am, Jules  wrote:
> 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 solution.
>
> 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 a pure function which accepts the object's
> current state and input and returns the object's new state.
>
> The problem is that there is no clear mechanism for returning the
> object's output from the same pure function.
>
> At the moment, I am going with a solution whereby my object's state is
> a variable length tuple e.g. [current-state & latest-output]. This
> allows me to return both new state and output from the same swap! I
> just have to agree with all other functions reading the state that
> only e.g. current-state is relevant and latest-output can be ignored
> by all except the caller of swap!, which actually processes/delivers
> it, but this feels clumsy.
>
> Am I missing something here or is there room for another member of the
> swap! family which returns a tuple with a similar structure to mine,
> but only uses the head of this tuple to reset the state of the
> enclosing atom ?
>
> Thanks for your time,
>
> Jules
>
> --
> 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 your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group 
> athttp://groups.google.com/group/clojure?hl=en

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 deprecated. #^ will remain doing
> what it did up to now. ^ will go away w/o replacement.


Sorry to disagree, but the most recent changes I know about it (less
than one month ago) are (in 1.2):

  * the old behaviour of ^ will not be supported anymore (and users
will just have to use calls to meta)
  * and will be replaced by the current behaviour of #^
  * #^ remains but becomes deprecated

So the OP is wrong, AFAIK.

Cheers,

-- 
Laurent

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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.
#'user/foo
user=> (defn foo [^Integer x] (.longValue x))
#'user/foo


On May 17, 8:58 am, Meikel Brandmeyer  wrote:
> 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 did up to now. ^ will go away w/o replacement.
>
> Sincerely
> Meikel
>
> --
> 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 your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group 
> athttp://groups.google.com/group/clojure?hl=en

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 thread-local) and that an
atom would be far more efficient for my use case.

I didn't notice that compare-and-set! had been exposed - so, yes, I
could use this, but it would probably only be to roll my own swap!
variant that allowed me to return a tuple of [new-state output]

So, am I just being awkward :-) - should I really be using refs/STM's
to achieve this ? or am I using a pattern peculiar to myself because
of some other wierd design decision that I have taken ? or have others
come across the same requirement and been similarly perplexed ?

thx

Jules


On May 17, 5:12 pm, ataggart  wrote:
> 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 threads changing the state, then don't use atoms; use refs.
>
> On May 17, 8:49 am, Jules  wrote:
>
>
>
> > 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 solution.
>
> > 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 a pure function which accepts the object's
> > current state and input and returns the object's new state.
>
> > The problem is that there is no clear mechanism for returning the
> > object's output from the same pure function.
>
> > At the moment, I am going with a solution whereby my object's state is
> > a variable length tuple e.g. [current-state & latest-output]. This
> > allows me to return both new state and output from the same swap! I
> > just have to agree with all other functions reading the state that
> > only e.g. current-state is relevant and latest-output can be ignored
> > by all except the caller of swap!, which actually processes/delivers
> > it, but this feels clumsy.
>
> > Am I missing something here or is there room for another member of the
> > swap! family which returns a tuple with a similar structure to mine,
> > but only uses the head of this tuple to reset the state of the
> > enclosing atom ?
>
> > Thanks for your time,
>
> > Jules
>
> > --
> > 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 
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group 
> > athttp://groups.google.com/group/clojure?hl=en
>
> --
> 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 your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group 
> athttp://groups.google.com/group/clojure?hl=en

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 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))
>
> > so I can set my game state without using transactions, agents, etc.
> > Any comments about it?
>
> I wrote a Pong clone in Clojure just to stretch my mind a bit. Here's what I 
> do:
>
> The entire game world is a single struct-map (may become a record at some 
> point), stored in a global ref. When my world-update timer fires, I deref the 
> world and then pass it to my world-updater functions. These updaters return 
> the new world state, which I then set via ref-set.
>
> This is almost as simple as the usual global vars approach, and allowed me to 
> trivially split the world-drawing code into another thread that runs on a 
> different schedule. It also permits stuff like printing out or saving the 
> entire world state very easily.
>
> Actually, were it not for Swing, I wouldn't even be using mutable structures 
> at all-- I'd be passing the world state from update to update using 
> tail-recursion.
>
> You might also be interested in these links:
>
> http://nakkaya.com/2009/12/19/cloning-pong-part-1/(I originally based my Pong 
> game on this 
> code)http://jng.imagine27.com/articles/2009-09-12-122605_pong_in_clojure.html(cloning
>  Pong is apparently pretty 
> popular!)http://briancarper.net/blog/making-an-rpg-in-clojure-part-one-of-many(site
>  down at the moment)http://prog21.dadgum.com/23.html(not Clojure, but 
> interesting for functional games in general)
>
> --
> 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 your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group 
> athttp://groups.google.com/group/clojure?hl=en

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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
MUTABLE.

I STRONGLY RECOMMEND that you use a dispatch fn that returns a
keyword, and use that to select a closure from a hash map for local
bindings.

Sean

On May 17, 10:41 am, Mikhail Kryshen  wrote:
> 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 parameter which may be totally dynamic, or materialized -when
> > serialized- by some key in the configuration - spring bean name,
> > etc.).
>
> That makes sense. It looks like I was trying to avoid explicit
> double-dispatch by manipulating the protocol at runtime. Is it abuse
> of dynamic features of Clojure?
>
> > Protocols are based on a single dispatch mechanism, as classical
> > "class based" languages (e.g. Java) are.
>
> > When you write "kind of expandability almost free with well-designed
> > OO systems", I guess this design implies some kind of implementation
> > of the Strategy pattern, or more probably Delegation pattern.
>
> What I was actually talking about is the possibility to avoid global
> state and being able to extend existing implementation to multiple
> instances without much refactoring.
>
> Protocols and multimethods both have global state. From what I saw in
> Clojure source protocols are manipulated by changing root binding of
> associated var, and multimethods are actually mutable functions
> changed by defmethod (I see inconsistency here).
>
> There is no standard way to create multimethod or protocol without
> binding it to global var. Why is it possible to create non-global
> function but not multimethod?
>
> --
> Mikhail
>
> --
> 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 your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group 
> athttp://groups.google.com/group/clojure?hl=en

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 #^ become
> >> deprecated?
>
> > No. They are not equivalent and ^ is deprecated. #^ will remain doing
> > what it did up to now. ^ will go away w/o replacement.
>
> Sorry to disagree, but the most recent changes I know about it (less
> than one month ago) are (in 1.2):
>
>   * the old behaviour of ^ will not be supported anymore (and users
> will just have to use calls to meta)
>   * and will be replaced by the current behaviour of #^
>   * #^ remains but becomes deprecated

that sounds like a citation.  Is it?  If so, what's the source?  Will
#^ become deprecated in 1.2 or in the following release? And, are
there any plans for the future beyond 1.2++?

Ah, so many questions...

Regards,
Stefan

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 (TwitterStreamFactory.) "foo" "bar")
java.lang.IllegalArgumentException: Can't call public method of non-
public class: public java.lang.Object
twitter4j.TwitterFactoryBase.getInstance(java.lang.String,java.lang.String)
(NO_SOURCE_FILE:0)

obviously somethings different between these two condtions (?)



On May 16, 5:11 pm, ataggart  wrote:
> Works fine for me:
>
> $ java -cp clojure.jar:twitter4j-core-2.1.2.jar clojure.main
> Clojure 1.2.0-master-SNAPSHOT
> user=> (import 'twitter4j.TwitterStreamFactory)
> twitter4j.TwitterStreamFactory
> user=> (.getInstance (TwitterStreamFactory.) "foo" "bar")
> [Sun May 16 17:09:37 PDT 2010]Using class
> twitter4j.internal.logging.StdOutLoggerFactory as logging factory.
> # password='**''}}>
>
> On May 16, 1:25 pm, Brian Wolf  wrote:
>
>
>
> > Hi,
>
> > I was wondering how to 'clojurize'
>
> >   twitterStream = new TwitterStreamFactory().getInstance(args[0],
> > args[1]);
>
> > from the java code below,which is the  from the open source twitter4j
> > java library (http://twitter4j.org/en/index.html)
>
> > from the source, .getInstance(args[0], args[1])  is a "protected"
> > method of TwitterStreamFactory, :
>
> > so I think should be callable on the function (?),
>
> > tried this and various permutations
>
> > (.getInstance ( new TwitterStreamFactory) "something" "other")
>
> > but the error says
>
> > "cant call public method on non-public class
> > : public java.lang.Object twitter4j.TwitterFactoryBase.getInstance
>
> > or  twitterStream can to be instantiated using a public method using
> > 'this' like below (if im following the java code right), but I
> > understand the java concept of 'this' doesn't exist in clojure
>
> > Thanks,
>
> > Brian
>
> > import twitter4j.Status;
> > import twitter4j.StatusDeletionNotice;
> > import twitter4j.StatusListener;
> > import twitter4j.TwitterException;
> > import twitter4j.TwitterStream;
> > import twitter4j.TwitterStreamFactory;
>
> > /**
> >  * This is a code example of Twitter4J Streaming API - sample
> > method support.
> >  * Usage: java twitter4j.examples.PrintSampleStream
> > [TwitterScreenName TwitterPassword]
> >  * 
> >  * @author Yusuke Yamamoto - yusuke at mac.com
> >  */
> > public final class PrintSampleStream implements StatusListener{
> >     /**
> >      * Main entry of this application.
> >      * @param args String[] TwitterID TwitterPassword
> >      */
> >     public static void main(String[] args)throws TwitterException {
> >         PrintSampleStream printSampleStream = new
> > PrintSampleStream(args);
> >         printSampleStream.startConsuming();
> >     }
>
> >     TwitterStream twitterStream;
>
> >     PrintSampleStream(String[] args) {
> >         try {
> >             twitterStream = new
> > TwitterStreamFactory(this).getInstance();
> >         } catch (IllegalStateException is) {
> >             // screen name / password combination is not in
> > twitter4j.properties
> >             if (args.length < 2) {
> >                 System.out.println(
> >                         "Usage: java
> > twitter4j.examples.PrintSampleStream [ScreenName Password]");
> >                 System.exit(-1);
> >             }
> >             twitterStream = new
> > TwitterStreamFactory().getInstance(args[0], args[1]);
> >         }
> >     }
>
> > --
> > 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 
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group 
> > athttp://groups.google.com/group/clojure?hl=en
>
> --
> 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 your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group 
> athttp://groups.google.com/group/clojure?hl=en

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 avoid deadlock, meaning that while you will
> not deadlock in the message passing system you can cause memory
> exhaustion.
>
> Disclaimer: While I've played with erlang I'm not really that into it,
> please correct me someone if I've misrepresented anything.

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

sincerely.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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

Here's an example usage taking square roots using the Heron
approximation.

http://gist.github.com/403990

This was all done with the following versions -- take from the lein
project.clj file.

--8<---cut here---start->8---
(defproject propagator "1.0.0-SNAPSHOT"
  :description "Concurrent propagator system"
  :dependencies [[org.clojure/clojure "1.1.0-alpha-SNAPSHOT"]
 [org.clojure/clojure-contrib "1.0-SNAPSHOT"]
 [vijual "0.1.0-SNAPSHOT"]
 [ring "0.2.0"]]
  :dev-dependencies [[leiningen/lein-swank "1.0.0-SNAPSHOT"]])
--8<---cut here---end--->8---

Best -- Eric

Steven Devijver  writes:

> I'm experimenting with cells in clojure and am currently using the
> "lazy" branch for this. However, I'm getting some strange behavior.
>
> So my question is: which branch should I be using if I want to test-
> drive the watcher feature?
>
> Thanks

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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, with a synchronous send+receive you can easily deadlock. The
bounded mailboxes was under the assumption of asynchronous sends, but
I suppose another way to put it is that such asynchronous sends
effectively turn synchronous (or potentially synchronous) again once
you limit mailbox size.

I think the interesting generalization is that regardless of your
underlying primitives, you will always be able to create a system
which has some potential for deadlocks and/or race conditions. Just
because your low-level primitives "guarantee" that you don't, does not
mean that you cannot use them to build something on top that *is*
susceptible to deadlock/races.

-- 
/ Peter Schuller

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 full implementation.
>
> http://gist.github.com/403987
>
> Here's an example usage taking square roots using the Heron
> approximation.
>
> http://gist.github.com/403990
>
> This was all done with the following versions -- take from the lein
> project.clj file.
>
> --8<---cut here---start->8---
> (defproject propagator "1.0.0-SNAPSHOT"
>   :description "Concurrent propagator system"
>   :dependencies [[org.clojure/clojure "1.1.0-alpha-SNAPSHOT"]
>                  [org.clojure/clojure-contrib "1.0-SNAPSHOT"]
>                  [vijual "0.1.0-SNAPSHOT"]
>                  [ring "0.2.0"]]
>   :dev-dependencies [[leiningen/lein-swank "1.0.0-SNAPSHOT"]])
> --8<---cut here---end--->8---
>
> Best -- Eric
>

Hey Eric,

This looks like a very tight implementation indeed! I'll take it for a
spin soon.

Thanks

Steven

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 "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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 #^?  Will all printers emit that? Will #^ become
>> >> deprecated?
>>
>> > No. They are not equivalent and ^ is deprecated. #^ will remain doing
>> > what it did up to now. ^ will go away w/o replacement.
>>
>> Sorry to disagree, but the most recent changes I know about it (less
>> than one month ago) are (in 1.2):
>>
>>   * the old behaviour of ^ will not be supported anymore (and users
>> will just have to use calls to meta)
>>   * and will be replaced by the current behaviour of #^
>>   * #^ remains but becomes deprecated
>
> that sounds like a citation.  Is it?  If so, what's the source?  Will
> #^ become deprecated in 1.2 or in the following release? And, are
> there any plans for the future beyond 1.2++?


It's just what I personally know, from having followed things on
#clojure, and also from reading the recent clojure.io patch from Stu
Halloway where what I described above is applied.

I've already made the relative change in counterclockwise syntax
coloring, as Rich stated in #clojure. He also gave a "go" to a clojure
book author for doing the appropriate semantics modifications in the
corresponding chapters.

So yes, I'm pretty sure this will be as I described for 1.2.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 Ubuntu.

However, whenever I try to install swank-clojure or clojure, the
package system reports:

let: File exists:
/home/metaperl/.emacs.d/elpa/clojure-mode-1.7.1/clojure-mode.el


Manually removing the directory
/home/metaperl/.emacs.d/elpa/clojure-mode-1.7.1 and trying again
simply leads to the same error.

Here is the output of M-x report-emacs-bug

In GNU Emacs 23.2.1 (i686-pc-linux-gnu, GTK+ Version 2.18.3)
 of 2010-05-14 on locohost
Windowing system distributor `The X.Org Foundation', version 11.0.10604000
configured using `configure  '--with-x-toolkit=gtk''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Apropos

Minor modes in effect:
  desktop-save-mode: t
  shell-dirtrack-mode: t
  show-paren-mode: t
  global-auto-revert-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
  
  
  
   
   
  
  
   
C-x 2 C-x b * m e s  C-p C-p C-p C-p C-p C-p
C-p C-p C-p C-p C-p C-p C-p C-v C-l  

   
   
  

   
i x C-x o C-x o C-x d   g n n n
n ! r m SPC - r f  g C-x o x y e s 
ESC < C-x o ESC > C-x b *  ESC > 
   
   
   g
p p v C-x k  p p p p p v ESC > C-x k 
   
   
  
  
  
   
  


   
   
   
  
  
  
   
  
  
  
   
x
   
  
   
   
 ESC x m e a c s -  
e m
a c s - b uC-g  a b u g 
C-x o C-v C-s e m a s c ESC x r e p o r t e 
- e m  

Recent messages:
byte-code: Beginning of buffer
Mark set
Contacting host: tromey.com:80
Reading [text/plain]... 28k of 28k (100%)
Reading... done.
let: File exists:
/home/metaperl/.emacs.d/elpa/clojure-mode-1.7.1/clojure-mode.el
byte-code: End of buffer [2 times]
Quit
Type M-x display-buffer RET to restore the other window.
Mark saved where search started

Load-path shadows:
~/emacs-contrib/cperl-mode hides ~/emacs/cperl-mode
~/emacs/table hides /usr/local/share/emacs/23.2/lisp/textmodes/table
~/emacs-contrib/prolog hides /usr/local/share/emacs/23.2/lisp/progmodes/prolog
~/emacs-contrib/cperl-mode hides
/usr/local/share/emacs/23.2/lisp/progmodes/cperl-mode

Features:
(shadow sort mail-extr message ecomplete rfc822 mml mml-sec mm-decode
mm-bodies mm-encode mailabbrev nnheader gmm-utils mailheader canlock
sha1 hex-util hashcash emacsbug clojure-mode-autoloads
slime-repl-autoloads slime-autoloads derived gud noutline outline
apropos arc-mode archive-mode pp thingatpt warnings byte-opt compile
bytecomp byte-compile autoload mail-utils url-cache url-http tls
mail-parse rfc2231 rfc2047 rfc2045 qp ietf-drums url-gw url-auth url
url-proxy url-privacy url-expand url-methods url-history url-cookie
url-util url-parse timezone url-vars mm-util mail-prsvr mailcap
help-mode debug nroff-mode multi-isearch view vc-git dired-x dired-aux
dired package init-window-system color-theme-random color-theme wid-edit
sendmail reporter menu-bar+ init-windows-xp init-standard-packages
desktop ido shell-current-directory ansi-color uniquify tramp-imap
tramp-gw tramp-fish tramp-smb tramp-cache tramp-ftp tramp-cmds tramp
auth-source gnus-util netrc time-date advice help-fns advice-preload
shell comint password-cache format-spec tramp-compat trampver
init-settings paren init-set-key init-emacs hideshow-org easy-mmode
edmacro kmacro hideshow pastebin autorevert init-functions emacs-contrib
cperl-mode regexp-opt cl cl-19 info etags ring easymenu imenu man assoc
tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd
font-setting tool-bar dnd fontset image fringe lisp-mode register page
menu-bar rfn-eshadow timer select scroll-bar mldrag mouse jit-lock
font-lock syntax facemenu font-core frame cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew
greek romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button
minibuffer faces cus-face files text-properties overlay md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process font-render-setting gtk x-toolkit x
multi-tty emacs)

-- 
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 pat

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 regards,

alux

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 to the standard get-in?
>
> Cheers,
> Alexy
>
> --
> 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
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

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 first of the month until it is past the second date.
This works using standard recursion but I wanted to use TCO.

Any help is most appreciated (as usual...!)

Thanks

Base


(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))

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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, I successfully installed slime and slime-repl using package.el
> under a manually built GNU Emacs 23 with Ubuntu.
>
> However, whenever I try to install swank-clojure or clojure, the
> package system reports:
>
> let: File exists:
> /home/metaperl/.emacs.d/elpa/clojure-mode-1.7.1/clojure-mode.el
>
>
> Manually removing the directory
> /home/metaperl/.emacs.d/elpa/clojure-mode-1.7.1 and trying again
> simply leads to the same error.
>
> Here is the output of M-x report-emacs-bug
>
> In GNU Emacs 23.2.1 (i686-pc-linux-gnu, GTK+ Version 2.18.3)
>  of 2010-05-14 on locohost
> Windowing system distributor `The X.Org Foundation', version 11.0.10604000
> configured using `configure  '--with-x-toolkit=gtk''
>
> Important settings:
>  value of $LC_ALL: nil
>  value of $LC_COLLATE: nil
>  value of $LC_CTYPE: nil
>  value of $LC_MESSAGES: nil
>  value of $LC_MONETARY: nil
>  value of $LC_NUMERIC: nil
>  value of $LC_TIME: nil
>  value of $LANG: en_US.UTF-8
>  value of $XMODIFIERS: nil
>  locale-coding-system: utf-8-unix
>  default enable-multibyte-characters: t
>
> Major mode: Apropos
>
> Minor modes in effect:
>  desktop-save-mode: t
>  shell-dirtrack-mode: t
>  show-paren-mode: t
>  global-auto-revert-mode: t
>  tooltip-mode: t
>  mouse-wheel-mode: t
>  menu-bar-mode: t
>  file-name-shadow-mode: t
>  global-font-lock-mode: t
>  font-lock-mode: t
>  blink-cursor-mode: t
>  auto-encryption-mode: t
>  auto-compression-mode: t
>  line-number-mode: t
>  transient-mark-mode: t
>
> Recent input:
>   
>   
>   
>
>
>   
>   
>
> C-x 2 C-x b * m e s  C-p C-p C-p C-p C-p C-p
> C-p C-p C-p C-p C-p C-p C-p C-v C-l  
> 
>
>
>   
> 
>
> i x C-x o C-x o C-x d   g n n n
> n ! r m SPC - r f  g C-x o x y e s 
> ESC < C-x o ESC > C-x b *  ESC > 
>
>
>g
> p p v C-x k  p p p p p v ESC > C-x k 
>
>
>   
>   
>   
>
>   
> 
> 
>
>
>
>   
>   
>   
>
>   
>   
>   
>
> x
>
>   
>
>
>  ESC x m e a c s -  
> e m
> a c s - b uC-g  a b u g 
> C-x o C-v C-s e m a s c ESC x r e p o r t e 
> - e m  
>
> Recent messages:
> byte-code: Beginning of buffer
> Mark set
> Contacting host: tromey.com:80
> Reading [text/plain]... 28k of 28k (100%)
> Reading... done.
> let: File exists:
> /home/metaperl/.emacs.d/elpa/clojure-mode-1.7.1/clojure-mode.el
> byte-code: End of buffer [2 times]
> Quit
> Type M-x display-buffer RET to restore the other window.
> Mark saved where search started
>
> Load-path shadows:
> ~/emacs-contrib/cperl-mode hides ~/emacs/cperl-mode
> ~/emacs/table hides /usr/local/share/emacs/23.2/lisp/textmodes/table
> ~/emacs-contrib/prolog hides
> /usr/local/share/emacs/23.2/lisp/progmodes/prolog
> ~/emacs-contrib/cperl-mode hides
> /usr/local/share/emacs/23.2/lisp/progmodes/cperl-mode
>
> Features:
> (shadow sort mail-extr message ecomplete rfc822 mml mml-sec mm-decode
> mm-bodies mm-encode mailabbrev nnheader gmm-utils mailheader canlock
> sha1 hex-util hashcash emacsbug clojure-mode-autoloads
> slime-repl-autoloads slime-autoloads derived gud noutline outline
> apropos arc-mode archive-mode pp thingatpt warnings byte-opt compile
> bytecomp byte-compile autoload mail-utils url-cache url-http tls
> mail-parse rfc2231 rfc2047 rfc2045 qp ietf-drums url-gw url-auth url
> url-proxy url-privacy url-expand url-methods url-history url-cookie
> url-util url-parse timezone url-vars mm-util mail-prsvr mailcap
> help-mode debug nroff-mode multi-isearch view vc-git dired-x dired-aux
> dired package init-window-system color-theme-random color-theme wid-edit
> sendmail reporter menu-bar+ init-windows-xp init-standard-packages
> desktop ido shell-current-directory ansi-color uniquify tramp-imap
> tramp-gw tramp-fish tramp-smb tramp-cache tramp-ftp tramp-cmds tramp
> auth-source gnus-util netrc time-date advice help-fns advice-preload
> shell comint password-cache format-spec tramp-compat trampver
> init-settings paren init-set-key init-emacs hideshow-org easy-mmode
> edmacro kmacro hideshow pastebin autorevert init-functions emacs-contrib
> cperl-mode regexp-opt cl cl-19 info etags ring easymenu imenu man assoc
> tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd
> font-setting tool-bar dnd fontset image fringe lisp-mode register page
> menu-bar rfn-eshadow timer select scroll-bar mldrag mouse jit-lock
> font-lock syntax facemenu font-core frame cham georgian utf-8-lang
> misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew
> greek romanian slovak czech european ethiopic indian cyrillic chinese
> case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button
> minibuffer faces cus-face files text-properties overlay md5

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" position means it's the last call at the top level of the
loop. I.e. - you can't call anything after the recur. In your case

> The function takes 2 joda dates and returns a sequence of dates
> starting at the first of the month until it is past the second date.
> This works using standard recursion but I wanted to use TCO.
> 
> Any help is most appreciated (as usual...!)
> 
> Thanks
> 
> Base
> 
> 
> (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))

In this case, you're calling cons with the result of the recur, which
means it happens "after" the recur, which is the error.

I suspect your original wasn't tail recursive, since the two loop
arguments are two dates (assuming my guesses about time/before? are
correct), and the values in the list you returns would be stored on
the call stack, to be pasted together by the string of conses you've
left to run after each recursive call.

To make it tail recursive, you need to make the list you're going to
return one of the arguments of the loop, adjust the code for that,
then push the cons into the if, sort of like so:

(defn date-seq
  [d1 d2]
  (loop [b (-> d1
 (.dayOfMonth)
 (.withMinimumValue))
 e [d2]]
   (if (time/before? b (first e))
 (recur (.plusMonths b 1) (conj e b))
 (reverse b

This is just a swag; I'm not familiar enough with Java to reconstruct
your arguments...

  http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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-seq [d1 d2]
  (let [start (-> d1
(.dayOfMonth)
(.withMinimumValue))]
 (cons start (if (joda/before? start d2)
(date-seq (.plusMonths start 1) d2)

(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))

The lazy version worked like a champ and appears (to me) to be more in
the vain of Lisp (with a touch of Haskell).
Is the author of the blog correct about using lazy seq in this way?
Assuming that he is correct and I converted date-seq to a loop/recur
format to use TCO, would one of these be preferable over the other in
terms of idiomatic clojure?


Thanks

Bassel




On May 17, 5:27 pm, Mike Meyer  wrote:
> 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" position means it's the last call at the top level of the
> loop. I.e. - you can't call anything after the recur. In your case
>
>
>
> > The function takes 2 joda dates and returns a sequence of dates
> > starting at the first of the month until it is past the second date.
> > This works using standard recursion but I wanted to use TCO.
>
> > Any help is most appreciated (as usual...!)
>
> > Thanks
>
> > Base
>
> > (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))
>
> In this case, you're calling cons with the result of the recur, which
> means it happens "after" the recur, which is the error.
>
> I suspect your original wasn't tail recursive, since the two loop
> arguments are two dates (assuming my guesses about time/before? are
> correct), and the values in the list you returns would be stored on
> the call stack, to be pasted together by the string of conses you've
> left to run after each recursive call.
>
> To make it tail recursive, you need to make the list you're going to
> return one of the arguments of the loop, adjust the code for that,
> then push the cons into the if, sort of like so:
>
> (defn date-seq
>   [d1 d2]
>   (loop [b (-> d1
>              (.dayOfMonth)
>              (.withMinimumValue))
>          e [d2]]
>    (if (time/before? b (first e))
>      (recur (.plusMonths b 1) (conj e b))
>      (reverse b
>
> This is just a swag; I'm not familiar enough with Java to reconstruct
> your arguments...
>
>       --
> Mike Meyer             http://www.mired.org/consulting.html
> Independent Network/Unix/Perforce consultant, email for more information.
>
> O< ascii ribbon campaign - stop html mail -www.asciiribbon.org
>
> --
> 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 your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group 
> athttp://groups.google.com/group/clojure?hl=en

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 collection might be nil).
> 
> (collection-like-map key) (get collection-like-map key)

Makes sense. Thanks.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 cons, this
call must return

I am not on a machine with clojure at the moment, but offhand you
probably want something shaped more like:

(defn date-seq [d1 d2]
  (let [b (-> d1 (.dayOfMonth) (.withMinimumValue))])
  (reverse (date-seq-helper b dend (list

(defn- date-seq-helper [dbot dend dates]
  (let [ndates (cons dbot dates)]
(if (time/before? dbot dend)
  (recur (.plusMonths dbot 1) dend ndates) ; Recurse from tail position
  ndates))) ; Or end the recursion

Please note that the tail recursion is in a tail position for the
helper call, meaning that there is no computation that must take place
after the call to recur returns.

- dlf


On Mon, May 17, 2010 at 2:36 PM, 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 function takes 2 joda dates and returns a sequence of dates
> starting at the first of the month until it is past the second date.
> This works using standard recursion but I wanted to use TCO.
>
> Any help is most appreciated (as usual...!)
>
> Thanks
>
> Base
>
>
> (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))
>
> --
> 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 your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en



-- 
-- 
Dave Fayram
dfay...@gmail.com

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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:38 pm, grav  wrote:
> > 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
>
> Getting "Wrong number of args passed to: basic$eval--986$compile-file-
> for-emacs" when usingC-cC-k
>
> Any advice?
>
> --
> 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 your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group 
> athttp://groups.google.com/group/clojure?hl=en

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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-plugin-2010-jan.nbm and
maven plugins

I d/l'd the labrepl from github from here: http://github.com/relevance/labrepl

Then simply went to Netbeans and did this:
* File -> Open Project
* Navigate to where you have d/l the labrepl  (parent dir to be exact)
* It should show in the file open dialog with a special "ma" icon.
Just click on this then click on "open project"

This will take a minute to open as it scans the project and gets the
deps from the maven repo.

* Now right click on the labrepl project and select "Start Project Repl".
* This will open a new window that says "Clojure Repl (labrepl):
* Punch this into this repl window and you're all set:
(require 'labrepl)
(labrepl/-main)

You can also right click on any of the .clj files and right click ->
load into repl.

hope this helps,
pratik

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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
 wrote:
>> 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 actor is that of parameter(s) to an infinitely tail-recursive
> function.
>
> 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 avoid deadlock, meaning that while you will
> not deadlock in the message passing system you can cause memory
> exhaustion.
>
> Disclaimer: While I've played with erlang I'm not really that into it,
> please correct me someone if I've misrepresented anything.
>
> --
> / Peter Schuller
>
> --
> 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 your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en



-- 
-- 
Dave Fayram
dfay...@gmail.com

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 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 Ubuntu.
>
> However, whenever I try to install swank-clojure or clojure, the
> package system reports:
>
> let: File exists:
> /home/metaperl/.emacs.d/elpa/clojure-mode-1.7.1/clojure-mode.el
>
>
> Manually removing the directory
> /home/metaperl/.emacs.d/elpa/clojure-mode-1.7.1 and trying again
> simply leads to the same error.
>
> Here is the output of M-x report-emacs-bug
>
> In GNU Emacs 23.2.1 (i686-pc-linux-gnu, GTK+ Version 2.18.3)
>  of 2010-05-14 on locohost
> Windowing system distributor `The X.Org Foundation', version 11.0.10604000
> configured using `configure  '--with-x-toolkit=gtk''
>
> Important settings:
>  value of $LC_ALL: nil
>  value of $LC_COLLATE: nil
>  value of $LC_CTYPE: nil
>  value of $LC_MESSAGES: nil
>  value of $LC_MONETARY: nil
>  value of $LC_NUMERIC: nil
>  value of $LC_TIME: nil
>  value of $LANG: en_US.UTF-8
>  value of $XMODIFIERS: nil
>  locale-coding-system: utf-8-unix
>  default enable-multibyte-characters: t
>
> Major mode: Apropos
>
> Minor modes in effect:
>  desktop-save-mode: t
>  shell-dirtrack-mode: t
>  show-paren-mode: t
>  global-auto-revert-mode: t
>  tooltip-mode: t
>  mouse-wheel-mode: t
>  menu-bar-mode: t
>  file-name-shadow-mode: t
>  global-font-lock-mode: t
>  font-lock-mode: t
>  blink-cursor-mode: t
>  auto-encryption-mode: t
>  auto-compression-mode: t
>  line-number-mode: t
>  transient-mark-mode: t
>
> Recent input:
>   
>   
>   
>
>
>   
>   
>
> C-x 2 C-x b * m e s  C-p C-p C-p C-p C-p C-p
> C-p C-p C-p C-p C-p C-p C-p C-v C-l  
> 
>
>
>   
> 
>
> i x C-x o C-x o C-x d   g n n n
> n ! r m SPC - r f  g C-x o x y e s 
> ESC < C-x o ESC > C-x b *  ESC > 
>
>
>g
> p p v C-x k  p p p p p v ESC > C-x k 
>
>
>   
>   
>   
>
>   
> 
> 
>
>
>
>   
>   
>   
>
>   
>   
>   
>
> x
>
>   
>
>
>  ESC x m e a c s -  
> e m
> a c s - b uC-g  a b u g 
> C-x o C-v C-s e m a s c ESC x r e p o r t e 
> - e m  
>
> Recent messages:
> byte-code: Beginning of buffer
> Mark set
> Contacting host: tromey.com:80
> Reading [text/plain]... 28k of 28k (100%)
> Reading... done.
> let: File exists:
> /home/metaperl/.emacs.d/elpa/clojure-mode-1.7.1/clojure-mode.el
> byte-code: End of buffer [2 times]
> Quit
> Type M-x display-buffer RET to restore the other window.
> Mark saved where search started
>
> Load-path shadows:
> ~/emacs-contrib/cperl-mode hides ~/emacs/cperl-mode
> ~/emacs/table hides /usr/local/share/emacs/23.2/lisp/textmodes/table
> ~/emacs-contrib/prolog hides
> /usr/local/share/emacs/23.2/lisp/progmodes/prolog
> ~/emacs-contrib/cperl-mode hides
> /usr/local/share/emacs/23.2/lisp/progmodes/cperl-mode
>
> Features:
> (shadow sort mail-extr message ecomplete rfc822 mml mml-sec mm-decode
> mm-bodies mm-encode mailabbrev nnheader gmm-utils mailheader canlock
> sha1 hex-util hashcash emacsbug clojure-mode-autoloads
> slime-repl-autoloads slime-autoloads derived gud noutline outline
> apropos arc-mode archive-mode pp thingatpt warnings byte-opt compile
> bytecomp byte-compile autoload mail-utils url-cache url-http tls
> mail-parse rfc2231 rfc2047 rfc2045 qp ietf-drums url-gw url-auth url
> url-proxy url-privacy url-expand url-methods url-history url-cookie
> url-util url-parse timezone url-vars mm-util mail-prsvr mailcap
> help-mode debug nroff-mode multi-isearch view vc-git dired-x dired-aux
> dired package init-window-system color-theme-random color-theme wid-edit
> sendmail reporter menu-bar+ init-windows-xp init-standard-packages
> desktop ido shell-current-directory ansi-color uniquify tramp-imap
> tramp-gw tramp-fish tramp-smb tramp-cache tramp-ftp tramp-cmds tramp
> auth-source gnus-util netrc time-date advice help-fns advice-preload
> shell comint password-cache format-spec tramp-compat trampver
> init-settings paren init-set-key init-emacs hideshow-org easy-mmode
> edmacro kmacro hideshow pastebin autorevert init-functions emacs-contrib
> cperl-mode regexp-opt cl cl-19 info etags ring easymenu imenu man assoc
> tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd
> font-setting tool-bar dnd fontset image fringe lisp-mode register page
> menu-bar rfn-eshadow timer select scroll-bar mldrag mouse jit-lock
> font-lock syntax facemenu font-core frame cham georgian utf-8-lang
> misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew
> greek romanian slovak czech european ethiopic indian cyrillic chinese
> case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button
> minibuffer fac

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))
#'user/foo
user> foo
#
user> (send foo (fn[num] (do (println num) (inc num
#

I ran the exact same code in command-line and the thread could print
the output fine.

Clojure 1.1.0-master-SNAPSHOT
user=> (def foo (agent 0))
#'user/foo
user=> foo
#
user=> (send foo (fn[num] (do (println num) (inc num) )))
0
#

I installed everything from elpa, so I guess some of the component
might gone wrong. Any idea ?

thanks.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 call them. You write the functions for your application
and plug them into the libraries of well-defined messaging behavior.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 example first; find (gather all ints in a vector larger than
some given int...

(defn gather-ints
  [x coll-ints]
  (loop [s-ints (seq coll-ints) v-out []]
(if (nil? s-ints) v-out
  (let [i (first s-ints)
v-out (if (> i x) (conj v-out i) v-out)]
(recur (next s-ints) v-out)

(gather-ints 3 [1 2 3 4 5 6])
=> [4 5 6]

Note that you can access all bindings in lexical scope, e.g x. Also
see how v-out is reused (like a variable, but its not - its just the
name rebound to a new value. We use seq of the collection which
returns either nil or a sequable to which you use next for the next
item. This is idiomatic for clojure for loop/recur.

Now for your problem;

(defn date-seq
  [d1 d2]
  (loop [b (-> d1 (.dayOfMonth)
 (.withMinimumValue))
 v-out [] ]
(if (time/before? b e)
  (recur (.plusMonths b 1) (conj v-out b))
  v-out)))

-Hth, Adrian.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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 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 Ubuntu.
>
> However, whenever I try to install swank-clojure or clojure, the
> package system reports:
>
> let: File exists:
> /home/metaperl/.emacs.d/elpa/clojure-mode-1.7.1/clojure-mode.el
>
> Manually removing the directory
> /home/metaperl/.emacs.d/elpa/clojure-mode-1.7.1 and trying again
> simply leads to the same error.
>
> Here is the output of M-x report-emacs-bug
>
> In GNU Emacs 23.2.1 (i686-pc-linux-gnu, GTK+ Version 2.18.3)
>  of 2010-05-14 on locohost
> Windowing system distributor `The X.Org Foundation', version 11.0.10604000
> configured using `configure  '--with-x-toolkit=gtk''
>
> Important settings:
>   value of $LC_ALL: nil
>   value of $LC_COLLATE: nil
>   value of $LC_CTYPE: nil
>   value of $LC_MESSAGES: nil
>   value of $LC_MONETARY: nil
>   value of $LC_NUMERIC: nil
>   value of $LC_TIME: nil
>   value of $LANG: en_US.UTF-8
>   value of $XMODIFIERS: nil
>   locale-coding-system: utf-8-unix
>   default enable-multibyte-characters: t
>
> Major mode: Apropos
>
> Minor modes in effect:
>   desktop-save-mode: t
>   shell-dirtrack-mode: t
>   show-paren-mode: t
>   global-auto-revert-mode: t
>   tooltip-mode: t
>   mouse-wheel-mode: t
>   menu-bar-mode: t
>   file-name-shadow-mode: t
>   global-font-lock-mode: t
>   font-lock-mode: t
>   blink-cursor-mode: t
>   auto-encryption-mode: t
>   auto-compression-mode: t
>   line-number-mode: t
>   transient-mark-mode: t
>
> Recent input:
>   
>   
>   
>
>
>   
>   
>
> C-x 2 C-x b * m e s  C-p C-p C-p C-p C-p C-p
> C-p C-p C-p C-p C-p C-p C-p C-v C-l  
> 
>
>
>   
> 
>
> i x C-x o C-x o C-x d   g n n n
> n ! r m SPC - r f  g C-x o x y e s 
> ESC < C-x o ESC > C-x b *  ESC > 
>
>
>g
> p p v C-x k  p p p p p v ESC > C-x k 
>
>
>   
>   
>   
>
>   
> 
> 
>
>
>
>   
>   
>   
>
>   
>   
>   
>
> x
>
>   
>
>
>  ESC x m e a c s -  
> e m
> a c s - b uC-g  a b u g 
> C-x o C-v C-s e m a s c ESC x r e p o r t e 
> - e m  
>
> Recent messages:
> byte-code: Beginning of buffer
> Mark set
> Contacting host: tromey.com:80
> Reading [text/plain]... 28k of 28k (100%)
> Reading... done.
> let: File exists:
> /home/metaperl/.emacs.d/elpa/clojure-mode-1.7.1/clojure-mode.el
> byte-code: End of buffer [2 times]
> Quit
> Type M-x display-buffer RET to restore the other window.
> Mark saved where search started
>
> Load-path shadows:
> ~/emacs-contrib/cperl-mode hides ~/emacs/cperl-mode
> ~/emacs/table hides /usr/local/share/emacs/23.2/lisp/textmodes/table
> ~/emacs-contrib/prolog hides /usr/local/share/emacs/23.2/lisp/progmodes/prolog
> ~/emacs-contrib/cperl-mode hides
> /usr/local/share/emacs/23.2/lisp/progmodes/cperl-mode
>
> Features:
> (shadow sort mail-extr message ecomplete rfc822 mml mml-sec mm-decode
> mm-bodies mm-encode mailabbrev nnheader gmm-utils mailheader canlock
> sha1 hex-util hashcash emacsbug clojure-mode-autoloads
> slime-repl-autoloads slime-autoloads derived gud noutline outline
> apropos arc-mode archive-mode pp thingatpt warnings byte-opt compile
> bytecomp byte-compile autoload mail-utils url-cache url-http tls
> mail-parse rfc2231 rfc2047 rfc2045 qp ietf-drums url-gw url-auth url
> url-proxy url-privacy url-expand url-methods url-history url-cookie
> url-util url-parse timezone url-vars mm-util mail-prsvr mailcap
> help-mode debug nroff-mode multi-isearch view vc-git dired-x dired-aux
> dired package init-window-system color-theme-random color-theme wid-edit
> sendmail reporter menu-bar+ init-windows-xp init-standard-packages
> desktop ido shell-current-directory ansi-color uniquify tramp-imap
> tramp-gw tramp-fish tramp-smb tramp-cache tramp-ftp tramp-cmds tramp
> auth-source gnus-util netrc time-date advice help-fns advice-preload
> shell comint password-cache format-spec tramp-compat trampver
> init-settings paren init-set-key init-emacs hideshow-org easy-mmode
> edmacro kmacro hideshow pastebin autorevert init-functions emacs-contrib
> cperl-mode regexp-opt cl cl-19 info etags ring easymenu imenu man assoc
> tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd
> font-setting tool-bar dnd fontset image fringe lisp-mode register page
> menu-bar rfn-eshadow timer select scroll-bar mldrag mouse jit-lock
> font-lock syntax facemenu font-core frame cham georgian utf-8-lang
> misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew
> g

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))

Yes. This is more or less the way lazy-seq is used.
However I would move the check outside the cons. Then
you get an empty sequence if d1 is initially after d2.
This would seem as a reasonable behaviour. (Now you get
a sequence containing d1.)

Also a one-branched if is usually written as when.

(defn date-seq
  [d1 d2]
  (let [start (-> d1 .dayOfMonth .withMinimumValue)]
(lazy-seq
  (when (joda/before? start d2)
(cons start (date-seq (.plusMonths start 1) d2))

I don't see why transforming this into a TC form should
bring any benefit. The only reason I can think of is a
performance optimisation. Then see Adrian's answer.

Although not your question: In this case you also easily
use Clojure's seq library to get your sequence.

(defn date-seq
  [d1 d2]
  (let [start (-> d1 .dayOfMonth .withMinimumValue)]
(take-while #(joda/before? % d2) (iterate #(.plusMonths % 1)
start

Sincerely
Meikel

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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))
>
> The lazy version worked like a champ and appears (to me) to be more in
> the vain of Lisp (with a touch of Haskell).
> Is the author of the blog correct about using lazy seq in this way?
> Assuming that he is correct and I converted date-seq to a loop/recur
> format to use TCO, would one of these be preferable over the other in
> terms of idiomatic clojure?

The lazy version is more idiomatic. By default, you should make
sequences lazy unless there is a compelling reason to do otherwise.

In this case it also avoids the stack building problem that the
recursive version has.

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


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. The claim is rather that
the intended fundamental model implemented by an actor is not one of
shared mutable state.

-- 
/ Peter Schuller

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en