Re: Opinions on - macro? (was Re: Extensive use of let?)

2009-03-01 Thread Meikel Brandmeyer
Hi, Am 01.03.2009 um 02:19 schrieb Belfabius: I quickly learned the - macro can't be used in the same way for one simple reason; the value that is threaded through to the forms is always placed in the first argument position. How about adding a macro -- it could be called | just as in F# --

Re: Opinions on - macro? (was Re: Extensive use of let?)

2009-02-28 Thread Stuart Sierra
On Feb 27, 1:39 pm, John D. Hume duelin.mark...@gmail.com wrote: As a Java/Ruby guy who is not used to reading inside out, I'm curious as to whether people who ARE accustomed to LISP find the - macro distracting since it flops things around. Are there circumstances where you prefer it?

Re: Opinions on - macro? (was Re: Extensive use of let?)

2009-02-28 Thread Belfabius
First, I have to say thanks. I'm only a part-time Clojure user, and I didn't know of the - macro until today. Second, I think the - syntax leads to more readable code for precisely those situations where you're coding a sequence of actions. Finally, I've got a comment about what I think might

Opinions on - macro? (was Re: Extensive use of let?)

2009-02-27 Thread John D. Hume
On Wed, Feb 25, 2009 at 4:11 PM, Jason Wolfe jawo...@berkeley.edu wrote: (you'll get use to reading inside-out quickly). As a Java/Ruby guy who is not used to reading inside out, I'm curious as to whether people who ARE accustomed to LISP find the - macro distracting since it flops things

Re: Opinions on - macro? (was Re: Extensive use of let?)

2009-02-27 Thread James Reeves
On Feb 27, 6:39 pm, John D. Hume duelin.mark...@gmail.com wrote: As a Java/Ruby guy who is not used to reading inside out, I'm curious as to whether people who ARE accustomed to LISP find the - macro distracting since it flops things around. Are there circumstances where you prefer it? It's

Re: Opinions on - macro? (was Re: Extensive use of let?)

2009-02-27 Thread Allen Rohner
It's pretty useful for nested keywords:   (:name (:profile (:user message)))   (- message :user :profile :name) - James That is really cool. Once again the language and the community impress me with how elegant the language is. Allen

Re: Extensive use of let?

2009-02-26 Thread Luke VanderHart
Very interesting ideas, everyone... thanks a lot for the input. Yeah, I recognize that each case is going to be different - I guess I was just looking for suggestions on how to manage it. Which I found... Comp and partial look particularly interesting. Thanks! -Luke On Feb 25, 5:09 pm, Kevin

Extensive use of let?

2009-02-25 Thread levand
Recently, in my code, I have been struggling with which of the two equivalent forms is, in a general sense, better. (defn my-fn1 [input] (let [value1 (op1 input) value2 (op2 input) value3 (op4 value1 value2)] (op5 value3))) (defn my-fn2 [input] (op5 (op4 (op1 input) (op2

Re: Extensive use of let?

2009-02-25 Thread Joshua Fox
Of course, the use of let does not make the code any more imperative or less functional, as long as there are no side effects. Also, the scope is limited to the let block, keeping it clean, and there should be no harm to performance. IMHO, the code with let is simply more readable and therefore

Re: Extensive use of let?

2009-02-25 Thread Jason Wolfe
There's also a middle ground: (defn my-fn2 [input]   (op5 (op4 (op1 input) (op2 input If your op names are descriptive, this can still be very easy to read, with significantly fewer characters than the let version (you'll get use to reading inside-out quickly). You can also

Re: Extensive use of let?

2009-02-25 Thread Laurent PETIT
Hello, I fear there isn't (at least for me) a simple general answer for such a general problem, because : * it will really depend on the context : are op1 and op2 themselves cryptic names that would benefit from having their result clearly named ? are op1 and op2 low level operations for which

Re: Extensive use of let?

2009-02-25 Thread Kevin Downey
You should look at - it lest you take (op3 (op2 (op1 input))) and write it as (- input op1 op2 op3) there is also comp which composes functions, and partial for partial application. some example comp usage: