Re: Idiomatic usage of partial

2012-05-17 Thread Alan Malloy
#() syntax can accept as many arguments as you like. For example, you can define partial using #(): (defn partial [f & args] #(apply f (concat args %&))) On May 16, 7:13 pm, greg r wrote: > The reader notation is limited to the arity of the number of arguments > provided.  partial allows varia

Re: Idiomatic usage of partial

2012-05-17 Thread greg r
The reader notation is limited to the arity of the number of arguments provided. partial allows variable arity. Check out pages 67-68 of "Clojure Programming". Regards, Greg On Wednesday, May 16, 2012 1:57:40 PM UTC-4, Murtaza Husain wrote: > > Hi, > > What is the idiomatic use of partial. I un

Re: Idiomatic usage of partial

2012-05-17 Thread Tim Visher
On Wed, May 16, 2012 at 1:57 PM, Murtaza Husain wrote: > What is the idiomatic use of partial. I understand it helps create closures, > however the reader notation also allows to the same. So when should partial > be use dover other forms of creating functions. Also, for the sake of spamming of g

Re: Idiomatic usage of partial

2012-05-17 Thread Tim Visher
On Wed, May 16, 2012 at 1:57 PM, Murtaza Husain wrote: > What is the idiomatic use of partial. I understand it helps create closures, > however the reader notation also allows to the same. So when should partial > be use dover other forms of creating functions. I have no idea if it is idiomatic o

Re: Idiomatic usage of partial

2012-05-16 Thread Alan Malloy
On May 16, 2:05 pm, Stuart Sierra wrote: > Every literal instance of `fn` or `#()` compiles to a new class definition. > This is only at compile time: once the code is running, each execution of > the `fn` expression merely creates an instance of that class. > > partial is implemented in terms of

Re: Idiomatic usage of partial

2012-05-16 Thread Stuart Sierra
Every literal instance of `fn` or `#()` compiles to a new class definition. This is only at compile time: once the code is running, each execution of the `fn` expression merely creates an instance of that class. partial is implemented in terms of `fn`, so every usage of `partial` merely creates

Re: Idiomatic usage of partial

2012-05-16 Thread Jay Fields
Someone once mentioned that partials are more performant. i.e. (partial println "foo") is better than #(println "foo" %). I can't remember why, something about creating classes under the covers, I believe. Hopefully someone can chime in. Personally, I used to use #(... %) due to it being less char

Re: Idiomatic usage of partial

2012-05-16 Thread Jim - FooBar();
One of the best examples of partial that I've seen is in the debug-repl...look it up on github and see how it is being used there in the main function that starts the debug repl...basically every time you invoke the debug-repl within the same repl session you're going to have different local bi

Idiomatic usage of partial

2012-05-16 Thread Murtaza Husain
Hi, What is the idiomatic use of partial. I understand it helps create closures, however the reader notation also allows to the same. So when should partial be use dover other forms of creating functions. Thanks, Murtaza -- You received this message because you are subscribed to the Google Gr