Re: building with Ant vs building with Maven

2008-12-16 Thread Meikel Brandmeyer

Hi,

On 16 Dez., 12:47, kkw  wrote:
> Should I build using Ant instead of Maven?

Using ant is the official way to build Clojure.

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
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: 'require' doc string out of date?

2008-12-16 Thread Chouser

On Mon, Dec 15, 2008 at 10:41 PM, Daniel Eklund  wrote:
>
> I've been trying to get 'ns' right.  The doc for 'require' tells me
> the following about library loading:
>
> "The root resource path
>  is derived from the root directory path by repeating its last
> component
>  and appending '.clj'. For example, the lib 'x.y.z has root directory
>  /x/y/z; root resource /x/y/z/z.clj."
>
> It looks like this this is out of date as per
> http://groups.google.com/group/clojure/browse_frm/thread/8618a1d93cbbf8b7/58e3f8e5dfb876c9?lnk=gst&q=aot#58e3f8e5dfb876c9
>
> If my observation is correct, could we update the 'require' doc
> string?

You are correct, it should say something like:

  A 'lib' is a named set of resources in classpath whose contents define a
  library of Clojure code. Lib names are symbols and each lib is associated
  with a Clojure namespace and a Java package that share its name. A lib's
  name also locates its source file path using Java's package name to
  classpath-relative path mapping.  All definitions a lib makes should
  be in its associated namespace.  Other resources in a lib
  may be contained in a similarly-named directory.

  'require loads a lib by loading its root resource. The root resource path
  is derived from the root directory path by appending '.clj'. For
  example, the lib 'x.y.z has root resource /x/y/z.clj. The root
  resource should contain code to create the lib's namespace and load any
  additional lib resources.

In general, clojure-contrib is a good place to look to find examples
of properly laid-out libs, as well as generally idiomatic Clojure
code.

--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 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: template.clj (r306) in clojure.contrib won't compile

2008-12-16 Thread Stuart Sierra

Thanks for the report, walterc.  Fixed now -- I'd accidentally deleted
a big chunk of the macro.
-Stuart Sierra

On Dec 16, 1:18 am, walterc  wrote:
> the template function is missing parameter binding part of a let
--~--~-~--~~~---~--~~
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: Does ANTS.CLJ still work?

2008-12-16 Thread Peter Wolf

Hmmm...  I am also having problems with SLIME (see below)

Perhaps the otherwise-very-nice Ubuntu instructions need to be updated

http://riddell.us/clojure/

Can someone recommend the current best way to get a matching Clojure and 
Swank and Slime

Thanks
Peter


ser=> java.lang.Exception: Unsupported binding form: 
clojure.lang.persistentl...@f50439d
clojure.lang.Compiler$CompilerException: util.clj:76: Unsupported 
binding form: clojure.lang.persistentl...@f50439d
at clojure.lang.Compiler.analyzeSeq(Compiler.java:3865)
at clojure.lang.Compiler.analyze(Compiler.java:3698)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:3848)
at clojure.lang.Compiler.analyze(Compiler.java:3698)
at clojure.lang.Compiler.analyze(Compiler.java:3671)
at clojure.lang.Compiler.access$100(Compiler.java:37)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:3384)
at clojure.lang.Compiler$FnMethod.parse(Compiler.java:3231)
at clojure.lang.Compiler$FnMethod.access$1200(Compiler.java:3142)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java:2766)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:3856)
at clojure.lang.Compiler.analyze(Compiler.java:3698)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:3848)
at clojure.lang.Compiler.analyze(Compiler.java:3698)
at clojure.lang.Compiler.access$200(Compiler.java:37)
at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:343)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:3858)
at clojure.lang.Compiler.analyze(Compiler.java:3698)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:3848)
at clojure.lang.Compiler.analyze(Compiler.java:3698)
at clojure.lang.Compiler.analyze(Compiler.java:3671)
at clojure.lang.Compiler.eval(Compiler.java:3895)
at clojure.lang.Compiler.load(Compiler.java:4196)
at clojure.lang.RT.loadResourceScript(RT.java:360)
at clojure.lang.RT.loadResourceScript(RT.java:347)
at clojure.lang.RT.loadResourceScript(RT.java:339)
at clojure.load__1722$fn__1724.invoke(boot.clj:3195)
at clojure.load__1722.doInvoke(boot.clj:3194)
at clojure.lang.RestFn.invoke(RestFn.java:413)
at clojure.load_one__1685.invoke(boot.clj:3041)
at clojure.load_lib__1705.doInvoke(boot.clj:3078)
at clojure.lang.RestFn.applyTo(RestFn.java:147)
at clojure.apply__135.doInvoke(boot.clj:364)
at clojure.lang.RestFn.invoke(RestFn.java:443)
at clojure.load_libs__1709.doInvoke(boot.clj:3108)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.apply__135.doInvoke(boot.clj:364)
at clojure.lang.RestFn.invoke(RestFn.java:460)
at clojure.use__1716.doInvoke(boot.clj:3173)
at clojure.lang.RestFn.invoke(RestFn.java:458)
at swank.eval__2299.invoke(core.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:3891)
at clojure.lang.Compiler.load(Compiler.java:4196)
at clojure.lang.RT.loadResourceScript(RT.java:360)
at clojure.lang.RT.loadResourceScript(RT.java:347)
at clojure.lang.RT.loadResourceScript(RT.java:339)
at clojure.load__1722$fn__1724.invoke(boot.clj:3195)
at clojure.load__1722.doInvoke(boot.clj:3194)
at clojure.lang.RestFn.invoke(RestFn.java:413)
at clojure.load_one__1685.invoke(boot.clj:3041)
at clojure.load_lib__1705.doInvoke(boot.clj:3078)
at clojure.lang.RestFn.applyTo(RestFn.java:147)
at clojure.apply__135.doInvoke(boot.clj:364)
at clojure.lang.RestFn.invoke(RestFn.java:443)
at clojure.load_libs__1709.doInvoke(boot.clj:3108)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.apply__135.doInvoke(boot.clj:364)
at clojure.lang.RestFn.invoke(RestFn.java:460)
at clojure.use__1716.doInvoke(boot.clj:3173)
at clojure.lang.RestFn.invoke(RestFn.java:441)
at user.eval__2296.invoke(swank.clj:11)
at clojure.lang.Compiler.eval(Compiler.java:3891)
at clojure.lang.Compiler.load(Compiler.java:4196)
at clojure.lang.RT.loadResourceScript(RT.java:360)
at clojure.lang.RT.loadResourceScript(RT.java:347)
at clojure.lang.RT.loadResourceScript(RT.java:339)
at clojure.load__1722$fn__1724.invoke(boot.clj:3195)
at clojure.load__1722.doInvoke(boot.clj:3194)
at clojure.lang.RestFn.invoke(RestFn.java:413)
at clojure.load_one__1685.invoke(boot.clj:3041)
at clojure.load_lib__1705.doInvoke(boot.clj:3078)
at clojure.lang.RestFn.applyTo(RestFn.java:147)
at clojure.apply__135.doInvoke(boot.clj:364)
at clojure.lang.RestFn.invoke(RestFn.java:443)
at clojure.load_libs__1709.doInvoke(boot.clj:3104)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.apply__135.doInvoke(boot.clj:364)
at clojure.lang.RestFn.invoke(RestFn.java:443)
at clojure.require__1713.doInvoke(boot.clj:3163)
at clojure.lang.RestFn.invoke(RestFn.java:413)
at user.eval__2293.invoke(Unknown Source)
at clojure.lang.Compiler.eval(Compiler.java:3891)
at clojure.lang.Repl.main(Repl.java:75)
Caused by: java.lang.Exception: Uns

Re: test-is uncaught exception behavior

2008-12-16 Thread Stuart Sierra

Fixed now (rev. 311), thanks for the report.
-Stuart Sierra

On Dec 16, 12:42 am, Allen Rohner  wrote:
> 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: 'require' doc string out of date?

2008-12-16 Thread Daniel Eklund

> In general, clojure-contrib is a good place to look to find examples
> of properly laid-out libs, as well as generally idiomatic Clojure
> code.
>
> --Chouser

Yeah, just recently I've taken to scanning the code in 'webjure' and
'swank' to see how things are done, rather than relying on the APIs.

I never got to downloading 'clojure-contrib' but the more I read the
group, the more it seems like this is where the magic is happening.
Thanks for the recommendation.
--~--~-~--~~~---~--~~
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: Best Way to Ensure a Call to (shutdown-agents)?

2008-12-16 Thread Randall R Schulz

On Tuesday 16 December 2008 06:02, MikeM wrote:
> You can try this:
>
> (let [t (new Thread (fn[] (shutdown-agents)))]
>(.. java.lang.Runtime (getRuntime) (addShutdownHook t)))
>
> It works for me, but seems to take a long time to complete the
> shutdown.

I tried adding this to the module that starts the agents in question 
(the question of the proper place for such code being left aside for 
now):

(def *shutdown-hook* (atom nil))

(when-not @*shutdown-hook*
 (let [shutdown-thread (new Thread shutdown-agents)]
  (swap! *shutdown-hook* (fn [old] shutdown-thread))
  (when (identical? @*shutdown-hook* shutdown-thread)
   (.. Runtime (getRuntime) (addShutdownHook shutdown-thread
)

I think this is doing what I think it's doing (reliably registering only 
one agent shutdown handler Thread), but exiting the REPL via CTRL-D 
still hangs. I can't say it hangs literally forever, obviously, but for 
longer than I'm willing to wait, certainly. So then it occurred to me 
to try calling (System/exit 0), and that exits immediately. So then I 
took out the code to set up the shutdown handler and found the 
(System/exit 0) _still_ effects an immediate exit from the REPL.

Lastly, if I just execute Mike's code directly:

 (let [shutdown-thread (new Thread shutdown-agents)]
  (.. Runtime (getRuntime) (addShutdownHook shutdown-thread)))

the hang upon CTRL-D / EOF at the REPL still happens.


So I am still confused about the right way to deal with agents in order 
to get reliable and prompt exit from the REPL and why an  EOF from the 
terminal hangs (only if agents were started and regardless of whether a 
shutdown hook is in place) but (System/exit 0) does not hang (again, 
regardless of whether agents were started and whether a shutdown hook 
is in place).

What am I missing?


> Your question made me wonder if the agent thread pools should use
> daemon threads - then this wouldn't be an issue.

Yes. That seems plausible, but I don't know enough about the possible 
subtleties to say for sure.


Randall Schulz

--~--~-~--~~~---~--~~
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: Listen on changes to refs

2008-12-16 Thread Stuart Sierra

On Dec 16, 7:50 am, Timothy Pratley  wrote:
> SS wrote a cells that works on refs quite a while 
> ago:http://groups.google.com/group/clojure/browse_thread/thread/d79392e4c...

Yeah, it works, but the interface is a little awkward.  Rich said he
wants to add watchers for refs and atoms in addition to agents.  Then
you can use all the regular ref functions instead of "alter-cell".
-Stuart Sierra

--~--~-~--~~~---~--~~
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: Best Way to Ensure a Call to (shutdown-agents)?

2008-12-16 Thread Randall R Schulz

On Tuesday 16 December 2008 07:36, Randall R Schulz wrote:
> ...
>
> So I am still confused about the right way to deal with agents in
> order to get reliable and prompt exit from the REPL and why an  EOF
> from the terminal hangs (only if agents were started and regardless
> of whether a shutdown hook is in place) but (System/exit 0) does not
> hang (again, regardless of whether agents were started and whether a
> shutdown hook is in place).
>
> What am I missing?

One last piece of evidence on this. If I directly call (shutdown-agents) 
before exiting the REPL using CTRL-D, then Clojure exits promptly.


Randall Schulz

--~--~-~--~~~---~--~~
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: Emtpy (filter ...) Result Yields nil; Could / Should It Be An Empty List?

2008-12-16 Thread J. McConnell

On Tue, Dec 16, 2008 at 12:26 AM, Mon Key  wrote:
>
> whoops, chopped of the end of that last message - forgot the nasake-no
> ichigeki
> user> (seq? '(nil))
> ==|]==>true

'(nil) is a list containing the single element nil. nil is no kind of
list whatsoever. So, (seq? '(nil)) is true, since '(nil) is a list and
lists are seqs and (seq? nil) is false since nil is not a sequence.

The quoted list equivalent of (seq? nil) is not (seq? '(nil)), it's
(seq? '()) and it rightly returns false:

1:1 user=> (seq? '())
false

This is why flatten's behavior was considered a bug. In Clojure, an
empty sequence is equivalent to nil, not to '(nil).

HTH,

- J.

--~--~-~--~~~---~--~~
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: doall and dorun

2008-12-16 Thread Christian Vest Hansen

I think I'll be putting my money on (for) returning a cached lazy seq,
and (macroexpand) also tells me that there's a lazy-cons hidin in
there:

user=> (macroexpand '(for [i (range 1 3)] (do (println i) i)))
(let* [iter__4007 (clojure.core/fn iter__7 [s__8]
(clojure.core/when-first [i s__8] (clojure.core/when true (if true
(clojure.core/lazy-cons (do (println i) i) (iter__7 (clojure.core/rest
s__8))) (recur (clojure.core/rest s__8))] (iter__4007 (range 1
3)))

So the side-effects are only executed once, and then the result is
cached, and if you ask Rich he'd probably tell you that that is by
design.

On Tue, Dec 16, 2008 at 7:02 AM, Brian Doyle  wrote:
> I'll take a crack at this.  It may appear that the doall and dorun return
> something
> different with subsequent calls but they don't actually.   The doall always
> returns
> the sequence (1 2) and dorun always returns nil.
>
> The first time (doall x) is called the for loop executes and prints 1 2 (a
> side effect
> and is not returned from the for loop) and then returns the seq.  The second
> time
> it's called x is already assigned the seq and just returns it. It does not
> execute
> the for loop again.
>
> The dorun call is similar, but instead of returning the seq of the for loop,
> it always
> returns nil.  According to the api docs, dorun is used to force side
> effects.
>
> On Mon, Dec 15, 2008 at 9:19 PM, wubbie  wrote:
>>
>> Hello,
>>
>> doall and dorun returns different results from seond run on...
>> e.g.
>> user=> (def x (for [i (range 1 3)] (do (println i) i)))
>> #'user/x
>> user=> (doall x)
>> 1
>> 2
>> (1 2)
>> user=> (doall x)
>> (1 2)
>> user=> (doall x)
>> (1 2)
>> user=>
>>
>> user=> (def x (for [i (range 1 3)] (do (println i) i)))
>> #'user/x
>> user=> (dorun x)
>> 1
>> 2
>> nil
>> user=> (dorun x)
>> nil
>> user=> (dorun x)
>> nil
>> user=>
>>
>>
>> What's the explanation for that?
>>
>> thanks
>> sun
>>
>>
>>
>>
>
>
> >
>



-- 
Venlig hilsen / Kind regards,
Christian Vest Hansen.

--~--~-~--~~~---~--~~
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: Emtpy (filter ...) Result Yields nil; Could / Should It Be An Empty List?

2008-12-16 Thread Randall R Schulz

On Tuesday 16 December 2008 08:03, J. McConnell wrote:
> ...
>
> '(nil) is a list containing the single element nil. nil is no kind of
> list whatsoever. So, (seq? '(nil)) is true, since '(nil) is a list
> and lists are seqs and (seq? nil) is false since nil is not a
> sequence.
>
> The quoted list equivalent of (seq? nil) is not (seq? '(nil)), it's
> (seq? '()) and it rightly returns false:
>
> 1:1 user=> (seq? '())
> false

It is also the case that empty lists are self-evaluating:

user=> ''()
(quote ())

user=> '()
()

user=> ()
()


>...
>
> - J.


Randall Schulz

--~--~-~--~~~---~--~~
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: Getting Started with Gen-Class

2008-12-16 Thread J. McConnell
On Mon, Dec 15, 2008 at 7:33 PM, Rich Hickey  wrote:
>
> When pulling new Clojure from SVN, please do:
>
> ant clean
> ant
>
> So you know you have a consistent build.

If the supported way to build Clojure is to clean before the build,
can we just have the init target depend on clean? Attached is the
trivial patch to do this.

Regards,

- J.

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

Index: build.xml
===
--- build.xml	(revision 1162)
+++ build.xml	(working copy)
@@ -11,7 +11,7 @@
   
   
 
-  
+  
 
 
   


Re: Emtpy (filter ...) Result Yields nil; Could / Should It Be An Empty List?

2008-12-16 Thread J. McConnell

On Tue, Dec 16, 2008 at 11:23 AM, Randall R Schulz  wrote:
>
> It is also the case that empty lists are self-evaluating:
>
> user=> ''()
> (quote ())
>
> user=> '()
> ()
>
> user=> ()
> ()

Ahhh, good to know. Thanks!

- J.

--~--~-~--~~~---~--~~
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: Does ANTS.CLJ still work?

2008-12-16 Thread Chouser

On Mon, Dec 15, 2008 at 11:54 AM, Peter Wolf  wrote:
>
> I get the following error when I try ANTS.CLJ.  Has something changed?

Recent Clojure from SVN and a recent download of ants.clj from the
google group seem to work fine together for me.

--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 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Getting Started with Gen-Class

2008-12-16 Thread Randall R Schulz

On Tuesday 16 December 2008 08:26, J. McConnell wrote:
> On Mon, Dec 15, 2008 at 7:33 PM, Rich Hickey  
wrote:
> > When pulling new Clojure from SVN, please do:
> >
> > ant clean
> > ant
> >
> > So you know you have a consistent build.
>
> If the supported way to build Clojure is to clean before the build,
> can we just have the init target depend on clean? Attached is the
> trivial patch to do this.

I've been bitten by not doing clean before the build a couple of times 
(which then led to Rich being pestered needlessly by me), so it's 
probably a good idea.

However, if you make the init target depend on clean, it's then 
impossible to do an incremental build, which probably isn't good for 
Rich or anyone else actively working on the guts, so it would be better 
to make the default target one that depends on clean and jar and thus 
leave it possible for those who know that a clean is not required to 
get a quick incremental build.


> Regards,
>
> - J.


Randall Schulz

--~--~-~--~~~---~--~~
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: Listen on changes to refs

2008-12-16 Thread Timothy Pratley

SS wrote a cells that works on refs quite a while ago:
http://groups.google.com/group/clojure/browse_thread/thread/d79392e4c79f8cde/f92eae422e4086c5?lnk=gst&q=cells+refs#f92eae422e4086c5

If you search the group for "cells" you'll find quite a bit of
discussion
--~--~-~--~~~---~--~~
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: building with Ant vs building with Maven

2008-12-16 Thread Dave Newton

--- On Tue, 12/16/08, kkw  wrote:
> Since the Ant-built file is bigger, should I build
> using Ant instead of Maven?

It looks like the Ant build is compiling more; for example the Maven build 
includes zip.clj, where the Ant build has all the zip%*.class files.

Dave


--~--~-~--~~~---~--~~
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: Emtpy (filter ...) Result Yields nil; Could / Should It Be An Empty List?

2008-12-16 Thread Mon Key

> This is why flatten's behavior was considered a bug. In Clojure, an
> empty sequence is equivalent to nil, not to '(nil).

This does not comport with the various differences enumerated @
http://clojure.org/lisps
Perhaps they need to be changed.  RH care to weigh in on this?

which says:
"() is not the same as nil"

and this one:
"In Clojure nil means 'nothing'. It signifies the absence of a value,
of any type, and is not specific to lists or sequences."

and probably this one too:
"Empty collections are distinct from nil. Clojure does not equate nil
and '()."

and this one as well:
"...There is no such thing as an empty sequence. Either there is a
sequence (with elements) or there isn't (nil)..."

add this to the pile:
"...The Clojure return values differ in not returning empty
collections, but rather a sequence or not"


On Dec 16, 11:28 am, "J. McConnell"  wrote:
> On Tue, Dec 16, 2008 at 11:23 AM, Randall R Schulz  wrote:
>
>
>
> > It is also the case that empty lists are self-evaluating:
>
> > user=> ''()
> > (quote ())
>
> > user=> '()
> > ()
>
> > user=> ()
> > ()
>
> Ahhh, good to know. Thanks!
>
> - J.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



building with Ant vs building with Maven

2008-12-16 Thread kkw

Hi folks,

When I run 'mvn install' from the clojure\trunk directory (svn
1160), Maven creates:
16/12/2008  10:37 PM   519,267 clojure-lang-1.0-SNAPSHOT.jar

When I run 'ant' from the clojure\trunk directory (svn 1160), Ant
creates:
16/12/2008  10:37 PM 1,393,895 clojure.jar

Since the Ant-built file is bigger, should I build using Ant
instead of Maven? Which is the recommended way of building Clojure
from the SVN checkout? I searched through the group archives to see if
this question had been asked and answered but didn't have much luck.
Kindly point me to the right thread if this question has been answered
already.

With Thanks,

Kev

--~--~-~--~~~---~--~~
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: Best Way to Ensure a Call to (shutdown-agents)?

2008-12-16 Thread MikeM

You can try this:

(let [t (new Thread (fn[] (shutdown-agents)))]
   (.. java.lang.Runtime (getRuntime) (addShutdownHook t)))

It works for me, but seems to take a long time to complete the
shutdown.

Your question made me wonder if the agent thread pools should use
daemon threads - then this wouldn't be an issue.
--~--~-~--~~~---~--~~
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: Emtpy (filter ...) Result Yields nil; Could / Should It Be An Empty List?

2008-12-16 Thread Stuart Sierra

Thanks, Lennart.  That works, although it took me a few minutes to
figure out why.  (For the record, tree-seq returns a copy of its
argument as the first item in the sequence.)  This also means that

(flatten "string")
;=> (\s \t \r \i \n \g)

I've put in a patch.
-Stuart Sierra

On Dec 15, 2:45 pm, Lennart Staflin  wrote:
> How about adding a rest around tree-seq:
>
> (defn flatten
>   "Takes any nested combination of sequential things (lists, vectors,
>   etc.) and returns their contents as a single, flat sequence."
>   [x]
>   (let [s? #(instance? clojure.lang.Sequential %)]
>     (filter (complement s?) (rest (tree-seq s? seq x)
--~--~-~--~~~---~--~~
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: License of/permission for Clojure's logo

2008-12-16 Thread Dudley Flanders


On Dec 16, 2008, at 8:37 AM, Tom Hickey wrote:

>
> Hey Rich,
>
> Eric and I were also wondering if the logo was under the same license
> as Clojure itself. If it is, should this be explicitly stated
> somewhere?

I think using a license designed for code is slightly inappropriate  
for artwork. I don't want to start yet another license war, but maybe  
a creative commons license would be a better fit? The attribution- 
share-alike[0] license seems to share the spirit of Clojure's license.

:dudley

[0] http://creativecommons.org/licenses/by-sa/3.0/



--~--~-~--~~~---~--~~
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: Initialize java.util.TreeSet/TreeMap using clojure set/map value

2008-12-16 Thread Rich Hickey

On Tue, Dec 16, 2008 at 12:11 AM, Feng  wrote:
>
> Hi,
>
> Because clojure set, vector and map all implements
> java.util.Comparator (indirectly via AFn), they interact with
> java.util.TreeSet/TreeMap in surprising way due to overloaded ctor
> (java.util.Comparator).
>
> user=> (def s (java.util.TreeSet. [1 2 3 3]))
> #'user/s
> user=> s
> #=(java.util.TreeSet. #{})
> user=> (.add s 3)
> true
> user=> s
> #=(java.util.TreeSet. #{3})
> user=> (.add s 3)
> java.lang.RuntimeException: java.lang.IllegalArgumentException: Wrong
> number of args passed to: PersistentVector (NO_SOURCE_FILE:0)
> user=> (def m (java.util.TreeMap. {:a 1 :b 2 }))
> #'user/m
> user=> m
> #=(java.util.TreeMap. {})
> user=> (.put m :a 2)
> nil
> user=> m
> #=(java.util.TreeMap. {:a 2})
> user=> (.put m :c 3)
> java.lang.RuntimeException: java.lang.ClassCastException:
> clojure.lang.Keyword (NO_SOURCE_FILE:0)
>
> Is this an oversight or a compromise by design?
>

I've refactored Comparator into superclass of functions only (SVN
1161), i.e. collections no longer implement Comparator.

Thanks for the report,

Rich

--~--~-~--~~~---~--~~
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: License of/permission for Clojure's logo

2008-12-16 Thread Tom Hickey

Hey Rich,

Eric and I were also wondering if the logo was under the same license
as Clojure itself. If it is, should this be explicitly stated
somewhere?

Thanks,
Tom

On Dec 9, 1:03 am, samppi  wrote:
> I've uploaded thelogo'sglyph and added it to Clojure's article.
>
> However, I'm wondering, Mr. Hickey—have you considered releasing the
> language'slogounder a free license? The language itself is under the
> Common Public License; releasing itslogounder another free license
> is a logical step. If you do so, sites like Wikipedia and bloggers
> talking about Clojure would be free to use and spread thelogo. (I'm
> bringing this up because Wikipedia itself doesn't like non-free images
> on it because it says its materials can be used freely by anyone.)
>
> On Dec 4, 5:23 am, Rich Hickey  wrote:
>
> > On Dec 3, 11:30 pm, samppi  wrote:
>
> > > I want to put the 
> > > Clojurelogo:http://clojure.googlegroups.com/web/Clojure-logo.png?gda=y8lqvUIAAABo...
>
> > > ...on Wikipedia's article on Clojure. What is the license of Clojure's
> > >logo--is it a free image? Or can Mr. Hickley give me permission to use
> > > it on Wikipedia?
>
> > You can use thelogoon the wikipedia article on Clojure, but only if
> > you spell my name correctly :)
>
> > Rich
--~--~-~--~~~---~--~~
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: Gorilla: key combinations

2008-12-16 Thread Drew Olson
On Mon, Dec 15, 2008 at 10:08 PM, Alex Burka  wrote:

>
> Thanks for Gorilla. I am using it with MacVim. One (or :bug :pebkac)
> report...
>
> I put plugin/gorilla.vim in /Applications/MacVim.app/Contents/
> Resources/vim/runtime/plugin/ and it seems to be loaded when MacVim
> starts. But the keybindings are not set up. \sr doesn't do anything
> (well, the 's' puts Vim in insert mode).


Alex -

Make sure your filetype is set to clojure. You can test this with:

:set filetype?

If it's not, try:

:set filetype=clojure

then perform the command \sr again.

- Drew

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



Is clojure.core/require documentation out of date ?

2008-12-16 Thread lpetit

Hello,

I try to fill the gap from when I discovered clojure several months
ago, and I'm trying to understand the lib vs namespace stuff.

I go straight to what I consider may be the primary source of
documentation by calling (doc require), and I see this :

"  'require loads a lib by loading its root resource. The root
resource path
  is derived from the root directory path by repeating its last
component
  and appending '.clj'. For example, the lib 'x.y.z has root directory
  /x/y/z; root resource /x/y/z/z.clj. The root
  resource should contain code to create the lib's namespace and load
any
  additional lib resources.
"

Is it accurate ? In clojure's source, I can see src/clojure/ but no
src/clojure/clojure.clj, and lots of namespaces defined in src/
clojure/ .

And also, even after reading the doc, I'm not sure I fully understand
the relationships between a lib and a namespace.

Is it right to say :
- a namespace corresponds to one and only one lib
- a lib is composed of one and only one namespace
?

If I'm wrong, could you please help me understand, maybe by giving me
a URL I may have missed ?

Regards,

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



ClassName. Constructor Notation in Macros?

2008-12-16 Thread Randall R Schulz

Hi,

A couple of days ago I was having a lot of trouble getting the 
(ClassName. ctor-args...) form of constructors to work while (new 
ClassName ctor-args...) was fine. It eventually occurred to me that the 
problem had to do with those constructor calls being in macro bodies. 
Now it turns out those macros were very poorly written, and now the 
constructor code is isolated in a function called by the macro 
expansion (you might never know how ugly something can be until you 
(macroexpand ...) it!).

However, I am left wondering what exactly is the interaction that was 
causing the dot-suffix form of the constructor call to fail in a macro 
expansion. I sense it has to do with the fact that symbols (other than 
gensyms or syntax-unquoted macro arguments) used in macro definitions 
are qualified with the namespace of the macro definition when that 
macro is expanded.

Is this understanding correct? If so, is the behavior deliberate?


Randall Schulz

--~--~-~--~~~---~--~~
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: Patch: precompiling Clojure core sources in Ant build script

2008-12-16 Thread Bill Clementson

FYI - I forwarded the patch to Jeffrey Chu and he has patched
swank-clojure in git.

- Bill

On Sun, Dec 14, 2008 at 2:20 PM, Feng  wrote:
>
> This is due to the change in clojure svn 1158. (.method ClassName ...)
> syntax has been changed to call java.lang.Class method for ClassName,
> not static field/method any more. Use namespace syntax instead.
>
> diff --git a/swank/commands/basic.clj b/swank/commands/basic.clj
> index ac0736f..4705cd5 100644
> --- a/swank/commands/basic.clj
> +++ b/swank/commands/basic.clj
> @@ -273,7 +273,7 @@
> (when-let [meta (and sym-var (meta sym-var))]
>   (if-let [path (or (slime-find-file-in-paths (:file meta) (slime-
> search-paths))
>(slime-find-file-in-paths (str (namespace-to-
> path (:ns meta))
> -  (.separator
> File)
> +  File/separator
>   (:file meta))
> (slime-search-paths))
> `((~(str "(defn " (:name meta) ")")
>(:location
> diff --git a/swank/util/io.clj b/swank/util/io.clj
> index 56b037e..48fd5b8 100644
> --- a/swank/util/io.clj
> +++ b/swank/util/io.clj
> @@ -28,7 +28,7 @@
>(dothread
>  (thread-set-name "Call-on-write Stream")
>  (continuously
> -   (.sleep Thread 200)
> +   (Thread/sleep 200)
>(when-not @closed?
>  (.flush stream
>
>
>
>
> On Dec 14, 4:41 pm, kunnar  wrote:
>> Hi,
>>
>> Looks like patch is already applied, but i now i get following error
>> after "M-."
>>
>> java.lang.IllegalArgumentException: No matching field found: separator
>> for class java.lang.Class (NO_SOURCE_FILE:0)
>>   [Thrown class clojure.lang.Compiler$CompilerException]
>>
>> I updated everything clojure related - clojure itself, swank-clojure,
>> clojure-mode, slime, clojure-contrib, but i still get that error.
>> Before update "M-." did work.
>>
>> Kunnar
>>
>> On Dec 11, 7:04 am, "Bill Clementson"  wrote:
>>
>> > Hi Matt,
>>
>> > FYI - Jeffrey Chu just sent me an email and the patch has now been
>> > applied to swank-clojure.
>>
>> > - Bill
>>
>> > On Wed, Dec 10, 2008 at 1:09 PM, Bill Clementson  
>> > wrote:
>> > > Hi Matt,
>>
>> > > On Wed, Dec 10, 2008 at 12:47 PM, MattyDub  wrote:
>>
>> > >> I can confirm that that patch fixed my problem - I can now M-. to
>> > >> render-place.  Thanks, Bill!
>>
>> > > Good to hear that the patch fixes the issue for you.
>>
>> > >>   What paths doesslime-edit-definitionsearch for the definitions?
>> > >> It's not finding the clojure macros/functions (like defn, dosync,
>> > >> etc.), so I must not have that path configured correctly.
>> > >> -Matt
>>
>> > > Basically, it searches a bunch of standard Java locations plus the
>> > > locations you specified in your classpath. If you want to see what
>> > > will be searched, enter the following 2 statements in your Clojure
>> > > REPL:
>> > > (in-ns 'swank.commands.basic)
>> > > (slime-search-paths)
>>
>> > > Note: the function "slime-search-paths" isn't public
>>
>> > > If M-. isn't working on standard Clojure symbols, it could be for a
>> > > number of reasons:
>> > > 1. You're using an old version of Clojure
>> > > 2. You've built Clojure excluding source from the jar file
>> > > 3. The Clojure source isn't in your classpath (only necessary if #2 is 
>> > > true)
>>
>> > > - Bill
> >
>

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



Microsoft SQL Server and the sql contrib

2008-12-16 Thread Scott Jaderholm
I'm trying to use the sql contrib with Microsoft SQL Server Express 2005.

1. I've included sqljdbc.jar in my classpath.

2. In my namespace I (:require [clojure.contrib.sql :as sql])

3. I'm defining my database connection as follows:

(def db {:classname "com.microsoft.sqlserver.jdbc.SQLServerDriver"
  :subprotocol "sqlserver"
  :subname "//sqlserver\\sqlexpress" ; this is hostname and instance
name. I've tried just //sqlserver and sqlserver also
  :user "username"
  :password "password"
  })

 4. But when I try to access the database:
(sql/with-connection db
  (sql/with-results res
"select * from exercises"
(doseq rec res
  (println rec

5. I get the following error:
No suitable driver found for jdbc:sqlserver://sqlserver\sqlexpress
  [Thrown class java.sql.SQLException]

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

Backtrace:
  0: java.sql.DriverManager.getConnection(Unknown Source)
  1: java.sql.DriverManager.getConnection(Unknown Source)

Can anyone help?

Thanks!
Scott

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



Listen on changes to refs

2008-12-16 Thread Rowdy Rednose

Can I listen on changes done to refs?

Let's say in a scenario like that on
http://en.wikibooks.org/wiki/Clojure_Programming#Mutation_Facilities
could I add a facility that allows the registration of listeners that
get called on certain changes to the refs?

For example I'd like to be notified on all changes to employees where
name is "Jim".

--~--~-~--~~~---~--~~
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: Emtpy (filter ...) Result Yields nil; Could / Should It Be An Empty List?

2008-12-16 Thread J. McConnell

On Tue, Dec 16, 2008 at 11:59 AM, Mon Key  wrote:
>
>> This is why flatten's behavior was considered a bug. In Clojure, an
>> empty sequence is equivalent to nil, not to '(nil).
>
> This does not comport with the various differences enumerated @
> http://clojure.org/lisps
> Perhaps they need to be changed.  RH care to weigh in on this?
>
> which says:
> "() is not the same as nil"

I didn't say () was the same as nil, I said an empty sequence was and
that you should be comparing (seq? nil) to (seq? ()), not (seq?
'(nil)).

> and this one:
> "In Clojure nil means 'nothing'. It signifies the absence of a value,
> of any type, and is not specific to lists or sequences."
>
> and probably this one too:
> "Empty collections are distinct from nil. Clojure does not equate nil
> and '()."

These docs are all correct and consistent. Also, I did not equate nil
and '(), I equated (seq? nil) and (seq? '()), and only to illustrate
why (flatten nil) should not return '(nil).

> and this one as well:
> "...There is no such thing as an empty sequence. Either there is a
> sequence (with elements) or there isn't (nil)..."

This is exactly the point. As Randall pointed out, flattening nothing
should not create something (since '(nil)) is something. Remember, you
don't expect a list out of (flatten), you expect a sequence and an
empty sequence is nil.

> add this to the pile:
> "...The Clojure return values differ in not returning empty
> collections, but rather a sequence or not"

Again, this is exactly why flatten should return nil in this case. It
should return "a sequence or not" and flattening nothing should give
you nothing.

I don't see any inconsistencies here.

- J.

--~--~-~--~~~---~--~~
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: Listen on changes to refs

2008-12-16 Thread Rowdy Rednose

There must be a smarter way to achieve this than polling the
collection for changes, I guess.

On 16 Dez., 21:43, Dave Griffith  wrote:
> Right now, you add listeners to agents, but not refs.   IIRC, there
> was talk of adding listeners to refs to enable just the sort of
> reactive programming you describe, but I don't know the status.
--~--~-~--~~~---~--~~
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: Problems with "gen-and-load-class" (defn user-exception-test [] (try (throw (new user.UserException "msg: user exception was here!!")) (catch user.UserException e (prn "caught exception" e)) (fina

2008-12-16 Thread Chouser

On Sun, Dec 14, 2008 at 4:29 PM, Tommy  wrote:
>
> Hello.
>
> I am having problems with "gen-and-load-class". I have a file with an
> example from the wiki book:
>
> (gen-and-load-class 'user.UserException :extends Exception)
>
> (defn user-exception-test []
>  (try
>(throw (new user.UserException "msg: user exception was here!!"))
>(catch user.UserException e
>  (prn "caught exception" e))
>(finally (prn "finally clause invoked!!!"
>
> But when I load it, I get the message "java.lang.Exception: Unable to
> resolve symbol: gen-and-load-class in this context (throwException.clj:
> 1)".
>
> I have tried to load the file "clojure-path/classes/clojure/
> genclass.clj" but I still cannot use "gen-and-load-class".
>
> Can anyone help?
>
> - Tommy

If you're using a recent version from SVN, the gen-class stuff has
changed.  See http://clojure.org/compilation

--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 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



ants.clj demo and old single core CPU

2008-12-16 Thread prhlava


Hello,

Is the ants.clj supposed to work on single core ~700MHZ CPU?

The program loads and runs, but all ants "stay at home" (but the CPU
is busy).

I am using latest svn version of clojure on:

java version "1.6.0_0"
IcedTea6 1.3.1 Runtime Environment (build 1.6.0_0-b12)
OpenJDK Client VM (build 1.6.0_0-b12, mixed mode)

Kind regards,

Vlad
--~--~-~--~~~---~--~~
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: Listen on changes to refs

2008-12-16 Thread Dave Griffith


Right now, you add listeners to agents, but not refs.   IIRC, there
was talk of adding listeners to refs to enable just the sort of
reactive programming you describe, but I don't know the status.
--~--~-~--~~~---~--~~
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: ants.clj demo and old single core CPU

2008-12-16 Thread prhlava


Well,

Reducing the number of ants helped and it works...

Vlad
--~--~-~--~~~---~--~~
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: Is clojure.core/require documentation out of date ?

2008-12-16 Thread Daniel Eklund

> If I'm wrong, could you please help me understand, maybe by giving me
> a URL I may have missed ?
>
> Regards,
>
> --
> Laurent PETIT

yes it is out of date... check the post 5 posts down:

http://groups.google.com/group/clojure/browse_frm/thread/4a4c2e3e7aab5325#

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



Blogging About Clojure?

2008-12-16 Thread Randall R Schulz

Hi,

Wordy though I am, I've never done any blogging before, but now that I'm 
finally beginning to get up-to-speed on Clojure, I think I might have 
some things to say.

So I was wondering if anyone could recommend a good blog site for this 
purpose? Naturally, I'll want to include source code, so it should be 
able to present that easily and cleanly. Apart from that, I don't think 
I need much in the way of fanciness. I'd prefer a site whose 
presentation is clean and uncluttered.

Does anyone have any recommendations?


Randall Schulz

--~--~-~--~~~---~--~~
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: Microsoft SQL Server and the sql contrib

2008-12-16 Thread MikeM

To make sure your driver is really on the classpath, try this from the
REPL:

(. Class (forName  "com.microsoft.sqlserver.jdbc.SQLServerDriver"))


--~--~-~--~~~---~--~~
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: ClassName. Constructor Notation in Macros?

2008-12-16 Thread Stuart Halloway

Hi Randall,

The syntactic sugar forms are reader behavior, and occur too soon: at  
read time, not macro expansion time.

Macros need to expand to real forms, not reader shortcuts.

Stuart

> Hi,
>
> A couple of days ago I was having a lot of trouble getting the
> (ClassName. ctor-args...) form of constructors to work while (new
> ClassName ctor-args...) was fine. It eventually occurred to me that  
> the
> problem had to do with those constructor calls being in macro bodies.
> Now it turns out those macros were very poorly written, and now the
> constructor code is isolated in a function called by the macro
> expansion (you might never know how ugly something can be until you
> (macroexpand ...) it!).
>
> However, I am left wondering what exactly is the interaction that was
> causing the dot-suffix form of the constructor call to fail in a macro
> expansion. I sense it has to do with the fact that symbols (other than
> gensyms or syntax-unquoted macro arguments) used in macro definitions
> are qualified with the namespace of the macro definition when that
> macro is expanded.
>
> Is this understanding correct? If so, is the behavior deliberate?
>
>
> Randall Schulz
>
> >


--~--~-~--~~~---~--~~
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: ClassName. Constructor Notation in Macros?

2008-12-16 Thread Randall R Schulz

On Tuesday 16 December 2008 11:32, Stuart Halloway wrote:
> > Hi,
> >
> > ...
> >
> > However, I am left wondering what exactly is the interaction that
> > was causing the dot-suffix form of the constructor call to fail in
> > a macro expansion. I sense it has to do with the fact that symbols
> > (other than gensyms or syntax-unquoted macro arguments) used in
> > macro definitions are qualified with the namespace of the macro
> > definition when that macro is expanded.
> >
> > Is this understanding correct? If so, is the behavior deliberate?

> Hi Randall,
>
> The syntactic sugar forms are reader behavior, and occur too soon: at
> read time, not macro expansion time.
>
> Macros need to expand to real forms, not reader shortcuts.

Thanks. That makes sense.

I didn't realize the dot-suffix form was a special reader form. 
Actually, all that's said about this at  is:

"... Symbols beginning or ending with '.' are reserved by Clojure. ..."


> Stuart


Randall Schulz

--~--~-~--~~~---~--~~
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: ClassName. Constructor Notation in Macros?

2008-12-16 Thread Rich Hickey



On Dec 16, 2:32 pm, Stuart Halloway  wrote:
> Hi Randall,
>
> The syntactic sugar forms are reader behavior, and occur too soon: at
> read time, not macro expansion time.
>

Actually, the dot sugar is not reader magic, but macroexpansion, as
documented here:

http://clojure.org/java_interop

(read-string "(java.util.ArrayList.)")
-> (java.util.ArrayList.) ;a list with one symbol

(macroexpand (read-string "(java.util.ArrayList.)"))
-> (new java.util.ArrayList)

(eval (read-string "(java.util.ArrayList.)"))
-> #=(java.util.ArrayList. [])

> Macros need to expand to real forms, not reader shortcuts.
>

That's generally true, but does not apply here, because Classname. is
a regular symbol reader-wise.

Rich

--~--~-~--~~~---~--~~
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: ClassName. Constructor Notation in Macros?

2008-12-16 Thread Randall R Schulz

On Tuesday 16 December 2008 12:37, Rich Hickey wrote:
> On Dec 16, 2:32 pm, Stuart Halloway  wrote:
> > Hi Randall,
> >
> > The syntactic sugar forms are reader behavior, and occur too soon:
> > at read time, not macro expansion time.
>
> ...
>
> > Macros need to expand to real forms, not reader shortcuts.
>
> That's generally true, but does not apply here, because Classname. is
> a regular symbol reader-wise.

Which takes us back to why the dot-suffix notation was not working in a 
macro but (new ...) was. Can you explain that in terms of intended 
behaviors (the operation of nested macro expansion, perhaps?), or might 
it be a bug? If it matters, my macro was expanding to a (cond ...) 
which contained dot-suffixed-classname constructor notation and my 
constructors consistently got errors such as this one:

java.lang.IllegalArgumentException: Unable to resolve classname: BufferedWriter

As I pointed out on #clojure when it first arose, import declarations 
for java.io.BufferedWriter are in place in the file in which the macro 
definition appeared.


> Rich


Randall Schulz

--~--~-~--~~~---~--~~
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: building with Ant vs building with Maven

2008-12-16 Thread kkw

Thanks Meikel and Dave! Much appreciated.

Kev

On Dec 17, 12:13 am, Dave Newton  wrote:
> --- On Tue, 12/16/08, kkw  wrote:
>
> > Since the Ant-built file is bigger, should I build
> > using Ant instead of Maven?
>
> It looks like the Ant build is compiling more; for example the Maven build 
> includes zip.clj, where the Ant build has all the zip%*.class files.
>
> Dave
--~--~-~--~~~---~--~~
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: ClassName. Constructor Notation in Macros?

2008-12-16 Thread Stuart Halloway

This is confusing. First, if you read the docs, they begin with:

-
(Classname. args*)
(new Classname args*)
Special form.
-

Only if  you read further do you discover that (Classname. args*) is  
not a special form but a macro. Also, it is a macro that cannot be  
written in Clojure, that is, a "special macroexpansion" per the docs.

So a special macroexpansion is reader-macro-like, in that it involves  
a special syntax rules not available to normal Clojure code, but macro- 
like in that it expands at macroexpansion time.

Is that right?

Stuart

> On Dec 16, 2:32 pm, Stuart Halloway  wrote:
>> Hi Randall,
>>
>> The syntactic sugar forms are reader behavior, and occur too soon: at
>> read time, not macro expansion time.
>>
>
> Actually, the dot sugar is not reader magic, but macroexpansion, as
> documented here:
>
> http://clojure.org/java_interop
>
> (read-string "(java.util.ArrayList.)")
> -> (java.util.ArrayList.) ;a list with one symbol
>
> (macroexpand (read-string "(java.util.ArrayList.)"))
> -> (new java.util.ArrayList)
>
> (eval (read-string "(java.util.ArrayList.)"))
> -> #=(java.util.ArrayList. [])
>
>> Macros need to expand to real forms, not reader shortcuts.
>>
>
> That's generally true, but does not apply here, because Classname. is
> a regular symbol reader-wise.
>
> Rich
>
> >


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



confused by Vars, Refs, Agents and Atoms

2008-12-16 Thread falcon

I am fairly familiar with basic functional programming.  I've studied
a bit of scheme and Haskell.  I don't quite understand Vars, Refs,
Agents and Atoms.  I am a Java developer and have worked with
concurrency constructs: locks, synchronized, Executor framework, etc.

I've read a couple of chapters of the upcoming Clojure book and the
tutorial at http://en.wikibooks.org/wiki/Learning_Clojure.

Vars seem to be basic mutable variables.  What is root binding and
thread local binding?  I am _very_ interested in 'monkey patching'
running systems, which apparently involve vars, but root binding and
thread local bindings are a bit confusing.

Refs can apparently only be changed in transactions (presumably
similar to database transactions or Haskell's transactions).  I
understand that, but why are vars and refs different?

Agents can only be changed through a queue.  I assume this is so the
process of changing an agent is asynchronous and changes are applied
in order.  Are agents basically just actors (similar to Erlang)?

Atoms ensure atomic changes to a mutable variable...so we have the
option of mutating a variable in an atomic manner (single command) or
doing so in a transaction (perhaps involving several operations)?

There are several descriptions of each of these constructs, but I'm
not quite sure which is most appropriate for what.  I recall from
discussion on reactive programming/CELLS that more experienced folks
weren't sure which of these should be used as the base for CELLs
implementation.

Could this be an example of over-engineering?  Is it better to have
these four constructs or is it better to combine them and alter their
behavior by using different higher order functions?  eh...the last
sentence probably doesn't mean anythingI'm just trying to get an
intuitive feel for them.

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 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



reload library, blowing away old public symbols

2008-12-16 Thread Stuart Halloway

Hi all,

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

(defmacro ns-reload! [ns]
   `(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/193023afbf87698d

--~--~-~--~~~---~--~~
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: Microsoft SQL Server and the sql contrib

2008-12-16 Thread Scott Jaderholm
I don't think that's a problem:
user> (. Class (forName "com.microsoft.sqlserver.jdbc.SQLServerDriver"))
com.microsoft.sqlserver.jdbc.SQLServerDriver


On Tue, Dec 16, 2008 at 12:21 PM, MikeM wrote:

>
> To make sure your driver is really on the classpath, try this from the
> REPL:
>
> (. Class (forName  "com.microsoft.sqlserver.jdbc.SQLServerDriver"))
>
>
> >
>

--~--~-~--~~~---~--~~
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: confused by Vars, Refs, Agents and Atoms

2008-12-16 Thread Andrew Baine


Check out http://blip.tv/file/812787/ which is a video presentation by
Rich Hickey on clojure concurrency; it ends with an description of an
ant simulation that uses refs and agents -- it really helped my own
intuitive feel of when to use those two constructs.

Best,

Andrew


--~--~-~--~~~---~--~~
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: confused by Vars, Refs, Agents and Atoms

2008-12-16 Thread Randall R Schulz

On Tuesday 16 December 2008 13:54, Andrew Baine wrote:
> Check out http://blip.tv/file/812787/ ...

Rich's video presentations are also available via the iTunes store. 
Search for "Clojure," of course—you won't get any false hits.


> Best,
>
> Andrew


Randall Schulz

--~--~-~--~~~---~--~~
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 classes graph (was chart.png)

2008-12-16 Thread Randall R Schulz

On Sunday 14 December 2008 13:47, Chouser wrote:
> I've updated the Clojure classes graph (thanks for the push, R.
> Schulz!)  The new version includes the newest classes as well as Java
> interfaces that are applicable.  These latter are shown inside
> diamonds.
>
> ...
>
> I won't be maintaining the chart.png in the file upload area of this
> group, since it's much easier to just push new versions to the github
> repo.  There you can also find older versions, other formats, etc.
>
> --Chouser

I just noticed that AtomicReference and / or AtomicReference$IRef are 
missing from the Clojure type system graph.


Randall Schulz

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



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

2008-12-16 Thread Stephen C. Gilardi
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 class written in Java so it is always available with  
Clojure's runtime. Each of the entry points provided by class  
clojure.main ensures that namespace clojure.main is loaded (using  
"require") and then calls the corresponding fn in namepace clojure.main.


class clojure.main entry points:

- main : unified entry point for clojure. Can run a repl or a  
script, calls clojure.main/main


- legacy_repl : called by the new, stubbed clojure.lang.Repl,  
calls clojure.main/legacy-repl


- legacy_script : called by the new, stubbed clojure.lang.Script,  
calls clojure.main/legacy-script


Because the clojure.main class is always compiled along with the rest  
of the Clojure runtime, it can be Clojure's unified entry point  
whether or not ahead-of-time compiled Clojure code is available.


The pre-unification Clojure entry points (clojure.lang.Repl,  
clojure.lang.Script) are still available and now run via fns in  
namespace clojure.main. As a result, those fns will get a good workout  
even if users don't make any changes to how they drive clojure.jar.


[2] clojure.main/repl's handling of (read-line) was different than  
that of clojure.lang.Repl and not useful. This was because  
clojure.main/repl *always* reads from *in*, while clojure.lang.Repl  
created its own LineNumberingPushbackReader on System.in instead. In  
order to handle (read-line) well while still using *in* exclusively,  
clojure.main/repl needed to become aware of lines in the input stream  
rather than treating all whitespace the same. I've implemented that,  
notably without any change to LispReader.java so loading from files  
remains exactly the same.


Some visible changes to the repl:

- The repl now only prompts when the input stream is pointing to the  
start of a new line of input.


  - Multiple expressions on a line will only yield a single prompt.  
Blank lines (or lines containing only whitespace) will be consumed and  
yield a new prompt.


  user=> 1 2
  1
  2
  user=>
  user=>

- (read-line) will read a fresh line if there is nothing (or only  
whitespace) left on the current input line, or the (post-whitespace)  
rest of the input line otherwise.


  user=> (read-line)
  123
  "123"
  user=> (read-line) 456
  "456"

  user=>

  In the first example, the repl waited on the line after (read-line)  
and I typed 123. This should be the most common case an gives the same  
effect as clojure.lang.Repl used to. (Note that it doesn't have to be  
a naked call to (read-line) as shown here, (read-line) from within  
another function down the stack would behave the same way.)


  In the second example, (read-line) read 456 from the rest of the  
input line and printed the string that it read. It then waited for  
input without prompting on the next (blank) line. This is unfortunate,  
but I don't see a clean way around it--it's a consequence of code  
running during "eval" (in this case the read-line) changing the input  
stream in a way the repl can't predict. (read-line) consumes the  
newline after 456 on the input line. Whatever is typed on the line  
after "456" will be evaluated and printed. Just pressing return will  
produce a prompt (as shown).


- Exceptions caught by the repl now cause the rest of the input line  
to be skipped.


  user=> 1 2 3 (/ 1 0) 4 5 6
  1
  2
  3
  java.lang.ArithmeticException: Divide by zero (NO_SOURCE_FILE:0)
  user=>

- Comments to end of line (;) are now supported at the repl. This can  
be convenient when using a session transcript to demonstrate something.


  user=> (use 'clojure.set) ; pull in the set functions
  nil
  user=> 3 4 ; 5 6
  3
  4
  user=>

[3] clojure.lang.LineNumberingPushbackReader extends  
java.io.PushbackReader, but was not always honoring the latter's  
contract that when a character is successfully "unread", it will be  
the next character read. In the case of LNPBR's readLine, the pushed  
back character was ignored. Most of the time this had no significant  
effect, but I needed to fix it to support (read-line) from the same  
stream. These examples show the problem and the fixed behavior:


WAS:

user=> (with-in-str "12\n3" [(read-line) (read)])
["12" 3]
user=> (with-in-str "12\n3" (.unread *in* (.read *in*)) [(read-line)  
(read)])

["2" 13]
user=>

IS:

user=> (with-in-str "12\n3" [(read-line) (read)])
["12" 3]
user=> (with-in-str "12\n3" (.unread *in* (.read *in*)) [(read-line)  
(read)])

["12" 3]

[4] The "prompt" hook for clojure.main/repl now takes an argument: a  
keyword that indicates where on the line the input stream is pointing.  
The "only prompt on a fresh line" behavior is implemented by only  
printing the prompt when the "where" argument is :line-start. Anyone  
using the prompt hook will need to update.


Re: confused by Vars, Refs, Agents and Atoms

2008-12-16 Thread Mark Engelberg

On Tue, Dec 16, 2008 at 1:22 PM, falcon  wrote:
>
> I am fairly familiar with basic functional programming.  I've studied
> a bit of scheme and Haskell.  I don't quite understand Vars, Refs,
> Agents and Atoms.  I am a Java developer and have worked with
> concurrency constructs: locks, synchronized, Executor framework, etc.

Vars are like global variables in other languages.  The "root binding"
is an initial default value that is shared by all threads.  When you
alter a var, those changes will not be seen by other threads.  Since
changes aren't seen by other threads, there are no coordination
issues.  The "binding" construct acts as if the var has been altered
by set!, but it is automatically restored to its previous value upon
exiting the scope of the binding construct.  The semantics can seem
quite odd if you're not used to this kind of construct, and most
languages don't have anything quite like this (I think I've only seen
it in Lisp and Scheme), so Vars can take a while to get the hang of.

Refs are like ref cells in ML, boxes in Scheme, or pointers in other
languages.  It's a "box", that you can change the contents of.  But
unlike the other languages, the twist is that you can only make the
change inside of a transaction.

Agents are somewhat like Erlang actors, but you can always read the
contents of agents without needing to send a message, and as a result,
they aren't really useful for the kind of distributed programming that
Erlang is designed for.  Also since Java threads aren't as lightweight
as Erlang threads, I'm not totally convinced agents are as useful as
the corresponding constructs in Erlang.  But in any case, this is the
way to accomplish asynchronous things in Clojure.

Atoms are the newest construct, designed primarily to speed up
memoization caching versus the former ref implementation.  It's
reportedly a bit faster than refs, but less safe, in the sense that
you've got to make sure your program won't fail if the atom swap is
executed multiple times from a transaction retrying.  The only real
guarantee an atom provides is that the "swap" command is atomic, in
the sense that Clojure automatically checks that nothing altered the
value between when you read it and when you swap it with a new value.
But it's probably not much use for things other than memoization and
very similar scenarios.

My take on all this: when in doubt, use Refs, as they are most likely
what you want.

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

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  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! [ns]
>    `(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...
--~--~-~--~~~---~--~~
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  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  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
-~--~~~~--~~--~--~---



Re: reload library, blowing away old public symbols

2008-12-16 Thread Randall R Schulz

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 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)))
> > >
> > > ...
> > >
> > > Cheers,
> > > Stuart
> > >
> > > ...
> > >
> On Dec 16, 4:55 pm, Stuart Sierra  wrote:
> > I would find this useful; I've even tried writing it in the past.
> > Perhaps it could go in clojure.contrib.ns-utils.
> >
> > ...
> >
> > -the other Stuart (Sierra)
> >
>
> I'm also interested in having this utility. After it works, the next
> thing I would write is (ns-reload-all!), which reloads everything.

Trying to create a home-away-from-home? A place you never have to 
leave?? Seeking to never shut down your Emacs-embedded REPL???

Anyway, I, too, find bulk / pervasive namespace reload interesting. If 
it's to be used for very-long- running (dynamic / interactive) Clojure 
applications, then it will be important to make sure that no unwanted 
references linger in places that can lead to unrecoverable heap 
storage.

It seems to me that to be a completely general facility, some root data 
value bindings might require special roll-over logic (to propagate an 
existing value across a namespace reload in non-trivial ways), lest 
root defs for non-functions and -macros always revert to their initial 
values.


> Allen


Randall Schulz

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



creating new sequences

2008-12-16 Thread Mark Volkmann

If I create a new sequence by adding data to an existing one, does
Clojure allow the two sequences to share data as opposed to copying
the original sequence? For example,

(def coll1 [1 2])
(def coll2 (cons 3 coll1))

Does coll2 share the data in coll1 or have a copy of it?

I'm guessing the answer is yes, but I couldn't find it in writing and
want to be sure.

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~-~--~~~---~--~~
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: Is clojure.core/require documentation out of date ?

2008-12-16 Thread lpetit

OK, thank you for the link.

I know don't feel comfortable with the notion of lib. I currently
assume that it is more or less similar to a namespace : it looks like
a namespace, it tastes like a namespace, but still does seem to be not
considered a namespace.

In which ways does the notion of "lib" offer something different from
the notion of "namespace", currently ?

I can see a value if a lib can be a collection of namespaces. Then it
would be closer to the notion of "unit of reuse / distribution" ->
clojure is a lib, clojure-contrib is a lib ... But it does not seem to
be the case, or is it just that the documentation I read isn't up to
date, too ?

I also think that the notion of lib is a step towards dependency
management : what libs a lib needs to compile (maybe libs that contain
macros that are not needed after the compilation step), what libs are
lib needs to run. And also a version number for the lib.


On 16 déc, 19:58, Daniel Eklund  wrote:
> > If I'm wrong, could you please help me understand, maybe by giving me
> > a URL I may have missed ?
>
> > Regards,
>
> > --
> > Laurent PETIT
>
> yes it is out of date... check the post 5 posts down:
>
> http://groups.google.com/group/clojure/browse_frm/thread/4a4c2e3e7aab...
--~--~-~--~~~---~--~~
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: creating new sequences

2008-12-16 Thread Stephen C. Gilardi


On Dec 16, 2008, at 6:29 PM, Mark Volkmann wrote:


If I create a new sequence by adding data to an existing one, does
Clojure allow the two sequences to share data as opposed to copying
the original sequence? For example,

(def coll1 [1 2])
(def coll2 (cons 3 coll1))

Does coll2 share the data in coll1 or have a copy of it?


It shares the data--which is safe because of immutability and  
efficient because Rich designed and implemented Clojure's persistent  
data structures carefully and well.


I recommend Rich's presentations on blip tv or iTunes to everyone  
who's interested in Clojure. They give good overviews and discuss a  
lot about why things are the way they are in Clojure.


--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: creating new sequences

2008-12-16 Thread Stephen C. Gilardi


On Dec 16, 2008, at 6:35 PM, Stephen C. Gilardi wrote:

It shares the data--which is safe because of immutability and  
efficient because Rich designed and implemented Clojure's persistent  
data structures carefully and well.


But Mark was talking about sequences, not persistent data structures!

Good point... But same answer. There's lots of data sharing going on.

Here's an example where I use metadata to mark a member so I can tell  
if it's identical in the aggregate sequence.


user=> (def a [#^{:blue 2} [:a]])
#'user/a
user=> a
[[:a]]
user=> (def b (cons 3 a))
#'user/b
user=> b
(3 [:a])
user=> ^(frest b)
{:blue 2}
user=>

I recommend Rich's presentations on blip tv or iTunes to everyone  
who's interested in Clojure. They give good overviews and discuss a  
lot about why things are the way they are in Clojure.


And a good recommendation nonetheless...

--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: Bug in unchecked operations?

2008-12-16 Thread J. McConnell

On Sun, Dec 14, 2008 at 3:24 PM, Michel Salim  wrote:
>
> My mistake; unchecked operations work just fine if their arguments
> (including constants) are given type hints. What happens if unchecked-
> add/sub/... is given an argument of unknown type, though? It still
> seems to work, though slowly.

Reflection ... since Clojure doesn't know the types at compile time it
has to determine them at runtime via reflection. While Java's
reflection support is much faster than it used to be, it's still a big
hit.

- J.

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



clojure wrapper for Saxon XSLT 2.0 library

2008-12-16 Thread Perry Trolard

Hi All,

For any of you who do XSLT 2.0 processing, I've written a simple
Clojure wrapper around Saxon's (saxonica.com) high-level Java API.
It's at

 http://github.com/pjt/saxon/tree/master

Best,
Perry



--~--~-~--~~~---~--~~
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: Is clojure.core/require documentation out of date ?

2008-12-16 Thread Daniel Eklund

>
> I know don't feel comfortable with the notion of lib. I currently
> assume that it is more or less similar to a namespace : it looks like
> a namespace, it tastes like a namespace, but still does seem to be not
> considered a namespace.
>

I understand your pain.  I am right now going through the same thought
process, and do not have a satisfactory understanding myself.  The
myriad connections between namespaces and libraries as manifest
through 'load-file', 'require', 'use', 'refer', 'load', have left me
scratching my head.  In the end, someone like you or I might need to
publish our discoveries here (with the understanding that we are
looking for feedback).

I am currently going through the core.clj to understand the
dependencies.  I think you will find the API will stay out of date for
the short term as things are fleshed out here and on the IRC channel.

I thought that clojure was further along when I started a few weeks
ago.

Please don't mistake this last statement for a criticism.  In fact,
now that I see that I am in the middle of the birth of something
extremely impressive, I am rather excited.  The primitives and major
design decisions of this language seem to be solid.  It seems to be
these higher level notions that are being refined as we speak.  I've
dug up month-old to half-year old posts on this group where people
propose and implement breaking changes.  The AOT compilation change
came only a short time ago and seems to be the source of this
particular API staleness.  I've seen posts where the binding forms to
most of the sequencing funcitons are fleshed out on the group and then
committed.  There seems to be a great willingness to allow these
'API's to gestate in contrib libraries before they are promoted to
core -- after all, they're all just macros and functions in the end.

I am guessing this trend will continue for the foreseeable future, and
some examples, APIs and code libraries will be out of synch.  Heck, a
lot of the information I gleaned came from watching the movies, and
even those are out of date (there is no longer a boot.clj for
instance).

I think the best course of action, for now, is to just read the code.
Make core.clj your friend.  It has deepened my understanding of the
language decisions.  (Still trying to grok 'libraries' though :)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
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: Microsoft SQL Server and the sql contrib

2008-12-16 Thread Wayne R

Have a look at 
http://dertompson.com/2007/10/06/connection-to-mssql-server-express-2005-with-jdbc/

Apparently using JDBC with MSSQL Express requires some extra setup.


On Dec 16, 3:49 pm, "Scott Jaderholm"  wrote:
> I don't think that's a problem:
> user> (. Class (forName "com.microsoft.sqlserver.jdbc.SQLServerDriver"))
> com.microsoft.sqlserver.jdbc.SQLServerDriver
>
> On Tue, Dec 16, 2008 at 12:21 PM, MikeM wrote:
>
>
>
> > To make sure your driver is really on the classpath, try this from the
> > REPL:
>
> > (. Class (forName  "com.microsoft.sqlserver.jdbc.SQLServerDriver"))
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



question about (commute messages conj msg)

2008-12-16 Thread wubbie

Hello,

My question is that conj takes two argument and how conj finds
the first argument? Is it somehow provided by commute?

Thanks,
sun

--~--~-~--~~~---~--~~
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: question about (commute messages conj msg)

2008-12-16 Thread Randall R Schulz

On Tuesday 16 December 2008 18:10, wubbie wrote:
> Hello,
>
> My question is that conj takes two argument and how conj finds
> the first argument? Is it somehow provided by commute?

Consider the documentation for (commute ...) (at 
):

-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
commute ref fun & args)
Must be called in a transaction. Sets the in-transaction-value of ref 
to:

(apply fun in-transaction-value-of-ref args)

and returns the in-transaction-value of ref.

At the commit point of the transaction, sets the value of ref to be:

(apply fun most-recently-committed-value-of-ref args)

Thus fun should be commutative, or, failing that, you must accept 
last-one-in-wins behavior. commute allows for more concurrency than 
ref-set.
-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-

In both cases, the first argument to the "fun" argument to (commute ...) 
is implicitly either the "in-transacxtion-value-of-ref" 
or "most-recently-committed-value-of-ref". All other / subsequent 
arguments are those appearing as the 3rd and subsequent arguments to 
(commute ...).


> Thanks,
> sun


Randall Schulz

--~--~-~--~~~---~--~~
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: question about (commute messages conj msg)

2008-12-16 Thread wubbie

Thanks Randall.

My background is mostly in imperative languages, including perl
and perl has closure, so it looks commute uses closure concept
to implement this. Is it right?

Thanks again,
sun


On Dec 16, 9:28 pm, Randall R Schulz  wrote:
> On Tuesday 16 December 2008 18:10, wubbie wrote:
>
> > Hello,
>
> > My question is that conj takes two argument and how conj finds
> > the first argument? Is it somehow provided by commute?
>
> Consider the documentation for (commute ...) (at
> ):
>
> -==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
> commute ref fun & args)
> Must be called in a transaction. Sets the in-transaction-value of ref
> to:
>
> (apply fun in-transaction-value-of-ref args)
>
> and returns the in-transaction-value of ref.
>
> At the commit point of the transaction, sets the value of ref to be:
>
> (apply fun most-recently-committed-value-of-ref args)
>
> Thus fun should be commutative, or, failing that, you must accept
> last-one-in-wins behavior. commute allows for more concurrency than
> ref-set.
> -==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
>
> In both cases, the first argument to the "fun" argument to (commute ...)
> is implicitly either the "in-transacxtion-value-of-ref"
> or "most-recently-committed-value-of-ref". All other / subsequent
> arguments are those appearing as the 3rd and subsequent arguments to
> (commute ...).
>
> > Thanks,
> > sun
>
> Randall Schulz
--~--~-~--~~~---~--~~
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: question about (commute messages conj msg)

2008-12-16 Thread Timothy Pratley

> and perl has closure, so it looks commute uses closure concept
> > > My question is that conj takes two argument and how conj finds
> > > the first argument? Is it somehow provided by commute?

commute is passed conj as a function.
commute then calls conj messages msg,
and sets messages to be the result (which is messages with msg added
on)

There is a more in-depth example at
http://en.wikibooks.org/wiki/Clojure_Programming/Concepts
(defn add-employee [e]
  "add new employee e to employee-records"
  (dosync (commute employee-records conj e)))

commute: At the commit point of the transaction, sets the value of ref
to be:
(apply fun most-recently-committed-value-of-ref args)

ie: (commute messages conj msg)
means: messages = apply conj messages msg

No closures involved.


Regards,
Tim.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---