Re: first element after an element in the sorted-set?

2011-05-23 Thread Sunil S Nandihalli
finger-trees would have solved the problem .. but unfortunately it is not
part of the clojure distro yet.. :(

On Tue, May 24, 2011 at 11:53 AM, Sunil S Nandihalli <
sunil.nandiha...@gmail.com> wrote:

> that may be inefficient for a large-set..? I was hoping it would be
> log(n)..
>
>
> On Tue, May 24, 2011 at 11:45 AM, Michael Wood  wrote:
>
>> On 24 May 2011 08:07, Sunil S Nandihalli 
>> wrote:
>> > Hello everybody,
>> > is there a function to find the first element after an element in the
>> > sorted-set?
>> > (first-element-after 3 (sorted-set 1 2 3 4 5 6))
>> > should return 4?
>>
>> How about this?:
>>
>> (first (drop-while (partial >= 3) (sorted-set 1 2 3 4 5 6)))
>>
>> --
>> Michael Wood 
>>
>> --
>> 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: first element after an element in the sorted-set?

2011-05-23 Thread Sunil S Nandihalli
that may be inefficient for a large-set..? I was hoping it would be log(n)..


On Tue, May 24, 2011 at 11:45 AM, Michael Wood  wrote:

> On 24 May 2011 08:07, Sunil S Nandihalli 
> wrote:
> > Hello everybody,
> > is there a function to find the first element after an element in the
> > sorted-set?
> > (first-element-after 3 (sorted-set 1 2 3 4 5 6))
> > should return 4?
>
> How about this?:
>
> (first (drop-while (partial >= 3) (sorted-set 1 2 3 4 5 6)))
>
> --
> Michael Wood 
>
> --
> 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: first element after an element in the sorted-set?

2011-05-23 Thread Michael Wood
On 24 May 2011 08:07, Sunil S Nandihalli  wrote:
> Hello everybody,
> is there a function to find the first element after an element in the
> sorted-set?
> (first-element-after 3 (sorted-set 1 2 3 4 5 6))
> should return 4?

How about this?:

(first (drop-while (partial >= 3) (sorted-set 1 2 3 4 5 6)))

-- 
Michael Wood 

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


first element after an element in the sorted-set?

2011-05-23 Thread Sunil S Nandihalli
Hello everybody,
is there a function to find the first element after an element in the
sorted-set?

(first-element-after 3 (sorted-set 1 2 3 4 5 6))

should return 4?

thanks,
Sunil.

-- 
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: Passing "environment configuration parameters" to a Clojure web app

2011-05-23 Thread Shantanu Kumar
> This assumes you have a ServletContextListener or equivalent in place
> to read on deployment.
>
> This is quick and dirty. I'd definitely like to see something better emerge.

I noticed this: http://j.mp/l5vsjS -- looks like it suits the workflow
you described.

Regards,
Shantanu

-- 
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: interest in STM, where can I start to get knowing well about it?

2011-05-23 Thread jaime
huh, I do not know this topic well, any good resource for this??

On May 19, 3:59 pm, MohanR  wrote:
> So I think readng the actual STM source with Java' features might
> help.
>
> Are there actually books on this topic ? Peter Van roy's Data flow
> concurrency book ?
>
> Thanks,
> Mohan

-- 
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: interest in STM, where can I start to get knowing well about it?

2011-05-23 Thread jaime
Tom,

I had a fast view on the first several slides (slides about your MC-
STM implementation version 1), and found it concise and precise and
could be a good resource for demonstration/comprehension on basic STM
concepts/mechanism. Great job! I will definitely come back to this
useful slide when I have more time :-)

Thanks,
Jaime

On May 24, 12:50 am, Tom Van Cutsem  wrote:
> If you are more interested in the semantics of STM (such as "how is commute
> different from alter?"), rather than in the actual Java implementation, I
> wrote a little "meta-circular" STM system in Clojure that could be helpful:
> 
>
> Kind regards,
> Tom
>
> 2011/5/19 MohanR 
>
>
>
>
>
>
>
> > So I think readng the actual STM source with Java' features might
> > help.
>
> > Are there actually books on this topic ? Peter Van roy's Data flow
> > concurrency book ?
>
> > Thanks,
> > Mohan
>
> > --
> > 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: Functional Blackjack in Clojure

2011-05-23 Thread David Nolen
On Mon, May 23, 2011 at 5:02 PM, Sam Ritchie  wrote:

> Hey all,
>
> As an exercise in Clojure, I recently went about implementing a functional
> version of BlackJack, and wanted to post it here for everyone's perusal. The
> goal here was to write idiomatic code with good testing and documentation,
> and, hopefully, to provide the basis for an example of a well structured
> project, for newcomers to the language. I'd really love any input and advice
> on how to improve the code, with an eye toward making it really accessible
> to newcomers.
>
> Here's the code: https://github.com/sritchie/blackjack
>
> To get it working, run
>
> git clone git://github.com/sritchie/blackjack.git
> cd blackjack
> lein deps
>
> And then, to run the game from the REPL (slower):
>
> lein repl
> blackjack.core=> (-main)
>
> Or from the uberjar (faster):
>
> lein uberjar
> java -jar blackjack-0.0.1-SNAPSHOT-standalone.jar
>
> Looking forward to hearing what you all have to say!
> ~Sam
>

Code looks nice! No other feedback to provide beyond that :)

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

Re: Passing "environment configuration parameters" to a Clojure web app

2011-05-23 Thread Allen Johnson
On a related note. About a month or two ago I started work on a patch
for lein-ring so you'd have more control over the web.xml that is
generated. This was motivated by the desire to use the container's
datasource instead of creating one yourself. If anyone is interested I
can finish this up and contact weavejester to see if it's something
worth incorporating.

https://github.com/mefesto/lein-ring/commit/3016142e1c7aadc77d273453e04f9196319406a2

Allen

On Mon, May 23, 2011 at 7:43 PM, Allen Johnson  wrote:
> I'm also interested in this topic. It was discussed briefly on the
> clojure-web-dev mailing list a little while ago. What I've been doing
> is something like this:
>
> # lein ring project
> myapp/
>  config/
>    production/WEB-INF/myapp.properties
>    development/WEB-INF/myapp.properties
>    test/WEB-INF/myapp.properties
>  src/
>  project.clj
>
> $ # create war file
> $ lein ring uberwar
>
> $ # update configuration for production
> $ jar uvf myapp.war -C config/production .
>
> $ # or... update configuration for development server
> $ jar uvf myapp.war -C config/development .
>
> This assumes you have a ServletContextListener or equivalent in place
> to read on deployment.
>
> This is quick and dirty. I'd definitely like to see something better emerge.
>
> Allen
>
> On Mon, May 23, 2011 at 3:59 PM, Shantanu Kumar
>  wrote:
>> Hello Laurent, Quite interesting points there.
>>
>> Yes, I agree - having confidential config (production etc.) in code
>> base is not advisable. The reason I mentioned that though, was because
>> I was trying to cover a gamut of workflows the situation may demand.
>> One one extreme there may be a company where no developer gets to
>> touch production servers and must develop for a target config
>> constraint. On the other a set of developers who routinely deploy to
>> production and can get away with changing deployment practices on the
>> fly.
>>
>> What I would like to emphasize is to distinguish one environment from
>> the other (the code base may contain dummy config data in version
>> control.) A developer can change the dev config to a valid setup, and
>> similarly the person who builds for production deployment can change
>> the config locally (without committing the config details back to the
>> version control) and build a deployable bundle.
>>
>> An added level of indirection (where a config script loads details
>> from either a discoverable or a fixed resource) can bring some
>> flexibility -- the Ops guys can even edit config and re-start the app.
>> Though web container specific and servlet specific solutions are
>> useful for many cases, I am not sure I would recommend that as a
>> general practice -- for example, what am I to do if I have to deploy
>> my code to Netty/Aleph? IMHO ideally a Clojure webapp should be easily
>> buildable/deployable as a WAR (or EAR :-\) for web containers like
>> Tomcat/JBoss etc., but it may not depend on one.
>>
>> How to accomplish such builds where we cherry pick config stuff when
>> building for a certain environment (and how it integrates with the
>> development workflow) is a different aspect. I think I have seen
>> Apache Ant gives sufficient flexibility to do these things. Maybe
>> Leiningen can deliver some of the same things using plugins.
>>
>> Regards,
>> Shantanu
>>
>> On May 23, 12:48 pm, Laurent PETIT  wrote:
>>> Hello,
>>>
>>> Thanks for answering !
>>>
>>> My remarks follow:
>>>
>>> 2011/5/22 Shantanu Kumar :
>>>
>>> > I have wondered about this problem and at the first glance it looked
>>> > straightforward to me to put moving parts (config elements that could
>>> > change) into dynamic vars/atoms/refs. The production env can use the
>>> > default config, and anything else (dev, testing) can alter the default
>>> > config to override the settings.
>>>
>>> The idea of having production settings in the codebase as "default
>>> values" doesn't feel right to me -in general- (and in my particular
>>> case).
>>> Generally, some of these info are confidential, and their lifecycle
>>> does not match the lifecycle of the product.
>>>
>>> > The dev/testing should have different
>>> > entry point (may be in "test" directory, as opposed to "src") than the
>>> > prod version. That said, the config elements themselves can be loaded
>>> > from certain config files. If it's a web app, you can bundle config in
>>> > file(s) in WEB-INF and load from there on init -- now that leads to a
>>> > complicated build process because you cherry pick the config file (for
>>> > staging, prod or integration test?) for the build target.
>>>
>>> > Another complexity might arise where the config must be used to carry
>>> > out certain stateful initialization to be useful to the app. How do
>>> > you gracefully handle the errors? So we go back to some mutable flag
>>> > that gives the go-ahead. Ugh!
>>>
>>> For what you describe, there are ways (as far as I remember) to manage
>>> this with webapps, I think. By placing an HttpFilter/Listener 

Re: Clojure, Swank, and Leiningen with Emacs on Mac OS X

2011-05-23 Thread Tom Hicks
> :dev-dependencies [[swank-clojure "1.2.1"]])

I think this is an outdated dependency. I got it to work with 1.4.0-
SNAPSHOT.
(1.2.1 is, of course, the latest stable clojure.jar version, so this
might have
been a typo from your previous experiments).
   good luck   -t


On May 22, 1:53 am, dokondr  wrote:
> Hello,
> I am trying to install Clojure tools on Mac OS X according to the
> instructions:
> "Clojure, Swank, and Leiningen with Emacs on 
> Linux"http://riddell.us/ClojureSwankLeiningenWithEmacsOnLinux.html
>
> Everything goes fine until these steps:
>
> ~$ lein deps
>
> ~$ lein swank
>
> In my project.clj I have:
>
> (defproject test-project "0.1.0"
>   :description "Test Project"
>   :dependencies [[org.clojure/clojure "1.3.0-master-SNAPSHOT"]
>                  [org.clojure/clojure-contrib "1.3.0-SNAPSHOT"]]
>   :dev-dependencies [[swank-clojure "1.2.1"]])
>
> Running 'lein deps' gives these errors:
>
> Downloading: org/clojure/clojure-contrib/1.3.0-SNAPSHOT/clojure-
> contrib-1.3.0-SNAPSHOT.pom from cloju\
> re-snapshots
> Downloading: org/clojure/clojure-contrib/1.3.0-SNAPSHOT/clojure-
> contrib-1.3.0-SNAPSHOT.pom from cloja\
> rs
> Downloading: org/clojure/clojure-contrib/1.3.0-SNAPSHOT/clojure-
> contrib-1.3.0-SNAPSHOT.jar from cloju\
> re-snapshots
> Downloading: org/clojure/clojure-contrib/1.3.0-SNAPSHOT/clojure-
> contrib-1.3.0-SNAPSHOT.jar from cloja\
> rs
> An error has occurred while processing the Maven artifact tasks.
>  Diagnosis:
>
> Unable to resolve artifact: Missing:
> --
> 1) org.clojure:clojure-contrib:jar:1.3.0-SNAPSHOT
>
>   Try downloading the file manually from the project website.
>
>   Then, install it using the command:
>       mvn install:install-file -DgroupId=org.clojure -
> DartifactId=clojure-contrib -Dversion=1.3.0-SNA\
> PSHOT -Dpackaging=jar -Dfile=/path/to/file
>
>   Alternatively, if you host your own repository you can deploy the
> file there:
>       mvn deploy:deploy-file -DgroupId=org.clojure -
> DartifactId=clojure-contrib -Dversion=1.3.0-SNAPS\
> HOT -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -
> DrepositoryId=[id]
>
>   Path to dependency:
>         1) org.apache.maven:super-pom:jar:2.0
>         2) org.clojure:clojure-contrib:jar:1.3.0-SNAPSHOT
>
> When  I run 'lein swank' I get:
>
> "That's not a task. Use "lein help" to list all tasks."
>
> Any ideas how to install these tools without so much pain?
>
> Thanks,
> Dmitri

-- 
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: Passing "environment configuration parameters" to a Clojure web app

2011-05-23 Thread Allen Johnson
I'm also interested in this topic. It was discussed briefly on the
clojure-web-dev mailing list a little while ago. What I've been doing
is something like this:

# lein ring project
myapp/
  config/
production/WEB-INF/myapp.properties
development/WEB-INF/myapp.properties
test/WEB-INF/myapp.properties
  src/
  project.clj

$ # create war file
$ lein ring uberwar

$ # update configuration for production
$ jar uvf myapp.war -C config/production .

$ # or... update configuration for development server
$ jar uvf myapp.war -C config/development .

This assumes you have a ServletContextListener or equivalent in place
to read on deployment.

This is quick and dirty. I'd definitely like to see something better emerge.

Allen

On Mon, May 23, 2011 at 3:59 PM, Shantanu Kumar
 wrote:
> Hello Laurent, Quite interesting points there.
>
> Yes, I agree - having confidential config (production etc.) in code
> base is not advisable. The reason I mentioned that though, was because
> I was trying to cover a gamut of workflows the situation may demand.
> One one extreme there may be a company where no developer gets to
> touch production servers and must develop for a target config
> constraint. On the other a set of developers who routinely deploy to
> production and can get away with changing deployment practices on the
> fly.
>
> What I would like to emphasize is to distinguish one environment from
> the other (the code base may contain dummy config data in version
> control.) A developer can change the dev config to a valid setup, and
> similarly the person who builds for production deployment can change
> the config locally (without committing the config details back to the
> version control) and build a deployable bundle.
>
> An added level of indirection (where a config script loads details
> from either a discoverable or a fixed resource) can bring some
> flexibility -- the Ops guys can even edit config and re-start the app.
> Though web container specific and servlet specific solutions are
> useful for many cases, I am not sure I would recommend that as a
> general practice -- for example, what am I to do if I have to deploy
> my code to Netty/Aleph? IMHO ideally a Clojure webapp should be easily
> buildable/deployable as a WAR (or EAR :-\) for web containers like
> Tomcat/JBoss etc., but it may not depend on one.
>
> How to accomplish such builds where we cherry pick config stuff when
> building for a certain environment (and how it integrates with the
> development workflow) is a different aspect. I think I have seen
> Apache Ant gives sufficient flexibility to do these things. Maybe
> Leiningen can deliver some of the same things using plugins.
>
> Regards,
> Shantanu
>
> On May 23, 12:48 pm, Laurent PETIT  wrote:
>> Hello,
>>
>> Thanks for answering !
>>
>> My remarks follow:
>>
>> 2011/5/22 Shantanu Kumar :
>>
>> > I have wondered about this problem and at the first glance it looked
>> > straightforward to me to put moving parts (config elements that could
>> > change) into dynamic vars/atoms/refs. The production env can use the
>> > default config, and anything else (dev, testing) can alter the default
>> > config to override the settings.
>>
>> The idea of having production settings in the codebase as "default
>> values" doesn't feel right to me -in general- (and in my particular
>> case).
>> Generally, some of these info are confidential, and their lifecycle
>> does not match the lifecycle of the product.
>>
>> > The dev/testing should have different
>> > entry point (may be in "test" directory, as opposed to "src") than the
>> > prod version. That said, the config elements themselves can be loaded
>> > from certain config files. If it's a web app, you can bundle config in
>> > file(s) in WEB-INF and load from there on init -- now that leads to a
>> > complicated build process because you cherry pick the config file (for
>> > staging, prod or integration test?) for the build target.
>>
>> > Another complexity might arise where the config must be used to carry
>> > out certain stateful initialization to be useful to the app. How do
>> > you gracefully handle the errors? So we go back to some mutable flag
>> > that gives the go-ahead. Ugh!
>>
>> For what you describe, there are ways (as far as I remember) to manage
>> this with webapps, I think. By placing an HttpFilter/Listener in front
>> of the servlet, etc. (not sure about the details)
>>
>> > If the config element is common enough (e.g. database coords), it
>> > might make sense to go for convention-based settings that remains more
>> > or less the same. I have experimented a bit on this here:
>> >https://bitbucket.org/kumarshantanu/clj-dbcp/src(jump to the section
>> > "Create DataSource from .properties file") - I am interested in
>> > knowing what others think about this.
>>
>> Yes, to some extent convention settings can work. But it's not rare to
>> have some intermediate servers (dev's computer, test server) run on
>> e.g. Linux, and someti

Re: Contagious BigDecimals?

2011-05-23 Thread pmbauer
(re: why then...)
P.S.
I mean in more general context of how double contagion is handled in most 
languages.
Clojure 1.3 alphas auto-promote floats to doubles in almost every case eg. 
exception: (type (float 1.0))

On Monday, May 23, 2011 4:16:48 PM UTC-7, pmbauer wrote:
>
> If you add an inexact number and an exact number, the only thing that
>> makes sense is to return something that is inexact.
>
>
> So why then are double's contagious when mixing double and float values in 
> a calculation? 
> Doubles and floats are both inexact, but floats are at least less exact 
> than doubles.
>

-- 
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: Contagious BigDecimals?

2011-05-23 Thread pmbauer

>
> If you add an inexact number and an exact number, the only thing that
> makes sense is to return something that is inexact.


So why then are double's contagious when mixing double and float values in a 
calculation? 
Doubles and floats are both inexact, but floats are at least less exact than 
doubles.

-- 
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: Contagious BigDecimals?

2011-05-23 Thread Mark Engelberg
doubles are inherently inexact; they are approximations of a real number.
If you add an inexact number and an exact number, the only thing that
makes sense is to return something that is inexact.

BigInt contagion is different, because you are adding two exact
things, it's just a question of internal representation.

-- 
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: Parameterizing project.clj

2011-05-23 Thread Phil Hagelberg
On May 23, 6:19 am, Rasmus Svensson  wrote:
>     (defproject foo 1.0.0
>       ...the usual stuff...
>       :aws {:access-key ~access-key
>                :secret-key ~secret-key}

This is good advice, but you can also use leiningen.core/user-
settings, which returns a map of user-level configuration. This should
be set in ~/.lein/init.clj using (def settings {:aws {:access-key
"[...]"}})

-Phil

-- 
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: Navigating to Clojure Source using Emacs' Find Source Command

2011-05-23 Thread Simon Katz
On Mon, May 23, 2011 at 15:11, Simon Katz  wrote:

> On Mon, May 23, 2011 at 14:36, Simon Katz  wrote:
>
>> On Sun, May 22, 2011 at 03:35, Phil Hagelberg  wrote:
>>
>>> On May 21, 1:28 pm, Simon Katz  wrote:
>>> > I'm having trouble using Emacs' Find Source command to navigate to
>>> > Clojure source.
>>> >
>>> > I'm using Leiningen (1.4.2) and Emacs (23.2).
>>>
>>> > I thought this would be enough to allow the Emacs Find Source command
>>> > (meta-.) to find Clojure source code.  But when, for example, I try
>>> > meta-. on reduce, Emacs jumps to a buffer showing this line...
>>>
>>> Works fine for me. Would need more details to debug. How did you
>>> install slime? How did you launch and connect to the swank server?
>>> From what buffer did you invoke M-.? What does C-h c say about M-.
>>> from that buffer?
>>>
>>> -Phil
>>
>>
>> Thanks for confirming it should work.
>>
>> I should also have mentioned:
>>
>> - I have the behaviour I'm describing on Windows XP and Windows Vista.
>>
>> - M-. works ok to find my own definitions.
>>
>> I've now installed an unzip.exe (from
>> http://gnuwin32.sourceforge.net/packages/unzip.htm),
>> and now when I try M-. on reduce I get the line
>>   caution: filename not matched:  "clojure/core.clj"
>>   in a buffer described as
>>   core.clj (cloju...51 Clojure
>>  [...]/sk-mini-project-1-2-0/lib/clojure-1.2.0.jar:clojure/core.clj
>>
>> Googling led me to this...
>>   http://web.archiveorange.com/archive/v/UcW9CERUAfsCRJzpBo7s
>> which says there are issues with Emacs and unzipping on
>> Windows. I followed the suggestion there (in the post dated
>> Wed Dec 08 2010), but that just reverted me to the original behaviour
>> I described.
>>
>> Any further pointers would be appreciated!
>>
>> Here are the answers to Phil's questions in case any of these details
>> may be useful:
>>
>> - Looking back at my notes, I didn't explicitly install slime.  Does
>>   slime come as part of installing Clojure Mode and/or Swank Clojure in
>>   Emacs (using the package-list-packages command)?
>>
>> - I launch the swank server with
>> lein swank
>>
>> - I connect to the swank server with
>> M-x slime-connect
>>
>> - I have the behaviour I described when using M-. from either a REPL or
>>   from a buffer displaying a .clj file in Clojure mode.
>>
>> - C-h c for both the REPL and Clojure mode says "M-. runs the command
>>   slime-edit-definition".
>>
>> Simon
>>
>
> Replying to myself...
>
> Actually, following the advice at...
>   http://web.archiveorange.com/archive/v/UcW9CERUAfsCRJzpBo7s
> ...(in the post dated Wed Dec 08 2010) gives rise to different behaviours
> on my XP machine and my Vista machine.  On the XP machine, I get the
> behaviour I described originally but on the Vista machine I still get the
> "caution: filename not matched" behaviour.
>
> The only difference I can find in the two Emacs installations is that the
> XP installation has clojure-test-mode-1.5.1 and the Vista installation does
> not.
>
> Simon
>

Replying to myself again...

In fact, the advice at
http://web.archiveorange.com/archive/v/UcW9CERUAfsCRJzpBo7s does work -- it
was me that was malfunctioning.  Problem solved.

Simon

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

Functional Blackjack in Clojure

2011-05-23 Thread Sam Ritchie
Hey all,

As an exercise in Clojure, I recently went about implementing a functional
version of BlackJack, and wanted to post it here for everyone's perusal. The
goal here was to write idiomatic code with good testing and documentation,
and, hopefully, to provide the basis for an example of a well structured
project, for newcomers to the language. I'd really love any input and advice
on how to improve the code, with an eye toward making it really accessible
to newcomers.

Here's the code: https://github.com/sritchie/blackjack

To get it working, run

git clone git://github.com/sritchie/blackjack.git
cd blackjack
lein deps

And then, to run the game from the REPL (slower):

lein repl
blackjack.core=> (-main)

Or from the uberjar (faster):

lein uberjar
java -jar blackjack-0.0.1-SNAPSHOT-standalone.jar

Looking forward to hearing what you all have to say!
~Sam

-- 
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: Passing "environment configuration parameters" to a Clojure web app

2011-05-23 Thread Shantanu Kumar
Hello Laurent, Quite interesting points there.

Yes, I agree - having confidential config (production etc.) in code
base is not advisable. The reason I mentioned that though, was because
I was trying to cover a gamut of workflows the situation may demand.
One one extreme there may be a company where no developer gets to
touch production servers and must develop for a target config
constraint. On the other a set of developers who routinely deploy to
production and can get away with changing deployment practices on the
fly.

What I would like to emphasize is to distinguish one environment from
the other (the code base may contain dummy config data in version
control.) A developer can change the dev config to a valid setup, and
similarly the person who builds for production deployment can change
the config locally (without committing the config details back to the
version control) and build a deployable bundle.

An added level of indirection (where a config script loads details
from either a discoverable or a fixed resource) can bring some
flexibility -- the Ops guys can even edit config and re-start the app.
Though web container specific and servlet specific solutions are
useful for many cases, I am not sure I would recommend that as a
general practice -- for example, what am I to do if I have to deploy
my code to Netty/Aleph? IMHO ideally a Clojure webapp should be easily
buildable/deployable as a WAR (or EAR :-\) for web containers like
Tomcat/JBoss etc., but it may not depend on one.

How to accomplish such builds where we cherry pick config stuff when
building for a certain environment (and how it integrates with the
development workflow) is a different aspect. I think I have seen
Apache Ant gives sufficient flexibility to do these things. Maybe
Leiningen can deliver some of the same things using plugins.

Regards,
Shantanu

On May 23, 12:48 pm, Laurent PETIT  wrote:
> Hello,
>
> Thanks for answering !
>
> My remarks follow:
>
> 2011/5/22 Shantanu Kumar :
>
> > I have wondered about this problem and at the first glance it looked
> > straightforward to me to put moving parts (config elements that could
> > change) into dynamic vars/atoms/refs. The production env can use the
> > default config, and anything else (dev, testing) can alter the default
> > config to override the settings.
>
> The idea of having production settings in the codebase as "default
> values" doesn't feel right to me -in general- (and in my particular
> case).
> Generally, some of these info are confidential, and their lifecycle
> does not match the lifecycle of the product.
>
> > The dev/testing should have different
> > entry point (may be in "test" directory, as opposed to "src") than the
> > prod version. That said, the config elements themselves can be loaded
> > from certain config files. If it's a web app, you can bundle config in
> > file(s) in WEB-INF and load from there on init -- now that leads to a
> > complicated build process because you cherry pick the config file (for
> > staging, prod or integration test?) for the build target.
>
> > Another complexity might arise where the config must be used to carry
> > out certain stateful initialization to be useful to the app. How do
> > you gracefully handle the errors? So we go back to some mutable flag
> > that gives the go-ahead. Ugh!
>
> For what you describe, there are ways (as far as I remember) to manage
> this with webapps, I think. By placing an HttpFilter/Listener in front
> of the servlet, etc. (not sure about the details)
>
> > If the config element is common enough (e.g. database coords), it
> > might make sense to go for convention-based settings that remains more
> > or less the same. I have experimented a bit on this here:
> >https://bitbucket.org/kumarshantanu/clj-dbcp/src(jump to the section
> > "Create DataSource from .properties file") - I am interested in
> > knowing what others think about this.
>
> Yes, to some extent convention settings can work. But it's not rare to
> have some intermediate servers (dev's computer, test server) run on
> e.g. Linux, and sometimes the final server run on Windows. Not to say
> that this places a strong constraint on the server.
>
> I've got some more ideas from friends of mine, one of which seems real
> interesting : leverage extensions provided by the servlet container
> (e.g. Tomcat) provider: tomcat provides a way to "extend" the
> classpath of the webapp via configuration : that way you can put in
> your externalized context.xml file a "VirtualWebAppLoader" and
> initialize it to add to the classloader of the webapp the contents of
> e.g. $catalina_home$/conf/myAppConfig/ directory. From them on, your
> webapp will be able to see your configuration files in the classpath,
> even so they're neither in WEB-INF/classes/ nor WEB-INF/libs/
> directories.
>
> Of course this technique will be limited to those servlet containers
> which provide similar classpath extension mechanism, so you need to be
> in control of the potent

Re: Books on Java Objects and Primitives

2011-05-23 Thread Armando Blancas
Maybe something like this:
Java for Programmers [Paperback]
Paul J. Deitel (Author), Harvey M. Deitel (Author)

You can start with the basics of the language and then move on to
using the libraries as needed. The docs api (linked above) is a great
reference but not a place for learning how to use those APIs.

On May 23, 9:16 am, octopusgrabbus  wrote:
> I apologize for not being clearer in why I asked this question. While
> learning Clojure, I thought it would be helpful to have some Java
> objects/primitives documentation to know what I can call in Clojure.
> Thanks and sorry for the too brief original post.
>
> On May 23, 10:01 am, octopusgrabbus  wrote:
>
>
>
> > What are some recent books that cover Java objects and primitives?- Hide 
> > quoted text -
>
> - Show quoted text -

-- 
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: RIncater

2011-05-23 Thread Ulises
Ugh!

Actually, I was more after a wrapper around the Rserve client more
than anything however RIncanter is the closest thing I could find.

>        Sortof.  The original author is updating thing so that they work more 
> cleanly.  In the interim if you want to get it to work modify the project.clj 
> to look like this: https://gist.github.com/962673.  Then comes the hard bit.  
> The JRI uses native libraries that upon compilation seem to hardlink in the 
> directory in which the R dynamic libs are saught.  So you either have to make 
> a static link R/Versions/ that points 2.10 to the Current.  Or, and this is 
> better, download JRI: http://www.rforge.net/JRI/snapshot/JRI_0.5-1.tar.gz 
> then compile up the dynamic libs (thus hardlinking your machine) and move 
> them to the appropriate subdirectory of ./native in your clojure project and 
> you should be good to go.

Eek! :(

U

-- 
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: Books on Java Objects and Primitives

2011-05-23 Thread octopusgrabbus
This was very helpful. Thanks.

On May 23, 12:36 pm, Chas Emerick  wrote:
> I'm still not certain what you're asking after here.  The JVM comes with a 
> sizable standard library, documented here:
>
> http://download.oracle.com/javase/6/docs/api/
>
> and then you have at your feet the entirety of the Java library ecosystem.  
> It's big.  Pending your obtaining the library(ies) you'd like to work with 
> and adding their jars to your classpath, you can call them using the interop 
> forms detailed here:
>
> http://clojure.org/java_interop
>
> Hopefully this is helpful?
>
> - Chas
>
> On May 23, 2011, at 12:16 PM, octopusgrabbus wrote:
>
> > I apologize for not being clearer in why I asked this question. While
> > learning Clojure, I thought it would be helpful to have some Java
> > objects/primitives documentation to know what I can call in Clojure.
> > Thanks and sorry for the too brief original post.
>
> > On May 23, 10:01 am, octopusgrabbus  wrote:
> >> What are some recent books that cover Java objects and primitives?
>
> > --
> > 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: We need a better way to handle errors.

2011-05-23 Thread Ken Wesson
On Mon, May 23, 2011 at 1:28 PM, Daniel Werner
 wrote:
> On May 23, 12:24 am, Aaron Bedra  wrote:
>> Have you signed a CA yet? If so, you can sign up for a confluence account
>> and start a wiki page around this.  This way the appropriate discussions and
>> review can take place and then possibly a JIRA ticket/patch to fix things
>> up.
>
> Discussions about improving Clojure error handling are already under
> way:
>
> http://dev.clojure.org/display/design/Error+Handling

Hmm.

> The RuntimeException wrapping problem seems not to have been brought
> up yet, though.

It would be simple, backward compatible with code that catches (or
lets slip) RuntimeException, and a substantial improvement to create a
ClojureRuntimeException subclass of RuntimeException and add a
function to core that takes an exception and, if it's a
ClojureRuntimeException instance, recurses down the .getCause() chain
until it isn't and then returns it. This would return the outermost
exception generated by an API and not wrapped by Clojure HOFs.

-- 
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

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

2011-05-23 Thread Laurent PETIT
2011/5/23 Daniel Werner :
> On May 22, 10:53 pm, Laurent PETIT  wrote:
>> Your discussion has been slowly getting me into the mindstate that
>> I'll add this missing "reindent whole file/current selection" feature
>> in CCW, AH !
>
> Or, perhaps into a separate library so we can use your reindenting
> feature in Emacs, VimClojure etc. as well? :-)

Clearly it will be added to paredit.clj, yes.

>
> --
> 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: Clojure stack

2011-05-23 Thread Daniel Werner
On May 22, 10:53 pm, Laurent PETIT  wrote:
> Your discussion has been slowly getting me into the mindstate that
> I'll add this missing "reindent whole file/current selection" feature
> in CCW, AH !

Or, perhaps into a separate library so we can use your reindenting
feature in Emacs, VimClojure etc. as well? :-)

-- 
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: We need a better way to handle errors.

2011-05-23 Thread Daniel Werner
On May 23, 12:24 am, Aaron Bedra  wrote:
> Have you signed a CA yet? If so, you can sign up for a confluence account
> and start a wiki page around this.  This way the appropriate discussions and
> review can take place and then possibly a JIRA ticket/patch to fix things
> up.

Discussions about improving Clojure error handling are already under
way:

http://dev.clojure.org/display/design/Error+Handling

The RuntimeException wrapping problem seems not to have been brought
up yet, though.

-- 
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: interest in STM, where can I start to get knowing well about it?

2011-05-23 Thread Tom Van Cutsem
If you are more interested in the semantics of STM (such as "how is commute
different from alter?"), rather than in the actual Java implementation, I
wrote a little "meta-circular" STM system in Clojure that could be helpful:


Kind regards,
Tom

2011/5/19 MohanR 

> So I think readng the actual STM source with Java' features might
> help.
>
> Are there actually books on this topic ? Peter Van roy's Data flow
> concurrency book ?
>
> Thanks,
> Mohan
>
> --
> 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: Books on Java Objects and Primitives

2011-05-23 Thread Chas Emerick
I'm still not certain what you're asking after here.  The JVM comes with a 
sizable standard library, documented here:

http://download.oracle.com/javase/6/docs/api/

and then you have at your feet the entirety of the Java library ecosystem.  
It's big.  Pending your obtaining the library(ies) you'd like to work with and 
adding their jars to your classpath, you can call them using the interop forms 
detailed here:

http://clojure.org/java_interop

Hopefully this is helpful?

- Chas

On May 23, 2011, at 12:16 PM, octopusgrabbus wrote:

> I apologize for not being clearer in why I asked this question. While
> learning Clojure, I thought it would be helpful to have some Java
> objects/primitives documentation to know what I can call in Clojure.
> Thanks and sorry for the too brief original post.
> 
> On May 23, 10:01 am, octopusgrabbus  wrote:
>> What are some recent books that cover Java objects and primitives?
> 
> -- 
> 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: Books on Java Objects and Primitives

2011-05-23 Thread octopusgrabbus
I apologize for not being clearer in why I asked this question. While
learning Clojure, I thought it would be helpful to have some Java
objects/primitives documentation to know what I can call in Clojure.
Thanks and sorry for the too brief original post.

On May 23, 10:01 am, octopusgrabbus  wrote:
> What are some recent books that cover Java objects and primitives?

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


Contagious BigDecimals?

2011-05-23 Thread Chas Emerick
Bigints are contagious, so (+ 1 XXXN) => XXYN.  It occurred to me to ask, Why 
aren't BigDecimals contagious as well?

As things stand, (+ 1.0 1e400M) => Infinity — doubles are contagious, even when 
operated over with BigDecimals.

I've never seen any discussion of BigDecimal contagion, so I assume my raising 
this question is merely revealing (again) my lack of understanding of 
floating-point representations and such.

The quorum in #clojure came up with some suggestions for why contagious 
BigDecimals might not be desirable/practical:

The management of precision is fundamentally too complicated and/or expensive.  
For example, providing a proper treatment of the differing levels of precision 
in e.g. (+ 1.0 1.15e400M) properly and efficiently may not be practical.
Big ints subset the set of longs, so the promotion is straightforward.  That's 
not the case for BigDecimals/doubles, where the latter's NaN and infinity 
values cannot be represented (AFAIK) by BigDecimal.
The semantics around scale and rounding aren't easily reconciled with Clojure's 
existing operators.  e.g.:

=> (/ 1M 3M)
#http://groups.google.com/group/clojure?hl=en

Re: Navigating to Clojure Source using Emacs' Find Source Command

2011-05-23 Thread Simon Katz
On Mon, May 23, 2011 at 14:36, Simon Katz  wrote:

> On Sun, May 22, 2011 at 03:35, Phil Hagelberg  wrote:
>
>> On May 21, 1:28 pm, Simon Katz  wrote:
>> > I'm having trouble using Emacs' Find Source command to navigate to
>> > Clojure source.
>> >
>> > I'm using Leiningen (1.4.2) and Emacs (23.2).
>>
>> > I thought this would be enough to allow the Emacs Find Source command
>> > (meta-.) to find Clojure source code.  But when, for example, I try
>> > meta-. on reduce, Emacs jumps to a buffer showing this line...
>>
>> Works fine for me. Would need more details to debug. How did you
>> install slime? How did you launch and connect to the swank server?
>> From what buffer did you invoke M-.? What does C-h c say about M-.
>> from that buffer?
>>
>> -Phil
>
>
> Thanks for confirming it should work.
>
> I should also have mentioned:
>
> - I have the behaviour I'm describing on Windows XP and Windows Vista.
>
> - M-. works ok to find my own definitions.
>
> I've now installed an unzip.exe (from
> http://gnuwin32.sourceforge.net/packages/unzip.htm),
> and now when I try M-. on reduce I get the line
>   caution: filename not matched:  "clojure/core.clj"
>   in a buffer described as
>   core.clj (cloju...51 Clojure
>  [...]/sk-mini-project-1-2-0/lib/clojure-1.2.0.jar:clojure/core.clj
>
> Googling led me to this...
>   http://web.archiveorange.com/archive/v/UcW9CERUAfsCRJzpBo7s
> which says there are issues with Emacs and unzipping on
> Windows. I followed the suggestion there (in the post dated
> Wed Dec 08 2010), but that just reverted me to the original behaviour
> I described.
>
> Any further pointers would be appreciated!
>
> Here are the answers to Phil's questions in case any of these details
> may be useful:
>
> - Looking back at my notes, I didn't explicitly install slime.  Does
>   slime come as part of installing Clojure Mode and/or Swank Clojure in
>   Emacs (using the package-list-packages command)?
>
> - I launch the swank server with
> lein swank
>
> - I connect to the swank server with
> M-x slime-connect
>
> - I have the behaviour I described when using M-. from either a REPL or
>   from a buffer displaying a .clj file in Clojure mode.
>
> - C-h c for both the REPL and Clojure mode says "M-. runs the command
>   slime-edit-definition".
>
> Simon
>

Replying to myself...

Actually, following the advice at...
  http://web.archiveorange.com/archive/v/UcW9CERUAfsCRJzpBo7s
...(in the post dated Wed Dec 08 2010) gives rise to different behaviours on
my XP machine and my Vista machine.  On the XP machine, I get the behaviour
I described originally but on the Vista machine I still get the "caution:
filename not matched" behaviour.

The only difference I can find in the two Emacs installations is that the XP
installation has clojure-test-mode-1.5.1 and the Vista installation does
not.

Simon

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

Books on Java Objects and Primitives

2011-05-23 Thread octopusgrabbus
What are some recent books that cover Java objects and primitives?

-- 
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: Navigating to Clojure Source using Emacs' Find Source Command

2011-05-23 Thread Simon Katz
On Sun, May 22, 2011 at 03:35, Phil Hagelberg  wrote:

> On May 21, 1:28 pm, Simon Katz  wrote:
> > I'm having trouble using Emacs' Find Source command to navigate to
> > Clojure source.
> >
> > I'm using Leiningen (1.4.2) and Emacs (23.2).
>
> > I thought this would be enough to allow the Emacs Find Source command
> > (meta-.) to find Clojure source code.  But when, for example, I try
> > meta-. on reduce, Emacs jumps to a buffer showing this line...
>
> Works fine for me. Would need more details to debug. How did you
> install slime? How did you launch and connect to the swank server?
> From what buffer did you invoke M-.? What does C-h c say about M-.
> from that buffer?
>
> -Phil


Thanks for confirming it should work.

I should also have mentioned:

- I have the behaviour I'm describing on Windows XP and Windows Vista.

- M-. works ok to find my own definitions.

I've now installed an unzip.exe (from
http://gnuwin32.sourceforge.net/packages/unzip.htm),
and now when I try M-. on reduce I get the line
  caution: filename not matched:  "clojure/core.clj"
  in a buffer described as
  core.clj (cloju...51 Clojure
 [...]/sk-mini-project-1-2-0/lib/clojure-1.2.0.jar:clojure/core.clj

Googling led me to this...
  http://web.archiveorange.com/archive/v/UcW9CERUAfsCRJzpBo7s
which says there are issues with Emacs and unzipping on
Windows. I followed the suggestion there (in the post dated
Wed Dec 08 2010), but that just reverted me to the original behaviour
I described.

Any further pointers would be appreciated!

Here are the answers to Phil's questions in case any of these details
may be useful:

- Looking back at my notes, I didn't explicitly install slime.  Does
  slime come as part of installing Clojure Mode and/or Swank Clojure in
  Emacs (using the package-list-packages command)?

- I launch the swank server with
lein swank

- I connect to the swank server with
M-x slime-connect

- I have the behaviour I described when using M-. from either a REPL or
  from a buffer displaying a .clj file in Clojure mode.

- C-h c for both the REPL and Clojure mode says "M-. runs the command
  slime-edit-definition".

Simon

-- 
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: Callback functions

2011-05-23 Thread Vivek Khurana
On Mon, May 23, 2011 at 1:06 PM, Meikel Brandmeyer  wrote:
> Hi,
>
> works for me. Did you call (require (symbol ns-name)) before the resolve
> call?

Thanks I was using (:use) which was not working.

regards
Vivek

-- 
The hidden harmony is better than the obvious!!

-- 
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: Parameterizing project.clj

2011-05-23 Thread Rasmus Svensson
2011/5/23 Ulrik Sandberg :
> How can I parameterize stuff in Leiningen's project.clj? For example,
> I don't want to put my AWS credentials inside the project file:
>
> ...
> :aws {:access-key "XX"
>      :secret-key "Y"}
>
> but instead use some kind of property names that refer to environment
> variables or something:
>
> ...
> :aws {:access-key "${aws.access.key}"
>      :secret-key "${aws.secret.key}"}

Actually, the project.clj file is evaluated by Leiningen using the
ordinary Clojure evaluator. This means that you can put arbitrary code
at the top level of the file to, for example, extract the keys from
environment variables. Any dev-dependencies will be available in this
Leiningen JVM instance too.

'defproject' is a macro, so its contents is not evaluated the usual
way. But it does have a helpful feature: Unquoted forms will be
evaluated with normal Clojure rules, so it's possible to do something
like this:

(def access-key ...)

(def secret-key ...)

(defproject foo 1.0.0
  ...the usual stuff...
  :aws {:access-key ~access-key
   :secret-key ~secret-key}

You can of course write the whole expressions directly after the
tildes, but I wanted to demonstrate the possibility of using def here.

Hope this helps!
// Rasmus Svensson (raek)

-- 
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-clj 0.1.0 - a refactored swank-clojure, with sldb support

2011-05-23 Thread Sam Aaron

On 23 May 2011, at 13:23, Hugo Duncan wrote:
>> Out of interest, how do swank-clj and swank-clojure (with merged in cdt 
>> stuff) compare?
> 
> I would have to let others comment on the user experience, not having used 
> the cdt support in swank-clojure.  From reading the code, I see two 
> differences.
> 
> i) swank-clj uses SLDB vs the use of GUD in swank-clojure,
> 
> ii) swank-clj starts two jvms, one for the debugger and one for the debuggee. 
> If I understand correctly, CDT uses a single jvm process.
> 
> In swank-clj at the moment, a swank server runs in both jvms, but I am 
> working towards being able to run using just JPDA/JDI to talk to the debugee. 
> At that point it will be possible to attach the debugger to any jvm process 
> running with debugging enabled.
> 


Thanks for the explanation. I'm relatively new to Emacs - and certainly new to 
any debugging support. I hadn't heard of the Slime debugger or the "Grand 
Unified Debugger" before. Given my current understanding of the Emacs ecosystem 
it doesn't surprise me that there is more than one supported approach to 
debugging :-)

What I do think is interesting is that there are two different approaches to 
Clojure debugging within Emacs that are relatively young in terms of 
implementation maturity. Competing systems can be good for cross-fertilisation 
and motivation - however they can also be confusing to the newcomer when faced 
with a choice. Currently I'm that newcomer and I have been using swank-clojure 
only because it was the only way I knew. George's work on the CDT has been very 
exciting and I was thrilled to see it get merged in with swank-clojure. 
However, I now see swank-clj which also seems remarkably exciting - truly cool 
stuff.

It appears both approaches are incompatible - is this true? If so, I'm 
wondering what the merits of SLDB over GUD and visa versa are. SLDB sound great 
cos it has slime in the name and, after all, I'm using slime. However, GUD 
sounds amazing cos it has the words grand and unified in the title. My initial 
thoughts are focussed and bespoke vs generalised and abstract. Which personally 
makes me think SLDB. Clearly choosing purely by name is utter madness though. 
So if anyone has any more information that can help people decide which 
approach to invest their time learning that would be much appreciated.

Sam

---
http://sam.aaron.name

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


Parameterizing project.clj

2011-05-23 Thread Ulrik Sandberg
How can I parameterize stuff in Leiningen's project.clj? For example,
I don't want to put my AWS credentials inside the project file:

...
:aws {:access-key "XX"
  :secret-key "Y"}

but instead use some kind of property names that refer to environment
variables or something:

...
:aws {:access-key "${aws.access.key}"
  :secret-key "${aws.secret.key}"}

-- 
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-clj 0.1.0 - a refactored swank-clojure, with sldb support

2011-05-23 Thread Hugo Duncan

On Sun, 22 May 2011 18:09:50 -0400, Jason Wolfe  wrote:


1.  The usual repl entry point is not used, and so, e.g., (set! *warn-
on-reflection* true) fails.


Thanks, I raised an issue to track this  
https://github.com/hugoduncan/swank-clj/issues/8



2.  I could not figure out a way to browse exception chains.
Typically the "real" stack trace for an exception is reached by
repeatedly calling .getCause on the exception until the innermost
exception is reached, but right now I can't see how to access causes
in the swank-clj debugger.  For example try:


There is no support for exception chains. The reasoning behind this is  
that swank-clj can catch the original exception, before it gets caught and  
re-thrown in the program. At the moment, there is some rigid filtering of  
exceptions that means in some cases the original exception is not caught.


I am hoping that improved (user modifiable) filtering of exceptions based  
on thrown type, throw location and catch location, will obviate the need  
for handling exception chains in the interface.  Does that sound  
reasonable?



If you want, I'm happy to help out on these.  Thanks for the great
work!


All help appreciated - if you can, I would prefer pull requests from  
feature branches. There is lots to be done, especially around adding test  
cases to get the project to the point where we can make changes with  
confidence.


Raising issues for broken slime features would also be useful.

--
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: swank-clj 0.1.0 - a refactored swank-clojure, with sldb support

2011-05-23 Thread Hugo Duncan

On Sun, 22 May 2011 16:59:24 -0400, Sam Aaron  wrote:


Very cool!


Thanks.

Out of interest, how do swank-clj and swank-clojure (with merged in cdt  
stuff) compare?


I would have to let others comment on the user experience, not having used  
the cdt support in swank-clojure.  From reading the code, I see two  
differences.


i) swank-clj uses SLDB vs the use of GUD in swank-clojure,

ii) swank-clj starts two jvms, one for the debugger and one for the  
debuggee. If I understand correctly, CDT uses a single jvm process.


In swank-clj at the moment, a swank server runs in both jvms, but I am  
working towards being able to run using just JPDA/JDI to talk to the  
debugee. At that point it will be possible to attach the debugger to any  
jvm process running with debugging enabled.



--
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: Passing "environment configuration parameters" to a Clojure web app

2011-05-23 Thread Chas Emerick

On May 23, 2011, at 3:48 AM, Laurent PETIT wrote:

> So far, the "most" general techniques I can see are : either
> bundle/repackage your webapp for the target servlet container
> instance, either pass the path to configuration file(s) via one (or
> more) JNDI parameters.

That's about right — though of course you don't need to be using JNDI if you're 
willing to configure each parameter separately as a system property or servlet 
init param.

Beyond that, ring is quite container-agnostic (to the point where you don't 
necessarily need to use a servlet container to deploy ring apps), whereas 
configuration mechanisms are likely to be container-specific.

- Chas

-- 
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: Passing "environment configuration parameters" to a Clojure web app

2011-05-23 Thread Laurent PETIT
Hello,

Thanks for answering !

My remarks follow:

2011/5/22 Shantanu Kumar :
> I have wondered about this problem and at the first glance it looked
> straightforward to me to put moving parts (config elements that could
> change) into dynamic vars/atoms/refs. The production env can use the
> default config, and anything else (dev, testing) can alter the default
> config to override the settings.

The idea of having production settings in the codebase as "default
values" doesn't feel right to me -in general- (and in my particular
case).
Generally, some of these info are confidential, and their lifecycle
does not match the lifecycle of the product.

> The dev/testing should have different
> entry point (may be in "test" directory, as opposed to "src") than the
> prod version. That said, the config elements themselves can be loaded
> from certain config files. If it's a web app, you can bundle config in
> file(s) in WEB-INF and load from there on init -- now that leads to a
> complicated build process because you cherry pick the config file (for
> staging, prod or integration test?) for the build target.
>
> Another complexity might arise where the config must be used to carry
> out certain stateful initialization to be useful to the app. How do
> you gracefully handle the errors? So we go back to some mutable flag
> that gives the go-ahead. Ugh!

For what you describe, there are ways (as far as I remember) to manage
this with webapps, I think. By placing an HttpFilter/Listener in front
of the servlet, etc. (not sure about the details)

> If the config element is common enough (e.g. database coords), it
> might make sense to go for convention-based settings that remains more
> or less the same. I have experimented a bit on this here:
> https://bitbucket.org/kumarshantanu/clj-dbcp/src (jump to the section
> "Create DataSource from .properties file") - I am interested in
> knowing what others think about this.

Yes, to some extent convention settings can work. But it's not rare to
have some intermediate servers (dev's computer, test server) run on
e.g. Linux, and sometimes the final server run on Windows. Not to say
that this places a strong constraint on the server.

I've got some more ideas from friends of mine, one of which seems real
interesting : leverage extensions provided by the servlet container
(e.g. Tomcat) provider: tomcat provides a way to "extend" the
classpath of the webapp via configuration : that way you can put in
your externalized context.xml file a "VirtualWebAppLoader" and
initialize it to add to the classloader of the webapp the contents of
e.g. $catalina_home$/conf/myAppConfig/ directory. From them on, your
webapp will be able to see your configuration files in the classpath,
even so they're neither in WEB-INF/classes/ nor WEB-INF/libs/
directories.

Of course this technique will be limited to those servlet containers
which provide similar classpath extension mechanism, so you need to be
in control of the potential servlet containers to which your app may
be deployed.

So far, the "most" general techniques I can see are : either
bundle/repackage your webapp for the target servlet container
instance, either pass the path to configuration file(s) via one (or
more) JNDI parameters.

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: RIncater

2011-05-23 Thread Edmund Jackson
Hey Ulises,

Sortof.  The original author is updating thing so that they work more 
cleanly.  In the interim if you want to get it to work modify the project.clj 
to look like this: https://gist.github.com/962673.  Then comes the hard bit.  
The JRI uses native libraries that upon compilation seem to hardlink in the 
directory in which the R dynamic libs are saught.  So you either have to make a 
static link R/Versions/ that points 2.10 to the Current.  Or, and this is 
better, download JRI: http://www.rforge.net/JRI/snapshot/JRI_0.5-1.tar.gz then 
compile up the dynamic libs (thus hardlinking your machine) and move them to 
the appropriate subdirectory of ./native in your clojure project and you should 
be good to go.

 Edmund


On 20 May 2011, at 22:25, Ulises wrote:

> Hi,
> 
> Is RIncanter still alive?
> 
> Cheers,
> 
> U
> 
> -- 
> 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


Aw: Callback functions

2011-05-23 Thread Meikel Brandmeyer
Hi,

works for me. Did you call (require (symbol ns-name)) before the resolve 
call?

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

Callback functions

2011-05-23 Thread Vivek Khurana
Hi!

 I am building an application with menu callbacks. Based on the url
request the application has to call a function. The function name and
namespace is available as strings from database. The issue I am facing
is, when I try to call the function using ns-resolve, I get an error
saying "No namesapce found" . This is how I am calling the required
callback

((ns-resolve (symbol ns-name) (symbol callback)))

where "ns-name" is the name of the namespace containing the function
and "callback" is the actual function to be called.

 How do I fix the namespace not found error ?

regards
Vivek

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