Re: ANN: ClojureScript 0.0-3211

2015-04-25 Thread Allen Rohner


On Saturday, April 25, 2015 at 4:11:40 PM UTC-5, Allen Rohner wrote:



 On Saturday, April 25, 2015 at 12:02:08 PM UTC-5, Mike Fikes wrote:

 Hey Tony, try updating the version of Clojure in your project.clj to 
 1.7.0-beta1, which is used by 0.0-3211. 

 (In short, reader/read was given a second arity to allow options to be 
 passed, thus supporting #? conditional reading.)


 I'm seeing the same behavior on 1.7.0-beta2. Yes, I've cleaned.  


Upgrading tools.reader fixed the problem for me. My project doesn't specify 
tools.reader, but a dependency does, and that was presumably pulling in an 
older version that the cljs compiler wanted. 

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ANN: ClojureScript 0.0-3211

2015-04-25 Thread Allen Rohner


On Saturday, April 25, 2015 at 12:02:08 PM UTC-5, Mike Fikes wrote:

 Hey Tony, try updating the version of Clojure in your project.clj to 
 1.7.0-beta1, which is used by 0.0-3211. 

 (In short, reader/read was given a second arity to allow options to be 
 passed, thus supporting #? conditional reading.)


I'm seeing the same behavior on 1.7.0-beta2. Yes, I've cleaned.  

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Are keys and vals guaranteed to return in the same order?

2015-04-18 Thread Allen Rohner

On Friday, April 17, 2015 at 4:40:07 PM UTC-5, Michael Blume wrote:


 In other people's Clojure code I sometimes see things like

 (zipmap
   (map some-fn (keys m))
   (map other-fn (vals m)))

 If it were my code I'd be much more inclined to write

 (into {}
   (for [[k v] m]
 [(some-fn k) (other-fn v)]))

 Is this a to-each-their-own thing or is the latter preferred?


One minor quibble is that your example only makes one pass over the data. 
If the map is big enough, there could be a performance advantage. 

 

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ANN] lein-docker, lein-beandock

2015-04-07 Thread Allen Rohner
https://github.com/arohner/lein-docker

https://github.com/arohner/lein-beandock

`lein-docker` is a simple plugin for performing `docker build` and `docker 
push`. lein-beandock is a semi-fork of `lein-beanstalk`, specializing in 
deploying docker containers to AWS Elastic Beanstalk. 

Thanks,
Allen

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Continuously Integrating Leiningen Projects

2015-02-18 Thread Allen Rohner
CircleCI uses:

https://github.com/circleci/lein-version-specs
https://github.com/circleci/version-specs

Which can be used to set the version string arbitrarily. 

Thanks,
Allen


On Wednesday, February 18, 2015 at 2:10:14 PM UTC-6, Michael Blume wrote:

 Afraid the plugin's internal.

 On Wed Feb 18 2015 at 2:34:32 AM Rick Moynihan rick.m...@gmail.com 
 javascript: wrote:

 This sounds very close to what I'm looking for.

 Is this plugin opensourced or something you're using locally, as the
 closest thing I can find to what you describe is lein-git-version:

 https://github.com/cvillecsteele/lein-git-version

 Which seems to follow project middleware approach you describe, but
 for a different use case.

 R.

 On 18 February 2015 at 06:18, Michael Blume blume...@gmail.com 
 javascript: wrote:
  We use a Leiningen plugin to set the version dynamically
 
  https://github.com/technomancy/leiningen/blob/master/doc/PLUGINS.md -- 
 if
  you skip down to project middleware you'll see how to create the kind 
 of
  plugin I'm talking about. Within the middleware function, we update the
  :version key in the project map to a version string composed of a 
 timestamp
  and the first few characters of the commit hash. The timestamp part is
  important because it ensures that maven/lein consider newer builds to be
  newer.
 
  As for lein-ancient, we don't really have it *do* anything, it just 
 prints
  its suggestions in the build output, and if you look at your build from 
 time
  to time, you'll see there are libraries you can upgrade. It's not a 
 perfect
  system, but it helps.
 
  On Tue Feb 17 2015 at 4:23:03 PM Rick Moynihan rick.m...@gmail.com 
 javascript:
  wrote:
 
  Thanks for the tip,  I had used lein-ancient in the past and it seems
  to have come along a bit since then.
 
  How is it that you have this configured?
 
  Do you run lein ancient upgrade before each build that you want to
  check its dependencies?  I tried this locally and I can't find a way
  to tell lein ancient to only try and upgrade certain libraries, rather
  than all or nothing.
 
  For example I have a dependency on incanter 1.5.5 - I don't want it to
  upgrade to 1.9.0 because it will break the build catastrophically just
  now...  I do however want to whitelist it to my library, which I'm
  expecting to keep more current.
 
  R.
 
  On 17 February 2015 at 19:14, Michael Blume blume...@gmail.com 
 javascript: wrote:
   Related -- we run lein ancient as part of a lot of our builds so 
 that we
   can
   easily pick up dependencies with newer available versions.
  
   On Tue Feb 17 2015 at 11:13:44 AM Michael Blume blume...@gmail.com 
 javascript:
   wrote:
  
   What we do at Climate is avoid SNAPSHOT builds. Every build gets a
   version
   string with timestamp and git commit. If an upstream library is
   changed,
   it's up to downstream maintainers to update their dependency on it. 
 If
   you
   update a dependency and your build fails, you a) don't update your
   dependency just yet b) complain to the library maintainer that their
   new
   version breaks your project.
  
   On Tue Feb 17 2015 at 9:51:18 AM Rick Moynihan
   rick.m...@gmail.com javascript:
   wrote:
  
   Hi all,
  
   At work, we use Jenkins to continuously integrate our Clojure 
 projects
   which are factored into both applications and a small number of
   supporting libraries; all of which use Leiningen as their project
   build tool.
  
   Leiningen builds each project, and runs its tests; and then if they
   pass it lein installs the project jar into the local ~/.m2 repo and
   triggers any dependent builds to start.  The dependencies then 
 start
   building and pick up the latest SNAPSHOT build from the ~/.m2
   directory.
  
   This works ok; but it has a relatively major flaw, which is that 
 just
   because a project passes its local tests; it doesn't mean that it
   hasn't broken an upstream library.  When this happens the broken
   library is left in the shared ~/.m2 directory - breaking other 
 builds
   and generally lying around causing havoc.
  
   Fortunately this rarely happens in practice; but it is a potential
   cause of hard to diagnose (unrepeatable build) problems - 
 especially
   when using snapshot builds - which is what I think we want to use 
 for
   tracking branches until we
  
   We currently use the Jenkins leiningen plugin, but I don't think it
   supports a more sophisticated setup than this.
  
   I was wondering if anyone with experience of running robust CI 
 builds
   (with Jenkins) might have any ideas about to solve this in a more
   robust manner??
  
   Many thanks,
  
   Rick
   --
   http://twitter.com/RickMoynihan
  
   --
   You received this message because you are subscribed to the Google
   Groups Clojure group.
   To post to this group, send email to clo...@googlegroups.com 
 javascript:
   Note that posts from new members are moderated - please be patient
   with
   your first post.
   To unsubscribe from 

Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-08 Thread Allen Rohner


On Wednesday, January 7, 2015 at 2:49:50 PM UTC-6, Sean Corfield wrote:

 On Jan 7, 2015, at 10:21 AM, Allen Rohner aro...@gmail.com javascript: 
 wrote: 
  As a design rule, I prefer making I/O fns (things that hit the DB or a 
 REST API), 'dumb', and perform all logic/processing in fns that just 
 receive plain data, and return plain data. 


In my current project, I'm using component + datomic, so I'll talk about 
that here.

 

 I’m curious: do you have wrapper functions for the DB reads/writes (i.e., 
 a domain layer that just wraps the calls to your persistence library as 
 well as managing the connections etc)? 


Yes. Finding a user looks like

(defn get-user-by-login [db login]
  (d/q '[:find (pull ?u [*]) :in $ ?login :where [?u :user/login ?login]] 
db login))

I'm passing the datomic DB value into the find function. 



Currently we primarily run Clojure as the embedded Model in a legacy MVC 
 app so we can’t really use Stuart’s Component (at least, I don’t think we 
 can, because we have a lot of entry points into the Clojure code) but we 
 would like to figure out a cleaner way to separate DB access from our 
 business logic on a per request basis... 


The important part of component isn't using the actual library, it's the 
philosophy. The most important thing is the signatures on your fns. You 
just need to change all of your code to take the DB connection as an 
argument, rather than doing something like:

(defn get-user-by-login [login]
  (d/q '[:find...] db login))

The only difference from the first example is that the DB is no longer an 
argument, so now it's implicit global state. Fixing that is 90% of the 
benefit of component, the rest of component is designed to make starting 
the system simpler. Component may or may not be a good fit for you, but you 
can certainly get most of the benefit on your own. 

Thanks,
Allen




-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to handle refactoring with TDD and mocking/stubbing

2015-01-07 Thread Allen Rohner


On Wednesday, December 31, 2014 8:48:27 AM UTC-6, Jonathon McKitrick wrote:

 I use TDD and mocking/stubbing (conjure) to test each layer of my code.  
 The problem is when I change the function signature and the tests do not 
 break, because the mocks/stubs do not know when their argument lists no 
 longer agree with the underlying function they are mocking.  Is there a way 
 to catch this?  Short of a test suite that eschews stubbing in favor of 
 full setup/teardown of DB data for each test?


I'll second the avoiding mocks, and avoiding midje votes.  

As for practical advice, I noticed that many times when I had 
mocking/stubbing problems in my tests, it was because my app was too 
tightly complected or stateful. I highly highly recommend using 
https://github.com/stuartsierra/component . Component strongly encourages 
you to program in a style where it's easy to e.g. replace your DB with an 
in-memory instance, and make it obvious which fns need DB access, 
encouraging you to split fns into pure and impure. Also, use core.async to 
communicate between separate components, where it makes sense. 

As a design rule, I prefer making I/O fns (things that hit the DB or a REST 
API), 'dumb', and perform all logic/processing in fns that just receive 
plain data, and return plain data. 

When you follow those two practices, your need for stubbing  mocking will 
drop significantly. As a bonus, your tests usually get faster!

Thanks,
Allen





-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ClojureScript] Re: [ANN] Silk, an isomorphic routing library for Clojure and ClojureScript

2014-08-09 Thread Allen Rohner
I'd like to thank everyone in the community for both Silk, and Secretary. 

I'll throw out some (uninvited) feature requests I'd love to see in a 
future route-matching library. 

1) Make trie-based route dispatching possible. A feature pedestal has/will 
soon have, is to compile the routing table into trie, rather than the 
compojure-style wrapped functions. This can have a nice speedup on busy 
applications. I'm not asking anyone to write this code, just consider the 
design such that it's possible to add this behavior in the future. 

2) I'll claim that making route definition order is a misfeature. Routes 
should always be fully qualified, such that re-arranging them doesn't 
affect routing behavior (and therefore, the route table should be an 
unordered collection, like a map or set, not a vector). One nice 
readability reason for this is that if your route order does matter, than 
at least one route definition is lying about which routes it actually 
dispatches on. 

Just things to consider :-)

Thanks,
Allen

On Thursday, August 7, 2014 9:31:56 PM UTC-5, DomKM wrote:

 Thanks for your feedback, Dylan!

 If you define routes with :path and :query, will the route match/unmatch 
 with undefined query keys? If so, how are they handled? If not, I'd suggest 
 making query matching optional, where nils are substituted.


 I'm not entirely sure what you mean, but I'll give it a shot. Please 
 provide some example code if I answered the wrong question.

 `nil` is a pattern that matches anything. If your URL pattern query is 
 `nil` then the URL query will not be checked.
 A map is a pattern that matches its values against the values of another 
 map. Therefore, `nil` and `{}` are equivalent when used as a query pattern.
 You can make a query value pattern optional by wrapped it with 
 `silk/option`. 

 It's a little unclear how your matching functions relate to route. It 
 looks like Silk always breaks at / in path and matches, is that correct?

  
 Yes. There is a URL type in Silk and matching is done against instances of 
 it. The path is represented as a vector of segments.

 The readme is currently very deficient and I apologize for that.

 There are some really good things in secretary. What do you think about 
 them?
 Splat, regex, format matchers.


 In terms of regex matching, Silk used to have a built-in regex pattern but 
 I removed it when I made a big architectural change. I forget why I removed 
 it, but I'll re-add it since it does seem like a very common requirement.

 Currently, part of Secretary's splat exists as a built-in Silk pattern. 
 For example, `(silk/composite [foo :* bar])` would match 
 fooanythingbar and return `{:* anything}`. The `:*` isn't special; it's 
 just a keyword. Format is just a specific case of composite: 
 `(silk/composite [:* . :format])`. Unlike Secretary, Silk does not have a 
 built-in special syntax for string patterns. This is because special syntax 
 strings are not composable and, since Silk matches against unencoded 
 strings, who am I to say you can't have : or * in your URL paths? ;)

 Looking at the Secretary readme, there appear to be two ways to use splat 
 that Silk currently does not have built-in support for. In Secretary, 
 /foo/* would match /foo/bar/baz and return `{:* bar/baz}`. Also, 
 /*/* would match /a/b and return `{:* [a b]}`. I keep saying 
 built-in because, while multi-segment path patterns and binding the same 
 parameter key to multiple path segments does not currently exist in Silk, 
 it is very easy to extend Silk with that functionality. You could easily 
 create a pattern that did exactly what Secretary and Clout do by default 
 and use it to match a path instead of a vector. However, I do question the 
 utility of these two features. Are either of these common requirements and, 
 if so, could I see some examples of why they are necessary or helpful? This 
 isn't rhetorical; please let me know if Silk is missing something that is 
 within its scope and is useful to most consumers.

 protocol based render function for multiple arity unmatching. this is 
 really great.


 I don't think I fully understand the use cases for this protocol. Do you 
 want to be able to look routes up by types? If so, since route names in 
 Silk can be anything, you could use a type as a name. Anyway, I put 
 together this little gist 
 https://gist.github.com/DomKM/26658b53a50e48f0be70 of ways in which 
 Silk could be used similarly to how I *think* someone might use Secretary's 
 IRenderRoute. Do these cover the use cases for that protocol?


 I also agree with everything in Joel's response and look forward to 
 working with him on improving the routing story. :)


 On Thu, Aug 7, 2014 at 2:52 PM, Joel Holdbrooks cjhold...@gmail.com 
 javascript: wrote:

 I'm in agreement that Silk is a step in the right direction. I've reached 
 out to Dom and I think we can learn a lot from each other and work together 
 to improve the routing story in Clojure 

Available for Contracting

2014-06-09 Thread Allen Rohner
I hope this isn't frowned upon here, but here goes. 

I'm looking for freelance work while I figure out my next startup. Until 
recently, I was Founder  CTO of a startup of 10 engineers, the product is 
100% Clojure (except for the UI, which was transitioning from Coffeescript 
to Clojurescript). I've been using Clojure full-time since 2009, and have 
commits in clojure core, contrib, lein, ring, compojure and many other 
libraries. I've talked at Clojure/West twice. 

Other skills:  
- strong understanding of linux internals  ops. I've shipped kernel 
modules and built production AWS clusters of hundreds of machines. 
- can ship functional, but ugly frontend 
code ({java,coffee,clojure}script) . 
- proficient, but rusty in: C, C++, Python, Ruby, Java
- machine learning background

If you're interested, please contact me at aroh...@gmail.com 

Thanks,
Allen



  

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] core.typed 0.2.0 - Production Ready

2013-08-28 Thread Allen Rohner
Awesome. Thanks for your hard work! 

Allen

On Wednesday, August 28, 2013 3:28:35 PM UTC-7, Ambrose Bonnaire-Sergeant 
wrote:

 Hi,

 After 10 months and 26 0.1.x releases of transitioning core.typed from an 
 ambitious student project, I am finally comfortable recommending core.typed 
 for production use.

 Production Ready

 My interpretation of production ready in this context is:
 - core.typed can *find bugs* in real code
 - core.typed will *not slow down* your existing code by loading
   a large library at production. (core.typed does introduce an extra 
 identity-like
   function call at type annotations, I assume this is a candidate for 
 optimisation via
   HotSpot)
 - A basic *tutorial*, API docs and example project exist
 - core.typed is *currently used in production* with success (at CircleCI 
 for several months)
 - The core type checking API is mostly *stable*, with only very
   minor removals/breaking changes in the last few months.

 There are several outstanding issues, but I am satisfied that core.typed 
 can bring real utility to real programs *today* and with *no 
 production-time drawbacks*, thus this release.

 How to get started

 Leiningen dep:

 [org.clojure/core.typed 0.2.0]
 ...; for very recent releases:repositories {sonatype-oss-public 
 https://oss.sonatype.org/content/groups/public/}

 If you like following tutorials try the user/types guide. If you just want 
 to get your hands on some typed code, see the Example project.

 core.typed User Guidehttps://github.com/clojure/core.typed/wiki/User-Guide
 core.typed Types Guide https://github.com/clojure/core.typed/wiki/Types
 Example project https://github.com/frenchy64/core.typed-example
 API Reference http://clojure.github.io/core.typed/

 core.typed Github Home https://github.com/clojure/core.typed
 core.typed Wiki https://github.com/clojure/core.typed/wiki

 Please report bugs, ask questions or discuss things on the mailing 
 listhttps://groups.google.com/forum/?fromgroups#!forum/clojure-core-typed
 .

 (FWIW I'm ambrosebs on #clojure.)

 Thanks,
 Ambrose


-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Seeking advice on a safe way to mock/stub fns

2013-03-24 Thread Allen Rohner

I've also run into the problem. You could write your own version of 
with-redefs (it's not that hard). In your case, it sounds like you're not 
running tests in parallel in the same process, so could you work around it 
by waiting for your app to finish initializing before running tests? 

Allen

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[ANN] bond, a spying stubbing library

2013-03-22 Thread Allen Rohner
I'd like to announce bond, a spying and stubbing library, intended for 
tests. 

https://github.com/circleci/bond

Don't let the low version number scare you, we've been using it in 
production every day for several months. 

Allen

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: lein-daemon 0.5

2013-01-16 Thread Allen Rohner
I've just released 0.5.0. I had to get a patch into leiningen to make 
things work in lein2, so you'll need to be using lein-2.0.0-RC1 or later. 
I've also updated the readme at https://github.com/arohner/lein-daemon

Let me know how it goes!

Allen

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

ANN clj-wallhack

2012-05-16 Thread Allen Rohner
I've resurrected old school clojure.contrib.java-utils/wall-hack-
{method,field} into a new library

https://github.com/arohner/clj-wallhack

Thanks to hiredman for the original implementation.

Allen

-- 
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: lein-daemon 0.3

2011-05-12 Thread Allen Rohner


 Can I use this in order to run, for examples, a lein ring session as a
 deamon? :)


Yes, that exactly its intention.

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


lein-daemon 0.3

2011-05-11 Thread Allen Rohner
I've released a new version of lein-daemon. daemon is like 'lein run',
only it runs the process in the background rather than blocking.

0.3 and up is a complete re-write, that no longer depends on apache
commons daemon. The new version has no dependencies on any external
programs.

For more, see https://github.com/arohner/lein-daemon

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


ANN lein-daemon, lein-test-out

2010-07-15 Thread Allen Rohner
I'd like to announce two new lein plugins, lein daemon and lein test-
out.

Lein-daemon is a wrapper around the Apache Commons Daemon, for
starting a clojure process as a daemon.

Lein test-out is a plugin for running your tests and outputting the
results to junit or TAP (using clojure.test.junit and
clojure.test.tap).

You can find them at http://github.com/arohner/lein-daemon , and
http://github.com/arohner/lein-test-out , and clojars.

Allen

-- 
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: Inheriting from IDeref - good idea or bad practise?

2010-02-07 Thread Allen Rohner
I can't comment on style, but I can say I successfully made a protocol
to implement SoftReferences:

(deftype SoftRefHolder [#^java.lang.ref.Reference ref]
  clojure.lang.IDeref
  (deref []
 (.get ref)))

(defn soft-reference
  returns a soft reference to x. Access using deref
  [x]
  (let [reference (SoftReference. x)
obj (SoftRefHolder reference)]
obj))

It works great, and I haven't encountered any problems yet. My
interpretation of the clojure source code is that Rich intentionally
made things that can be dereferenced (IDeref) orthogonal to things
that participate in clojure concurrency (IRef / Atom / Agent)

My one concern about fetching the session map from a database is the
cost in time. All the other deref operations take about as much time
as grabbing a lock. Going to the DB is an order of magnitude longer.
Typically, I use the session data multiple times per request. Maybe if
it were cached / memoized, that would be better.

Allen

On Feb 7, 3:12 pm, James Reeves weavejes...@googlemail.com wrote:
 On Feb 7, 4:06 pm, Laurent PETIT laurent.pe...@gmail.com wrote:

  I don't know, but it seems like a bad smell that you can't find your
  joy by using the built-in state management constructs

 The build-in state management constructs only deal with data in
 memory. I'm thinking deref could potentially be more general. For
 instance, derefing a session object might fetch the corresponding
 session map from a SQL database.

 The alternative would be to write some deref-like function with a
 different name. However, I'm wondering if deref is currently generic
 enough that it could be used instead.

 - James

-- 
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: merge doesn't work on deftypes implementing IPersistentMap

2009-12-30 Thread Allen Rohner
 i'm hoping the yet part means it is slated to maybe someday be upgraded?

I've filed a bug and submitted a patch. Assuming my fix is acceptable,
this should be in soon.

https://www.assembla.com/spaces/clojure/tickets/231-deftype-cons-doesn-t-support-maps-

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


merge doesn't work on deftypes implementing IPersistentMap

2009-12-28 Thread Allen Rohner
I tried to call merge on a deftype implementing IPersistentMap, and
got an exception:

user (deftype Foo [a b] clojure.lang.IPersistentMap)
#'user/Foo

user (Foo 1 2)
#:Foo{:a 1, :b 2}
user (merge (Foo 1 2) {:a 3})
; Evaluation aborted.

nth not supported on this type: PersistentArrayMap
  [Thrown class java.lang.UnsupportedOperationException]

Restarts:
 0: [ABORT] Return to SLIME's top level.

Backtrace:
  0: clojure.lang.RT.nth(RT.java:811)
  1: user.Foo__15735.cons(NO_SOURCE_FILE:1)
  2: clojure.lang.RT.conj(RT.java:534)
  3: clojure.core$conj__3951.invoke(core.clj:67)
  4: clojure.core$merge__4623$fn__4624.invoke(core.clj:1919)
  5: clojure.core$reduce__4135.invoke(core.clj:665)
  6: clojure.core$reduce__4135.invoke(core.clj:656)
  7: clojure.core$merge__4623.doInvoke(core.clj:1919)
  8: clojure.lang.RestFn.invoke(RestFn.java:422)
  9: user$eval__15820.invoke(NO_SOURCE_FILE:1)
 10: clojure.lang.Compiler.eval(Compiler.java:5258)
 11: clojure.lang.Compiler.eval(Compiler.java:5226)
 12: clojure.core$eval__4674.invoke(core.clj:2018)
 --more--


Interestingly, drewr on IRC pointed out that
(merge {:a 3} (Foo 1 2)) works. I then figured out that
(merge {} (Foo 1 2) {:a 3}) works.

This seems like a bug to me. Is it?

Allen


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


Hooks library. (Is this clojure-y?)

2009-12-06 Thread Allen Rohner
I started playing with the idea of a hooks library for Clojure,
similar to Emacs hooks.

You can see the code at http://gist.github.com/250575

Does this library have the Tao of Clojure?

If hooks aren't a clojure-y way of doing things, what is?

-- 
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: Hooks library. (Is this clojure-y?)

2009-12-06 Thread Allen Rohner

 What is it supposed to do?  What's the usage look like?


Oh right, a description would be useful. The point is to build up the
functionality of a function from several places. You define a hook
function:

(defhook foo [a b])

Initially, it does nothing. Then, other code can add hooks:

(add-hook foo :first-hook (fn [a b] (println first!)))

The hooks should all have the same signature as in defhook. You can
add as many as you like. The second argument is a name, so you can
remove the hook later if desired.

(add-hook foo :second (fn [a b] (println a= a b= b)))

Then, call the function, and all of the hooks get called in the order
added

user (foo 1 2)
first!
a= 1 b= 2
nil

There's also a function, remove-hook, that works about the way you'd
expect.
(remove-hook foo :first-hook)

 Why does defhook's signature arg never get used?
 It'd also help readability to wrap your doc string.

This is just a sketch. I meant for the signature to go into the
arglist metadata of the def'd var, but couldn't get it to work in 5
minutes, and gave up on it (for now). I plan on doing all of that
polishing, assuming nobody tells me it's not evil. Honestly, I'm not
sure yet, but it seems to work well for Emacs, and I couldn't think of
a better alternative for my own Clojure problem.

Allen

-- 
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: Datatypes and Protocols - early experience program

2009-11-24 Thread Allen Rohner


On Nov 12, 6:10 am, Rich Hickey richhic...@gmail.com wrote:
 An early version of the code for a few important new language
 features, datatypes[1] and protocols[2] is now available in the 'new'
 branch[3]. Note also that the build system[4] has builds of the new
 branch, and that the new branch works with current contrib.

 If you have the time and inclination, please try them out. Feedback is
 particularly welcome as they are being refined.

 Thanks,

 Rich

 [1]http://www.assembla.com/wiki/show/clojure/Datatypes
 [2]http://www.assembla.com/wiki/show/clojure/Protocols
 [3]http://github.com/richhickey/clojure/tree/new
 [4]http://build.clojure.org/



On Nov 12, 6:10 am, Rich Hickey richhic...@gmail.com wrote:
 An early version of the code for a few important new language
 features, datatypes[1] and protocols[2] is now available in the 'new'
 branch[3]. Note also that the build system[4] has builds of the new
 branch, and that the new branch works with current contrib.

 If you have the time and inclination, please try them out. Feedback is
 particularly welcome as they are being refined.

 Thanks,

 Rich

 [1]http://www.assembla.com/wiki/show/clojure/Datatypes
 [2]http://www.assembla.com/wiki/show/clojure/Protocols
 [3]http://github.com/richhickey/clojure/tree/new
 [4]http://build.clojure.org/

And a feature request: Validators on deftypes. Currently, I have a
bunch of refs that point at maps, with validator functions. The ref
validators mainly validate the contents of the map, i.e. that certain
keys are present and have sane values. It seems to make more sense to
do the checking on the type validator, and then the ref's validator
would just check that the ref's value is the correct type.

Allen

-- 
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: Datatypes and Protocols - early experience program

2009-11-23 Thread Allen Rohner


On Nov 12, 6:10 am, Rich Hickey richhic...@gmail.com wrote:
 An early version of the code for a few important new language
 features, datatypes[1] and protocols[2] is now available in the 'new'
 branch[3]. Note also that the build system[4] has builds of the new
 branch, and that the new branch works with current contrib.

 If you have the time and inclination, please try them out. Feedback is
 particularly welcome as they are being refined.

 Thanks,

 Rich

 [1]http://www.assembla.com/wiki/show/clojure/Datatypes
 [2]http://www.assembla.com/wiki/show/clojure/Protocols
 [3]http://github.com/richhickey/clojure/tree/new
 [4]http://build.clojure.org/

The first stumbling point I reached is that deftypes provide an
automatic implementation for IPersistentMap, but not IFn. I attempted
to write (instance key), which exploded, but (key instance) works just
fine. My existing code uses (instance key) almost universally. Should
I get used to this, or are there plans to provide a default IFn
implementation?

Allen

-- 
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: scriptjure, a library for generating javascript

2009-10-08 Thread Allen Rohner

It was a minor thing actually, I didn't like having to quote user
code, and AFAIK, it's not possible to add a quasiquote as part of a
macro. i.e. in my code, there is a function (_js) that does the heavy
lifting, and the macro (js). I couldn't write:

(defmacro js [forms]
   (quasiquote (_js forms))

That and IMO, (clj foo) is slightly more readable than ~foo.

Allen

On Oct 8, 12:50 am, Jarkko Oranen chous...@gmail.com wrote:
 On Oct 8, 5:01 am, Allen Rohner aroh...@gmail.com wrote:





  Hello, I'd like to announce the availability of a new library, called
  Scriptjure. It's a macro that generates javascript strings from
  Clojure s-exprs. My initial use for it is in glue code for Clojure
  webapps. For example:

   (js (fn foo [x]
           (var y 3)
           (return (+ x y
   = function foo (x) {
             var y = 3;
             return (x + y);
          }

  You can get the code and read the documentation 
  athttp://github.com/arohner/scriptjure

  Allen

 I took a quick look, and that looks really neat. One thing though:
 Instead of the clj form to escape back to clojure, why not just use
 unquote (and possibly unquote-splicing)? that would allow you to use
 the ~ reader macro as a shortcut, just like in syntax-quote.

 --
 Jarkko
--~--~-~--~~~---~--~~
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: scriptjure, a library for generating javascript

2009-10-08 Thread Allen Rohner

 Did you try
 (defmulti emit class) ?

That is a good point. I'm actually not sure why I used type there.
It's probably a bug. Thanks for pointing it out.

Allen

On Oct 8, 4:38 am, Emeka emekami...@gmail.com wrote:
 Allen,
 Great job!


 Regards,
 Emeka



 On Thu, Oct 8, 2009 at 7:18 AM, Meikel Brandmeyer m...@kotka.de wrote:

  Hi,

  On Oct 8, 7:50 am, Jarkko Oranen chous...@gmail.com wrote:

   I took a quick look, and that looks really neat. One thing though:
   Instead of the clj form to escape back to clojure, why not just use
   unquote (and possibly unquote-splicing)? that would allow you to use
   the ~ reader macro as a shortcut, just like in syntax-quote.

  +1

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



ANN: scriptjure, a library for generating javascript

2009-10-07 Thread Allen Rohner

Hello, I'd like to announce the availability of a new library, called
Scriptjure. It's a macro that generates javascript strings from
Clojure s-exprs. My initial use for it is in glue code for Clojure
webapps. For example:

 (js (fn foo [x]
 (var y 3)
 (return (+ x y
 = function foo (x) {
   var y = 3;
   return (x + y);
}

You can get the code and read the documentation at 
http://github.com/arohner/scriptjure

Allen


--~--~-~--~~~---~--~~
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: Was it decided to add these functions to core?

2009-06-23 Thread Allen Rohner


 (range 0 :infinity 1) is not any shorter than (iterate inc 0)

It's not shorter, but it is a lot more clear. That alone makes it
worthwhile IMO.

Allen

--~--~-~--~~~---~--~~
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: PermGen OutOfMemory error

2009-06-11 Thread Allen Rohner

I haven't hit the permgen issue, but it sounds like I have a similar
setup to you. Out of curiosity, how do you redeploy while compiling
your .clj files? I typically connect via Slime and use slime-load-
file, which I assume calls (load filename)

Allen

On Jun 11, 1:23 pm, hughw hwink...@gmail.com wrote:
 On Jun 11, 11:38 am, Rob rob.nikan...@gmail.com wrote:

  Hi all,

  I'm using Clojure for web apps inside Tomcat.  If I don't compile
  my .clj files ahead of time, I will eventually get one of these
  OutOfMemory errors, after a number of redeployments.  Is there
  something I can do about this?  Is this a bug somewhere, in my code,
  or in Clojure, or in Tomcat; or a limitation of the JVM?

 PermGen space is where Sun's VM keeps class  bytes. It's not garbage
 collected, so if you keep adding classes to a running VM you will
 eventally run out. We can only deploy a couple of times on our non-
 clojure webapp, in Jboss + Tomcat. It's not unique to Clojure, but
 it's true that generating classes on the fly can burn up permGen space
 faster. Try increasng your PermGen space as a workaround. This arg
 your jvm:
 -XX:MaxPermGen=128m or so might help.

 Hugh



  thanks,
  Rob

  Here is the entire barfage from my Tomcat log:

  Jun 11, 2009 12:01:57 PM org.apache.catalina.core.StandardWrapperValve
  invoke
  SEVERE: Servlet.service() for servlet ClojureServlet threw exception
  java.lang.NullPointerException
          at clojure.lang.Var.popThreadBindings(Var.java:289)
          at biz.encodia.webapps.webdispatch
  $make_dispatcher__3759$fn__3761.invoke(webdispatch.clj:90)
          at clojure.lang.Var.invoke(Var.java:350)
          at biz.encodia.webapps.ClojureServlet.processRequest
  (ClojureServlet.java:70)
          at biz.encodia.webapps.ClojureServlet.doGet
  (ClojureServlet.java:99)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:
  617)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:
  717)
          at
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
  (ApplicationFilterChain.java:290)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter
  (ApplicationFilterChain.java:206)
          at org.apache.catalina.core.StandardWrapperValve.invoke
  (StandardWrapperValve.java:233)
          at org.apache.catalina.core.StandardContextValve.invoke
  (StandardContextValve.java:191)
          at org.apache.catalina.authenticator.AuthenticatorBase.invoke
  (AuthenticatorBase.java:433)
          at org.apache.catalina.core.StandardHostValve.invoke
  (StandardHostValve.java:128)
          at org.apache.catalina.valves.ErrorReportValve.invoke
  (ErrorReportValve.java:102)
          at org.apache.catalina.core.StandardEngineValve.invoke
  (StandardEngineValve.java:109)
          at org.apache.catalina.connector.CoyoteAdapter.service
  (CoyoteAdapter.java:286)
          at org.apache.coyote.http11.Http11Processor.process
  (Http11Processor.java:845)
          at org.apache.coyote.http11.Http11Protocol
  $Http11ConnectionHandler.process(Http11Protocol.java:583)
          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run
  (JIoEndpoint.java:447)
          at java.lang.Thread.run(Thread.java:613)
  Jun 11, 2009 12:04:23 PM org.apache.catalina.core.ApplicationContext
  log
  SEVERE: StandardWrapper.Throwable
  java.lang.ExceptionInInitializerError
          at biz.encodia.webapps.ClojureServlet.loadDispatchCode
  (ClojureServlet.java:32)
          at biz.encodia.webapps.ClojureServlet.init(ClojureServlet.java:
  49)
          at org.apache.catalina.core.StandardWrapper.loadServlet
  (StandardWrapper.java:1172)
          at org.apache.catalina.core.StandardWrapper.allocate
  (StandardWrapper.java:808)
          at org.apache.catalina.core.StandardWrapperValve.invoke
  (StandardWrapperValve.java:129)
          at org.apache.catalina.core.StandardContextValve.invoke
  (StandardContextValve.java:191)
          at org.apache.catalina.authenticator.AuthenticatorBase.invoke
  (AuthenticatorBase.java:433)
          at org.apache.catalina.core.StandardHostValve.invoke
  (StandardHostValve.java:128)
          at org.apache.catalina.valves.ErrorReportValve.invoke
  (ErrorReportValve.java:102)
          at org.apache.catalina.core.StandardEngineValve.invoke
  (StandardEngineValve.java:109)
          at org.apache.catalina.connector.CoyoteAdapter.service
  (CoyoteAdapter.java:286)
          at org.apache.coyote.http11.Http11Processor.process
  (Http11Processor.java:845)
          at org.apache.coyote.http11.Http11Protocol
  $Http11ConnectionHandler.process(Http11Protocol.java:583)
          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run
  (JIoEndpoint.java:447)
          at java.lang.Thread.run(Thread.java:613)
  Caused by: java.lang.RuntimeException: java.lang.OutOfMemoryError:
  PermGen space (core.clj:2151)
          at clojure.lang.RT.clinit(RT.java:294)
          ... 15 more
  Caused by: java.lang.OutOfMemoryError: PermGen space 

unit testing private methods?

2009-06-02 Thread Allen Rohner

I have a namespace with some public functions, and some private
functions. I would like to write unit tests for the functions, and put
them in a separate file from the main name space. I would also like to
have an (ns) declaration in my tests file, because the tests require
several libraries. Of course, if I have private methods in namespace
A, I can't call them from namespace B. Right now, it seems I have
several options:

1) put the unit tests in the same file
2) put the unit tests in a separate file, in the same namespace
3) make the private functions public
4) ???

I don't really like the first three options. Ideally, the private
functions would remain private to every namespace except the testing
name space. Is there a good solution for this?

Allen

--~--~-~--~~~---~--~~
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: test-expect functional mocking/expectation library

2009-04-13 Thread Allen Rohner

Of course, it was not until I had an early working version that I discovered 
Allen
 Rohner's expectation tools, but I figured that mine were sufficiently
 different to merit further development (at least relative to the
 latest code of his I could find).


 Suggestions for further changes or improvements are more than
 welcome.  If people find this library useful I'd be more than happy to
 sign the CA and put this in contrib. Also, Allen, if you are
 interested in merging our efforts let me know.  Is your latest code
 available?

 -Matt

I like your code better. I didn't really want to write an expectation
library, I wanted to use an expectation library.

My code was never under serious development. I solved the problem
enough to scratch my itch, and posted the results. What you found is
the latest version of my code, but I don't see anything useful in
there to contribute. I'll start using your library, and if I have any
patches I'll send them your way.

-Allen

--~--~-~--~~~---~--~~
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
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: Transparent delays

2009-04-12 Thread Allen Rohner




  user= (= {:a 5 :b (delay 12)} {:a 5 :b 12})
  false
  user= (= {:a 5 :b (tdelay 12)} {:a 5 :b 12})
  true


 You shouldn't ignore your nervousness in this case:

 user= (= {:a 5 :b 12} {:a 5 :b (tdelay 12)})
 false



Out of curiosity, why are those different?

Allen

--~--~-~--~~~---~--~~
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
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 large Clojure deployment

2009-04-07 Thread Allen Rohner


 It's deployed on an Ubuntu server on Amazon EC2.  Just one server for
 now, but designed to scale to more.  No RDBMS!


Awesome, Congratulations. I was hoping to be the 2nd famous Clojure
app, but it looks you beat me to it. :-)

Can you go into detail about what/how you are persisting since you
aren't using an RDBMS?

Allen


--~--~-~--~~~---~--~~
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
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: inconsistency with ref get

2009-03-30 Thread Allen Rohner


 I disagree. When you understand what's happening (Refs implement IFn
 by dispatching, just like Vars), you see that it has nothing to do
 with obtaining the value of a ref without deref, and get can't work
 since it doesn't take a ref.


Thanks for the explanation. Since get can't work because it doesn't
take a ref, why should (get ref-map :a) return nil? To me, that seems
like a case of failing silently. get should raise an exception when
called with invalid arguments, just like every other function.

Allen

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



inconsistency with ref get

2009-03-29 Thread Allen Rohner

I noticed an inconsistency with refs and get:

(def ref-map (ref {:a 1, :b 2}))

(ref-map :a)
= 1

(get ref-map :a)
= nil

Now I haven't seen any documentation that getting the value of a ref
without a @/deref is supported at all, so maybe this isn't supported.
But if those forms are supported, both forms should return the same
value, and if it isn't supported, I think they should throw
exceptions.

I'm willing to write patches either way.

Allen
--~--~-~--~~~---~--~~
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
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: mocking in clojure

2009-03-16 Thread Allen Rohner



On Mar 13, 3:35 pm, Stephen C. Gilardi squee...@mac.com wrote:
 On Mar 13, 2009, at 4:10 PM, Stuart Sierra wrote:

  Hi Allen,
  Sorry I haven't kept up with this. I think, though, that it's best to
  have it as a standalone library in clojure-contrib, so that people can
  use it with other testing frameworks if they want to.
  -Stuart

 Allen,

 I see you have a contributor agreement on file. I'll be happy to help  
 check this in if you like. Please open an issue at:

        http://code.google.com/p/clojure-contrib/issues/list

 and attach a patch to it that creates the new lib.

 Thanks,

 --Steve

  smime.p7s
 3KViewDownload

Thanks for the suggestions. I'll set up a separate project soon.

One of the reasons I originally wrote this as a patch on test-is was
to get integration with the is assert and reporting functionality. I
guess than can be separated into a backend part and an interface to
the different testing frameworks fairly easily though.

Allen

--~--~-~--~~~---~--~~
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
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: suggestion for resultset-seq and duplicate column names

2009-03-16 Thread Allen Rohner



On Mar 12, 1:32 pm, Ron Lusk ronl...@alum.mit.edu wrote:
 Works for me: I just overwrote my copy of resultset-seq with one that
 uses getColumnLabel, and I am now getting the results I expected from
 complex queries (in Interbase, at least).

 On Feb 23, 9:33 am, Rich Hickey richhic...@gmail.com wrote:

  Sounds good to me - any drawbacks to this? Does it require that the
  columns be named explicitly?

  Rich

The change to getColumnLabel sounds good. Just one word of warning.
The reason the exception is there is that if the columns are still
duplicates, the call to struct-map will explode with an exception that
is not very obvious. (After writing that sentence, I realize that
maybe the better solution is to patch struct-map to complain with an
good error message). I wrote the original patch to throw an exception
in order to make the failure more obvious. Any change should handle
failure gracefully.

Allen

--~--~-~--~~~---~--~~
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
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, swank-clojure, and Debian

2009-03-14 Thread Allen Rohner

On Mar 14, 5:42 am, Javier javu...@gmail.com wrote:
 Ok, I can answer myself, thanks to maacl in the IRC:

 Download clojure-mode:

 git clone git://github.com/jochu/clojure-mode.git

 And put this:

 (add-to-list 'load-path /path/to/clojure-mode)
 (require 'clojure-mode)

 in .emacs, restart, and M-x clojure-install.

 Really fantastic.

 The guide I tried to follow is just broken.

 Thank you.

 On 14 mar, 10:22, Javier javu...@gmail.com wrote:

  Hello, I'm trying to start learning Clojure, but I fail miserably at
  some point trying to get a decent IDE to work.

  - First, Enclojure for Netbeans has lot of bugs, it is inusable for me
  at this stage.
  - I'm not used to Eclipse nor Intellijea, so I discard both.
  - I'm used to Emacs, and have used Slime and SBCL with success before,
  but I must admit that it was too easy: all I had to do is apt-get
  install sbcl slime.

  So I found this guide:

 http://riddell.us/clojure/

  It is for Ubuntu, but I do not see that the process could not be the
  same for Debian.

  I followed the entire guide, checked and rechecked everything. But
  when I want to start slime, I get:

  (add-classpath file:home/javi/program/clojure/swank-clojure/)

  (require 'swank.swank)

  (swank.swank/ignore-protocol-version 2009-03-09)

  (swank.swank/start-server /tmp/slime.20900 :encoding iso-latin-1-
  unix)

  Clojure
  user= nil
  user= java.lang.Exception: Unable to resolve symbol: lazy-seq in this
  context (core.clj:70)
  user= java.lang.Exception: No such var: swank.swank/ignore-protocol-
  version (NO_SOURCE_FILE:5)
  user= java.lang.Exception: No such var: swank.swank/start-server
  (NO_SOURCE_FILE:7)
  user=

  And Slime refuses to full start.

  I am just in the point of giving up and forget Clojure, so please help
  me.
  What I missed?

  Thank you.

Yeah, sorry about that. Clojure continues to have breaking changes
because it's still young, and SLIME refuses to have a stable release,
so it's sometimes hard to coordinate the two. Welcome to the bleeding
edge!

Allen

--~--~-~--~~~---~--~~
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
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: mocking in clojure

2009-03-13 Thread Allen Rohner



  Any other options out there?

I posted a patch for test-is a while ago that never made it in, and I
don't know why.
http://groups.google.com/group/clojure/browse_frm/thread/883d4833f869f764/47a45325c8f29599?lnk=gstq=test-is+expect+patch#47a45325c8f29599

The patch handles creating stub functions, you can specify the return
value of functions and assert that the function is called the correct
number of times.

Allen


--~--~-~--~~~---~--~~
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
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: What profilers are you using?

2009-03-11 Thread Allen Rohner



pmf wrote:
 On Mar 11, 4:41 am, Allen Rohner aroh...@gmail.com wrote:
  Replying to my own question because I figured it out. On the profiler
  tab, before you hit start profiling, click the settings checkbox.
  Edit the start from class field. Mine was set to jline.**. After
  changing it to the appropriate namespace for my app, hit the start
  profiling button. Visualvm starting working reliably for me after
  that.

 Thanks, this works really nice. I tried in vain to get Netbean's
 profiler to work with Clojure, but I'll think I'll stick to jvisualvm
 now.

Just FYI, I am using the standalone download of visualvm from
https://visualvm.dev.java.net/, because I couldn't find visualvm in
the Apple 1.6 JDK

Allen

--~--~-~--~~~---~--~~
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
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: What profilers are you using?

2009-03-10 Thread Allen Rohner



On Feb 7, 9:16 am, David Powell djpow...@djpowell.net wrote:
 Newer versions of JDK 1.6, eg Update 11, have an application called
 'jvisualvm' in the bin directory. It lets you attach to any running
 Java process and it has aprofilerthat you can switch on at runtime.

 It seems quite good. It does profiling via instrumentation, and yet
 doesn't slow the app down to much. I tried it with a clojure module
 that is run from a Java appserver, and it worked well.

 --
 Dave

Can you go into more detail about how you used visualvm? I'm trying to
run it (visualvm 1.1.1), and it seems to have a race condition with
the clojure classloader. Sometimes it won't find all of the compiled
clojure source, and sometimes it will correctly profile methods until
I reload a file, at which point the profiler no longer tracks calls to
the clojure fn.

Any advice?

Allen

--~--~-~--~~~---~--~~
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
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: What profilers are you using?

2009-03-10 Thread Allen Rohner



 Can you go into more detail about how you used visualvm? I'm trying to
 run it (visualvm 1.1.1), and it seems to have a race condition with
 the clojure classloader. Sometimes it won't find all of the compiled
 clojure source, and sometimes it will correctly profile methods until
 I reload a file, at which point theprofilerno longer tracks calls to
 the clojure fn.


Replying to my own question because I figured it out. On the profiler
tab, before you hit start profiling, click the settings checkbox.
Edit the start from class field. Mine was set to jline.**. After
changing it to the appropriate namespace for my app, hit the start
profiling button. Visualvm starting working reliably for me after
that.

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



Resurrecting request for infinity

2009-03-10 Thread Allen Rohner

http://groups.google.com/group/clojure/browse_frm/thread/5e665ce7a318f44a/3ddb49bd3ca34709?lnk=gstq=infinite+inc+0#3ddb49bd3ca34709

I would have replied to the above post, but google groups doesn't seem
to want to let me. In it, Stephen Gilardi makes the case for a fn
equivalent to (iterate inc 0) be built into the language. I ran into
needing to do this again tonight, and forgot the idiom for (iterate
inc 0).

Allen

--~--~-~--~~~---~--~~
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
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: Chrono date library

2009-03-07 Thread Allen Rohner


 Yes, but any library that requires third-party jars can't be used out of
 the box in contrib, and I think a language that doesn't support
 date-processing out of the box is at a severe disadvantage.


One of the primary reasons Clojure is on the JVM is to re-use Java
libraries. Date  Time calculations are

1) notoriously tricky
2) broken or incomplete in almost every language's standard library
3) solved fairly well in Joda

I don't think it's unreasonable to put a dependency on a third party
jar when it solves the problem better than other attempts.

Allen

--~--~-~--~~~---~--~~
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
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: Chrono date library

2009-03-06 Thread Allen Rohner



 What's the status of this JSR? Is it possible the JDK 7 will include
 more palatable date processing capabilities? I think it would be a shame
 if external libraries were required to get sane date processing in
 Clojure, but if the JDK 7 has potential to fix it, that's encouraging.


As far as I can tell, the JSR was approved to go into Java 7, but
there is some risk of them not being done by the deadline. JSR-310 is
a complete re-write, I assume for licensing reasons.

 Most of the problems mentioned seem to be related to timezones. It seems
 the worst case scenario is simply to have Chrono support no
 timezone-aware operations out of the box on JDKs 5 and 6, but be able to
 offer greater capabilities if either the JDK 7 or Joda time is
 installed. I agree that having a more limited library is better than
 having one that claims to have greater capabilities, but has bugs.


Yes, most problems I've encountered and read about are timezone
problems. I'll keep going back to the number of days between Jan 1
and June 1 problem, because it's easy and instructive. You cannot
answer that correctly without specifying a timezone. And if you don't
support timezones, the only timezone where your library can be used
correctly is UTC.

One of the large advantages of Joda is that the API is constructed in
such a way that it is obvious what will happen. For example, there are
two ways to specify a duration, an Instant and a Partial. An Instant
is used to say now + 86400 seconds. A partial is used to say now +
1 week. Those are two different operations because they can have two
different results depending on the current year and timezone.

This is actually a very convenient time to write this note, because it
makes my examples easy. :-) Where I live, Daylight Savings Time
happens this Sunday, and my timezone will change from Central Standard
Time to Central Daylight Time. It is currently Friday Mar 6 10:40 am
CST. If I ask for now + 7 days, the correct answer is Friday Mar
13, 10:40 am CDT. But if I ask for now + 86400 seconds, the correct
answer is Friday Mar 13, 11:40 am CDT. Naively converting from
seconds to days/weeks/months/years is not a well defined operation in
most timezones.

 I'm not convinced the problems can't be worked around once we are made aware 
 of them, but it definitely merits further investigation.

I'm sure the problems can be worked around once you're aware of them,
but a correct solution will end up with a lot of the same concepts as
Joda, and definitely won't have the same API as you do now. If you
base Chrono on Joda you can avoid all of that pain now.

Allen

--~--~-~--~~~---~--~~
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
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: Chrono date library

2009-03-05 Thread Allen Rohner



On Mar 5, 5:49 pm, Phil Hagelberg p...@hagelb.org wrote:
 Cosmin Stejerean cstejer...@gmail.com writes:
  I like the API so far, although I'll probably have to wait for
  timezone support before I can start using this.

 Would love some suggestions on what you'd expect the API to look like
 for this. Failing test cases would be even better. I haven't given it
 much thought yet.

  If anyone else is interested here is a link to github
  for chrono.clj (syntax highlighting). For some reason I couldn't
  locate test-chrono.clj in the repo.

 The convention in contrib is to keep tests in
 src/clojure/contrib/test_contrib/chrono.clj, but I didn't want to attach
 two chrono.clj files, so I renamed it. Here's the link:

 http://github.com/technomancy/clojure-contrib/blob/de4afee3dbfef2ed7f...

 -Phil

I strongly recommend that you make sure you understand where and why
Joda differs from the Java standard lib. If you don't handle the cases
that Joda already does, you *will* have bugs.

I would prefer having a dependency on an extra Jar vs. having bugs.
I'd also prefer having one obviously correct implementation vs.
multiple incorrect implementations and not knowing which one is least
broken, ala the python stdlib.

Joda correctly handles bugs I've personally encountered in java,
python, ruby and postgres.

I'm sorry if this sounds harsh, but I've spent too much time dealing
with Time bugs to suffer the creation of another broken
implementation, especially in my favorite language.

Allen

--~--~-~--~~~---~--~~
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
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: Chrono date library

2009-03-05 Thread Allen Rohner



On Mar 5, 6:10 pm, Phil Hagelberg p...@hagelb.org wrote:
 Allen Rohner aroh...@gmail.com writes:
  I strongly recommend that you make sure you understand where and why
  Joda differs from the Java standard lib. If you don't handle the cases
  that Joda already does, you *will* have bugs.

 Interesting. So far everyone I've talked to who recommended Joda did so
 because the built-in Java classes had extremely awkward/limited APIs,
 not because their behaviour was incorrect in some way.

 I'm definitely interested in looking into this deeper, but what kind of
 problems have you seen? Timezone-related bugs? Leap year problems?

 Perhaps I should look through their test suite.

 -Phil

A few links for more proof:

http://www.ociweb.com/jnb/jnbJul2008.html  As mentioned, one of the
problems with the JDK API is difficulty in calculating the number of
days between two different dates. To learn a bit about how to use Joda
Time, let's see how one can solve that problem a few different ways
using Joda Time. The example finds the number of days from January 1,
2008 to July 1, 2008 ... While this might seem a trivial problem, it
actually is not simple using just the JDK. The typical approach used
with the JDK is to compare the timestamps for the midnights of January
1 and July 1 and divide the result by the number of milliseconds in a
day. While this works in some cases, my computer would give 181.958333
using that approach instead of 182 for the given example. Why? Because
my computer is set to use Daylight Saving Time in the northern
hemisphere, and one hour was skipped in the first half of the year.

http://jcp.org/en/jsr/detail?id=310  This is the JSR for the
replacement of the java date/time libraries. The replacement is being
written by the author of Joda time, largely based on his experience in
Joda time. Section 2.5 of the JSR lists many current problems with the
java std lib time representation.

The javadocs for Date and Calendar are also worth reading:

http://java.sun.com/j2se/1.4.2/docs/api/java/util/Date.html
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Calendar.html

Additionally, the Joda library heavily emphasizes immutable objects.

HTH,

Allen
--~--~-~--~~~---~--~~
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
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: Opinions on - macro? (was Re: Extensive use of let?)

2009-02-27 Thread Allen Rohner



 It's pretty useful for nested keywords:

   (:name (:profile (:user message)))

   (- message :user :profile :name)

 - James

That is really cool. Once again the language and the community impress
me with how elegant the language is.

Allen

--~--~-~--~~~---~--~~
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
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: Mathy operations on non-numerics (was Adding strings)

2009-02-26 Thread Allen Rohner



 So my vote is that String are atomic built in objects, and at least +, 
 and  should work with Strings.  The behavior should be just like Java,
 so (+ foo 2) -- foo2


-1

Concatenation is not addition. I'm almost opposed to numeric operators
all together. If we wrote (add 2 3), there would be no confusion at
all about what (add foo 2) should do, because you'd be writing (conj
foo (str 2))

If addition between a string and number is defined, what is
subtraction between a string and a number?

Allen




--~--~-~--~~~---~--~~
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
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: Mathy operations on non-numerics (was Adding strings)

2009-02-26 Thread Allen Rohner


 I agree regarding concatenation as well, but I think the case for
 comparison of non-numerics is still pretty strong.

 -Phil

Are you referring to using , , =, with objects that implement
java.lang.Comparable?

i.e. given x.compareTo(y) == -1
( x y)
= true

I would find that useful.

Allen

--~--~-~--~~~---~--~~
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
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: Mathy operations on non-numerics (was Adding strings)

2009-02-26 Thread Allen Rohner

 If we wrote (add 2 3), there would be no confusion at
 all about what (add foo 2) should do, because you'd be writing (conj
 foo (str 2))

I wrote this too hastily. This could more easily be written (str foo
2)

--Allen
--~--~-~--~~~---~--~~
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
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: test-is: is called? [PATCH]

2009-02-05 Thread Allen Rohner

On Jan 6, 10:06 pm, Allen Rohner aroh...@gmail.com wrote:
 I had to revisit my test stubbing/expectation code after the recent
 changes to test-is. The good news is, because of the excellent change
 to make is a multi-method, the expectation code easily fits into
 test-is. The following patch adds a new assertion for is, (is
 (called?))

 ;;  creates a stub function, binds it to an existing var and asserts
 ;;  the stub fn was called the correct number of times.

    (is (called? [[user/foo :times 2 :returns 42]
                       [user/bar :times 1 :returns 3]]
          (user/foo x y z)
          (user/bar z)))

 Inside of the called? block, user/foo and user/bar are rebound to stub
 functions, and then asserts that each function is called the proper
 number of times. Currently, the only two options an expectation takes
 are :times and :returns. I expect that more will be needed.

 http://groups.google.com/group/clojure/web/test_is_called.patch

 Allen

I noticed this hasn't been merged in. It's starting to cause some
inconvenience to me because I have tests in my project that depend on
the called? patch. If this still needs work before it's acceptable,
let me know and I'll work on it.

In the mean time, I'll create a fork on github that contains my patch.

Allen

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



very simple javascript source using clojurescript?

2009-01-21 Thread Allen Rohner

Chouser, how usable is clojurescript to generate extremely simple
javascript calls? When creating HTML templates, I find myself using
ugly string interpolation to generate the .js. I would really love it
if I could do something like:

(clojurescript/str (swfobject/embedSWF open-flash-chart.swf
my_chart, 500, 200, 9.0.0, false, {:data-file /my/data}))

turns into:

script type=text/javascript
  swfobject.embedSWF(open-flash-chart.swf, my_chart, 550, 200,
9.0.0, expressInstall.swf, {data-file:/my/data});
/script

There would be no complex code generation, just very simple function
calls being converted to javascript source.

I know this is a much lower bar than you've set out for, but at this
point, is all I need :-)

Allen
--~--~-~--~~~---~--~~
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
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 to implement go to definition and find all references

2009-01-16 Thread Allen Rohner



On Jan 16, 9:32 am, Peter Wolf opus...@gmail.com wrote:
 Hello, and thanks for all the help with the IntelliJ plugin.

 The next feature I want to implement is references.  That is, one
 selects a symbol, and then can go to the location where that symbol was
 defined (e.g. def, defn, let, etc.).  One can also get a list of all the
 locations where that symbol is referenced.  This feature is very nice
 for navigating code, and is also the core of many automatic refactorings
 (e.g. rename).

 Implementing references are pretty straightforward in a static language
 like Java, were all the references are resolved at compile time.  
 However, in a language like Clojure some references get resolved at run
 time.

 How do other IDEs handle this?  Is there a recommended set of rules for
 what references can and can not be resolved by the editor?  How does one
 detect a possible non-static reference, or how does one ensure that a
 reference will always refer to the same location?

 Note that I need a 100% reliable solution, if I am going to implement
 automatic refactoring on top of it.  No one wants refactoring that
 messes up the code 5% of the time.

 Thanks
 Peter

I haven't been following the IntelliJ plugin. Does it use slime? SLIME
+ Lisp has had a solution for this for years by directly asking the
running lisp process. The high level description is that the process
keeps track of all of the functions it has loaded/compiled, and the
list of functions each of those functions calls. Then to find out who
calls foo, you just ask the process. The answer is pretty reliable and
doesn't require writing your own parser. Of course, it too can't deal
with eval'ing and identifiers in XML, but I'm not sure that anything
can.

I've been toying with the idea of implementing this in clojure.

Allen


It would be fairly straightforward to modify the running clojure

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



test-is: set! *e

2009-01-14 Thread Allen Rohner

Here's a trivial patch that I've found useful. After catching an
uncaught exception in a test, set! *e so you can examine the stack
trace afterward.

===
--- src/clojure/contrib/test_is.clj (revision 314)
+++ src/clojure/contrib/test_is.clj (working copy)


@@ -233,7 +289,8 @@
 (try (t)
  (catch Throwable e
(report :error Uncaught exception, not in assertion.
-   nil e))
+   nil e)
+  (set! *e 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
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: Can't lookup java.lang.Long keys in a map using int literal

2009-01-13 Thread Allen Rohner

I still find this confusing, but thanks for the quick response.

 In general, you should use uniform types for hash keys.

I thought I was using all ints, but it turns out that a java API
returned a long when I thought it returned an int. So then my map had
some keys that were ints and some that were long, and some lookups
failed, based on whether the keys were in the code path that returned
ints vs. the code path that returned longs.

What if ints and longs had different literal syntax, i.e. 42 vs. 42L?
In my example above, if you take that map, write it to a string and
then read it back, the behavior would be different. In the original,
the key is a long, and in the reconstituted version, it would be an
int, right?

Allen


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



Can't lookup java.lang.Long keys in a map using int literal

2009-01-12 Thread Allen Rohner

Keys in a map that are of type long can't be looked up in a map using
int literal syntax:

user= (def my_map { (java.lang.Long. 42) foo})
#'user/my_map

user= my_map
{42 foo}

user= (my_map 42)
nil

user= (my_map (long 42))
foo

user= (= 42 (java.lang.Long. 42))
true

I found this behavior incredibly confusing, especially given the fact
that ints and longs print the same.

I believe this is a bug. Rich, do you agree?

Allen

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



test-is: is called? [PATCH]

2009-01-06 Thread Allen Rohner

I had to revisit my test stubbing/expectation code after the recent
changes to test-is. The good news is, because of the excellent change
to make is a multi-method, the expectation code easily fits into
test-is. The following patch adds a new assertion for is, (is
(called?))

;;  creates a stub function, binds it to an existing var and asserts
;;  the stub fn was called the correct number of times.

   (is (called? [[user/foo :times 2 :returns 42]
  [user/bar :times 1 :returns 3]]
 (user/foo x y z)
 (user/bar z)))

Inside of the called? block, user/foo and user/bar are rebound to stub
functions, and then asserts that each function is called the proper
number of times. Currently, the only two options an expectation takes
are :times and :returns. I expect that more will be needed.

http://groups.google.com/group/clojure/web/test_is_called.patch

Allen
--~--~-~--~~~---~--~~
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
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: Multiple table SELECT problem

2009-01-05 Thread Allen Rohner

I made a post about this in October, with an attached patch. I guess
it got lost in the shuffle.

http://groups.google.com/group/clojure/browse_frm/thread/e533e9cdf758f210?q=#43e5775c2d959dc7

I'll file a bug and attach the patch.

Allen

--~--~-~--~~~---~--~~
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
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: reload library, blowing away old public symbols

2008-12-16 Thread Allen Rohner

On Dec 16, 4:55 pm, Stuart Sierra the.stuart.sie...@gmail.com wrote:
 I would find this useful; I've even tried writing it in the past.
 Perhaps it could go in clojure.contrib.ns-utils.

 A thought -- would it be more thorough to use remove-ns?

 -the other Stuart (Sierra)

 On Dec 16, 4:32 pm, Stuart Halloway stuart.hallo...@gmail.com wrote:

  Hi all,

  I sometimes need to (re)load a library, removing public symbols from  
  previously loaded version of the same lib:

  (defmacro ns-reload
     `(do
        (if (find-ns '~ns)
          (doseq [s# (keys (ns-publics '~ns))] (ns-unmap '~ns s#)))
        (require :reload-all '~ns)))

  Use case: Writing tests with Fact [1]. Tests are named with gensyms,  
  and I want to reload a set of tests without continuing to run outdated  
  versions of the tests.

  Does this already exist? It not, is it useful enough to deserve a home  
  somewhere?

  Cheers,
  Stuart

  [1]http://groups.google.com/group/clojure/browse_thread/thread/193023afb...

I'm also interested in having this utility. After it works, the next
thing I would write is (ns-reload-all!), which reloads everything.

Allen

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



test-is uncaught exception behavior

2008-12-15 Thread Allen Rohner

In recent versions of test-is, it appears that exceptions are only
caught inside of the 'is' macro, as opposed to during the whole test
run. This is a problem when running test-is from slime, because when a
test throws an exception outside of the 'is' macro, it requires user
intervention to handle the uncaught exception.

The following modification to test-var worked for me:

diff --git a/src/clojure/contrib/test_is.clj b/src/clojure/contrib/
test_is.clj
index 6a91132..cb97c0b 100644
--- a/src/clojure/contrib/test_is.clj
+++ b/src/clojure/contrib/test_is.clj
@@ -213,7 +213,10 @@
   (when-let [t (:test (meta v))]
   (binding [*test-name* (str v)]
 (report-count :test)
-(t
+   (try
+(t)
+(catch Throwable ex
+  (report :error (str uncaught exception while running 
*test-name*) nil ex))


I didn't use try-expr because it prints expected: (t) when reporting
the failure, because (t) is the name of the local variable inside of
test-var.

Allen
--~--~-~--~~~---~--~~
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
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.contrib.test-is: first major rewrite

2008-12-07 Thread Allen Rohner

 In the mean time; I'm happy to hear about what you think, and
 any other improvements I could make to the library.  Some things I
 have in mind for the next version:

 3. Adding test metadata to vars that are already defined elsewhere.


I had a related idea the other night. I commonly like to write
functional and system tests using a unit test framework, mainly for
the organization and reporting capabilities. Since functional and
system tests are often significantly slower than unit tests, it's nice
to be able to group the tests.

My desired use case is to be able to say something like run all of
the functional tests that hit the DB. Or, run all of the functional
tests that hit the UI.

One obvious way to do that is to tag tests using metadata. Then the
above use case turns into run all of the tests that have metadata tag
:foo. The only problem is that tests are functions, but metadata goes
on Vars. This causes problems when a test is attached to the real
function using the :test metadata flag. Is your tag metadata about the
test, or the real fn?

An acceptable alternative would be to have a way to run all the tests
in a namespace and all 'children' of a namespace. Then I could create
a namespace like test.functional.db.foo test.functional.db.bar and
then say (run-tests-recursive test.functional.db) and have it run
the tests in foo and bar.

Thoughts?

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: clojure.contrib.test-is: first major rewrite

2008-12-07 Thread Allen Rohner

One other feature idea: I'd like the ability to run individual tests.
Once I've discovered a unit test failure, I want to be able to run the
test by itself without the noise from other tests.

Allen
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



expectation framework

2008-11-23 Thread Allen Rohner

I've been working on a small library to assert that functions are
called during a unit test.

The syntax looks like:

(calls [[user/foo :times 2 :returns 3]
   [user/bar :returns 42]]
(fn-being-tested))

This will assert that foo is called exactly twice, and bar is called
exactly once inside the block. I plan to add support for asserting
that the functions are called with the right arguments.

Comments appreciated, especially about my use of macros, and the
syntax.


(ns clojure.contrib.expectation
  (:require [clojure.contrib.test-is :as test]))

(defstruct expectation-hash :called :failed :times)

(defn expect-obj [[var  args]]
  (let [opts (apply hash-map args)
state (ref (struct-map expectation-hash :name var :called
0 :failed [] :times (get args :times 1)))]
{:fn (fn [ _]
   (dosync
(alter state assoc :called (inc (@state :called
   (opts :returns))
 :state state}))

(defn- validate-expectation
  checks that the expectation was met. Returns true on success
  [expt]
  (let [expected-calls (@(expt :state) :times)
actual-calls (@(expt :state) :called)]
(if (= expected-calls actual-calls)
  (do
(test/is true (str (@(expt :state) :name) was called correctly))
true)
  (test/failure (@(expt :state) :name) (str  expected  expected-
calls  actually called  actual-calls  times)

(defmacro calls [args  body]
  creates a stub function and asserts the fn was called the correct
number of times

   (calls [[user/foo :times 2 :returns 42]
   [user/bar :times 1 :returns 3]]
 (user/foo x y z)
 (user/bar z)

  (let [quote-name (fn [sym] `(var ~sym))
get-name (fn [expt] (first expt))
names (into [] (map (comp quote-name get-name) args))]
`(let [expect-opts# (map rest ~args)
   expectations# (map (fn [name# arglist#] (expect-obj (cons name#
arglist#))) ~names expect-opts#)
   fns# (map :fn expectations#)
   thread-bindings# (apply hash-map (interleave ~names fns#))]
   (. clojure.lang.Var (pushThreadBindings thread-bindings#))
   (try
[EMAIL PROTECTED]
(finally
 (. clojure.lang.Var (popThreadBindings
   (every? validate-expectation expectations#
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: with-gensyms

2008-11-20 Thread Allen Rohner



On Nov 20, 1:58 pm, Rock [EMAIL PROTECTED] wrote:
 I've done my best to get a good enough grasp of how macros and syntax-
 quotes work in Clojure. While waiting for some more detailed
 documentation (thanks Meikel), I thought I'd work on something
 practical. Here's my attempt at writing a version of WITH-GENSYMS for
 Clojure, taken directly from Peter Seibel's Practical Common Lisp:

 (defmacro with-gensyms [[ names] form]
   `(let ~(apply vector (loop [n names result []]
                          (if (nil? n)
                            result
                            (recur (rest n)
                                   (conj result (first n) `(gensym))
      ~form))

 Tried it out with macroexpand and it seems to work fine. Let me know
 what you all think. Perhaps something like with-gensyms could be
 included directly in the core lanuage. I've always thought that it
 should have been included in Common Lisp, given that it is employed so
 frequently.

 Rock

I'm new to macros as well. Can you please explain when this would be
useful? How is it different from the auto-gensym that the reader
provides ( foo#)?

Allen

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: General question, what are using for clojure?

2008-11-18 Thread Allen Rohner

On Nov 18, 5:16 pm, BerlinBrown [EMAIL PROTECTED] wrote:
 What projects have you used clojure for?  Have you completed them? Are
 they one-off projects.  Small big?  Is it web based, a GUI?

 I am working on this, haven't made much progress but at least I
 started.

 http://code.google.com/p/botnodetoolkit/

 And if you are interested, post your project here.  I am the
 maintainer.

 http://www.reddit.com/r/codeprojects/

I am working on a startup webapp written in clojure and compojure,
using statistics and simple AI techniques. It's not done yet, but I'll
definitely post it here once it's public.

Allen

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: (Newbie) Are lexically-scoped methods possible?

2008-11-18 Thread Allen Rohner


On Nov 18, 6:48 pm, samppi [EMAIL PROTECTED] wrote:
 I'm trying to unit-test a library with which a user can define methods
 on the library's multi-function to change its behavior. So I need to
 be able to define lexically-scoped methods in each test. Is it
 possible to use let to create a lexically-scoped method?

 The problems I'm encountering are that, unlike for functions, there
 doesn't seem to be a special-form for creating methods, and that even
 if it could be defined it'd go in the current namespace instead of the
 library's namespace. But does anyone know how I can test this anyway?

 Thanks in advance!

Yes, this is all possible.

fn is the special form that creates new functions.

(fn [x] (* x x)) returns an anonymous function.

You can also use let to assign names to the anonymous functions:

(let [foo (fn [x] (* x x))
(println (foo 3))

defn is a macro that translates to

(def name (fn [args] ...))

Allen

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: (Newbie) Are lexically-scoped methods possible?

2008-11-18 Thread Allen Rohner


On Nov 18, 11:53 pm, samppi [EMAIL PROTECTED] wrote:
 Yes, but I meant creating methods rather than regular functions, in a
 lexical scope. Is it possible to create methods using fn?


What do you mean by methods as distinct from functions? In clojure
there are only functions. Are you referring to Java methods?


--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Standard Error to the REPL under Slime?

2008-11-13 Thread Allen Rohner



On Nov 7, 3:00 am, [EMAIL PROTECTED] wrote:
 Hey folks,

 Is there a way to get the System.err directed to the slime-repl
 clojure buffer instead of (or in addition to) inferior-lisp buffer?  I
 looked through the docs, but I didn't see anything obvious.

 Thanks!
 --Darren

I'd also like to be able to do this. The recent swank-clojure history
doesn't show anything promising though.

Allen

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: troubleshooting classloader problems

2008-10-28 Thread Allen Rohner

On Oct 28, 8:48 am, Stuart Halloway [EMAIL PROTECTED] wrote:
 Hi all,

 When I am troubleshooting classloader problems I find myself wanting  
 to know the list of URLs currently on the classpath. I didn't find  
 this exposed anywhere, so I wrote the functions below.

 Usage:

 (take 3 (classpath-url-seq))
 - (file:/Users/stuart/relevance/personal/SHCLOJ_svn/Book/code/
        file:/Users/stuart/repos/clojure-contrib/clojure-contrib.jar
        file:/Users/stuart/devtools/java/joda-time-1.5.2/joda-
 time-1.5.2.jar)

 Of course to be most helpful this needs to be in clojure.jar --  
 otherwise you might have classloader problems loading the classloader  
 help code. :-) Not sure if this is general enough to deserve to be in  
 clojure.jar, but you're welcome to it if others find it useful.

 Stuart

 ; ---
 (defn classloader-seq
    ([] (classloader-seq (clojure.lang.RT/baseLoader)))
    ([cl]
       (loop [loaders (vector cl)]
         (if (nil? (last loaders))
          (drop-last loaders)
          (recur (conj loaders (.getParent (last loaders

 (defn classpath-url-seq [ args]
    (map (memfn toExternalForm)
         (reduce concat
                (map (memfn getURLs)
                     (apply classloader-seq args)

I like it. I think it is a good idea to put it in clojure.jar. It
certainly helps troubleshooting.

Allen

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Debugging with JSwat

2008-10-21 Thread Allen Rohner

 I wonder if this doesn't have something to do with the fact that I'm
 doing everything via the REPL. Is it possible to break on code you've
 evaluated via M-x slime-eval-buffer? I'm able to set breakpoints in
 (e.g.) boot.clj.

I think it does. The compiler associates a file name line number with
each line in your file. The debugger uses those line numbers to set
breakpoints i.e. set breakpoint on file foo.clj, line 15. Eval-ing
into the repl you don't get useful line numbers. Try using slime-load-
file.

Allen

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: offtopic - where are you come from? (poll)

2008-10-17 Thread Allen Rohner



On Oct 17, 4:27 am, Rastislav Kassak [EMAIL PROTECTED] wrote:
 Hello Clojurians,

 I think after 1st year of Clojure life it's good to check how far has
 Clojure spread all over the world.

 So wherever are you come from, be proud and say it.


Austin, Texas

Allen

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Can macros be used for blunt token-pasting?

2008-10-16 Thread Allen Rohner


 I've wanted to do this type of thing before (with CL) and generally
 try to avoid it, so I'll share my reason: the declaration does not
 appear in source code.  

I completely agree with you. That being said, clojure does have a very
useful, underrated feature that makes this kind of problem less of an
issue than in other languages: resolve.

(meta (var (resolve 'foobar)) :file)

Allen

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: with-open binding form

2008-10-13 Thread Allen Rohner

 I noticed with-open kind of stuck out because it doesn't use vectors
 for binding like let, loop, and others.

I had a similar comment about doseq. I don't think the obstacle is the
technical challenge, but rather Rich's decision about whether to do it
or not. This would be a breaking change, or else we'd have to come up
with new names for the new versions. Personally I'm in favor of it.

Allen
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



BUG: resultset-seq breaks on duplicate column names

2008-10-11 Thread Allen Rohner

If you create a SQL query that returns duplicate names, resultset-seq
throws an exception: java.lang.RuntimeException:
java.lang.IllegalArgumentException: Too many arguments to struct
constructor

i.e.

(let [rs (query select description,description from table)]
   (resultset-seq rs)

The following patch adds a method duplicate-col-names? which returns
true if the resultset contains duplicate column names, and modifies
resultset-seq to throw an exception if there are duplicate column
names.

As an aside, now that clojure has real libraries, it seems that
boot.clj is not the best place for the resultset code.

Allen

Index: src/clj/clojure/boot.clj
===
--- src/clj/clojure/boot.clj(revision 1060)
+++ src/clj/clojure/boot.clj(working copy)
@@ -1901,10 +1901,26 @@
 (clojure.lang.LineNumberingPushbackReader.))]
 (load-reader rdr)))

+(defn set
+  Returns a set of the distinct elements of coll.
+  [coll] (apply hash-set coll))
+
+(defn duplicate-col-names? [#^java.sql.ResultSet rs]
+  returns true if the columns in the result set contain duplicate
names
+  (let [rsmeta (. rs (getMetaData))
+   idxs (range 1 (inc (. rsmeta (getColumnCount
+   keys (map (comp keyword (memfn toLowerCase))
+ (map (fn [i] (. rsmeta (getColumnName i))) idxs))
+   unique-keys (set keys)]
+(not (= (count keys) (count unique-keys)
+
+
 (defn resultset-seq
   Creates and returns a lazy sequence of structmaps corresponding to
   the rows in the java.sql.ResultSet rs
   [#^java.sql.ResultSet rs]
+  (when (duplicate-col-names? rs)
+(throw (Exception. resultset-seq does not handle queries with
duplicate column names)))
 (let [rsmeta (. rs (getMetaData))
   idxs (range 1 (inc (. rsmeta (getColumnCount
   keys (map (comp keyword (memfn toLowerCase))
@@ -1916,10 +1932,6 @@
 (lazy-cons (apply struct row-struct (row-values)) 
(thisfn]
   (rows)))

-(defn set
-  Returns a set of the distinct elements of coll.
-  [coll] (apply hash-set coll))
-
 (defn #^{:private true}
   filter-key [keyfn pred amap]
 (loop [ret {} es (seq amap)]

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: REPL does not print stack trace in some cases

2008-10-11 Thread Allen Rohner

It's odd to me that that the stack traces were only removed in a few
instances. There are still plenty of places that do print traces.

I'm all in favor of getting rid of the meaningless stack traces,
once we have better error reporting.

Allen

On Oct 11, 2:36 pm, Chouser [EMAIL PROTECTED] wrote:
 On Sat, Oct 11, 2008 at 1:26 PM, Allen Rohner [EMAIL PROTECTED] wrote:

  If you exercise the bug in my previous post about resultset-seq, the
  repl will not print a stack trace, it will only print the name of the
  exception and the message.

 That's a feature!  I recent one, no less.

 Seriously, people were complaining about giant meaningless stack
 traces at the REPL, so the default now is to just print the exception
 itself.  To get the stack trace after an exception has occurred, try:

 (.printStackTrace *e)

 --Chouser
--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: can we change how contains? works for vectors

2008-10-03 Thread Allen Rohner

 It is not necessary. All Java collections can already be turned in to
 sets using set:

 (set (java.util.ArrayList. [1 2 3 4 5 3 2]))
 #{1 2 3 4 5}

 Enumerations are not collections, but can be turned into seqs
 (manually only) using enumeration-seq.

 Rich

It's always great to see stuff already worked. Thanks!

Allen

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Getting Started is NOT starting for me...

2008-09-19 Thread Allen Rohner

On Sep 19, 1:10 pm, .Bill Smith [EMAIL PROTECTED] wrote:
 I see the same problem on Windows XP SP 3.

 % java -version
 java version 1.6.0_03
 Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
 Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode)


Works for me on XP SP2.

$ java -version
java version 1.5.0_04
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)

Allen

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Improved compiler error messages, part 2

2008-09-18 Thread Allen Rohner

 I've made some enhancements to the location info (rev 1031), see if
 that helps.

 Rich

This looks good. 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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Improved compiler error messages, part 2

2008-09-18 Thread Allen Rohner

Ok, I have a new one.

Reader errors don't tell you the name of the file that had problems:

eof.clj:

(defn foo [a]
   (println hello)

$ java -cp clojure.jar clojure.lang.Repl eof.clj
java.lang.Exception: ReaderError:(3,1) EOF while reading
at clojure.lang.LispReader.read(LispReader.java:164)
at clojure.lang.Compiler.load(Compiler.java:4253)
at clojure.lang.Compiler.loadFile(Compiler.java:4224)
at clojure.lang.Repl.main(Repl.java:48)
Caused by: java.lang.Exception: EOF while reading
at clojure.lang.LispReader.readDelimitedList(LispReader.java:847)
at clojure.lang.LispReader$ListReader.invoke(LispReader.java:784)
at clojure.lang.LispReader.read(LispReader.java:130)
... 3 more
Clojure
user=

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Patch to provide special form documentation online (doc, find-doc)

2008-09-18 Thread Allen Rohner



  There's simply no substitute for reading the special forms page on the
  site, and everyone who intends to use Clojure should do so in its
  entirety.

  If we want to make it so (doc def) et al do something, they should
  return the simple message:

  Please see:http://clojure.org/special_forms


I think it's very cool that this works at all. I've gotten annoyed at
the equivalent to doc in other languages because it didn't work on
special forms.

I completely agree that users should read the site, but can we make
the special form doc just include a reminder of the syntax and then
link to the site? i.e.

user= (doc if)
-
(if test then)
(if test then else)

Special Form. Please see http://clojure.org/special_forms/if for more
information.

Allen



--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Improved compiler error messages, part 2

2008-09-18 Thread Allen Rohner



 Reader errors don't tell you the name of the file that had problems:

 eof.clj:

 (defn foo [a]
    (println hello)

 $ java -cp clojure.jar clojure.lang.Repl eof.clj
 java.lang.Exception: ReaderError:(3,1) EOF while reading
         at clojure.lang.LispReader.read(LispReader.java:164)
         at clojure.lang.Compiler.load(Compiler.java:4253)
         at clojure.lang.Compiler.loadFile(Compiler.java:4224)
         at clojure.lang.Repl.main(Repl.java:48)
 Caused by: java.lang.Exception: EOF while reading
         at clojure.lang.LispReader.readDelimitedList(LispReader.java:847)
         at clojure.lang.LispReader$ListReader.invoke(LispReader.java:784)
         at clojure.lang.LispReader.read(LispReader.java:130)
         ... 3 more
 Clojure
 user=

Here's my attempt at a patch to fix the above problem

I made the existing LispReader.read() private. I made a new public
LispReader.read() that takes an extra argument, a sourcePath. The new
method pushes the sourcePath into a var and then calls the private
method. Then I modifed all existing calls to LispReader.read() to use
the new method.

http://clojure.googlegroups.com/web/reader-error.diff

Feedback?

Allen



--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Improved compiler error messages, part 2

2008-09-17 Thread Allen Rohner


 It seems to me you need to distinguish runtime errors from compilation
 errors. For runtime errors, the file and line numbers are already in
 the stack trace, as Clojure emits that information in the bytecode.
 For example, in the above trace:

          at user.eval__2291.invoke(broken-arity.clj:6)

 I'm not going to make any changes for people unwilling to look a few
 lines down in a stack trace.

I don't think that unwillingness is the only criteria here. One reason
is for consistency. We're already heading down the track of making
compiler error messages easier to read. It doesn't seem very friendly
to make the compiler error messages easier and then intentionally
leave the runtime errors obfuscated. Another reason is ease of
understanding. I can read the stack trace just fine, but I will
happily write the patch just because it makes my edit-compile-test
cycle easier and faster. It's much easier to read the problem at the
top than to filter through the stack trace.


 A new exception class hierarchy that duplicates these values seems
 redundant. The world does not need more exception types, or a
 reinvention of stack traces, IMO.

I've seen cases where the default Java exception.printStackTrace()
doesn't include the entire stack and the part that I care about is
hidden in that and 60 more lines message. I think there it's
entirely appropriate to write our own printStackTrace() that does
display everything. I'll post to the group the next time I see one of
those.

My goal in creating a new exception type was to avoid copypaste code.
At the point where you want to throw a new exception, I see a few
possible choices here.

1) throw new java.lang.IllegalArgumentException(Too many arguments to
def);
2) throw new
java.lang.IllegalArgumentException(Compiler.SOURCE_PATH.get() +  line
 + Compiler.LINE_AFTER.get() + Too many arguments to def);
3) throw new
java.lang.IllegalArgumentException(Compiler.exceptionPrefix() + Too
many arguments to def);
4) throw new Clojure.CompileError(too many arguments to def);

where Compiler.exceptionPrefix() is

String exceptionPrefix()
{
   return Compiler.SOURCE_PATH.get() +  line  +
Compiler.LINE_AFTER.get();
}

1 is the current code. 2,3,4 have the same behavior, with increasing
levels of encapsulation. I assume you are in favor of 3) then?

Allen

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Clojure Poll 09/2008

2008-09-11 Thread Allen Rohner



On Sep 11, 8:32 am, Paul Stadig [EMAIL PROTECTED] wrote:
 I have a stupid idea as well (related to reader macros). Is there any
 way we can get the reader to not have problems with
 #!/usr/bin/clojure as the first line?

 This would allow simple and standard use of Clojure in a script file.
 Or perhaps a solution (other than mucking with the reader) is to have
 clojure.lang.Script ignore the first line if it is the shebang?

 I mean this is cool (in a really geeky way)

 #^:shebang '[
 exec java -cp $HOME/src/clj/clojure/clojure.jar clojure.lang.Script
 $0 -- $@
 ]

 But its not standard, nor is it simple to remember, and if you have a
 bin script that does stuff like read a Clojure rc file, or set the
 classpath, or something you either lose that functionality, or you
 have to basically try to duplicate the bin script at the top of every
 clojure script. Additionally, if you want to hard code the path for
 security like so

 #^:shebang '[
 exec /usr/bin/java -cp $HOME/src/clj/clojure/clojure.jar
 clojure.lang.Script $0 -- $@
 ]

 Clojure has issues with it.


I already voted, but I agree with this. Having a standard way to run
clojure scripts from a  command line would be very useful.

Allen

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: local functions?

2008-09-10 Thread Allen Rohner

I apologize for the double post. An emacs shortcut didn't work very
well in my firefox edit window. :-). Now to actually finish what I was
trying to type.

I was considering putting this in Rich's Clojure poll, but I wasn't
sure it was broken yet.

Is there a cleaner way to create local functions than
(let [foo (fn [x]
...)]
   (foo 42))

?

I find that syntax to be slightly annoying, because you could end up
with multiple lines and a good amount indentation even in small local
functions. I find myself writing lots of small defns right before a
real defn that I intended to write. It would be nice if there were a
nice way t define these inside the real defn.

I would like to write a macro to improve this, but I don't see how you
could ever end up with the following, unless there is a way to mess
with the enclosing function's bindings

(def bar [x]
   (localfn foo [y]
...)
   (localfn baz [z]
...)
   (foo (baz x)))

Allen

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: local functions?

2008-09-10 Thread Allen Rohner



On Sep 10, 5:01 pm, Allen Rohner [EMAIL PROTECTED] wrote:
  For very short functions one can use the cut notation: #(...). In case
  there are several functions or functions going over several lines, this
  is a sign that they should go into an own defn(-) with appropriate
  docstring.

Sorry, emacs again. I'm having the stupids today.

Maybe the solution is to use defn-. Scheme made me used to the local
function approach for encapsulation. I don't have a problem with doing

 (defn foo [x]
     (defn bar [y]
   doc string)
     (defn baz [z]
   doc string2)
     (do_stuff (bar[x]))

except that the interior defns are public. To me, the local functions
are a stronger indication that bar and baz are *only* used inside foo.
That indication isn't as apparent with


(defn bar [y]
   ...)

(defn baz [z]
  ...)

(defn foo [x]
  (do_stuff (bar x)))

As an aside, how is (defn- ) supposed to work? private symbols cannot
be referred to outside of the namespace? The macroexpand looks
identical:

user= (macroexpand '(defn- foo [x] x))
(def foo (clojure/fn ([x] x)))
user= (macroexpand '(defn foo [x] x))
(def foo (clojure/fn ([x] x)))

Allen



--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Clojure Robustness

2008-09-03 Thread Allen Rohner

 Any opinions on whether Clojure is solid enough to be used in actual
 production systems?

I have no data yet, but I'm planning on putting a webapp on the web
using compojure just as soon as it's ready.

Allen

--~--~-~--~~~---~--~~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---