Re: Listen on changes to refs

2008-12-17 Thread Rowdy Rednose
The structure of the wikibook page has changed and that link doesn't work any more. This will: http://en.wikibooks.org/wiki/Clojure_Programming/Concepts#Mutation_Facilities On 16 Dez., 20:58, Rowdy Rednose rowdy.redn...@gmx.net wrote: Can I listen on changes done to refs? Let's say in a

Re: Listen on changes to refs

2008-12-17 Thread Rowdy Rednose
If Rich adds watchers for refs, would watchers be notified inside the transaction? I'm actually trying to get a notification after a transaction successfully finished. Although there might be use cases for firing events inside the transaction. On 17 Dez., 00:37, Stuart Sierra

Re: Circular Require Change?

2008-12-17 Thread Rich Hickey
On Dec 17, 12:43 am, Kevin Martin martink...@gmail.com wrote: I unfortunately ran into circular requires today. In previous versions of Clojure a circular require was answered with an exception. The text of this was something along the lines of Cannot load 'a' because already loading 'a'.

Recursive traversal of an object

2008-12-17 Thread Itay Maman
Hi, I am trying to write a function that recursively traverses a given object - applying a function to each node. Something along these lines: (defn traverse [f os] (f os) (when (coll? os) (doseq [o os] (traverse f o Although this fragment seems to be doing the job, I am not

Re: FAQ

2008-12-17 Thread Rich Hickey
On Dec 17, 11:34 am, Stuart Sierra the.stuart.sie...@gmail.com wrote: On Dec 17, 10:32 am, Rich Hickey richhic...@gmail.com wrote: The Clojure FAQ will be here: http://code.google.com/p/clojure/wiki/FAQ Suggestions for entries welcome here. Suggestions, based on common questions in

Re: FAQ

2008-12-17 Thread Chouser
On Wed, Dec 17, 2008 at 11:34 AM, Stuart Sierra the.stuart.sie...@gmail.com wrote: Suggestions, based on common questions in the group: These are good, Stuart, thanks! Except... * Why doesn't #([%]) work? Answer: Because it expands to (fn [x] ([x])). #() always assumes that the thing

Re: FAQ

2008-12-17 Thread J. McConnell
On Wed, Dec 17, 2008 at 10:32 AM, Rich Hickey richhic...@gmail.com wrote: The Clojure FAQ will be here: http://code.google.com/p/clojure/wiki/FAQ Suggestions for entries welcome here. I recently found out about Google Moderator (http://moderator.appspot.com/), which might be a good fit

Re: FAQ

2008-12-17 Thread Rich Hickey
On Dec 17, 11:50 am, J. McConnell jdo...@gmail.com wrote: On Wed, Dec 17, 2008 at 10:32 AM, Rich Hickey richhic...@gmail.com wrote: The Clojure FAQ will be here: http://code.google.com/p/clojure/wiki/FAQ Suggestions for entries welcome here. I recently found out about Google

Re: A quasiquote for Clojure?

2008-12-17 Thread Meikel Brandmeyer
Hi, Am 17.12.2008 um 18:21 schrieb David Nolen: You can have unresolved symbols within a macro with: ~'symbol I don't think this is really an alternative. (def x 5) (sql col1 from table1 where col2 = ~x) (sql `(~'select ~'col1 ~'from ~'table1 ~'where ~'col2 ~'= ~x)) (def *cmd*

Re: reload library, blowing away old public symbols

2008-12-17 Thread Chouser
On Tue, Dec 16, 2008 at 6:21 PM, Randall R Schulz rsch...@sonic.net wrote: On Tuesday 16 December 2008 15:05, Allen Rohner wrote: On Dec 16, 4:32 pm, Stuart Halloway wrote: Hi all, I sometimes need to (re)load a library, removing public symbols from previously loaded version of

Clojure issue tracker

2008-12-17 Thread Rich Hickey
As a benefit of moving to Google Code, Clojure has also acquired an issue tracker: http://code.google.com/p/clojure/issues/list Please note the following very carefully: This is not an invitation to have (now thousands) of people give me a todo list! Nor is it a collective wishlist. I would

Re: (con)current confusion

2008-12-17 Thread Raoul Duke
hi, Got it working! Removed the overzealous use of dosync in defn do-year. Might I beg a small summary write-up of your experience and/or conclusions, recommendations? :-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

Re: ClassName. Constructor Notation in Macros?

2008-12-17 Thread Stuart Halloway
Something flakey there. I clicked the star several times and nothing happened. I then checked in Firebug that the star is backed by JavaScript, and when I tried it again it worked. Odd. Randall, let me know if you need anything else upvoted. :-) Stuart On Wednesday 17 December 2008 06:55,

Re: Best Way to Ensure a Call to (shutdown-agents)?

2008-12-17 Thread Randall R Schulz
On Monday 15 December 2008 17:58, Randall R Schulz wrote: Hi, I've just started using agents and as I've done that, I've noticed that once you use an agent, exiting the REPL leads to a hang (with zero CPU usage). As Rich pointed out to me, this is avoided by calling (shutdown-agents). So

Re: Best Way to Ensure a Call to (shutdown-agents)?

2008-12-17 Thread Randall R Schulz
On Wednesday 17 December 2008 10:57, Randall R Schulz wrote: On Monday 15 December 2008 17:58, Randall R Schulz wrote: ... This sequence of evaluations ends in the REPL hanging: 1:1 user= (.. Runtime (getRuntime) (addShutdownHook (new Thread shutdown-agents))) nil 1:2 user= (def agent-99

Re: ClassName. Constructor Notation in Macros?

2008-12-17 Thread Meikel Brandmeyer
Hi, On 17 Dez., 15:40, Rich Hickey richhic...@gmail.com wrote: The point of that page is that it is extremely frustrating to get reports about macros where people haven't taken the simplest steps of generating the expansions and looking at them. I cannot identify myself with this point of

Re: Listen on changes to refs

2008-12-17 Thread Chouser
On Wed, Dec 17, 2008 at 7:26 AM, Rowdy Rednose rowdy.redn...@gmx.net wrote: Now before I start working on a small and handy framework to handle stuff similar to what's called biz objects / biz models in the java world - has by any chance someone already implemented something in that

Re: Patch available: unifies entry points, fixes (read-line) for clojure.main/repl, provides source-only jar

2008-12-17 Thread Rich Hickey
On Dec 16, 5:13 pm, Stephen C. Gilardi squee...@mac.com wrote: The enclosed patch updates clojure.main to fix a bug and implement changes discussed here recently. Details below. Feedback welcome. --Steve [1] clojure.main no longer calls gen-class. Instead there is now a stub clojure.main

Re: Best Way to Ensure a Call to (shutdown-agents)?

2008-12-17 Thread Chouser
On Wed, Dec 17, 2008 at 2:10 PM, Randall R Schulz rsch...@sonic.net wrote: Since Chouser asked on #clojure which REPL (I was using the Contrib REPL), I tried this with the stock REPL and the hang does not occur. Specifically, this line causes the JVM to shut down, even if there are agent

Re: Listen on changes to refs

2008-12-17 Thread Rich Hickey
On Dec 17, 2008, at 4:16 AM, Rowdy Rednose wrote: If Rich adds watchers for refs, would watchers be notified inside the transaction? No, only on commit. Rich I'm actually trying to get a notification after a transaction successfully finished. Although there might be use cases for

Re: ClassName. Constructor Notation in Macros?

2008-12-17 Thread Randall R Schulz
On Wednesday 17 December 2008 06:21, Meikel Brandmeyer wrote: Hi Randall, On 17 Dez., 15:12, Randall R Schulz rsch...@sonic.net wrote: user= (dcmfail) java.lang.IllegalArgumentException: Unable to resolve classname: BufferedWriter (repl-1:2) This doesn't help, I know, but it works for

Clojure's code has moved to Google Code

2008-12-17 Thread Rich Hickey
I've moved Clojure's source repo to Google Code: http://code.google.com/p/clojure/ as well as Clojure contrib: http://code.google.com/p/clojure-contrib/ All new checkins will occur there. Rich --~--~-~--~~~---~--~~ You received this message because you are

Re: A quasiquote for Clojure?

2008-12-17 Thread Rich Hickey
On Dec 17, 4:30 am, Meikel Brandmeyer m...@kotka.de wrote: Hi, I'd like to propose/put up for discussion a change to the unquote handling. I basically ran into the following problem: I'd like to embed a DSL into my system. Using macros it should be possible to define a language, which

Re: A quasiquote for Clojure?

2008-12-17 Thread David Nolen
You can have unresolved symbols within a macro with: ~'symbol David On Wed, Dec 17, 2008 at 3:30 AM, Meikel Brandmeyer m...@kotka.de wrote: Hi, I'd like to propose/put up for discussion a change to the unquote handling. I basically ran into the following problem: I'd like to embed a DSL

FAQ

2008-12-17 Thread Rich Hickey
The Clojure FAQ will be here: http://code.google.com/p/clojure/wiki/FAQ Suggestions for entries welcome here. Rich --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email

Re: Bug? sorted-map as fn behaves differently than hash-map as fn

2008-12-17 Thread Mark Volkmann
On Wed, Dec 17, 2008 at 8:14 AM, Meikel Brandmeyer m...@kotka.de wrote: Hi, On 17 Dez., 14:55, MikeM michael.messini...@invista.com wrote: ((sorted-map 'a 1 'b 2) a) = ClassCastException I would think that sorted-maps and hash-maps should both give nil for this, but perhaps the sorted-map

Re: Listen on changes to refs

2008-12-17 Thread Dave Griffith
I'm actually trying to get a notification after a transaction successfully finished. Well that's easy. Agent sends are buffered in a transaction, and only sent upon successful commit. The coolness of this is hard to overestimate. --Dave Griffith

Re: Microsoft SQL Server and the sql contrib

2008-12-17 Thread Scott Jaderholm
Thanks for the idea. Although those are definitely necessary steps, unfortunately the problem still persists. On Tue, Dec 16, 2008 at 5:47 PM, Wayne R johnway...@gmail.com wrote: Have a look at http://dertompson.com/2007/10/06/connection-to-mssql-server-express-2005-with-jdbc/ Apparently

Re: FAQ

2008-12-17 Thread Meikel Brandmeyer
Hi, Am 17.12.2008 um 17:34 schrieb Stuart Sierra: * Is there an IDE for Clojure? Answer: There are plug-ins for Eclipse http://code.google.com/p/ clojure-dev/ and NetBeans http://enclojure.net/. There's also Emacs. There is also Vim. Sincerely Meikel smime.p7s Description: S/MIME

Re: ClassName. Constructor Notation in Macros?

2008-12-17 Thread Randall R Schulz
On Wednesday 17 December 2008 05:48, Rich Hickey wrote: On Dec 16, 3:52 pm, Randall R Schulz rsch...@sonic.net wrote: ... Which takes us back to why the dot-suffix notation was not working in a macro but (new ...) was. ... Could you please post a short code example (reducing the

Re: A quasiquote for Clojure?

2008-12-17 Thread Chouser
On Wed, Dec 17, 2008 at 2:53 PM, Rich Hickey richhic...@gmail.com wrote: Moving syntax-quote out of the reader might be a big deal. But I think scenarios like this could be covered if: ~x not in a syntax-quote yielded the form (unquote x) from the reader unquote would not be defined by

Re: FAQ

2008-12-17 Thread Stuart Sierra
On Dec 17, 10:32 am, Rich Hickey richhic...@gmail.com wrote: The Clojure FAQ will be here: http://code.google.com/p/clojure/wiki/FAQ Suggestions for entries welcome here. Suggestions, based on common questions in the group: * Is there a repository for Clojure libraries? Answer: Yes, see

Re: Bug? sorted-map as fn behaves differently than hash-map as fn

2008-12-17 Thread Randall R Schulz
On Wednesday 17 December 2008 06:14, Meikel Brandmeyer wrote: Hi, On 17 Dez., 14:55, MikeM michael.messini...@invista.com wrote: ((sorted-map 'a 1 'b 2) a) = ClassCastException I would think that sorted-maps and hash-maps should both give nil for this, but perhaps the sorted-map

Re: Bug? sorted-map as fn behaves differently than hash-map as fn

2008-12-17 Thread Rich Hickey
On Dec 17, 9:26 am, Mark Volkmann r.mark.volkm...@gmail.com wrote: On Wed, Dec 17, 2008 at 8:14 AM, Meikel Brandmeyer m...@kotka.de wrote: Hi, On 17 Dez., 14:55, MikeM michael.messini...@invista.com wrote: ((sorted-map 'a 1 'b 2) a) = ClassCastException I would think that

Re: Bug? sorted-map as fn behaves differently than hash-map as fn

2008-12-17 Thread Randall R Schulz
On Wednesday 17 December 2008 06:26, Mark Volkmann wrote: ... It appears that you can create a sorted-map where all the keys are symbols and you can create a sorted-map where all the keys are strings, but you can't create a sorted-map where some of the keys are symbols and some are strings.

Re: Microsoft SQL Server and the sql contrib

2008-12-17 Thread Michael Reid
On Wed, Dec 17, 2008 at 11:00 AM, Scott Jaderholm jaderh...@gmail.com wrote: Thanks for the idea. Although those are definitely necessary steps, unfortunately the problem still persists. Can you get a similar Java program work correctly? i.e. we want to try and separate if this is specific to

Re: Clojure's code has moved to Google Code

2008-12-17 Thread Rich Hickey
On Dec 17, 8:22 am, Rich Hickey richhic...@gmail.com wrote: I've moved Clojure's source repo to Google Code: http://code.google.com/p/clojure/ as well as Clojure contrib: http://code.google.com/p/clojure-contrib/ All new checkins will occur there. There's also a read-only list/feed

Re: ClassName. Constructor Notation in Macros?

2008-12-17 Thread Rich Hickey
On Dec 17, 9:38 am, Meikel Brandmeyer m...@kotka.de wrote: Hi, On 17 Dez., 15:27, Randall R Schulz rsch...@sonic.net wrote: user= (macroexpand '(dcmfail)) (new BufferedWriter (FileWriter. stand-back)) I'm guessing it works for you 'cause in the macro expansion context you have an

Re: Bug? sorted-map as fn behaves differently than hash-map as fn

2008-12-17 Thread Meikel Brandmeyer
Hi, On 17 Dez., 14:55, MikeM michael.messini...@invista.com wrote: ((sorted-map 'a 1 'b 2) a) = ClassCastException I would think that sorted-maps and hash-maps should both give nil for this, but perhaps the sorted-map implementation requires a cast? Obviously a string is not a symbol. A

Re: Recursive traversal of an object

2008-12-17 Thread Stuart Sierra
Hi Itay, The only decomposable object which is not a collection (as far as I know) is a String: (seq hello) ;= (\h \e \l \l \o) But usually that's not what you want if you're traversing a data structure. If you're interacting with Java code that returns Iterators, Enumerables, or some weird

Re: ClassName. Constructor Notation in Macros?

2008-12-17 Thread Meikel Brandmeyer
Hi Randall, On 17 Dez., 15:12, Randall R Schulz rsch...@sonic.net wrote: user= (dcmfail) java.lang.IllegalArgumentException: Unable to resolve classname: BufferedWriter (repl-1:2) This doesn't help, I know, but it works for me. What does macroexpand say for your macros? See below link for

Re: ClassName. Constructor Notation in Macros?

2008-12-17 Thread Rich Hickey
On Dec 16, 3:52 pm, Randall R Schulz rsch...@sonic.net wrote: On Tuesday 16 December 2008 12:37, Rich Hickey wrote: On Dec 16, 2:32 pm, Stuart Halloway stuart.hallo...@gmail.com wrote: Hi Randall, The syntactic sugar forms are reader behavior, and occur too soon: at read time, not

Re: (con)current confusion

2008-12-17 Thread bOR_
Got it working! Removed the overzealous use of dosync in defn do-year. --~--~-~--~~~---~--~~ 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

unexpected partition behaviour

2008-12-17 Thread Remco van 't Veer
Hi all, First off, thanks for clojure! I've been playing with it for a couple days now and love it! Doing ruby in my day job, I've found some quirks I don't really understand. Most of them are obviously me being new to clojure and a lisp beginner. But the following keeps bugging me: user

Re: Circular Require Change?

2008-12-17 Thread Meikel Brandmeyer
Hi, On 17 Dez., 13:45, Rich Hickey richhic...@gmail.com wrote: I hope to re-enable the detection of the 'mistake' case, just requires some time to work out how to distinguish from the AOT case. I'm just guessing now (and maybe this doesn't help in the AOT case): currently require uses a list

Re: ClassName. Constructor Notation in Macros?

2008-12-17 Thread Randall R Schulz
On Wednesday 17 December 2008 06:55, Rich Hickey wrote: ... Added issue: http://code.google.com/p/clojure/issues/detail?id=7 Rich I tried to vote / star this issue, but it seems to have no effect. There was one star when I entered and that remains the case even after two attempts to

Re: ClassName. Constructor Notation in Macros?

2008-12-17 Thread Rich Hickey
On Dec 17, 9:31 am, Randall R Schulz rsch...@sonic.net wrote: On Wednesday 17 December 2008 06:21, Meikel Brandmeyer wrote: Hi Randall, ... http://clojure-log.n01se.net/macro.html That's a long way to go get a macro expansion! The point of that page is that it is extremely

Bug? sorted-map as fn behaves differently than hash-map as fn

2008-12-17 Thread MikeM
With SVN 1162, ((hash-map 'a 1 'b 2) a) = nil ((sorted-map 'a 1 'b 2) a) = ClassCastException I would think that sorted-maps and hash-maps should both give nil for this, but perhaps the sorted-map implementation requires a cast? --~--~-~--~~~---~--~~ You received

Re: unexpected partition behaviour

2008-12-17 Thread Rich Hickey
On Dec 17, 3:43 am, Remco van 't Veer rwvtv...@gmail.com wrote: Hi all, First off, thanks for clojure! I've been playing with it for a couple days now and love it! Doing ruby in my day job, I've found some quirks I don't really understand. Most of them are obviously me being new to

Re: building with Ant vs building with Maven

2008-12-17 Thread mledu
I also have found that building with Maven: java -cp clojure.jar clojure.main does not work although it does when compiling with ant. Since Swank-clojure was recently changed to call clojure.main and not lang.Repl my maven build wouldn't work in slime.

Re: ClassName. Constructor Notation in Macros?

2008-12-17 Thread Meikel Brandmeyer
Hi, On 17 Dez., 15:27, Randall R Schulz rsch...@sonic.net wrote: user= (macroexpand '(dcmfail)) (new BufferedWriter (FileWriter. stand-back)) I'm guessing it works for you 'cause in the macro expansion context you have an import in effect. I (use ...) the module bearing the failing macro

test-is: templates, composition, source lines!

2008-12-17 Thread Stuart Sierra
Hi folks, Just committed (on Google code) some new features to clojure.contrib.test-is: * failure reports include source file and line number when possible * Experimental: (are ...) uses clojure.contrib.template. The old each= is now (are (= _1 _2) ...). The old all-true is now (are _ ...) *

Re: FAQ

2008-12-17 Thread lpetit
Hello, * Is there an IDE for Clojure? Answer: There are plug-ins for Eclipse http://code.google.com/p/ clojure-dev/ and NetBeans http://enclojure.net/.  There's also Emacs. Sincerely, clojure-dev (Eclipse plugin) is still currently in infancy. I think it's not fair for the emacs version and

macro recursion

2008-12-17 Thread Mark Volkmann
Here's an example from Stuart Halloway's book. (defmacro chain ([x form] (list '. x form)) ([x form more] (concat (list 'chain (list '. x form)) more))) (macroexpand '(chain arm getHand getFinger getNail) ; I added the getNail part. The result is (. (. (. arm getHand) getFinger) getNail)

Re: Patch available: unifies entry points, fixes (read-line) for clojure.main/repl, provides source-only jar

2008-12-17 Thread Stephen C. Gilardi
On Dec 17, 2008, at 2:27 PM, Rich Hickey wrote: Thanks! You're welcome! Wow, that's a lot of changes. I'm not sure about this one: - Exceptions caught by the repl now cause the rest of the input line to be skipped. In what way is that the right thing to do? The idea was that the

code golf

2008-12-17 Thread rzeze...@gmail.com
Neat challenge on stackoverflow: http://stackoverflow.com/questions/372668/code-golf-how-do-i-write-the-shortest-character-mapping-program I added an implementation in Clojure. One that I'm sure could be greatly improved on. I don't really care for the extremely obfuscated examples. Sure,

Re: A quasiquote for Clojure?

2008-12-17 Thread James Reeves
On Dec 17, 8:25 pm, Chouser chou...@gmail.com wrote: ~x not in a syntax-quote yielded the form (unquote x) from the reader I very much like the sound of this. +1 I'm for this as well. I've been using keywords as a substitute, but an unquote would be more intuitive. - James

Superficial barriers to entry

2008-12-17 Thread Mibu
I recommended clojure to a dozen friends or so and after a while none of them stuck with it. I know clojure being a lisp and being at the current development stage is not for everyone, but after I probed why people gave up with it I saw the barriers to entry were largely superficial and can be

Re: FAQ

2008-12-17 Thread kkw
How about: What's the recommended way of getting Clojure up and running? - Download the latest snapshot with SVN - Create the Clojure.jar file with Ant - Test by starting up the REPL with java -cp clojure.jar clojure.lang.Repl Kev On Dec 18, 9:24 am, lpetit laurent.pe...@gmail.com wrote:

Re: code golf

2008-12-17 Thread Chouser
On Wed, Dec 17, 2008 at 6:15 PM, rzeze...@gmail.com rzeze...@gmail.com wrote: Neat challenge on stackoverflow: http://stackoverflow.com/questions/372668/code-golf-how-do-i-write-the-shortest-character-mapping-program I added an implementation in Clojure. One that I'm sure could be greatly

Re: code golf

2008-12-17 Thread Stephen C. Gilardi
On Dec 17, 2008, at 8:09 PM, Chouser wrote: But I can't deny that golfing is fun! Yes it is! (defn enc[s e](apply str(map(into{}(for[[o _ n](partition 3 4 e)][o n]))s))) Nice job as usual, Chouser! Here's my stroke--now shown to have landed well into the rough: (defn enc[p t](let[a

Re: code golf

2008-12-17 Thread rzeze...@gmail.com
On Dec 17, 8:09 pm, Chouser chou...@gmail.com wrote: I don't think I agree with the premise of the question, that golf answers help anyone learn about other languages. But I can't deny that golfing is fun! (defn enc[s e](apply str(map(into{}(for[[o _ n](partition 3 4 e)][o n]))s))) I

Re: Superficial barriers to entry

2008-12-17 Thread falcon
Good post! I have been going through the same problems myself. It looks like enclojure is going to have a Netbeans 6.5 release very soon (still alpha though). I've also tried to figure out the best way to learn Clojure. After flailing about a bit, last night I printed out all the documents on

Re: code golf

2008-12-17 Thread Mark Engelberg
78? I count 72 after you take out all the superfluous spaces. But I agree that it says nothing significant about the language. It's a fun optimization puzzle, though, and can help understand whether the built-in library of functions is fairly rich.

Re: code golf

2008-12-17 Thread Chouser
On Wed, Dec 17, 2008 at 9:53 PM, Mark Engelberg mark.engelb...@gmail.com wrote: This shaves 14 characters off of Chouser's solution: (defn enc[s e](apply str(map(apply hash-map(take-nth 2 e))s))) Very nice! --Chouser --~--~-~--~~~---~--~~ You received this

Re: code golf

2008-12-17 Thread Timothy Pratley
`{0~@(cons 0 (take-nth 2 %2))} o_O I tried the `...@v} splice in but never imagined doing that! nice :) On the subject of splice in, am I alone in thinking (str ~...@v) is more readable than (apply str v)? Of course the former doesn't work as there is no preceding syntax- quote, but bear