Re: NO_SOURCE_FILE

2009-09-23 Thread Timothy Pratley

There could be a verbose flag which would print the form in which the
error occurs. This shouldn't be default though as the forms can be
quite large.



On Sep 23, 3:37 pm, Raoul Duke rao...@gmail.com wrote:
 hi,

 is there perchance some way Clojure's REPL might be able to print out
 more information in such situations? i don't know what precisely the
 situations are. it is frustrating to not get more information to help
 debug something. seems like it might be about anonymous fns or some
 such?

 thanks for any brainstorms!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Streaming Data?

2009-09-23 Thread David Nolen
Dear Clojurians,


Are lazy-seqs good for streaming data that arrives at indeterminate
intervals? if not any pointers about which approach to take?


I'm working on a simple serial port library for Clojure and I'm trying to
understand how to best model a solution. Basically serial events will happen
periodically on the port and I'd rather design my program in a functional
way then just trying to translate Java serial port code that I've seen.


Thanks,

David

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



trouble running clojure.test

2009-09-23 Thread MarkSwanson

Hello,
I'm having trouble unit testing clojure code. To be sure I'm just
testing clojure.test, I'm trying to test clojure.contrib.json.read.

test.clj states:

  ;; RUNNING TESTS
  ;;
  ;; Run tests with the function (run-tests namespaces...):

  (run-tests 'your.namespace 'some.other.namespace)

However, this doesn't work:
 (run-tests 'clojure.contrib.json.read)
nil

What does seem to work is this:
 (test-ns 'clojure.contrib.json.read)
{:test 17, :pass 27, :fail 0, :error 0}

However, I need MUCH more verbose output: which functions passed?
which ones failed (expected/actual)???
test.clj states this should work perfectly:
  ;; You can type an is expression directly at the REPL, which will
  ;; print a message if it fails.
  ;;
  ;; user (is (= 5 (+ 2 2)))
  ;;
  ;; FAIL in  (:1)
  ;; expected: (= 5 (+ 2 2))
  ;;   actual: (not (= 5 4))
  ;; false

but it doesn't work this way at all:
 (is (= 5 (+ 2 2)))
false

Just false?
How do I enable the nice report?
NOTE: the code above doesn't have any failed functions, but a simple
test function I created only did this:
(test-ns 'test)
{:test 2, :pass 1, :fail 1, :error 0}
*missing == FAIL in ...

I've also tried test_is.clj but I only ever get 'nil' as a result. I
also tried with

I'm sure I've missed it. test.clj contains defmethod report ... that
has the FAIL println in it. I do not know why it is not getting
called.

All suggestions are warmly welcomed.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Streaming Data?

2009-09-23 Thread Timothy Pratley

Tom Faulhaber wrote a great article which uses fill-queue to create a
lazy-seq from a data stream, I think you might find it quite
applicable:
http://infolace.blogspot.com/2009/08/simple-webhooks-with-clojure-and-ring.html
http://richhickey.github.com/clojure-contrib/seq-utils-api.html#fill-queue


On Sep 23, 4:17 pm, David Nolen dnolen.li...@gmail.com wrote:
 Dear Clojurians,

 Are lazy-seqs good for streaming data that arrives at indeterminate
 intervals? if not any pointers about which approach to take?

 I'm working on a simple serial port library for Clojure and I'm trying to
 understand how to best model a solution. Basically serial events will happen
 periodically on the port and I'd rather design my program in a functional
 way then just trying to translate Java serial port code that I've seen.

 Thanks,

 David
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: trouble running clojure.test

2009-09-23 Thread Timothy Pratley

I think your environment is swallowing the output.
What setup are you running?
Try with just a blank REPL, this is what I get:

foo= (ns foo (:use [clojure.test]))
nil
foo= (is (= 5 (+ 2 2)))

FAIL in clojure.lang.persistentlist$emptyl...@1 (NO_SOURCE_FILE:6)
expected: (= 5 (+ 2 2))
  actual: (not (= 5 4))
false
foo=


On Sep 23, 4:51 pm, MarkSwanson mark.swanson...@gmail.com wrote:
 Hello,
 I'm having trouble unit testing clojure code. To be sure I'm just
 testing clojure.test, I'm trying to test clojure.contrib.json.read.

 test.clj states:

   ;; RUNNING TESTS
   ;;
   ;; Run tests with the function (run-tests namespaces...):

   (run-tests 'your.namespace 'some.other.namespace)

 However, this doesn't work: (run-tests 'clojure.contrib.json.read)

 nil

 What does seem to work is this: (test-ns 'clojure.contrib.json.read)

 {:test 17, :pass 27, :fail 0, :error 0}

 However, I need MUCH more verbose output: which functions passed?
 which ones failed (expected/actual)???
 test.clj states this should work perfectly:
   ;; You can type an is expression directly at the REPL, which will
   ;; print a message if it fails.
   ;;
   ;;     user (is (= 5 (+ 2 2)))
   ;;
   ;;     FAIL in  (:1)
   ;;     expected: (= 5 (+ 2 2))
   ;;       actual: (not (= 5 4))
   ;;     false

 but it doesn't work this way at all: (is (= 5 (+ 2 2)))

 false

 Just false?
 How do I enable the nice report?
 NOTE: the code above doesn't have any failed functions, but a simple
 test function I created only did this:
 (test-ns 'test)
 {:test 2, :pass 1, :fail 1, :error 0}
 *missing == FAIL in ...

 I've also tried test_is.clj but I only ever get 'nil' as a result. I
 also tried with

 I'm sure I've missed it. test.clj contains defmethod report ... that
 has the FAIL println in it. I do not know why it is not getting
 called.

 All suggestions are warmly welcomed.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Applying Java methods.

2009-09-23 Thread sross

On Sep 22, 2:30 pm, Chouser chou...@gmail.com wrote:
 On Mon, Sep 21, 2009 at 5:22 PM, sross ros...@gmail.com wrote:

  Hi All,

   I'm looking for a bit of advice for calling a java method which has a
  few different signatures (such as Connection.prepareStatement).
   Is there a cleaner way of passing a variable number of arguments to
  the method, such as

  (apply (memfn prepareStatement) (sql/connection) args)

   or is doing something like the  following the only approach.

  (defn prepare-statement
   ([sql] (.prepareStatement (sql/connection) sql))
   ([sql arg] (.prepareStatement (sql/connection) sql arg))
   ([sql arg arg2] (.prepareStatement (sql/connection) sql arg arg2))
   ([sql arg arg2 arg3] (.prepareStatement (sql/connection) sql arg
  arg2 arg3)))

 Your solution will provide the best performance (you may need
 to type-hint the args).  If performance doesn't matter, you
 can use Rich's jcall fn:

   (defn jcall [obj name  args]
     (clojure.lang.Reflector.invokeInstanceMethod
       obj
       (str name)
       (if args (to-array args) (clojure.lang.RT.EMPTY_ARRAY

 Then you could:

   (defn prepare-statement [ args]
     (apply jcall (sql/connection) prepareStatement args))

 Note that uses runtime reflection, array creation, etc. each
 time it's called.  You can expect it to be at least an order
 of magnitude slower than if it were directly compiled like
 your original solution could be.

 --Chouser


Thanks for a solution and the advice.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: If you wish to have a version for off-line use...

2009-09-23 Thread Kei Suzuki

Long time ago I posted a message with a Clojure program that does what
you are looking for.

http://groups.google.com/group/clojure/browse_thread/thread/1e7b9c0a2d839bca/e1d6a0f1282c60d2?q=saving+the+Clojure+webiste

The program, however, is terribly slow and inefficient. I've been
working on improving it since then. Recently I've got one that I think
good enough, so I made it available on GitHub:

http://github.com/ksuzuki/Save-cljsites

In the old thread you can find a way to download the Clojure website
using wget, if you like. But I think my program does better in speed
and result, and it can save the Clojure-contrib pages likewise.

Hope this helps.

On Sep 21, 7:37 am, MarkSwanson mark.swanson...@gmail.com wrote:
 Personally, that's not what I want.

 I want to download the clojure.org web page - one level deep so the
 files api, special_forms, macros, etc. are all available on my laptop
 offline.
 I tried a couple of programs (wget and httrack) to get this but there
 is some strange combobulation of redirects and cookie sessions going
 on that prevented these from working (for me).

 If anyone knows an easy way to get this documentation available
 offline please contribute.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Namespace/class visibility in eval

2009-09-23 Thread Rick Moynihan

 On Tue, Sep 22, 2009 at 6:46 PM, Eric Tschetter eched...@gmail.com wrote:
 But, this looks like a gaping security hole. You're taking an HTTP POST
 request body and eval'ing it. Someone will, sooner or later, try typing
 (delete all the secret files) into the web form and clicking Send. Or
 worse, something that will actually delete something or grant privilege.
 Sending (doall (iterate inc 1)) will crash the server with OOME after a
 lengthy 100%-cpu-use hang while it fills memory with consecutive Integer
 objects, for a cheap and easy DoS attack. And so forth.

Presumably the #clojure irc bot has solved or worked around many of
these issues?  It certainly operates in a sandbox:

http://github.com/hiredman/clojurebot

R.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



where is the contrib?

2009-09-23 Thread ELaN

I run a clj script file and get a FileNotFoundException.
The message is Could not locate clojure/contrib/
import_static__init.class or clojure/contrib/import_static.clj on
classpath.

But I didn't find any file or dir like contrib in the clojure files.
If anyone have any solution,please share it,thank you.

Here is the part of the code

(ns examples.atom-snake
  (:import (java.awt Color Dimension)
   (javax.swing JPanel JFrame Timer JOptionPane)
   (java.awt.event ActionListener KeyListener))
  (:use clojure.contrib.import-static
[clojure.contrib.seq-utils :only (includes?)]))
(import-static java.awt.event.KeyEvent VK_LEFT VK_RIGHT VK_UP VK_DOWN)

you can get all the code here

http://media.pragprog.com/titles/shcloj/code/examples/atom_snake.clj


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: How does (apply map + '((1 2) (2 3) (3 4))) work?

2009-09-23 Thread simon

That's good.

Thanks.
-Simon


On Aug 19, 8:03 am, CuppoJava patrickli_2...@hotmail.com wrote:
 (apply map + '((1 2) (2 3) (3 4)))

 is synonymous to:

 (map + [1 2] [2 3] [3 4])

 So you get

 ( (1+2+3)  (2+3+4) )  = (6 9)

 Hope that helps
   -Patrick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Namespace/class visibility in eval

2009-09-23 Thread Philipp Meier



On 23 Sep., 03:26, John Harrop jharrop...@gmail.com wrote:
 On Tue, Sep 22, 2009 at 6:46 PM, Eric Tschetter eched...@gmail.com wrote:
 But, this looks like a gaping security hole. You're taking an HTTP POST
 request body and eval'ing it. Someone will, sooner or later, try typing
 (delete all the secret files) into the web form and clicking Send. Or
 worse, something that will actually delete something or grant privilege.
 Sending (doall (iterate inc 1)) will crash the server with OOME after a
 lengthy 100%-cpu-use hang while it fills memory with consecutive Integer
 objects, for a cheap and easy DoS attack. And so forth.

Remember that clojure runs in the JVM and a JVM can have a
SecurityManager which can be configured to allow or deny at most any
dangeroues operatíon. A java policy file will to the trick, I think.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: If you wish to have a version for off-line use...

2009-09-23 Thread Mark Volkmann

It looks like that PDF is a little out of date. It doesn't include all
the pages accessible from the left nav. at http://clojure.org.

On Tue, Sep 22, 2009 at 7:51 PM, Julian juliangam...@gmail.com wrote:

 Did you mean this?
 http://clojure.googlegroups.com/web/manual.pdf

 On Sep 20, 4:59 am, cej38 junkerme...@gmail.com wrote:
 I was just looking through the main web page of clojure-contrib and
 came across this:

 If you wish to have a version for off-line use you can use the
 download button on the  page at GitHub .gh-pages branch.

 Is there a similar repository for the clojure.org?

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: where is the contrib?

2009-09-23 Thread Stuart Sierra

Clojure-contrib is available on Github:
http://github.com/richhickey/clojure-contrib/
-SS

On Sep 23, 5:14 am, ELaN mr.y...@gmail.com wrote:
 I run a clj script file and get a FileNotFoundException.
 The message is Could not locate clojure/contrib/
 import_static__init.class or clojure/contrib/import_static.clj on
 classpath.

 But I didn't find any file or dir like contrib in the clojure files.
 If anyone have any solution,please share it,thank you.

 Here is the part of the code
 
 (ns examples.atom-snake
   (:import (java.awt Color Dimension)
            (javax.swing JPanel JFrame Timer JOptionPane)
            (java.awt.event ActionListener KeyListener))
   (:use clojure.contrib.import-static
         [clojure.contrib.seq-utils :only (includes?)]))
 (import-static java.awt.event.KeyEvent VK_LEFT VK_RIGHT VK_UP VK_DOWN)
 
 you can get all the code here

 http://media.pragprog.com/titles/shcloj/code/examples/atom_snake.clj
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Q: is there a better way to do this

2009-09-23 Thread Dave Jack

 When it useful to be able to deref inside a dosync without ensuring?
When you deref and alter/set the same ref, the ref is protected from
modification as well.

I couldn't think of an example of what I think you had in mind,
something that requires a transaction but is tolerant of modification
of the ref.

 Ensure seems like a more safe default of what I'd expect from a
 transaction. So why not make deref automatically ensure within a
 dosync? It takes a bit of care to remember to use ensure instead of
 deref in a dosync.
I agree, and since I couldn't think of an example where the current
behavior is desirable, it seems like unnecessary mental overhead.  I
don't think having the semantics of deref change depending on whether
it's used inside a transaction is the way to go (especially since a
key part of its contract is that it will never block writers,
commuters, or other readers).  Maybe @ should expand to ensure rather
than deref inside a transaction, instead?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: trouble running clojure.test

2009-09-23 Thread Stuart Sierra

On Sep 23, 2:51 am, MarkSwanson mark.swanson...@gmail.com wrote:
 I'm having trouble unit testing clojure code. To be sure I'm just
 testing clojure.test, I'm trying to test clojure.contrib.json.read.

 I'm sure I've missed it. test.clj contains defmethod report ... that
 has the FAIL println in it. I do not know why it is not getting
 called.


Hi Mark,

I think Timothy is right; something in your setup is hiding standard
output.  Here's what should happen:

user (use 'clojure.test)
nil
user (require 'clojure.contrib.json.read)
nil
user (run-tests 'clojure.contrib.json.read)

Testing clojure.contrib.json.read

Ran 17 tests containing 27 assertions.
0 failures, 0 errors.
nil
user

If you want a report of passing tests; you can run with the TAP output
adapter in clojure.test.tap.

-SS
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: New Release for Enclojure plugin - 2009-09-22

2009-09-23 Thread Eric Thorsen

I updated the plugin on the Netbeans plugin portal and have submitted
it for verification.  I believe once it has passed verification it
will show up in the catalog.

Thanks!
Eric

On Sep 22, 9:21 pm, Wilson MacGyver wmacgy...@gmail.com wrote:
 any chance the enclojure plugin can be made available to download
 from the NetBeans repo? It would mean much easier for netbeans
 users to find and install it by simply bringing up the plugin menu
 from within NetBeans.

 Just a thought.





 On Tue, Sep 22, 2009 at 8:53 PM, Eric Thorsen ethor...@enclojure.org wrote:

  New release of the Enclojure plugin for Netbeans has been released!
  I have moved Enclojure to github and greatly simplified the build
  process.  See readme in the root directory of the repo for more
  details.
 http://github.com/EricThorsen/enclojure

  You can download the release at:
 http://github.com/EricThorsen/enclojure/downloads

  This release was primarily focused on bug fixes particularly on Ubuntu
  and Windows with a few enhancements to completion.

  Thanks again to everyone who has provided guidance and feedback!
  Eric

  git log
  === 
  =
  3 hours ago,  Added a testing file for completion-task
  4 hours ago,  Fixed a completion bug where the context was getting
  confused in some cases causing no symbols to be suggested at all.
  5 hours ago,  Fixed a completion bug when there was no context.
  28 hours ago,  Added an interface for REPL history to de-couple the
  repl-history from the specific IDE. Moved the generic prefs utilities
  into the ide project out of the Netbeans specific stuff.
  31 hours ago,  Moved enclojure preferences under the .netbeans dir
  31 hours ago,  Moved enclojure preferences under the .netbeans dir
  32 hours ago,  Fixed bugs on project creation and new source file
  support on Windows
  33 hours ago,  Fixed a let bug...
  2 days ago,  Changed the default home dir to use the netbeans dir.
  4 days ago,  Fixed a nasty bug in the form parser when there was an
  unreadble form in a source file.
  5 days ago,  Added docs to the completion
  5 days ago,  nothing changed?
  5 days ago,  Took out a temporary log statement in the launcher.
  6 days ago,  Added support for inter-project dependancies for the
  REPL.
  6 days ago,  Fixed several timing issues with the configuration
  settings and starting/stopping various REPLs.
  6 days ago,  Fixed the problem related to the *1,*,2*3,*e vars not
  being bound when pretty printing was enabled.
  7 days ago,  Working towards fixing the *1,*2,*3 binding issue when
  pretty printing is enabled.
  7 days ago,  Merge branch 'bugfix'
  7 days ago,  Merge branch 'master' of g...@github.com:EricThorsen/
  enclojure
  7 days ago,  Added a readme for building enclojure.
  7 days ago,  Added the new clojure platform to the layer.xml file.
  8 days ago,  Added the later clojure and clojure-contrib libs to the
  deps.zip and modified the build to use deps.zip
  11 days ago,  Continuing to work on added the embedded platform to
  automatically show up in the platform definitions.
  11 days ago,  Upgraded to the latest version of clojure (9/11/2009)
  Changed the logging strings to use the more efficient slf4j argument
  passing.
  2 weeks ago,  Cleaned up the new logging file.
  2 weeks ago,  Added log statement to troubleshoot intermitent platform
  config problems on Ubuntu.
  2 weeks ago,  Made some changes to fix build on Ubuntu.  I still have
  to get rid of the jdi explicit code if I can to make this build work
  on the mac as well. Working on a bug for goto-definition on Ubuntu was
  causing an exception.
  2 weeks ago,  Updated build to look at new deps.zip.
  2 weeks ago,  Added netbeans project to make development easier.
  Note: these are not required for the non-netbeans specific lib.
  Everything can be build with ant using free-form projects with another
  IDE or from the commaon line.
  2 weeks ago,  added the ivy-cache dir to gitignore. Updated some docs
  in the c_slf4j
  2 weeks ago,  Finished moving all log statements to c-slfj4.  The
  default jar maps to the java.util.logging. Fixed a bug related to the
  new project repl support for free form java projects.
  2 weeks ago,  First pass at cleaning up the used code on the commons
  project and more importantly, moving to the slf4j for logging.
  3 weeks ago,  Merge branch 'separate-repl'
  3 weeks ago,  See previous comment
  3 weeks ago,  Enabled project REPLs on free form java projects (Closes
  #6) Added classpath support functions into the repl-client module.
  Added the clojure facade on slf4j lib in commons (Refs #2)
  3 weeks ago,  updated project zip
  3 weeks ago,  Fixed a boundary bug in the insert text on completion
  for Ubuntu.
  3 weeks ago,  Fixed a bug in the Connect External repl dialog. Added a
  test script for the repl-server.
  3 weeks ago,  Fixed a bug that was causing an exception in some files
  during 

Re: Q: is there a better way to do this

2009-09-23 Thread Dave Jack

On Sep 23, 9:23 am, Dave Jack dav...@gmail.com wrote:
 Maybe @ should expand to ensure rather
 than deref inside a transaction, instead?

Should've thought about this more.  How is the reader supposed to know
that this code is called in a transaction?  And it would leak if you
deref'd inside a function called as part of the transaction (as the
function could be called outside a transaction as well).  You'd have
to modify deref, or expand to something else if you leave deref the
same.  Amazing what a cup of coffee does, eh?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Q: is there a better way to do this

2009-09-23 Thread Christophe Grand
On Wed, Sep 23, 2009 at 7:14 AM, Timothy Pratley
timothyprat...@gmail.comwrote:

 When it useful to be able to deref inside a dosync without ensuring?



In a read-only transaction.



 Ensure seems like a more safe default of what I'd expect from a
 transaction. So why not make deref automatically ensure within a
 dosync? It takes a bit of care to remember to use ensure instead of
 deref in a dosync.


You only need to ensure if you don't use alter or ref-set later.

The typical use case for ensure is:
(when (a-predicate? (ensure foo)) (alter bar f arg1 arg2))

Christophe

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Please apply build patch

2009-09-23 Thread Howard Lewis Ship
I submitted this simple patch about a month ago:
https://www.assembla.com/spaces/clojure-contrib/tickets/22-clojure-contrib-str-utils2-is-not-AOT-compiled

As it turns out, this patch is more important than I first thought ... other
necessary classes are not being AOT compiled as well.  Currently, I can't
use the Eclipse Clojure plugin against the development versions because of
this ticket. (class clojure.contrib.repl_ln is missing, not AOT compiled).

The ticket has a patch, it will take a few minutes to apply it.

-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to learn
how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Q: is there a better way to do this

2009-09-23 Thread Rich Hickey

On Wed, Sep 23, 2009 at 10:17 AM, Christophe Grand
christo...@cgrand.net wrote:


 On Wed, Sep 23, 2009 at 7:14 AM, Timothy Pratley timothyprat...@gmail.com
 wrote:

 When it useful to be able to deref inside a dosync without ensuring?


 In a read-only transaction.



 Ensure seems like a more safe default of what I'd expect from a
 transaction. So why not make deref automatically ensure within a
 dosync? It takes a bit of care to remember to use ensure instead of
 deref in a dosync.

 You only need to ensure if you don't use alter or ref-set later.

 The typical use case for ensure is:
 (when (a-predicate? (ensure foo)) (alter bar f arg1 arg2))


And even then, ensure is often not needed and overkill. Make sure you
have a real business requirement that the predicate remain true (or
value fixed) on transaction completion. We need to move to a world in
which we accept fewer guarantees of lockdown rather than more if we
want to get more concurrency. ensure pulls things into your
transaction footprint that plain reads would not. For instance, giving
a salesperson a bonus equal to 10% of their year-to-date sales need
not lock down their sales - it's merely a calculation done at a point
in time, while allowing sales to proceed.

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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Getting REPL transcript

2009-09-23 Thread Emeka
Hello All,

I would like to have a transcript of Repl. Could someone help me out here?

Regards,
Emeka

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: trouble running clojure.test

2009-09-23 Thread MarkSwanson

Environment: vimclojure-2.1.2. clojure from git as of a few days ago.

Running the tests in a plain REPL from the command line worked
perfectly!
-=* THANKS GUYS !!! *=-

I wasn't expecting this at all. I thought the REPL in vimclojure
actually supported stdout because this works:
 (def a abc)
#'user/a
 a
abc
 (println a)
abc
nil

I have noticed that mouse paste operations into the vimclojure repl
fail (the pasted text is truncated after a certain number of
characters).
These seem to be indications that stdin/stdout is not handled
perfectly by vimclojure...

Cheers.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Getting REPL transcript

2009-09-23 Thread Phil Hagelberg

Emeka emekami...@gmail.com writes:

 I would like to have a transcript of Repl. Could someone help me out here?

Sure; run it in GNU Screen with logging turned on.

  $ screen -l
  $ rlwrap java -cp clojure.jar clojure.main
  = (do some stuff)

It will get written to screenlog.0.

-Phil

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Getting REPL transcript

2009-09-23 Thread Michael Wood

2009/9/23 Phil Hagelberg p...@hagelb.org:

 Emeka emekami...@gmail.com writes:

 I would like to have a transcript of Repl. Could someone help me out here?

 Sure; run it in GNU Screen with logging turned on.

  $ screen -l
  $ rlwrap java -cp clojure.jar clojure.main
  = (do some stuff)

 It will get written to screenlog.0.

Or use script.

I'm sure there was a thread about this a few months ago.  There might
be some more useful suggestions if you manage to find it in the
archives.

-- 
Michael Wood esiot...@gmail.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Getting REPL transcript

2009-09-23 Thread Emeka
Mic,

Or use script . I don't think I understood clearly what you are referring
to.

Regards,
Emeka

On Wed, Sep 23, 2009 at 4:40 PM, Michael Wood esiot...@gmail.com wrote:


 2009/9/23 Phil Hagelberg p...@hagelb.org:
 
  Emeka emekami...@gmail.com writes:
 
  I would like to have a transcript of Repl. Could someone help me out
 here?
 
  Sure; run it in GNU Screen with logging turned on.
 
   $ screen -l
   $ rlwrap java -cp clojure.jar clojure.main
   = (do some stuff)
 
  It will get written to screenlog.0.

 Or use script.

 I'm sure there was a thread about this a few months ago.  There might
 be some more useful suggestions if you manage to find it in the
 archives.

 --
 Michael Wood esiot...@gmail.com

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Getting REPL transcript

2009-09-23 Thread Fogus

If you're running it with JLine, then the transcript is usually stored
in ~/.jline-clojure.lang.Repl.history


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Q: is there a better way to do this

2009-09-23 Thread Roger Gilliar

 And even then, ensure is often not needed and overkill. Make sure you
 have a real business requirement that the predicate remain true (or
 value fixed) on transaction completion. We need to move to a world in
--
It seems that my problem falls exactly in this category. Ensuring  
*consuming* prohibits that the consumer misses messages added to  
*data* . At least I hope that it does.

(def *data* (ref ()))
(def *consuming* (ref false))
(def *is-syncing* (ref true))
(def *consumer-agent* (agent '()))

(defn data-producer [value]
(if @*is-syncing*
(if (dosync
(if (ensure *consuming*)
  true
(do
(alter *data* conj value)
false)))
(do
(loop []
(Thread/sleep 100)
(if @*is-syncing*
(recur)))   


(defn producer []
(doseq [i (range 1)]
(data-producer i)))

(defn consume [agent]
(Thread/sleep 150)
(dosync
(ref-set *consuming* true))
(println Consuming started,  (count @*data*)  items to consume.)
(Thread/sleep 250)
(dosync
(ref-set *consuming* false)
(ref-set *is-syncing* false)))

(defn consumer []
(send-off *consumer-agent* consume))

(doseq [i (range 300)]
(future-call producer))

(consumer)

(shutdown-agents)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: where is the contrib?

2009-09-23 Thread 冯越
It's great. Thanks a lot!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



test.clj / test/tap.clj error

2009-09-23 Thread MarkSwanson

Hello,

I'm trying to use tst/tap.clj but the tap output does not contain the
'not ok' line.
I think this is a bug in tap.clj. Here is the small test:

(ns tc
  (:use [clojure.test]))

(deftest addition
 (is (= 4 (+ 2 2)))
 (is (= 8 (+ 3 4

(use 'clojure.test)
(use 'clojure.test.tap)
(require 'tc)
(with-tap-output
  (run-tests 'tc))

# {:type :begin-test-ns, :ns #Namespace tc}
# {:type :begin-test-var, :var #'tc/addition}
ok (addition) (tc.clj:30)
# expected:(= 4 (+ 2 2))
#   actual:(#core$_EQ___4341 clojure.core$_eq___4...@59556d12 4 4)
# {:actual (not (= 8 7)), :type :fail, :message nil, :expected (= 8 (+
3 4))}
# {:type :end-test-var, :var #'tc/addition}
# {:type :end-test-ns, :ns #Namespace tc}
1..1

test.clj seems to be working fine:
Testing tc

FAIL in (addition) (tc.clj:31)
expected: (= 8 (+ 3 4))
  actual: (not (= 8 7))

Ran 1 tests containing 2 assertions.
1 failures, 0 errors.

Unless I'm missing something to tell tap to generate 'not ok' lines?

Cheers.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: trouble running clojure.test

2009-09-23 Thread John Harrop
On Wed, Sep 23, 2009 at 12:29 PM, MarkSwanson mark.swanson...@gmail.comwrote:

 Environment: vimclojure-2.1.2. clojure from git as of a few days ago.

 Running the tests in a plain REPL from the command line worked
 perfectly!
 -=* THANKS GUYS !!! *=-

 I wasn't expecting this at all. I thought the REPL in vimclojure
 actually supported stdout because this works:
  (def a abc)
 #'user/a
  a
 abc
  (println a)
 abc
 nil

 I have noticed that mouse paste operations into the vimclojure repl
 fail (the pasted text is truncated after a certain number of
 characters).
 These seem to be indications that stdin/stdout is not handled
 perfectly by vimclojure...


I'm not surprised. In fact I am surprised that mouse paste operations work
at all in an editor that legacy. I've noticed that us NetBeans users have an
environment that just works, including mousing and pasting into the REPL as
well as stdout displaying correctly, while a quarter of the list traffic
here deals with problems configuring either emacs or vim, or quirky
post-configuration behavior from same. :)

Modern IDEs for the win?

But assuming you'd rather not change environments, I'd suggest not using
whatever crummy mouse and clipboard support has been retrofitted onto vim
and instead use your terminal emulator's paste that will present the pasted
text to vim as if it were being typed into vim. That should work however
long the pasted text is, unless the terminal emulator paste is equally
broken, which if it's xterm it shouldn't be, and otherwise you should
probably use xterm. :)

(No flames please. The above is offered as observations and a possible
workaround in the spirit of suggesting possible fixes so the O.P. can get on
with actually developing whatever they're developing with a minimum of fuss
and distractions.)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Getting REPL transcript

2009-09-23 Thread John Harrop
On Wed, Sep 23, 2009 at 1:05 PM, Fogus mefo...@gmail.com wrote:

 If you're running it with JLine, then the transcript is usually stored
 in ~/.jline-clojure.lang.Repl.history


Actually, that suggests a more general point: that we can have programmatic
access to the REPL's backlog if we modify the REPL process's Java code
somewhat. A simple example would be to make a repl.class that would provide
an interactive stdin/stdout repl but log everything to a ./repl.log file or
whatever. This could be used to obtain a text file with the interaction
history afterward, to massage, cut and paste from, etc. to one's heart's
content in a text editor. Even on MS-DOS, if anyone still uses such a
dinosaur. :)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Architecting a large multi-threaded process

2009-09-23 Thread Brian Hurt
So, I'm working on a medium-largish server application in Clojure (medium
amounts of code- currently 10KLOC and growing quickly, two people working
on it now and hopefully more in the future.  This isn't brag-worthy size,
but it's large enough to start causing problems).  Specifically, there will
be a lot of asynchronous compute-heavy jobs being spawned off, and other
jobs that want to start when some set of other jobs all complete.  Obviously
starting a new thread for every job is way to expensive, not to mention the
fact that trying to schedule 10K threads causes many OS's schedulers to fall
down and go boom.  What I want is some way to schedule tasks to be executed
by some set of worker threads, and then be able to control the number of
worker threads on a server.  What I'm interested in is other people's
opinions on how I should architect this app.

The first idea is to just use agents- every job has an agent associated with
it, and a little infrastructure code and I'm done.  This has the advantage
of being very idiomatic for clojure, but there is no way, to my knowledge,
to control how many worker threads are executing agents at any given time-
please correct me if I'm wrong.

The second possibility is to use the java.util.concurrent package, and build
something out of Futures and Executors etc.  This has the advantage of being
closer to the semantics I want, including giving me control on the number of
worker threads, but it's Java code and thus less idiomatic.  Here I'd be
worried about someone in the future using agents, if not directly then via
some careless use of a library.  I really hate trying to disallow the use
of an idiomatic feature of a language, as it rarely works.

Other possibilities include bringing in the Jakarata Commons or Apache
Commons or some other third-party library.

So that's my question: what are people's opinions?  Which of these options
(or other options I haven't noticed yet) is going be least pain/best
performance?  By all means, please pontificate.  Thanks.

Brian

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



question regarding agents

2009-09-23 Thread Roger Gilliar

I have the following code:

(defn handle-client [in out]
(binding [
*in* (reader in)
]
(with-connection db
(let [outstream (agent (writer out))]
(loop []
(let [xml (read-input)]
(if xml
(do
(send-answers 
(parse outstream (makestr xml)))
(recur))
(info 
disconnected


The problem is, that it doesn't work to assign an agent to the  
outstream. If I do, the content of the agent (the outstream in this  
case) is set to nil after it is passed to send-answers and all send- 
answers does is to store the agent in a struct.  Why that ? I

Regards
   Roger

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Architecting a large multi-threaded process

2009-09-23 Thread pmf

You might want to look into the stuff from JSR166 (scheduled for Java
7, but already available as a library for Java 6), which has advanced,
built-in workload-balancing which is vastly easier than trying to do
this with the raw, naive j.u.c.Executors-package (and Clojure's
agents, which are backed by j.u.c).

Clojure-core even supports this library via the clojure.parallel
namespace. I remember reading something about the status of support
for this, but I don't recall exactly what it was.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Architecting a large multi-threaded process

2009-09-23 Thread Roger Gilliar
 What I want is some way to schedule tasks to be executed by some set  
 of worker threads, and then be able to control the number of worker  
 threads on a server.  What I'm interested in is other people's  
 opinions on how I should architect this app.

This is exactly what we (a colleague and me) did with a large  C++ app  
and it works perfectly

One of the advantages I see in clojure  is the built-in support for  
concurrency. If I would feel that this support would not be suitable  
for the given task I would definitely choose Java with the  
java.util.concurrent package.

Regards
   Roger



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: question regarding agents

2009-09-23 Thread John Harrop
On Wed, Sep 23, 2009 at 4:18 PM, Roger Gilliar ro...@gilliar.de wrote:

 I have the following code:

 (defn handle-client [in out]
(binding [
*in* (reader in)
]
(with-connection db
(let [outstream (agent (writer out))]
(loop []
(let [xml (read-input)]
(if xml
(do

  (send-answers (parse outstream (makestr xml)))
(recur))
(info
 disconnected


 The problem is, that it doesn't work to assign an agent to the
 outstream. If I do, the content of the agent (the outstream in this
 case) is set to nil after it is passed to send-answers and all send-
 answers does is to store the agent in a struct.  Why that ?


Wrapping a mutable thing like an output stream in an agent seems dubious to
me.

Then you don't dereference it -- you pass the agent itself to parse as its
first argument, rather than the stream it wraps. That might not have been
what you intended.

Try just dropping the (agent ...) around (writer out).

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Q: is there a better way to do this

2009-09-23 Thread Timothy Pratley

Ok so there are two use cases:
1) testing constraint
2) referencing a snapshot

And two operations
A) @
B) ensure

1A is incorrect
1B is correct
2A is correct and concurrent
2B is correct but not concurrent

More concurrency is the default. This increases the chance of
incorrectness due to programmer error, as the tradeoff for lack of
concurrency due to programmer error. Can that be changed? If there
were no default the programmer would explicitly make a choice, so how
could we achieve that:

(let [s @sales]
  (dosync (ref-set bonus (/ (year-to-date s) 10
; overly tedious syntax, not really an option for more complex cases

; snap or ensure, deref not allowed
(dosync (ref-set bonus (/ (year-to-date (snap sales)
; breaks for functions (foo) returns @sales, should not care if in a
transaction or not.
; its up to the transaction level to decide (oh no this bodes poorly
for my quest)

; compiler checks for deref tests
LEGAL: (dosync (ref-set bonus (/ (year-to-date @sales
ILLEGAL: (dosync (ref-set bonus (if @constraint x y)))
; still breaks for function calls (if (foo) x y)  where foo returns
@constraint

; What if we made @ mean ensure and used snap instead of @?
; Same issues - doesn't work for function calls

So I can't see there being a more explicit way to choose between (1)
and (2) than what already exists [relying on the programmer to realise
when ensure is required]. I only just found out about write skew and
it worried me that I could be so wrong with my assumptions of what a
transaction means. That was a gap in understanding on my part. I do
think its an easy trap to fall into - but I can't see any way to
signpost it better.





On Sep 24, 1:45 am, Rich Hickey richhic...@gmail.com wrote:
 On Wed, Sep 23, 2009 at 10:17 AM, Christophe Grand



 christo...@cgrand.net wrote:

  On Wed, Sep 23, 2009 at 7:14 AM, Timothy Pratley timothyprat...@gmail.com
  wrote:

  When it useful to be able to deref inside a dosync without ensuring?

  In a read-only transaction.

  Ensure seems like a more safe default of what I'd expect from a
  transaction. So why not make deref automatically ensure within a
  dosync? It takes a bit of care to remember to use ensure instead of
  deref in a dosync.

  You only need to ensure if you don't use alter or ref-set later.

  The typical use case for ensure is:
  (when (a-predicate? (ensure foo)) (alter bar f arg1 arg2))

 And even then, ensure is often not needed and overkill. Make sure you
 have a real business requirement that the predicate remain true (or
 value fixed) on transaction completion. We need to move to a world in
 which we accept fewer guarantees of lockdown rather than more if we
 want to get more concurrency. ensure pulls things into your
 transaction footprint that plain reads would not. For instance, giving
 a salesperson a bonus equal to 10% of their year-to-date sales need
 not lock down their sales - it's merely a calculation done at a point
 in time, while allowing sales to proceed.

 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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Bug in count for hash-maps with nil values

2009-09-23 Thread Jason Wolfe

On the most recent git revision of Clojure (branch master, commit
64323d8c6ad4962ac780d4d904b69a891ab312f8),

user= (count {1 nil 2 nil 3 nil 4 nil 5 nil 6 nil 7 nil 8 nil})
8
user= (count {1 nil 2 nil 3 nil 4 nil 5 nil 6 nil 7 nil 8 nil 9 nil})
0
user= (count {1 nil 2 nil 3 nil 4 nil 5 nil 6 nil 7 nil 8 nil 9
true})
1


The bug seems to have appeared way back here:

commit eedcf35479737ab1136e3b8a00b2759190a73fdb
Author: Christophe Grand christo...@cgrand.net
Date:   Mon Aug 10 20:08:07 2009 +0200
Replaced PersistentHashMap by PersistentHashMap2
Signed-off-by: Rich Hickey richhic...@gmail.com

This works as expected in the previous commit:

commit 7b5d49396c5925f9fc9bd587760df6d9f19da5e1
Author: Christophe Grand christo...@cgrand.net
Date:   Mon Aug 10 20:04:20 2009 +0200
shrink when children count = 8
Signed-off-by: Rich Hickey richhic...@gmail.com

Can anyone else confirm?

Thanks,
Jason



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Getting REPL transcript

2009-09-23 Thread songoku

 Vimclojure and emacs (on any operating system) will have at least the
 ability to copy from the REPL's history and paste elsewhere in the editor,
 but maybe not any nice way to export it to something else, like the mail
 client used to post to this list.
With emacs you can simply safe the buffer of the repl.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Catching from Eval

2009-09-23 Thread John Harrop
On Wed, Sep 23, 2009 at 6:42 PM, Phil Hagelberg p...@hagelb.org wrote:

 What's going on here?


The exception is being transformed. Eval and just about anything using
closures -- just about any delayed evaluation, in other words -- wraps
exceptions in RuntimeException for some reason. Even if they already were
RuntimeExceptions (and InterruptedException isn't).

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: clojure-test-mode overlays

2009-09-23 Thread Phil Hagelberg

Rick Moynihan rick.moyni...@gmail.com writes:

 Ahh, great!  I have it working now... I was using clojure.test with
 clojure 1.0 rather than test-is from contrib.  My understanding was
 that clojure.contrib.test-is was deprecated when test-is moved from
 contrib into core.

 Does anyone know if this is the case?

That's right. I think test-is was replaced by a stub that just wraps
clojure.test though.

 Anyway, I've switched to test-is for now and the overlays work beautifully!

Great!

I've updated clojure-test-mode to work with clojure.test and the 1.1
snapshot, though I haven't submitted it to ELPA yet. If you still use
clojure 1.0 and test-is, you can use the previous version.

http://github.com/technomancy/clojure-mode

-Phil

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---