Re: Clojure Code Style

2009-08-17 Thread Daniel Lyons
On Aug 17, 2009, at 1:27 AM, Meikel Brandmeyer wrote: > Not in general. But as a rule of thumb: every fn/#() > generates a class and hence everything using it: > defn, comp, partial, letfn, thunk'ing in macros, ... Thanks! — Daniel Lyons --~--~-~--~~~---~--~~

Re: Clojure Code Style

2009-08-17 Thread Meikel Brandmeyer
Hi, On Aug 17, 8:51 am, Daniel Lyons wrote: > > Also this function generates two classes, while the > > other two variants generate 6. > > Is there an easy way to tell how many classes a given function   > generates? Not in general. But as a rule of thumb: every fn/#() generates a class and he

Re: Clojure Code Style

2009-08-16 Thread Daniel Lyons
On Aug 13, 2009, at 12:16 AM, Meikel Brandmeyer wrote: > Also this function generates two classes, while the > other two variants generate 6. Is there an easy way to tell how many classes a given function generates? — Daniel Lyons --~--~-~--~~~---~--~~ You

Re: Clojure Code Style

2009-08-13 Thread Daniel Lyons
On Aug 12, 2009, at 10:34 PM, Richard Newman wrote: > This is the difference between 'conventional' and point-free style, by > the way. Many people view point-free as being somehow more elegant, > and I'm generally inclined to agree... apart from in cases like your > example, where a ton of part

Re: Clojure Code Style

2009-08-12 Thread Richard Newman
> Also this function generates two classes, while the > other two variants generate 6. Thank you for pointing this out! It -- surprisingly -- hadn't occurred to me before that different approaches to writing the same code would actually generate different sets of classes, possibly of very d

Re: Clojure Code Style

2009-08-12 Thread Meikel Brandmeyer
Hi, On Aug 13, 6:34 am, Richard Newman wrote: > I find this much nicer than stacking parens: > > (defn clean-lines [x] >    (non-empty >      (trimmed-lines >        (read-lines x))) There is also the nice -> macro. (defn clean-lines [x] (-> x read-lines trimmed-li

Re: Clojure Code Style

2009-08-12 Thread Meikel Brandmeyer
Hi, On Aug 13, 2:02 am, Sean Devlin wrote: > A)  Traditional definition > > (defn str->date-map >   [input-string] >   ((trans :month (comp dec :month)) >    (apply hash-map (interleave >                     [:month :day :year] >                     (map parse-int (re-split input-string #"/")))

Re: Clojure Code Style

2009-08-12 Thread Stuart Halloway
A point-free definition does not explicitly mention the values of the space on which the function acts. See http://www.haskell.org/haskellwiki/Pointfree. > On Thu, Aug 13, 2009 at 12:34 AM, Richard Newman > wrote: > This is the difference between 'conventional' and point-free style, by > th

Re: Clojure Code Style

2009-08-12 Thread John Harrop
On Thu, Aug 13, 2009 at 12:34 AM, Richard Newman wrote: > This is the difference between 'conventional' and point-free style, by > the way. Many people view point-free as being somehow more elegant, > and I'm generally inclined to agree... apart from in cases like your > example, where a ton of p

Re: Clojure Code Style

2009-08-12 Thread Richard Newman
> Let me know what you all think! In this case, A. I've definitely been known to use composition, but only when the definition is simple and expressive: e.g., (def clean-lines (comp non-empty trimmed-lines read-lines)) I find this much nicer than stacking parens: (defn clean-lines [x] (no

Re: Clojure Code Style

2009-08-12 Thread Wilson MacGyver
I would also vote A, seems much more straight forward. On Wed, Aug 12, 2009 at 8:02 PM, Sean Devlin wrote: > > Hello Clojurians, > I've been experimenting with different coding styles, and I'm > interested in the group's opinion. Which set of code is easiest to > read? > > A)  Traditional definit

Re: Clojure Code Style

2009-08-12 Thread Timothy Pratley
> Let me know what you all think! Just thought it worth a mention that another approach to composed partials is to use a 'pipe' macro (similar to ->). There was a very good thread about various implementations which I can't find anymore : ( FWIW I like your use of & as comp but $ for partial doe

Re: Clojure Code Style

2009-08-12 Thread CuppoJava
The first one is still the most straightforward to me personally. I feel there's no need to introduce function composition if there's no immediate advantage. In this case, In Clojure's case, I'm guessing function composition comes with some performance costs as well. -Patrick --~--~-~--~

Clojure Code Style

2009-08-12 Thread Sean Devlin
Hello Clojurians, I've been experimenting with different coding styles, and I'm interested in the group's opinion. Which set of code is easiest to read? A) Traditional definition (defn str->date-map [input-string] ((trans :month (comp dec :month)) (apply hash-map (interleave