Re: Inheriting from IDeref - good idea or bad practise?

2010-02-08 Thread Jarkko Oranen
On Feb 8, 3:22 am, Stuart Halloway stuart.hallo...@gmail.com wrote: IMO Anything that implements IDeref should adhere to Clojure's vision   for identity, e.g. reads need to be thread safe, cheap, require no   coordination, and block no one. Dereferencing futures or undelivered promises block

Re: Clojure for system administration

2010-02-08 Thread Asbjørn Bjørnstad
On Feb 5, 12:33 am, Stuart Sierra the.stuart.sie...@gmail.com wrote: Clojure can certainly do these things; clojure-contrib contains many file and io-related utilities.  But remember that Clojure, like any Java program, takes more time to start up than scripting languages like

groovy builders equivalent

2010-02-08 Thread Laurent PETIT
Hello, Did anybody create a functionally equivalent clojure version of so-called Groovy Builders ? ( http://groovy.codehaus.org/Builders ) Not that it should be too difficult to come up with an equivalent, and also not that it would seem to you that it is interesting to do so given the power of

Removing (gensym) in macro

2010-02-08 Thread Roman Roelofsen
Hi, just for practicing Clojure's macros I wrote the following create-java-list macro. (defmacro create-java-list [ forms] (let [prefixfn (fn [obj form] (cons (symbol .) (cons obj form))) lname (gensym)] `(let [~lname (java.util.ArrayList.)] ~@(map (partial prefixfn lname)

Re: Removing (gensym) in macro

2010-02-08 Thread Meikel Brandmeyer
Hi, On Feb 8, 11:45 am, Roman Roelofsen roman.roelof...@googlemail.com wrote: just for practicing Clojure's macros I wrote the following create-java-list macro. (defmacro create-java-list   [ forms]   (let [prefixfn (fn [obj form] (cons (symbol .) (cons obj form)))         lname (gensym)]

Re: Removing (gensym) in macro

2010-02-08 Thread Michael Wood
On 8 February 2010 12:45, Roman Roelofsen roman.roelof...@googlemail.com wrote: Hi, just for practicing Clojure's macros I wrote the following create-java-list macro. (defmacro create-java-list  [ forms]  (let [prefixfn (fn [obj form] (cons (symbol .) (cons obj form)))        lname

Re: Removing (gensym) in macro

2010-02-08 Thread Meikel Brandmeyer
Hi, On Feb 8, 12:14 pm, Michael Wood esiot...@gmail.com wrote: user= (doto (java.util.ArrayList.) (.add 1) (.add 2)) #ArrayList [1, 2] Oops. Yes. You need doto instead of -. Sorry, my mistake. Is it possible to create the macro without the (gensym) call? I wasn't able to use something

Re: Removing (gensym) in macro

2010-02-08 Thread Roman Roelofsen
It doesn't work because the scope of lname# is limited to the `(). However lname is used in a ~@() which leaves the `() and enters the enclosing environment (in this case the macros). There the lname# is not valid. Ah, that makes sense, thanks! Is using (gensym) the common solution here? So

Re: Parallel version of list comprehension

2010-02-08 Thread Sean Devlin
Do you have a specific example, some code you could paste? On Feb 7, 11:53 pm, Tim Snyder tsnyder...@gmail.com wrote: Is there a straight-forward way to get parallelization when using list comprehension? The form of for syntax is much preferable to the closest I could come up with using pmap.

Re: groovy builders equivalent

2010-02-08 Thread Chouser
On Mon, Feb 8, 2010 at 5:29 AM, Laurent PETIT laurent.pe...@gmail.com wrote: Hello, Did anybody create a functionally equivalent clojure version of so-called Groovy Builders ? ( http://groovy.codehaus.org/Builders ) Not that it should be too difficult to come up with an equivalent, and

Re: Removing (gensym) in macro

2010-02-08 Thread Meikel Brandmeyer
Hi, On Feb 8, 2:06 pm, Roman Roelofsen roman.roelof...@googlemail.com wrote: Ah, that makes sense, thanks! Is using (gensym) the common solution here? So far I thought that (gensym) is more a internal function that I normally never need to call directly. In such a case using gensym is the

Re: Removing (gensym) in macro

2010-02-08 Thread Laurent PETIT
2010/2/8 Meikel Brandmeyer m...@kotka.de: Hi, On Feb 8, 2:06 pm, Roman Roelofsen roman.roelof...@googlemail.com wrote: Ah, that makes sense, thanks! Is using (gensym) the common solution here? So far I thought that (gensym) is more a internal function that I normally never need to call

Clojure talk TODAY (Feb 8) Paris, France 19:00

2010-02-08 Thread Howard Lewis Ship
Just a last minute reminder ... I'll be presenting Clojure: Towards the Essence of Programming on Monday Feb 8th at 19:00, in Paris. The event will be held at Zenika, SkillsMatter's partner in France. You must register for the talk ahead of time.

Re: groovy builders equivalent

2010-02-08 Thread Laurent PETIT
2010/2/8 Chouser chou...@gmail.com: On Mon, Feb 8, 2010 at 5:29 AM, Laurent PETIT laurent.pe...@gmail.com wrote: Hello, Did anybody create a functionally equivalent clojure version of so-called Groovy Builders ? ( http://groovy.codehaus.org/Builders ) Not that it should be too difficult to

Re: Clojure talk TODAY (Feb 8) Paris, France 19:00

2010-02-08 Thread Laurent PETIT
I wish I could be present ! I wish you the best, regards, -- Laurent 2010/2/8 Howard Lewis Ship hls...@gmail.com: Just a last minute reminder ... I'll be presenting Clojure: Towards the Essence of Programming on Monday Feb 8th at 19:00, in Paris. The event will be held at Zenika,

Re: groovy builders equivalent

2010-02-08 Thread Sean Devlin
Perhaps I have an incomplete grasp of the problem domain, but wouldn't a map stored in a ref let you do this? On Feb 8, 9:12 am, Laurent PETIT laurent.pe...@gmail.com wrote: 2010/2/8 Chouser chou...@gmail.com: On Mon, Feb 8, 2010 at 5:29 AM, Laurent PETIT laurent.pe...@gmail.com wrote:

Re: groovy builders equivalent

2010-02-08 Thread Laurent PETIT
2010/2/8 Sean Devlin francoisdev...@gmail.com: Perhaps I have an incomplete grasp of the problem domain, but wouldn't a map stored in a ref let you do this? I don't understand. On Feb 8, 9:12 am, Laurent PETIT laurent.pe...@gmail.com wrote: 2010/2/8 Chouser chou...@gmail.com: On Mon,

Re: Parallel version of list comprehension

2010-02-08 Thread Tim Snyder
Sure, I was going to add it last night, but brain had shut down for the night. The program I'm working on is a Communicating Sequential Processes toolbox, so you can write a process and collect the traces (along with other tools that simplify expressions and such). I've written a traces function

scope of binding

2010-02-08 Thread Alex
Hi, I have a question about the scope of binding of a var. Let's say I have the following var: (def *v* 1) And I define a function that uses it: (defn f [n] (+ *v* n)) binding behaves as expected, establishing a thread-local binding to a new value in its scope: user= (binding

Re: Clojure talk TODAY (Feb 8) Paris, France 19:00

2010-02-08 Thread Christian Guimaraes
The talk will be in English or French? On Mon, Feb 8, 2010 at 2:13 PM, Laurent PETIT laurent.pe...@gmail.comwrote: I wish I could be present ! I wish you the best, regards, -- Laurent 2010/2/8 Howard Lewis Ship hls...@gmail.com: Just a last minute reminder ... I'll be presenting

Re: scope of binding

2010-02-08 Thread Sean Devlin
The problem is that map returns a lazy seq, and the lazy seq is evaluated outside of the binding by the REPL. If you add a doall inside the binding, it behaves as you expect. user= (binding [*v* 2] (doall (map f [1 1 1]))) (3 3 3) Sean On Feb 8, 5:47 am, Alex alexander.bolodu...@gmail.com

Re: Inheriting from IDeref - good idea or bad practise?

2010-02-08 Thread Steven E. Harris
James Reeves weavejes...@googlemail.com writes: Would those more knowledgable about Clojure care to weigh in on whether it be a good idea to create a custom class inheriting from IDeref? That's how promise is implemented, but that's supposed to be an internal detail. -- Steven E. Harris --

Re: Inheriting from IDeref - good idea or bad practise?

2010-02-08 Thread Sean Devlin
I've got no clue, so I would just do the experiment. If it works out well, tell us why. If it's a disaster, tell us what didn't work. Sean On Feb 7, 3:57 pm, James Reeves weavejes...@googlemail.com wrote: Hi folks, Would those more knowledgable about Clojure care to weigh in on whether it

Please share your thoughts on dependency injection

2010-02-08 Thread Boris Mizhen - 迷阵
Hello all, I am playing with the idea of a little library for dependency injection. The idea is to declare injectable values as metadata-to-function map. I started with a sketch of what the client code may look like. Please let me know what you think. Thank you, Boris Dependency declaration

Re: Prepping clojure for packaging (was: Re: Clojure for system administration)

2010-02-08 Thread Konrad Hinsen
On 07.02.2010, at 03:25, Constantine Vetoshev wrote: I stopped using Python and Ruby and Perl partly because the packaging situation for all those languages is a horrible mess. For example, if I agree. It's not just packaging, even providing sufficiently general installation scripts is a

Re: Clojure talk TODAY (Feb 8) Paris, France 19:00

2010-02-08 Thread Konrad Hinsen
On 08.02.2010, at 15:10, Howard Lewis Ship wrote: Just a last minute reminder ... I'll be presenting Clojure: Towards the Essence of Programming on Monday Feb 8th at 19:00, in Paris. The event will be held at Zenika, If I had known this earlier, I might have been able to come :-( Konrad.

Re: Prepping clojure for packaging (was: Re: Clojure for system administration)

2010-02-08 Thread Greg
In short, I think that the Java and Clojure way of packaging software make life much easier for programmers, package maintainers, and administrators, not harder. Making applications self-contained helps I have no experience with this yet, but one reason for looking into the JVM has been

Re: return value of use, requires?

2010-02-08 Thread Raoul Duke
On Sat, Feb 6, 2010 at 2:08 AM, Timothy Pratley timothyprat...@gmail.com wrote: Good point, I've updated the ticket patch to check options are valid also, so the behavior is now: that is very cool, thank you! -- You received this message because you are subscribed to the Google Groups Clojure

Re: scope of binding

2010-02-08 Thread Richard Newman
You can also capture the binding. This looks a little ugly, but it works: it grabs the binding eagerly, and returns a closure that dynamically binds it when the function is invoked. (binding [*v* 2] (map (let [v *v*] (fn [n] (binding [*v* v] (f n

error reporting for macro expansion

2010-02-08 Thread John R. Williams
The Clojure compiler is not very helpful when it comes to debugging exceptions that occur while macros are being expanded. As an example, consider this code: ;; macro-fail.clj (defmacro broken [] (/ 0 0)) (broken) Here's the stack trace I get when I compile this file: Exception in thread main

Re: error reporting for macro expansion

2010-02-08 Thread Michał Marczyk
On 8 February 2010 20:11, John R. Williams shponglesp...@gmail.com wrote: ;; macro-fail.clj (defmacro broken [] (/ 0 0)) (broken) [ ... ] As you can see, line 3, where the macro is used, appears nowhere in the stack trace. That's because execution never reaches this point, because the (/ 0

Implicit style streams in Clojure

2010-02-08 Thread Brenton
What is the Clojure best practice, if there is one, for writing a function like this: pre (defn integral [integrand initial-value dt] (def --integral (cons initial-value (lazy-seq (add-streams (scale- streams integrand dt) --integral --integral) /pre

Re: Implicit style streams in Clojure

2010-02-08 Thread Michał Marczyk
Use let: (defn foo [...] (let [helper (fn [...] ...)] (helper ...))) or letfn: (defn foo [...] (letfn [(helper [...] ...)] (helper ...))) The latter allows you to introduce mutually recursive functions. Sincerely, Michał -- You received this message because you are subscribed to

Re: Implicit style streams in Clojure

2010-02-08 Thread Kevin Downey
don't use def inside functions, ever. in scheme define is lexically scoped, so you do that sort of thing. clojure is not scheme. if you want a lexically scoped function use a lexical scoping construct like let or letfn. On Mon, Feb 8, 2010 at 12:12 PM, Brenton bashw...@gmail.com wrote: What is

Re: Implicit style streams in Clojure

2010-02-08 Thread Brenton
letfn is exactly what I was looking for. Thank you. On Feb 8, 12:15 pm, Michał Marczyk michal.marc...@gmail.com wrote: Use let: (defn foo [...]   (let [helper (fn [...] ...)]     (helper ...))) or letfn: (defn foo [...]   (letfn [(helper [...] ...)]     (helper ...))) The latter

Re: Clojure talk TODAY (Feb 8) Paris, France 19:00

2010-02-08 Thread Howard Lewis Ship
I've posted it at least once on this list! On Mon, Feb 8, 2010 at 9:35 AM, Konrad Hinsen konrad.hin...@fastmail.net wrote: On 08.02.2010, at 15:10, Howard Lewis Ship wrote: Just a last minute reminder ... I'll be presenting Clojure: Towards the Essence of Programming on Monday Feb 8th at

clojure pathnames library

2010-02-08 Thread Vadim Shender
Hi. Is there any clojure third-party library functionally similar to python's os.path? Using java.io.File is not so convenient as os.path. Regards Vadim Shender -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Trait-like behavior with Protocols

2010-02-08 Thread aria42
Is it possible to have default implementations associated with functions in a protocol? This is most useful when some protocol functions are defined in terms of other. For instance, (defprotocol Span (start [self]) (stop [self]) (span-length [self])) Now I know I can just make span-length

Re: Prepping clojure for packaging (was: Re: Clojure for system administration)

2010-02-08 Thread Rick Moynihan
On 5 February 2010 18:47, Peter Schuller peter.schul...@infidyne.com wrote: I've been wondering about this.  The classpath issue seems like a major thorn in the side of the JVM, especially for Clojure and other It seems to be that there are two problems here. One problem is that there needs

Re: Trait-like behavior with Protocols

2010-02-08 Thread Stuart Sierra
On Feb 8, 6:13 pm, aria42 ari...@gmail.com wrote: (defprotocol Span   (start [self])   (stop [self])   (span-length [self])) Now I know I can just make span-length a function on Span as opposed to part of the protocol. Is that what one should do? Yes. -SS -- You received this message

Re: clojure pathnames library

2010-02-08 Thread Stuart Sierra
Look at clojure-contrib. In the 1.1 release, use duck-streams and java-utils. In the latest github sources, it's all in clojure.contrib.io. -SS On Feb 8, 5:43 pm, Vadim Shender vadim.shen...@gmail.com wrote: Hi. Is there any clojure third-party library functionally similar to python's

Detecting Number of Available CPU Threads

2010-02-08 Thread Wardrop
I'm wondering if there's anyway in Clojure, that one can detect the number of available processoring threads (ie. 4 core cpu with hyperthreading would equal 8 available threads). This will allow me to have a scalable processing app which can run on a single core CPU, or 250 core processor, without

Re: Detecting Number of Available CPU Threads

2010-02-08 Thread Timothy Pratley
On 9 February 2010 11:29, Wardrop t...@tomwardrop.com wrote: I'm wondering if there's anyway in Clojure, that one can detect the number of available processoring threads (.availableProcessors (Runtime/getRuntime)) might be what you are after? -- You received this message because you are

Re: Detecting Number of Available CPU Threads

2010-02-08 Thread Wardrop
That seems like what I'm after, thanks. I assume this would be pretty reliable across all platforms running the JVM. By the way, I did google the Java API with various keywords but never cam across this object property. Thanks On Feb 9, 11:33 am, Timothy Pratley timothyprat...@gmail.com wrote:

Re: Trait-like behavior with Protocols

2010-02-08 Thread Dan Larkin
On Feb 8, 2010, at 6:13 PM, aria42 wrote: Is it possible to have default implementations associated with functions in a protocol? This is most useful when some protocol functions are defined in terms of other. For instance, (defprotocol Span (start [self]) (stop [self]) (span-length

Re: Prepping clojure for packaging (was: Re: Clojure for system administration)

2010-02-08 Thread Brian Schlining
IMHO Ruby (and probably python) do this better than Clojure, though I'm not sure if we'll ever be able to find a solution we can all agree on. Groovy has a very decent solution to the classpath issue for scripts. Details can be found at http://groovy.codehaus.org/Grape . It might be

Re: Prepping clojure for packaging (was: Re: Clojure for system administration)

2010-02-08 Thread Meikel Brandmeyer
Hi, maybe I don't understand the problem. Why can't the system provide some kind of local repository? The package system (deb, rpm, ports, whatever) just installs the dependencies there. A wrapper script reads in the dependencies and adds them to the classpath on program start. Nothing is

Re: Trait-like behavior with Protocols

2010-02-08 Thread Meikel Brandmeyer
Hi, On Feb 9, 12:13 am, aria42 ari...@gmail.com wrote: Is it possible to have default implementations associated with functions in a protocol? This is most useful when some protocol functions are defined in terms of other. For instance, (defprotocol Span   (start [self])   (stop [self])