Re: Most Elegant Clojure Solution For Wilson's Maze Algorithm

2011-01-24 Thread Christophe Grand
Hi Conrad, Here is my take: https://gist.github.com/792959 Since I despise indices I wrote the core algorithm without them. That gave me a maze generation code which can create a maze in any kind of graph. This would be fun to run it on the utah teapot for example :-) Christophe On Thu, Jan

Re: A tiny producer-consumer framework

2011-01-24 Thread Eric Schulte
Ken Wesson kwess...@gmail.com writes: On Sat, Jan 22, 2011 at 11:26 AM, Eric Schulte schulte.e...@gmail.com wrote: Nice concise example, Thanks. A while back I implemented something similar; a propagator system using agents fed with `send', coming in at a slightly more verbose ~35 lines

Re: ANN: A simple scheme interpreter in clojure

2011-01-24 Thread dennis
Thanks,it is an issue. On Jan 24, 1:09 pm, David dsieg...@yahoo.com wrote: Line 86 of core.clj is:         (list 'cadr caddr) and should be:         (list 'caddr caddr) On Jan 23, 9:45 pm, dennis killme2...@gmail.com wrote: I have implemented a simple interpreter in clojure,it is just

Re: ANN: A simple scheme interpreter in clojure

2011-01-24 Thread dennis
Hi, Yes,i have seen the rscheme. cscheme is just an exercise,it is not practical at all. On Jan 24, 1:44 pm, Andrzej ndrwr...@googlemail.com wrote: Hi, You may want to see if there is anything of interest for you there:http://clojure.wikidot.com/scheme-interpreter-in-clojure It has its

api doc for clojure/libraries

2011-01-24 Thread Abraham
Dear all , how to get api download/generate for various lib such as contrib , enlive ,etc. thanks -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are

Re: api doc for clojure/libraries

2011-01-24 Thread .Bill Smith
You can download Clojure 1.2 by going to http://clojure.org/, clicking the Download link, and then clicking the Clojure 1.2 and Clojure Contrib 1.2 links. Bill -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

anon func syntax confusion

2011-01-24 Thread László Török
Hi, just a quick one: (mapcat #([% 1]) [1 3 5]) gives an exception (wrong argument) (mapcat (fn [a] [a 1]) [1 3 5]) works though... What did I get wrong? Thx Las -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email

Re: anon func syntax confusion

2011-01-24 Thread Meikel Brandmeyer
Hi, On 24 Jan., 13:59, László Török ltoro...@gmail.com wrote: just a quick one: (mapcat #([% 1]) [1 3 5]) gives an exception (wrong argument) (mapcat (fn [a] [a 1]) [1 3 5]) works though... What did I get wrong? #([% 1]) is equivalent to (fn [a] ([a 1])). Note the extra parens. You

Re: anon func syntax confusion

2011-01-24 Thread Nick Zbinden
That a problem people find often. The thing is #(%) not the same as (fn [x] x) its more like (fn [x] (x)). So if you write #([x]) is (fn [x] ([x])) witch throws an error. You would have to write #(vec %). On Jan 24, 1:59 pm, László Török ltoro...@gmail.com wrote: Hi, just a quick one:

Re: anon func syntax confusion

2011-01-24 Thread László Török
Thanks! :) 2011/1/24 Nick Zbinden nick...@gmail.com That a problem people find often. The thing is #(%) not the same as (fn [x] x) its more like (fn [x] (x)). So if you write #([x]) is (fn [x] ([x])) witch throws an error. You would have to write #(vec %). On Jan 24, 1:59 pm, László

Re: A tiny producer-consumer framework

2011-01-24 Thread Ken Wesson
On Mon, Jan 24, 2011 at 3:22 AM, Eric Schulte schulte.e...@gmail.com wrote: Ken Wesson kwess...@gmail.com writes: Why (fn [_] value) instead of (constantly value)? OK, actually (constantly value) is textually longer, but I'd argue it might be clearer. And it works; (constantly foo) accepts all

Re: api doc for clojure/libraries

2011-01-24 Thread Abraham
sorry , i want the documentation .which are the functions available ... etc? -- 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

Re: How does pmap partition its work?

2011-01-24 Thread Michael Gardner
On Jan 23, 2011, at 10:56 PM, Ken Wesson wrote: I've managed to make this more efficient, by making each agent send process a larger portion of the job than one single item: (defn eager-pmap [f colls] (let [cores (.. Runtime getRuntime availableProcessors) agents (cycle (for [_

Re: api doc for clojure/libraries

2011-01-24 Thread .Bill Smith
If you go to http://clojure.org/ and look at the links on the left-hand side of the page, you will find information about the language and the APIs. In particular, the API link on the left-hand side of the page takes you to information about all the core and contrib functions in the 1.2

basic exception handling

2011-01-24 Thread Ryan Waters
The following code doesn't catch the exception thrown like I think it should. Any recommendations appreciated. https://gist.github.com/793340 Thank you, Ryan - - - - (ns my-ns (:use [clj-time.core :only [date-time]])) (defn my-date-time same as clj-time.core date-time but returns nil on

Re: ANN: A simple scheme interpreter in clojure

2011-01-24 Thread Andrzej
On Mon, Jan 24, 2011 at 5:50 PM, dennis killme2...@gmail.com wrote: Hi, Yes,i have seen the rscheme. cscheme is just an exercise,it is not practical at all. So was rscheme. :-) In many respects your implementation is more complete than mine. Cheers, Andrzej -- You received this message

Re: api doc for clojure/libraries

2011-01-24 Thread Ken Wesson
On Mon, Jan 24, 2011 at 10:16 AM, Abraham vincent@gmail.com wrote: sorry , i want the documentation .which are the functions available ... etc? For clojure.contrib? There's documentation on the web at http://clojure.github.com/clojure-contrib/ and though I don't see a download link you

Re: [ANN] fs - file system utilities for Clojure

2011-01-24 Thread Michael Gardner
On Jan 19, 2011, at 11:32 AM, Miki wrote: I'd appreciate some comments about need functionality, bugs, code reviews and such. Thanks for this useful library. Some suggestions: -I'd rather (copy-tree src dest) worked like cp -R src dest (including when dest doesn't exist) rather than cp -R

Re: How does pmap partition its work?

2011-01-24 Thread Armando Blancas
This is much faster than either of the other eager-pmaps I posted to this thread, and yet it's only using 60% CPU on my dual-core box. That means there's still another x1.6 or so speedup possible(!) but I'm not sure how. Could -server make a difference here? -- You received this message

Re: Getting started with Counterclockwise

2011-01-24 Thread Sean Corfield
On Sun, Jan 23, 2011 at 7:57 PM, Ken Wesson kwess...@gmail.com wrote: Which tempts me to ask why you decided to bring it up again? :) Because the topic arose again. Because _you_ brought the topic up again. Did you expect a different outcome this time? You know what they say about madness

Re: A tiny producer-consumer framework

2011-01-24 Thread Eric Schulte
That would be a great application for this system.  Each cell of the spreadsheet could be a cell, and each formula could be a propagator. I've implemented this and it seems to work well, I've committed this to the repo above, and posted the spreadsheet code with example usage into a gist at

Re: How does pmap partition its work?

2011-01-24 Thread Ken Wesson
On Mon, Jan 24, 2011 at 10:29 AM, Michael Gardner gardne...@gmail.com wrote: Thanks for the work, Ken. You're welcome. Clojure's multi-threaded performance can be mysterious indeed I think that may be generally true of multi-processing of every kind. :) Anyway, for now I will probably just

Re: api doc for clojure/libraries

2011-01-24 Thread Abraham
how to get api docs for libraries such as enlive , etc? -- 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

Re: How does pmap partition its work?

2011-01-24 Thread Ken Wesson
On Mon, Jan 24, 2011 at 11:05 AM, Armando Blancas armando_blan...@yahoo.com wrote: This is much faster than either of the other eager-pmaps I posted to this thread, and yet it's only using 60% CPU on my dual-core box. That means there's still another x1.6 or so speedup possible(!) but I'm not

Re: api doc for clojure/libraries

2011-01-24 Thread .Bill Smith
I don't think there is a catch-all mechanism for downloading documentation for all libraries accessible by or written in Clojure. Perhaps you could try going to the website for each library you are interested in and looking for links with names like Download and Documentation. That often

Re: basic exception handling

2011-01-24 Thread Ken Wesson
On Mon, Jan 24, 2011 at 10:32 AM, Ryan Waters ryan.or...@gmail.com wrote: The following code doesn't catch the exception thrown like I think it should.  Any recommendations appreciated. https://gist.github.com/793340 Thank you, Ryan - - - - (ns my-ns  (:use [clj-time.core :only

Re: Getting started with Counterclockwise

2011-01-24 Thread Ken Wesson
On Mon, Jan 24, 2011 at 11:14 AM, Sean Corfield seancorfi...@gmail.com wrote: On Sun, Jan 23, 2011 at 7:57 PM, Ken Wesson kwess...@gmail.com wrote: Which tempts me to ask why you decided to bring it up again? :) Because the topic arose again. Because _you_ brought the topic up again. Did

Re: ANN: A simple scheme interpreter in clojure

2011-01-24 Thread Alan
Arguably it should be neither of these, but instead a macro of some kind. The solution that would make it impossible to get this wrong would be something like: (defmacro primitives [ specs] `(list ~@(for [s specs] (if (coll? s) `(list '~(first s) ~(second s)) `(list

Re: basic exception handling

2011-01-24 Thread Ryan Waters
Thank you Ken - I should have checked for Exception; not sure why I didn't. Your other explanations were helpful too. -- 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

Calling .close() on resources -- with-open macro

2011-01-24 Thread Shantanu Kumar
I noticed that in 'with-open' macro the .close() method is called without wrapping in another try-catch block. Exceptions raised in the finally block prevails over the exception raised in the try block. Is this intended behavior or I am missing something? Is there an alternative where the

Proposal for new implementation of defnk

2011-01-24 Thread Jeff Palmucci
I'd like to propose different implementation of defnk, attached below. Defnk2 translates keyword arguments to positional arguments at compile time, and is therefore about 36x faster on my machine. (defn expand-keyword-call [name pos kw-defaults args] (if ( (count args) (count pos)) (throw

Re: basic exception handling

2011-01-24 Thread Ken Wesson
On Mon, Jan 24, 2011 at 2:19 PM, Ryan Waters ryan.or...@gmail.com wrote: Thank you Ken - I should have checked for Exception; not sure why I didn't.  Your other explanations were helpful too. You're welcome. -- You received this message because you are subscribed to the Google Groups Clojure

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Laurent PETIT
2011/1/24 Shantanu Kumar kumar.shant...@gmail.com: I noticed that in 'with-open' macro the .close() method is called without wrapping in another try-catch block. Exceptions raised in the finally block prevails over the exception raised in the try block. Is this intended behavior or I am

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Michael Gardner
On Jan 24, 2011, at 1:54 PM, Laurent PETIT wrote: That's interesting. Indeed, it seems to me that the .close() call should be wrapped by a try / catch with an empty catch. Why would client code want an exception thrown by .close() to get swallowed? Is that not unexpected behavior in most

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread dysinger
Just wrap it if you are paranoid about exception on close (try (with-open [x y] (throw (Exception. lololol))) (catch Exception e (println (.getMessage e -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Shantanu Kumar
On Jan 25, 1:26 am, dysinger t...@dysinger.net wrote: Just wrap it if you are paranoid about exception on close (try (with-open [x y]        (throw (Exception. lololol)))      (catch Exception e (println (.getMessage e     The problem is that exception thrown by .close() overshadows

Re: api doc for clojure/libraries

2011-01-24 Thread Nurullah Akkaya
No need for wget etc, For core you can download from, https://github.com/clojure/clojure/tree/gh-pages For contrib, https://github.com/clojure/clojure-contrib/tree/gh-pages Just click on download... Regards... -- Nurullah Akkaya http://nakkaya.com On Mon, Jan 24, 2011 at 5:55 PM, Ken

Re: api doc for clojure/libraries

2011-01-24 Thread Ken Wesson
On Mon, Jan 24, 2011 at 3:58 PM, Nurullah Akkaya nurul...@nakkaya.com wrote: No need for wget etc, For core you can download from, https://github.com/clojure/clojure/tree/gh-pages For contrib, https://github.com/clojure/clojure-contrib/tree/gh-pages Just click on download... Perhaps

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread dysinger
(try (with-open [x y] ... ) (catch Exception)) ;; - catches any exception from with-open macro I don't think you are correct. -- 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

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Ken Wesson
On Mon, Jan 24, 2011 at 4:07 PM, dysinger t...@dysinger.net wrote: (try (with-open [x y] ... )      (catch Exception))  ;; - catches any exception from with-open macro I don't think you are correct. He is. Close exceptions lose any other exception or return value: user= (defprotocol

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Shantanu Kumar
On Jan 25, 2:07 am, dysinger t...@dysinger.net wrote: (try (with-open [x y] ... )      (catch Exception))  ;; - catches any exception from with-open macro I don't think you are correct. Maybe this is subjective, but I am rarely interested in knowing what exception does .close() throw - I

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread dysinger
Yes. you are correct and I agree that you would lose the original exception or return type. I was just saying you could catch the exception of the IO close if needed. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Luc Prefontaine
On Mon, 24 Jan 2011 13:30:49 -0800 (PST) Shantanu Kumar kumar.shant...@gmail.com wrote: On Jan 25, 2:07 am, dysinger t...@dysinger.net wrote: (try (with-open [x y] ... )      (catch Exception))  ;; - catches any exception from with-open macro I don't think you are correct.

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Aaron Cohen
On Mon, Jan 24, 2011 at 2:27 PM, Shantanu Kumar kumar.shant...@gmail.com wrote: I noticed that in 'with-open' macro the .close() method is called without wrapping in another try-catch block. Exceptions raised in the finally block prevails over the exception raised in the try block. Is this

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Shantanu Kumar
On Jan 25, 2:47 am, Aaron Cohen aa...@assonance.org wrote: On Mon, Jan 24, 2011 at 2:27 PM, Shantanu Kumar kumar.shant...@gmail.com wrote: I noticed that in 'with-open' macro the .close() method is called without wrapping in another try-catch block. Exceptions raised in the finally

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Laurent PETIT
Yes, you're right Shantanu. apache commons io and spring framework, to name 2 things I know for sure, are doing what you say: they swallow any exception that could be thrown within the finally block, for the reasons you mention. Of course, with-open allowing to do several binding, the

Re: Getting clojure projects into maven central - aot vs sources, -javadoc and -sources artifacts

2011-01-24 Thread Peter Schuller
First, Sonatype's validation of -sources.jar and -javadoc.jar aren't as stringent as you might expect.  That is, the OSS/central repos' validation routines appear to check for the existence of those artifacts corresponding to a given jar artifact, but they aren't inspected for completeness.

Re: anon func syntax confusion

2011-01-24 Thread Karl Ward
On Monday, January 24, 2011 12:59:09 PM UTC, Las wrote: What did I get wrong? I believe #([% 1]) is equivalent to (fn [a] ([a 1])), not (fn [a] [a 1]) . Thus, for #([% 1]) , [% 1] is called as a function. Vectors are functions that take an index and return the vector's value at that index.

Re: api doc for clojure/libraries

2011-01-24 Thread David Steiner
To build a browse-able API for clojure projects, you can use autodoc: http://tomfaulhaber.github.com/autodoc/ On 1/24/11, .Bill Smith william.m.sm...@gmail.com wrote: You can download Clojure 1.2 by going to http://clojure.org/, clicking the Download link, and then clicking the Clojure 1.2 and

Re: api doc for clojure/libraries

2011-01-24 Thread Adam
I personally find clojure docs (http://clojuredocs.org/) to be the best source of core/contrib documentation. ~Adam~ -- 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

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread David Powell
apache commons io and spring framework, to name 2 things I know for sure, are doing what you say: they swallow any exception that could be thrown within the finally block, for the reasons you mention. True, but if the body doesn't throw an exception, but the close does, I wouldn't want the

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Laurent PETIT
2011/1/24 David Powell djpow...@djpowell.net: apache commons io and spring framework, to name 2 things I know for sure, are doing what you say: they swallow any exception that could be thrown within the finally block, for the reasons you mention. True, but if the body doesn't throw an

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread David Powell
apache commons io and spring framework, to name 2 things I know for sure, are doing what you say: they swallow any exception that could be thrown within the finally block, for the reasons you mention. True, but if the body doesn't throw an exception, but the close does, I wouldn't want the

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Laurent PETIT
2011/1/25 Laurent PETIT laurent.pe...@gmail.com: 2011/1/24 David Powell djpow...@djpowell.net: apache commons io and spring framework, to name 2 things I know for sure, are doing what you say: they swallow any exception that could be thrown within the finally block, for the reasons you

Re: api doc for clojure/libraries

2011-01-24 Thread OGINO Masanori
Hello. If you have REPL, you can get any documentation via doc and find-doc functions. (doc reduce) ; print the documentation of reduce (find-doc append) ; search documentations including word append doc function can be used with almost all things documented: variable, function, namespace, etc.

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Alan
On Jan 24, 3:05 pm, Laurent PETIT laurent.pe...@gmail.com wrote: 2011/1/24 David Powell djpow...@djpowell.net: apache commons io and spring framework, to name 2 things I know for sure, are doing what you say: they swallow any exception that could be thrown within the finally block, for

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Laurent PETIT
2011/1/24 Laurent PETIT laurent.pe...@gmail.com: Yes, you're right Shantanu. apache commons io and spring framework, to name 2 things I know for sure, are doing what you say: they swallow any exception that could be thrown within the finally block, for the reasons you mention. for the

Re: [ANN] fs - file system utilities for Clojure

2011-01-24 Thread Miki
-I'd rather (copy-tree src dest) worked like cp -R src dest (including when dest doesn't exist) rather than cp -R src/* dest/. I agree, working on that. -It would be nice if functions that create files or dirs (like mkdir and touch) returned the new object's path, to allow chaining.

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Laurent PETIT
2011/1/25 Alan a...@malloys.org: On Jan 24, 3:05 pm, Laurent PETIT laurent.pe...@gmail.com wrote: 2011/1/24 David Powell djpow...@djpowell.net: apache commons io and spring framework, to name 2 things I know for sure, are doing what you say: they swallow any exception that could be

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Ken Wesson
Are we generally agreed that we want to preserve the body exception, if any, else the close exception, if any, else the body return value? Then, without further ado: (defmacro with-open2 [binding-exprs body] (if ( (count binding-exprs) 2) `(with-open2 ~(vec (take 2 binding-exprs))

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread David Powell
apache commons io and spring framework, to name 2 things I know for sure, are doing what you say: they swallow any exception that could be thrown within the finally block, for the reasons you mention. True, but if the body doesn't throw an exception, but the close does, I wouldn't want the

Re: Why no def- ?

2011-01-24 Thread Jeff Rose
On Jan 22, 5:13 pm, Stuart Halloway stuart.hallo...@gmail.com wrote: Please don't. It has already been discussed and declined. The metadata is uglier because we want doing this to be slightly ugly.. The Clojure/core team is led by its technical advisors, Rich Hickey and myself.  In this

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Aaron Cohen
On Mon, Jan 24, 2011 at 4:54 PM, Shantanu Kumar kumar.shant...@gmail.com wrote: On Jan 25, 2:47 am, Aaron Cohen aa...@assonance.org wrote: On Mon, Jan 24, 2011 at 2:27 PM, Shantanu Kumar kumar.shant...@gmail.com wrote: I noticed that in 'with-open' macro the .close() method is called

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Laurent PETIT
2011/1/25 Ken Wesson kwess...@gmail.com: Are we generally agreed that we want to preserve the body exception, if any, else the close exception, if any, else the body return value? Then, without further ado: (defmacro with-open2 [binding-exprs body]  (if ( (count binding-exprs) 2)    

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Ken Wesson
On Mon, Jan 24, 2011 at 7:26 PM, Aaron Cohen aa...@assonance.org wrote: The inner exception to me should clearly be caught and not rethrown. So I would really expect to see two printouts when this is run, once for doit and once for close. Neither would I. I think you've misunderstood

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Ken Wesson
On Mon, Jan 24, 2011 at 7:32 PM, Laurent PETIT laurent.pe...@gmail.com wrote: 2011/1/25 Ken Wesson kwess...@gmail.com: Are we generally agreed that we want to preserve the body exception, if any, else the close exception, if any, else the body return value? Then, without further ado:

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Alan
Thanks, Ken. Much more productive than all this philosophy about what makes sense the rest of us are discussing; I'd vote for this patch if you put it in JIRA. On Jan 24, 3:59 pm, Ken Wesson kwess...@gmail.com wrote: Are we generally agreed that we want to preserve the body exception, if any,

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Laurent PETIT
2011/1/25 Ken Wesson kwess...@gmail.com: On Mon, Jan 24, 2011 at 7:32 PM, Laurent PETIT laurent.pe...@gmail.com wrote: 2011/1/25 Ken Wesson kwess...@gmail.com: Are we generally agreed that we want to preserve the body exception, if any, else the close exception, if any, else the body return

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Ken Wesson
On Mon, Jan 24, 2011 at 7:40 PM, Alan a...@malloys.org wrote: Thanks, Ken. Much more productive than all this philosophy about what makes sense the rest of us are discussing; I'd vote for this patch if you put it in JIRA. No patch; sorry; don't have a CA. Laurent improved on it somewhat

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Laurent PETIT
2011/1/25 Ken Wesson kwess...@gmail.com: On Mon, Jan 24, 2011 at 7:32 PM, Laurent PETIT laurent.pe...@gmail.com wrote: 2011/1/25 Ken Wesson kwess...@gmail.com: Are we generally agreed that we want to preserve the body exception, if any, else the close exception, if any, else the body return

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Laurent PETIT
of course I missed something :-( 2011/1/25 Laurent PETIT laurent.pe...@gmail.com: 2011/1/25 Ken Wesson kwess...@gmail.com: On Mon, Jan 24, 2011 at 7:32 PM, Laurent PETIT laurent.pe...@gmail.com wrote: 2011/1/25 Ken Wesson kwess...@gmail.com: Are we generally agreed that we want to preserve

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Laurent PETIT
There it is, corrected: (in-ns 'clojure.core) (defmacro with-open bindings = [name init ...] Evaluates body in a try expression with names bound to the values of the inits, and a finally clause that calls (.close name) on each name in reverse order. {:added 1.0} [bindings body]

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Ken Wesson
On Mon, Jan 24, 2011 at 7:43 PM, Laurent PETIT laurent.pe...@gmail.com wrote: 2011/1/25 Ken Wesson kwess...@gmail.com: Ah, I guess it may be a bit cleaner to just eschew finally altogether and close in the try and in the catch. The one thing that's a bit icky about that is that if the body

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Ken Wesson
Huh. We came up with almost the same final version. I guess I took 13 minutes longer because I tested mine -- yours still has the missing #. :) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: Why no def- ?

2011-01-24 Thread Nick Brown
Ugly? Aww, I thought the ^ metadata looked kinda cute... It is a bit awkward that defn- exists and not def-, but it seems defs are not going to be as common as defns (though I'll admit I haven't written or read enough complex idiomatic Clojure code to know for sure). And if you really want to

Re: Why no def- ?

2011-01-24 Thread Ken Wesson
On Mon, Jan 24, 2011 at 8:42 PM, Nick Brown nwbr...@gmail.com wrote: Ugly?  Aww, I thought the ^ metadata looked kinda cute... It is a bit awkward that defn- exists and not def-, but it seems defs are not going to be as common as defns (though I'll admit I haven't written or read enough

Re: Why won't leiningen install for me?

2011-01-24 Thread Mark Rathwell
Seems pretty clear that your macports version of curl is the problem, it's up to you what you want to do about it. I don't know if uninstalling it would leave you with the OS X version of curl or not. Link to get you started:

Re: Why no def- ?

2011-01-24 Thread OGINO Masanori
Hello. And if you really want to be consistent you would probably also want defmulti-, defmacro-, defstruct-, defprotocol-, etc. In my opinion, if defn- is not in core but in contrib, I feel be consistent. By the way, defstruct- and defmacro- is in contrib consistently :-) If we really

Re: Why won't leiningen install for me?

2011-01-24 Thread Alex Osborne
Hi Larry, As a quick temporary workaround you could just set your PATH environment variable so that it picks up the curl executable from /usr/bin instead of the broken MacPorts one from /opt/local/bin. $ which curl /opt/local/bin/curl $ export PATH=/usr/bin:$PATH $ which curl /usr/bin/curl

Re: Why won't leiningen install for me?

2011-01-24 Thread gaz jones
i would totally recommend uninstalling macports, and moving over to homebrew which is far better (https://github.com/mxcl/homebrew). On Mon, Jan 24, 2011 at 8:44 PM, Alex Osborne a...@meshy.org wrote: Hi Larry, As a quick temporary workaround you could just set your PATH environment variable

Getting http-agent to throw an exception if url doesn't exist?

2011-01-24 Thread HiHeelHottie
user (use '[clojure.contrib.http.agent :as ha]) WARNING: bytes already refers to: #'clojure.core/bytes in namespace: user, being replaced by: #'clojure.contrib.http.agent/bytes nil user (string (http-agent http://url.that.doesnt.exist.com;)) This will block indefinitely since the url does not

Re: Getting http-agent to throw an exception if url doesn't exist?

2011-01-24 Thread Ken Wesson
On Mon, Jan 24, 2011 at 11:23 PM, HiHeelHottie hiheelhot...@gmail.com wrote: user (use '[clojure.contrib.http.agent :as ha]) WARNING: bytes already refers to: #'clojure.core/bytes in namespace: user, being replaced by: #'clojure.contrib.http.agent/bytes nil user (string (http-agent

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Shantanu Kumar
The changed code should catch 'Exception', not 'Throwable' because the latter is a common ancestor of both 'Exception' and 'Error'. An 'Error' must not be swallowed at any point in the system, unless you are writing an app server or a JVM implementation. ;-) Regards, Shantanu On Jan 25, 6:11 am,

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Meikel Brandmeyer
Hi, On 25 Jan., 01:33, Ken Wesson kwess...@gmail.com wrote: It looks a little quirky in macroexpand output and seems slightly ugly but it works and probably isn't even inefficient at runtime, as the close symbol presumably has a name slot that takes up four bytes whether it's nil or a

Re: Calling .close() on resources -- with-open macro

2011-01-24 Thread Meikel Brandmeyer
Hi, On 25 Jan., 01:57, Laurent PETIT laurent.pe...@gmail.com wrote: (try (. ~(bindings 0) close) (catch Throwable _)) New code should use (.close foo) instead of (. foo close), IIRC. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group.