Re: Naming Conventions for Functions that Modify State

2009-02-14 Thread Michael Wood

On Fri, Feb 13, 2009 at 3:07 AM, Jeffrey Straszheim
straszheimjeff...@gmail.com wrote:
 Well, there is the IO! macro to wrap side effects.  This works with the
 transactions mechanism.

Yes, see also (find-doc !).

 So foo! does show up, but is not followed rigorously.

There is also do- (doall, dorun, doseq, dotimes, etc.)

 On Thu, Feb 12, 2009 at 7:57 PM, Kevin Albrecht onlya...@gmail.com wrote:

 If no one knows of any existing conventions, does anyone have ideas
 for conventions?

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



Trojan horse in our Files section

2009-02-14 Thread Frantisek Sodomka

My antivirus doesn't like the Gift from the Stranger:
http://groups.google.com/group/clojure/files?sort=date

Not really nice of you, Stranger...

Frantisek

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A Clojure documentation browser

2009-02-14 Thread Craig Andera

 Github is fine. Once I see your name on clojure.org/contributing, I'll
 commit this to clojure.contrib. For changes going forward, once you're happy
 with some update on github, just let me know and I'll pull it into contrib.
 For bug reporting, I recommend you add a section to the comments at the top
 of the file letting folks know how you'd like to be contacted for that. If I
 see a question or issue raised and it looks like you're not aware, I'll also
 give you a heads up.

OK, sounds good. My email address is already in the file, so we should
be all set.

 I just did a run and I like the new output!

Glad to hear it. :)

We talked about getting doc generation to be part of the build, which
I think is a fine idea. Whose task is that?

--~--~-~--~~~---~--~~
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: Trojan horse in our Files section

2009-02-14 Thread Jeffrey Straszheim
Lovely.  Thanks for the warning.

On Sat, Feb 14, 2009 at 6:49 AM, Frantisek Sodomka fsodo...@gmail.comwrote:


 My antivirus doesn't like the Gift from the Stranger:
 http://groups.google.com/group/clojure/files?sort=date

 Not really nice of you, Stranger...

 Frantisek

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A Clojure documentation browser

2009-02-14 Thread Stephen C. Gilardi


On Feb 14, 2009, at 7:13 AM, Craig Andera wrote:


Glad to hear it. :)

We talked about getting doc generation to be part of the build, which
I think is a fine idea. Whose task is that?


clojure-contrib/build.xml is where the change I talked about would go.  
If you're up for giving it a try, that'd be great. I plan to look at  
it this weekend unless someone beats me to it.


--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: Trojan horse in our Files section

2009-02-14 Thread Rich Hickey



On Feb 14, 8:56 am, Jeffrey Straszheim straszheimjeff...@gmail.com
wrote:
 Lovely.  Thanks for the warning.

 On Sat, Feb 14, 2009 at 6:49 AM, Frantisek Sodomka fsodo...@gmail.comwrote:



  My antivirus doesn't like the Gift from the Stranger:
 http://groups.google.com/group/clojure/files?sort=date

  Not really nice of you, Stranger...


Gone now.

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



Concurrency and file writing

2009-02-14 Thread James Reeves

Hi folks,

I've been having some difficulty coming up with a scheme for writing
to files in a thread-safe manner. The files are named with the hash of
their content, so they are effectively immutable.

The problem comes with writing them for the first time. I need to
ensure that while a file is initially being written, no other thread
attempts to read or write to the file.

The best solution I've come up with so far is to write to a temporary
file, then rename the file to its hash once it has been closed. This
seems to work, but I'd be very interested to know how other people
have handled similar concurrent I/O problems in Clojure.

- James
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
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: Newbie at macros: Manipulating a vector of bindings

2009-02-14 Thread samppi

Thank you so much. I'm confused, however, about what functions you're
allowed to call inside a macro outside of a quote. I read once that
runtime information was unavailable during the macro phase. But it
seems that one is still allowed to call array-map, apply, take-nth,
and vec during the macro phase. What is the pattern for what is
allowed or prohibited in macros?

On Feb 13, 10:52 pm, Chouser chou...@gmail.com wrote:
 On Fri, Feb 13, 2009 at 11:17 PM, samppi rbysam...@gmail.com wrote:

  I'm trying to write a macro that expands from this:

  (product-context [n rule0, m rule1)]
   (rule-maker2 (+ n m)) rule3))

  Into this (assume that conc-fn and conc-products are functions):

  (fn [tokens]
   (if-let [[remainder# n m] (conc-products [rule0 rule1] tokens)]
     (conc-fn [(rule-maker2 (+ n m)) rule3] remainder#)))
  ...but I can't figure out how to change [n rule0 m rule1] to (if-let
  [[remainder# n m] (conc-products [rule0 rule1] tokens)] ...).

 Try working it out outside of the macro context.

 (def bindvec '[n rule0, m rule1])

 Now you've got something to work with.  There are plenty of acceptible
 answers.  Maybe you want to think of the vector as key/value pairs:

 (apply array-map bindvec)  == {n rule0, m rule1}
 (keys (apply array-map bindvec))  == (n m)
 (vals (apply array-map bindvec))  == (rule0 rule1)

 Or just use some seq function:

 (take-nth 2 bindvec)  == (n m)
 (take-nth 2 (rest bindvec))  == (rule0 rule1)

 Once you've got the pieces you need, try sticking them into a
 syntax-quote:

 user= `(if-let [[r# ~(take-nth 2 bindvec)] (cp ~(take-nth 2 (rest
 bindvec)))] ...)
 (clojure.core/if-let [[r__215__auto__ (n m)] (user/cp (rule0 rule1))] ...)

 Well, that's close by there are extra parens around (n m) and you want
 a vector not a list for the rules.  So play with it until it looks
 right:

 user= `(if-let [[r# ~@(take-nth 2 bindvec)] (cp ~(vec (take-nth 2
 (rest bindvec] ...)
 (clojure.core/if-let [[r__219__auto__ n m] (user/cp [rule0 rule1])] ...)

 Then you're ready to build the macro:

 (defmacro product-context [bindvec  body]
   `(fn [tokens#]
      (if-let [[remainder# ~@(take-nth 2 bindvec)]
                 (conc-products [~@(take-nth 2 (rest bindvec))] tokens#)]
        (conc-fn [...@body] remainder#

 --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: Newbie at macros: Manipulating a vector of bindings

2009-02-14 Thread David Nolen
You can pretty much call anything outside of the quote, in fact all runtime
information is available (you have access to anything that was previously
read).  The main thing to understand is that all parameters passed to your
macro are unevaluated.

On Sat, Feb 14, 2009 at 10:45 AM, samppi rbysam...@gmail.com wrote:


 Thank you so much. I'm confused, however, about what functions you're
 allowed to call inside a macro outside of a quote. I read once that
 runtime information was unavailable during the macro phase. But it
 seems that one is still allowed to call array-map, apply, take-nth,
 and vec during the macro phase. What is the pattern for what is
 allowed or prohibited in macros?

 On Feb 13, 10:52 pm, Chouser chou...@gmail.com wrote:
  On Fri, Feb 13, 2009 at 11:17 PM, samppi rbysam...@gmail.com wrote:
 
   I'm trying to write a macro that expands from this:
 
   (product-context [n rule0, m rule1)]
(rule-maker2 (+ n m)) rule3))
 
   Into this (assume that conc-fn and conc-products are functions):
 
   (fn [tokens]
(if-let [[remainder# n m] (conc-products [rule0 rule1] tokens)]
  (conc-fn [(rule-maker2 (+ n m)) rule3] remainder#)))
   ...but I can't figure out how to change [n rule0 m rule1] to (if-let
   [[remainder# n m] (conc-products [rule0 rule1] tokens)] ...).
 
  Try working it out outside of the macro context.
 
  (def bindvec '[n rule0, m rule1])
 
  Now you've got something to work with.  There are plenty of acceptible
  answers.  Maybe you want to think of the vector as key/value pairs:
 
  (apply array-map bindvec)  == {n rule0, m rule1}
  (keys (apply array-map bindvec))  == (n m)
  (vals (apply array-map bindvec))  == (rule0 rule1)
 
  Or just use some seq function:
 
  (take-nth 2 bindvec)  == (n m)
  (take-nth 2 (rest bindvec))  == (rule0 rule1)
 
  Once you've got the pieces you need, try sticking them into a
  syntax-quote:
 
  user= `(if-let [[r# ~(take-nth 2 bindvec)] (cp ~(take-nth 2 (rest
  bindvec)))] ...)
  (clojure.core/if-let [[r__215__auto__ (n m)] (user/cp (rule0 rule1))]
 ...)
 
  Well, that's close by there are extra parens around (n m) and you want
  a vector not a list for the rules.  So play with it until it looks
  right:
 
  user= `(if-let [[r# ~@(take-nth 2 bindvec)] (cp ~(vec (take-nth 2
  (rest bindvec] ...)
  (clojure.core/if-let [[r__219__auto__ n m] (user/cp [rule0 rule1])] ...)
 
  Then you're ready to build the macro:
 
  (defmacro product-context [bindvec  body]
`(fn [tokens#]
   (if-let [[remainder# ~@(take-nth 2 bindvec)]
  (conc-products [~@(take-nth 2 (rest bindvec))] tokens#)]
 (conc-fn [...@body] remainder#
 
  --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: Trojan horse in our Files section

2009-02-14 Thread bOR_


 Gone now.

 Rich

but was it written in clojure?

=).

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A pipe macro for left-to-right coll streams

2009-02-14 Thread Perry Trolard

Hi Timothy,

On Feb 12, 8:08 pm, Timothy Pratley timothyprat...@gmail.com wrote:

 What should happen when/if the seq arg doesn't contain the symbol? I
 believe how you currently handle it is correct and in the spirit of
 let- (alternatively it could be reported as an error) however it may
 raise yet another possibility for pipe:
 (pipe 5 inc (+ 2) (+ ? 3) (+ 4 ? 2))
 ie: if the argument is a seq and doesn't contain ? then it is assumed
 to be a post argument, but if it does contain ? then can be explicitly
 a pre or mid argument.

The problem that I see with scanning for the special symbol 
inserting it when not found is that it really requires a single symbol
as the binding. But I think it's good for let- to behave just like
let does -- no surprises -- which means arbitrary destructuring. So,
for example, if my binding is like

  (let- [[a :as all] coll]
 (if (pred? a) (map func1 all) (map func2 all))
 some-final-func)

what should happen if the last form was (map some-final-func) instead
of some-final-func? Which symbol should be inserted into the form?

One answer is that instead of a symbol being inserted, the value would
be (this is what happens when the form isn't a list, .e.g. (let- [a
string] .toUpperCase) = (.toUpperCase string)). But that brings
the question of *where* to put it -- second, or last? We'd have to
decide to follow - or pipe,  I don't know that one makes more sense
than the other.

I think it's most straightforward to require that one manually places
the symbol for all cases other than the non-list.

 Is it worth considering how (doto) fits into the picture? My initial
 observation is that (doto) is orthogonal in the sense that its primary
 use is for java object manipulation, and there is never a use case to
 have arguments in different places for that. So I suspect doto is
 irrelevant.

I agree -- doto assumes methods that mutate an object,  I think those
are always going to be of the form (.method object [args]).

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: Concurrency and file writing

2009-02-14 Thread Dan
On Sat, Feb 14, 2009 at 9:48 AM, James Reeves weavejes...@googlemail.comwrote:


 Hi folks,

 I've been having some difficulty coming up with a scheme for writing
 to files in a thread-safe manner. The files are named with the hash of
 their content, so they are effectively immutable.


What about making the file an agent and sending write actions to it?

--~--~-~--~~~---~--~~
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: More Swing Examples

2009-02-14 Thread Telman Yusupov

You need to download clojure-contrib library: 
http://code.google.com/p/clojure-contrib/

On Feb 14, 11:07 am, Sean francoisdev...@gmail.com wrote:
 Hi,
 I was trying to run this snake program, written by Mark Volkmann

 http://www.ociweb.com/mark/programming/ClojureSnake.html

 I'm getting the following error:

 Exception in thread main java.io.FileNotFoundException: Could not
 locate clojure/contrib/import_static__init.class or clojure/contrib/
 import_static.clj on classpath:  (snake.clj:0)
         at clojure.lang.Compiler.eval(Compiler.java:4193)
         at clojure.lang.Compiler.load(Compiler.java:4506)
         at clojure.lang.Compiler.loadFile(Compiler.java:4473)
         at clojure.main$load_script__5695.invoke(main.clj:206)
         at clojure.main$init_opt__5698.invoke(main.clj:211)
         at clojure.main$initialize__5708.invoke(main.clj:239)
         at clojure.main$null_opt__5730.invoke(main.clj:264)
         at clojure.main$legacy_script__5745.invoke(main.clj:295)
         at clojure.lang.Var.invoke(Var.java:340)
         at clojure.main.legacy_script(main.java:34)
         at clojure.lang.Script.main(Script.java:20)

 I built clojure from source (svn 1281).  Is there something I should
 have configured after building?

 Thanks.

 On Feb 13, 12:23 pm, Emeka emekami...@gmail.com wrote:

 http://clojure.googlegroups.com/web/2c-calculator.clj?gda=GfxNgEMAAAC...

 http://www.plt1.com/1070/even-smaller-snake/


--~--~-~--~~~---~--~~
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: cljc?

2009-02-14 Thread Meikel Brandmeyer

Hi,

Am 13.02.2009 um 23:02 schrieb Stephen C. Gilardi:

 the general case, a complete cljc program (in my opinion) would  
need to:


[1] create the dest dir if it doesn't already exist
[2] launch a clojure instance with that dest dir in classpath
[3] compile


I wrote a simple cljc as a bash script. It is based on Stephen's  
launcher.

It takes two optional parameters:

  -s path to source
  -d destination path for .class files

They default to src and classes. The destdir is created if it doesn't  
exist.
Though not a per file compiler, it may be useful too just compile a  
namespace

at the command-line.

Sincerely
Meikel



cljc
Description: Binary data




smime.p7s
Description: S/MIME cryptographic signature


Re: run clojure on 5,832 cores?

2009-02-14 Thread Christian Vest Hansen

On Sat, Feb 14, 2009 at 1:31 AM, Stuart Sierra
the.stuart.sie...@gmail.com wrote:

 On Feb 13, 6:13 pm, Christian Vest Hansen karmazi...@gmail.com
 wrote:
 I see no mention of a JVM being available for those CPUs, but perhaps
 the no-asm HotSpot can be build with gcc on it.

 Looks like they run Linux, so it would probably be possible.  This
 article http://www.networkworld.com/news/2009/020509-sicortex.html
 says they use slower, cheaper processors that work best when you're
 doing lots of small computations in parallel.

 The part I get excited about is the 8 TB of memory.  When can I get
 THAT on my desk?

You run into problems with the garbage collector when the heap gets
big: the bigger the heap, the longer it takes to compact. Azul has
hardware support for their garbage collector which allows their
compaction phase to run concurrently with the application, otherwise
there'd be no way they could make use of the 768 GB ram their kit can
scale to, unless striped across hundreds of JVMs. If you try to scale
a normal collector to those heap sizes, you will see your
stop-the-world collections jump from sub-second to minutes or even
hours.


 -Stuart Sierra
 




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



Circular Dependancy Question

2009-02-14 Thread Dan Larkin
So I've got a circular dependency problem.  There's a few ways to move  
functions and (require )s around but the problem remains -- these  
three files fundamentally depend on one another:

parser.clj - lexer  parser (using joshua choi's excellent fnparse  
library)
defaulttags.clj - multimethods for handing conditionals, looping,  
including other templates, etc.
template.clj - user facing code. Has functions to load templates  
from disk and helper functions for rendering templates.

And here's a dependency breakdown:

defaulttags.clj
   depends on template.clj for loading new templates from disk from an  
include template tag
   depends on parser.clj for parsing the templates it loads

template.clj
   depends on parser.clj for parsing/rendering templates it loads from  
disk
   also loads defaulttags.clj so the multimethods get registered


There's also another file, right now called foo.clj, which defines two  
functions (represent and invoke-templatetag) and has no dependencies,  
but is required by all 3 files.  I had to create the foo.clj file to  
get around an earlier circular dependency issue, and that works and  
there's no problem with it right now... just saying that's how  
parser.clj can call the tags registered in defaulttags.clj even though  
it doesn't import it.


So anyway, I guess that's a long-winded explanation of my current  
circular dependency problem. It'd be great if someone could suggest a  
remedy.

But as an aside, does this seem to anyone else like a wart on an  
otherwise great language? Thinking about file layout should not be one  
of my priorities... the language should not encourage me to put  
everything together in one file just to get it to work.  I should be  
able to separate functionality in a way that makes sense to the app  
I'm building.

Thanks for reading,
Dan
--~--~-~--~~~---~--~~
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: More Swing Examples

2009-02-14 Thread Sean

This worked for me.

I downloaded the svn and built it.  Once I added the jar to my
classpath, I was good to go.  I did this by modifying the clj script I
use.

Thanks!

On Feb 14, 12:37 pm, Telman Yusupov use...@yusupov.com wrote:
 You need to download clojure-contrib 
 library:http://code.google.com/p/clojure-contrib/

 On Feb 14, 11:07 am, Sean francoisdev...@gmail.com wrote:

  Hi,
  I was trying to run this snake program, written by Mark Volkmann

 http://www.ociweb.com/mark/programming/ClojureSnake.html

  I'm getting the following error:

  Exception in thread main java.io.FileNotFoundException: Could not
  locate clojure/contrib/import_static__init.class or clojure/contrib/
  import_static.clj on classpath:  (snake.clj:0)
          at clojure.lang.Compiler.eval(Compiler.java:4193)
          at clojure.lang.Compiler.load(Compiler.java:4506)
          at clojure.lang.Compiler.loadFile(Compiler.java:4473)
          at clojure.main$load_script__5695.invoke(main.clj:206)
          at clojure.main$init_opt__5698.invoke(main.clj:211)
          at clojure.main$initialize__5708.invoke(main.clj:239)
          at clojure.main$null_opt__5730.invoke(main.clj:264)
          at clojure.main$legacy_script__5745.invoke(main.clj:295)
          at clojure.lang.Var.invoke(Var.java:340)
          at clojure.main.legacy_script(main.java:34)
          at clojure.lang.Script.main(Script.java:20)

  I built clojure from source (svn 1281).  Is there something I should
  have configured after building?

  Thanks.

  On Feb 13, 12:23 pm, Emeka emekami...@gmail.com wrote:

  http://clojure.googlegroups.com/web/2c-calculator.clj?gda=GfxNgEMAAAC...

  http://www.plt1.com/1070/even-smaller-snake/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A Clojure documentation browser

2009-02-14 Thread Craig Andera

 clojure-contrib/build.xml is where the change I talked about would go. If
 you're up for giving it a try, that'd be great. I plan to look at it this
 weekend unless someone beats me to it.

If I did give it a shot, it likely wouldn't be until late next week,
so knock yourself 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
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: Circular Dependancy Question

2009-02-14 Thread Dan Larkin

On Feb 14, 2009, at 2:14 PM, Stephen C. Gilardi wrote:


 On Feb 14, 2009, at 1:40 PM, Dan Larkin wrote:

 But as an aside, does this seem to anyone else like a wart on an  
 otherwise great language? Thinking about file layout should not be  
 one of my priorities... the language should not encourage me to put  
 everything together in one file just to get it to work.  I should  
 be able to separate functionality in a way that makes sense to the  
 app I'm building.

 Within one namespace, we use declare to avoid this problem. Perhaps  
 declare could be extended (or another function created) to work with  
 namespace-qualified symbols that refer to namespaces and vars that  
 may not yet exist. I would imagine this would involve creating the  
 namespace and var within it if either didn't yet exist and pushing  
 the namespace name onto some deferred load queue so it's  
 guaranteed loaded by the time the top level load is complete.

 For this to be effective in our preferred way to declare  
 dependencies, it should be a new clause in within ns.

 Any thoughts?


What you describe is the first way I thought about it.  Some sort  
of :external-depends or something...

But thinking about it more, would it be possible to emulate the way  
python handles circular dependencies?  When a file is imported in  
python the interpreter evaluates top-level forms to create a list of  
exports. Of course the clojure reader has fundamental differences from  
the python reader, but couldn't clojure do something similar?  After  
all, (read (PushbackReader. (StringReader. (def a (foo 5) just  
returns a list, couldn't each (require )'d namespace be read, searched  
for exports and dependencies (which would have the same thing done to  
them) and then they could be evaluated? That way all the vars  
necessary for linking are present.

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



Specifying files with spaces in the name to clojure.contrib.command-line

2009-02-14 Thread Kevin Albrecht

This utility is very useful, but it seems unable to handle passing in
file names with spaces in them.

Example program:

;- begin args.clj
(ns args
  (:use clojure.contrib.command-line))

(with-command-line *command-line-args*
  args -- test of args
  [filenames]
  (doseq [filename filenames]
(prn filename)))
;-- end args.clj

I run the program like this:
 clj args.clj ~/src/no_spaces.txt ~/file with spaces.txt

And the results are this:

/Users/smith/src/no_spaces.txt
~/file
with
spaces.txt

When they should be this:

/Users/smith/src/no_spaces.txt
~/file with spaces.txt

--Kevin Albrecht

P.S. Also, unrelated to this problem, the following line in the
example code in command_line.clj is missing the vector surrounding the
bindings of the doseq:

  :else   (doseq filename filenames
--~--~-~--~~~---~--~~
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: Trojan horse in our Files section

2009-02-14 Thread Michael Wood

On Sat, Feb 14, 2009 at 5:58 PM, bOR_ boris.sch...@gmail.com wrote:


 Gone now.

 Rich

 but was it written in clojure?

 =).

Nope.  It was a rar file containing some text files (religious
propaganda) and a Windows .scr (i.e. I assume PE executable, but I
didn't check that.)

I can't work out if it's a strange way to promote a religion, or a
plot to discredit said religion. :)

If it had been written in Clojure it might have had some reason to be there :)

-- 
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
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: why fn key doesn't do what I want?

2009-02-14 Thread wubbie

thanks!
sun


On Feb 14, 4:34 pm, Brian Doyle brianpdo...@gmail.com wrote:
 On Sat, Feb 14, 2009 at 2:24 PM, wubbie sunj...@gmail.com wrote:

  Hi,

  a quick question:

  user= (keys {:a 1 :b 2})
  (:a :b)

  But
  user= (key {:a 1})
  java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot
  be cast to java.util.Map$Entry (NO_SOURCE_FILE:0)

  I see defn key in core.clj, though.
  What can be the correct usage of fn key, then?

 Here is the correct usage of fn key:

 1:1 user= (key (first {:a 1}))
 :a

 Key only accepts a map entry and not a Map object.

  thanks in advance,
  -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
-~--~~~~--~~--~--~---



why (seq? [1 2 3]) yields false?

2009-02-14 Thread wubbie

Hi,
Why vector is not a seq?

user= (seq? [1 2 3])
false
user= (seq? '(1 2 3))
true


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: why (seq? [1 2 3]) yields false?

2009-02-14 Thread Stephen C. Gilardi


On Feb 14, 2009, at 4:47 PM, wubbie wrote:


Hi,
Why vector is not a seq?

user= (seq? [1 2 3])
false
user= (seq? '(1 2 3))
true


Most sequence functions automatically arrange to call seq on their  
arguments, so it's easy to start thinking that Clojure collections  
*are* seqs. In the general case, they are not. They are, however, seq- 
able meaning that if you call seq on them you will get a seq: a view  
on their contents that implements the seq interface.


user= (seq? (seq [1 2 3]))
true
user= (seq? (seq '(1 2 3)))
true

List implements seq directly, so when you call seq on it, seq returns  
the list itself.
Vector does not implement seq directly (because that wouldn't be  
efficient), so when you call seq on it you get a new object.


user= (def l '(1 2 3))
#'user/l
user= (identical? l (seq l))
true
user= (def v [1 2 3])
#'user/v
user= (identical? v (seq v))
false

--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: why (seq? [1 2 3]) yields false?

2009-02-14 Thread Perry Trolard

wubbie,

In case you're asking because you're trying to test for collection-
like objects, there are (at least) two ways to do so:

1. coll? tests if its arg implements IPersistentCollection, i.e. is
one of the native Clojure persistent collections:

  user= (map coll? [{} [] '() #{}])
  (true true true true)

2. the (if (seq coll) ...) idiom (you'll see a lot of it in
clojure.core) tests if the coll arg is seq-able, i.e. can be viewed as
a seq as Steve says above. This test will match for more than just the
Clojure collections, e.g.

  user= (if (seq hello) true false)
  true
  user= (if (seq (into-array Character/TYPE [\a \b \c])) true false)
  true
  user= (if (seq (doto (java.util.HashMap.) (.put key val))) true
false)
  true

Since seq is lazy, simply calling seq realizes no elements from the
seq-able thing.

Note, however, that seq will throw an error if given a non-seq-able
item like an integer (this is because the (if (seq coll) ...) test
involves actually calling seq on the arg...). Which means that it's
only safe for contexts in which you know the arg will be seq-able or
empty.

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: Concurrency and file writing

2009-02-14 Thread James Reeves

On Feb 14, 5:30 pm, Dan redalas...@gmail.com wrote:
 What about making the file an agent and sending write actions to it?

I don't see how that would solve the problem, unless you're suggesting
that I have a single agent to handle all reads and writes?

- James
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
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: Concurrency and file writing

2009-02-14 Thread Laurent PETIT
Hello,

You could maybe solve the read problem by also embedding, in the name of the
file, its intended content size ?

So it could be reasonably cheap to check if a file is present but not yet
totally flushed to the disk by comparing its intended size (from its name)
and its current real size ?

For the write operation, one thing you should consider is using the
file.getFileDescriptor().sync() method, that will ensure that all the
content is flushed by the OS before the function responsible for writing to
the file returns to its caller but before calling sync(), you must also have
flushed any java buffer (e.g. calling flush() on the OutputStreams/Writers).

If the file is immutable, I don't understand why you could have concurrency
regarding the act of writing ?

HTH,

-- 
Laurent


2009/2/14 James Reeves weavejes...@googlemail.com


 Hi folks,

 I've been having some difficulty coming up with a scheme for writing
 to files in a thread-safe manner. The files are named with the hash of
 their content, so they are effectively immutable.

 The problem comes with writing them for the first time. I need to
 ensure that while a file is initially being written, no other thread
 attempts to read or write to the file.

 The best solution I've come up with so far is to write to a temporary
 file, then rename the file to its hash once it has been closed. This
 seems to work, but I'd be very interested to know how other people
 have handled similar concurrent I/O problems in Clojure.

 - James
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Clojure group.
To post to this group, send email to clojure@googlegroups.com
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: Bugs in set and sorted-set (?)

2009-02-14 Thread Frantisek Sodomka

Similar is:
user= #{[] ()}
#{[]}
user= #{[] [1 2]}
#{[] [1 2]}
user= (hash-set [] ())
#{[]}

Frantisek

On Feb 15, 12:38 am, Frantisek Sodomka fsodo...@gmail.com wrote:
 Hello!
 Function 'set' looses some of its data. It seems that there is a
 problem with comparison between lists and vectors:

 user= (count [nil false true 0 42 0.0 3.14 2/3 0M 1M \c  abc
 'sym :kw () '(1 2) [] [1 2] {} {:a 1 :b 2} #{} #{1 2}])
 23
 user= (set [nil false true 0 42 0.0 3.14 2/3 0M 1M \c  abc
 'sym :kw () '(1 2) [] [1 2] {} {:a 1 :b 2} #{} #{1 2}])
 #{nil 0 0.0 0M  {} #{} 2/3 () abc {:a 1, :b 2} (1 2) #{1 2} \c
 3.14 42 sym true :kw false 1M}
 user= (count (set [nil false true 0 42 0.0 3.14 2/3 0M 1M \c  abc
 'sym :kw () '(1 2) [] [1 2] {} {:a 1 :b 2} #{} #{1 2}]))
 21
 ; missing are [] and [1 2]

 user= (set [()])
 #{()}
 user= (set [() []])
 #{()}
 user= (set [() [] {}])
 #{{} ()}

 user= (set [[] [1 2]])
 #{[] [1 2]}
 user= (set [[] [1 2] 1])
 #{[] 1 [1 2]}
 user= (set [[] [1 2] ()])
 #{[] [1 2]}
 user= (set [() [] [1 2]])
 #{() [1 2]}

 What data types is sorted-set supposed to work on? When used with
 different data types, it errors out:http://clojure.org/data_structures

 user= (doc sorted-set)
 -
 clojure.core/sorted-set
 ([ keys])
   Returns a new sorted set with supplied keys.

 user= (sorted-set 4 2)
 #{2 4}
 user= (sorted-set () [])
 java.lang.ClassCastException: clojure.lang.PersistentList$EmptyList
 cannot be cast to clojure.lang.IPersistentVector (NO_SOURCE_FILE:0)
 user= (sorted-set nil false true 0 42 0.0 3.14 2/3 0M 1M \c  abc
 'sym :kw () '(1 2) [] [1 2] {} {:a 1 :b 2} #{} #{1 2})
 java.lang.ClassCastException: java.lang.Boolean cannot be cast to
 java.lang.Number (NO_SOURCE_FILE:0)
 user= (sorted-set '(1 2) 1)
 java.lang.ClassCastException: clojure.lang.PersistentList cannot be
 cast to java.lang.Number (NO_SOURCE_FILE:0)
 user= (sorted-set '(1 2) abc)
 java.lang.ClassCastException: clojure.lang.PersistentList cannot be
 cast to java.lang.String (NO_SOURCE_FILE:0)
 user= (sorted-set abc #{1 2})
 java.lang.ClassCastException: clojure.lang.PersistentHashSet cannot be
 cast to java.lang.Comparable
 (NO_SOURCE_FILE:0)
 user= (sorted-set 42 #{1 2})
 java.lang.ClassCastException: clojure.lang.PersistentHashSet cannot be
 cast to java.lang.Comparable
 (NO_SOURCE_FILE:0)

 It works when types are the same:
 user= (sorted-set z b)
 #{b z}
 user= (sorted-set 42 2.0)
 #{2.0 42}
 user= (sorted-set [2 3] [1])
 #{[1] [2 3]}

 Frantisek
--~--~-~--~~~---~--~~
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 executable Jars?

2009-02-14 Thread kkw

Hi Emeka,

Did you have success in this?

Kev

On Jan 29, 10:43 pm, Emeka emekami...@gmail.com wrote:
 luciofulci I'm interested in your instruction, however, are
 c:\user\apps\classes
 and c:\user\classes the same thing?

 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
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: run clojure on 5,832 cores?

2009-02-14 Thread Mark H.

On Feb 14, 10:00 am, Christian Vest Hansen karmazi...@gmail.com
wrote:
 You run into problems with the garbage collector when the heap gets
 big: the bigger the heap, the longer it takes to compact. Azul has
 hardware support for their garbage collector which allows their
 compaction phase to run concurrently with the application, otherwise
 there'd be no way they could make use of the 768 GB ram their kit can
 scale to, unless striped across hundreds of JVMs. If you try to scale
 a normal collector to those heap sizes, you will see your
 stop-the-world collections jump from sub-second to minutes or even
 hours.

*nods* It's not even clear that one would want to use memory as a
single shared blob for that many processors and that much memory.  I
would prefer a partitioned global address space like that used by
Titanium (http://titanium.cs.berkeley.edu/), UPC (http://
upc.lbl.gov/), or Global Arrays (http://www.emsl.pnl.gov/docs/
global/).  If you can distinguish between local and far-away
chunks of memory, it's easier to do garbage collection more
efficiently.

mfh
--~--~-~--~~~---~--~~
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: Specifying files with spaces in the name to clojure.contrib.command-line

2009-02-14 Thread Kevin Albrecht

Ah, this was the problem, thanks.

Michael Wood wrote:
 java -server -cp ${CLASSPATH} clojure.main ${script} $@

 The quotes are necessary around the $@, otherwise you will get the
 symptoms you are seeing.
--~--~-~--~~~---~--~~
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: map across code

2009-02-14 Thread Stephen C. Gilardi


On Feb 14, 2009, at 9:07 PM, kyle smith wrote:


I'm trying to map across code, but map evals each item in the list.
I've been trying to re-implement map as a macro, but so far no
success.  Is there some way to accomplish this?


Could you post a short example of the input and output you'd like to  
see?


--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: Git : I'm lazy

2009-02-14 Thread Kyle Schaffrick

On Wed, 11 Feb 2009 23:07:31 -0500
Stephen C. Gilardi squee...@mac.com wrote:

 
 On Feb 11, 2009, at 10:57 PM, Jeffrey Straszheim wrote:
 
  I know I should look this up on the web, but I'm really busy these  
  days.  I do intend to learn git someday, but I'm doing fine with  
  Subversion for my own work.  However, a lot of you are
  distributing your libs in git.
 
  So, can you give me a quick pointer on how to do two things:
 
  1. Check out someone's project into a folder (read only).
 
 cd the directory within which you want the new checkout
 git clone the git URL you have
 
  2. Update that project when the author makes changes.
 
 cd the git directory you checked out
 git pull
 
 --Steve
 

Hmm, forgive a possibly stupid question: Do you not also need to do a
git update to update your working copy to the new head revision? 

I don't know git that well, but it seems like many DVCSs like mercurial
distinguish between pull and update.

-Kyle

--~--~-~--~~~---~--~~
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: Git : I'm lazy

2009-02-14 Thread Stephen C. Gilardi


On Feb 14, 2009, at 10:44 PM, Kyle Schaffrick wrote:


Hmm, forgive a possibly stupid question: Do you not also need to do a
git update to update your working copy to the new head revision?

I don't know git that well, but it seems like many DVCSs like  
mercurial

distinguish between pull and update.


I haven't worked with mercurial.

In git, pull is a command that combines fetch and merge. There  
is no git update.


http://git.or.cz/gitwiki/GitDocumentation

--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: Bugs in set and sorted-set (?)

2009-02-14 Thread Chouser

On Sat, Feb 14, 2009 at 7:19 PM, Stephen C. Gilardi squee...@mac.com wrote:

 set is a hash set. It will never contain two items with equal hashes.

I don't think that's quite right.  I don't think it matters in this
case, but hash values aren't guaranteed unique.  A hash-map can have
two keys with the same hash value as long as = returns false.  Vectors
and lists with the same values evaluate as equal:

user= (= '(1 2) [1 2])
true

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