On Wed, Dec 3, 2008 at 4:49 PM, Meikel Brandmeyer <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Am 03.12.2008 um 22:06 schrieb levand:
>>
>> I am coming to Clojure from the Java side, and am completely ignorant
>> about lisp indentation & newline conventions.
>
> Good. Then you aren't spoiled, yet. ;)
>
> My advice: get a reasonable editor like emacs or vim and
> the corresponding clojure modes. They will help you with
> automatic indentation. Just go with that and you won't have
> problems.
>
>> Which leads to the other immortal question - tab characters, or [n]
>> consecutive spaces? I'm fairly ambivalent myself and can go either
>> way, but is there a clear preferred way in the clojure community that
>> I would be better served by adhering to?
>
> Never ever use tabs. Eg.
>
> (some-function xxx
>               yyy)
>
> is one way to format a multi-line function call. Mixing tabs and
> spaces in front of the yyy just begs for ugly effects for people
> with different tab settings. And since the function name in general
> doesn't align well with tabs you need spaces anyway. So use only
> spaces.
>
>> Does anyone know of a reference for, or would care to enumerate what
>> standard clojure indenting ought to be?
>
> Personally, I like the vim way of indenting. But that's not a
> reference of course.
>
>> I'm particularly interested in this as I've been hacking about with a
>> clojure eclipse plugin for my own use and am considering adding auto-
>> indent features.
>
> In that case, I'd suggest to pick a style you like from an other
> editor or a particular library (eg. clojure.core itself) and try
> to implement that.
>
> This easily turns into religious flame wars. So my Disclaimer:
> Nothing of the said (except maybe the tab thing) is any reference
> and your mileage may vary!

I would like it if the team of Clojure committers would come up with
some basic guidelines for formatting code and maybe some advice that
goes beyond formatting. The kinds of guidelines I'd like to see are
the following:

Limit line lengths, perhaps to 80. Why 80? Because it works well with
printers and long lines of code are harder to quickly understand.

Limit the number of lines in a single function, perhaps with a goal of
15 being an upper limit. Why? Because it can be time consuming to
figure out what a long function is doing. If a function is longer than
that, odds are it is doing more than one fundamental thing and can be
broken into smaller, perhaps private, well-named functions that are
called from the original function. This can dramatically reduce the
need for comments.

Either put all the arguments to a function on a single line (if it
will fit in the line length limit) or put each argument on a separate
line. Anything else is harder to read.

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to