Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Indentation
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 26 - 50 of 54 - Collapse all  -  Translate all to Translated (View all originals) < Older  Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Christopher Browne  
View profile  
 More options Jun 29 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: cbbro...@news.hex.net (Christopher Browne)
Date: 1999/06/29
Subject: Re: Indentation
On Tue, 29 Jun 1999 20:47:26 GMT, John Wiseman

Interesting.

Emacs does this "right" in Scheme mode, but does the "lesser"
indentation for the "else" in Lisp mode.

I don't think I like that...

--
"Be humble.  A lot happened before you were born."  - Life's Little
Instruction Book
cbbro...@ntlug.org- <http://www.hex.net/~cbbrowne/langlisp.html>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pierre R. Mai  
View profile  
 More options Jun 30 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: p...@acm.org (Pierre R. Mai)
Date: 1999/06/30
Subject: Re: Indentation
mkgar...@cs.uiuc.edu (Mark K. Gardner) writes:

> [Good material not needed for my question removed...]

> >way of indenting (especially in Lisp, where there is a canonical way),

> I have been following the discussion waiting for someone to give a
> reference to something which gives the canonical way to indent Lisp
> code. (Yes, I rely on Emacs to format things on correctly when I can
> run Emacs but would like to know what the rules are so that I can
> maintain the proper indention when I can't run Emacs.) Would you
> please post a reference to the canonical way?

Someone has already posted a description of what (GNU/X) Emacs does.
I'm not aware of any written specification for indentation.  In effect
most of the rules of indentation are passed on from generation to
generation by code.  This is made easier by the fact that most CL
constructs fall into a small number of categories, which follow very
simple rules.  The most important rule is that indentation of the body
(if there is any) of a construct, and that of special arguments
differs, i.e. the one is normally 2, the other often 4, unless it is
put directly on the first line of the form:

(defun abc (dddd)
  (bla)
  (blub))

vs.

(defun abc
    (dddd)
  (bla)
  (blub))

There are some slight differences in indentation styles (like in the
case of if), but none that diverge noticably, so that the basic rules
(e.g. parentheses stay on the same line, basic indentation size is 2,
special indentation is 4, etc.) are never violated.

Of course the most canonical way of indenting ANSI Common Lisp code is
given by PPRINT, which is part of every ANSI CL, although the precise
algorithm used for pretty printing isn't mandated by the ANSI spec,
and so there are some slight differences in different implementations
of pprint.

You could also look up the algorithm used by XP (the reference
implementation of a pretty-printer, by Richard C. Waters).  That
should give you a good understanding of indenting Common Lisp code.

Regs, Pierre.

--
Pierre Mai <p...@acm.org>         PGP and GPG keys at your nearest Keyserver
  "One smaller motivation which, in part, stems from altruism is Microsoft-
   bashing." [Microsoft memo, see http://www.opensource.org/halloween1.html]


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Breton  
View profile  
 More options Jun 30 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Tom Breton <t...@world.std.com>
Date: 1999/06/30
Subject: Re: Indentation

Hrvoje Niksic <hnik...@srce.hr> writes:
> I'm not aware of a canonical description, so I'll try to describe what
> Emacs does.  There are several cases.

> * Nesting with one word following open paren; indent by one space
>   relative to the paren.
[...]
> * Nesting with several words following open paren indent; indent by as
>   much as the first word takes up.

I sense the beginning of a one-true-indentation-style war.  FWIW,
Emacs doesn't do that with me, because my lisp hook sets
  ( setq lisp-indent-offset 2 ) ;;Indent more comfortably.

--
Tom Breton, http://world.std.com/~tob
Ugh-free Spelling (no "gh") http://world.std.com/~tob/ugh-free.html


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vassil Nikolov  
View profile  
 More options Jun 30 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Vassil Nikolov <vniko...@poboxes.com>
Date: 1999/06/30
Subject: Re: Indentation
On 1999-06-29 14:18 +0200,

Josef Eschgfaeller wrote:

  [...]
  > > What do you mean by `shapes'?
  >
  > Something as the interior or logical shape. I meant approximately
  > that when you have ready such a shape, you can put in easily the
  > constructions in your program. In some sense indentation means that
  > you never make that effort and so you are compelled each time to
  > begin from new.

Could it be you mean that indented code could not be copied and
pasted from one program to another??  (I am still trying to grasp
the meaning of `shape' in this context.  Would the word `form' (as in
`a form to be filled-in') be more appropriate than `shape'?)

  [...]
  > > However, what if there is a DO within a DO? Wouldn't it take
  > > time to disentangle one from the other?
  >
  > Perhaps it could also be a reason to avoid or reorganize too
  > complicated structures.

Sometimes this means to avoid too complicated problems.  I agree
this makes life easier...

  [...]
  > Lisp is a rich and
  > deep language and I have still much to learn.

By the way, it does indeed take some extra effort to learn Lisp
mode (of Emacs, for one who is just using fundamental mode),
but this effort pays off very handsomely (writing Lisp programs,
of course, not writing letters).

Good luck,
Vassil.

Vassil Nikolov
Permanent forwarding e-mail: vniko...@poboxes.com
For more: http://www.poboxes.com/vnikolov
  Abaci lignei --- programmatici ferrei.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marco Antoniotti  
View profile  
 More options Jun 30 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Marco Antoniotti <marc...@copernico.parades.rm.cnr.it>
Date: 1999/06/30
Subject: Re: Indentation

mkgar...@cs.uiuc.edu (Mark K. Gardner) writes:

> I have been following the discussion waiting for someone to give a
> reference to something which gives the canonical way to indent Lisp
> code. (Yes, I rely on Emacs to format things on correctly when I can
> run Emacs but would like to know what the rules are so that I can
> maintain the proper indention when I can't run Emacs.)

                                ^^^^^^^^^^^^^^^^^^^^^^

Isn't there an Emacs for the Palm Pilot? :)

--
Marco Antoniotti ===========================================
PARADES, Via San Pantaleo 66, I-00186 Rome, ITALY
tel. +39 - 06 68 10 03 17, fax. +39 - 06 68 80 79 26
http://www.parades.rm.cnr.it/~marcoxa


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marco Antoniotti  
View profile  
 More options Jun 30 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Marco Antoniotti <marc...@copernico.parades.rm.cnr.it>
Date: 1999/06/30
Subject: Re: Indentation

I kinda prefer

        "Let's keep going like this, let's hurt ourselves"

From the movie "Bianca" by Nanni Moretti (of "Dear Diary" fame).

Cheers

--
Marco Antoniotti ===========================================
PARADES, Via San Pantaleo 66, I-00186 Rome, ITALY
tel. +39 - 06 68 10 03 17, fax. +39 - 06 68 80 79 26
http://www.parades.rm.cnr.it/~marcoxa


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marco Antoniotti  
View profile  
 More options Jun 30 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Marco Antoniotti <marc...@copernico.parades.rm.cnr.it>
Date: 1999/06/30
Subject: Re: Indentation

Duane Rettig <du...@franz.com> writes:
> Incidentally, writing programs is also a form of communication in
> several ways; when I write a program I am communicating to three
> classes of receivers:
>   1. The computer.
>   2. Other programmers, who don't necessarily know my design.
>   3. Myself, six months after I wrote the program.

> By far, the most challenging receiver to communicate with is #3.

I gave up on #3 many years ago :)

Cheers

--
Marco Antoniotti ===========================================
PARADES, Via San Pantaleo 66, I-00186 Rome, ITALY
tel. +39 - 06 68 10 03 17, fax. +39 - 06 68 80 79 26
http://www.parades.rm.cnr.it/~marcoxa


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Jun 30 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 1999/06/30
Subject: Re: Indentation
* Josef Eschgfaeller <e...@felix.unife.it>
| The problem of indentation is interesting for me, because most
| programmers stick to it as if it were an axiom.

  from here, it seems you stick to your non-indentation line with something
  other than willingness to listen to good advice.  I'm not sure that's an
  impression you want to give.

| I had a similar discussion several years ago about C, and I was not able
| to convince anybody.

  well, that often happens when one is mistaken.

| (1) Writing a program should be similar as far as possbile to writing a
| letter.

  of all the things it could be similar to, why a _letter_?

| Also in letters some structure is useful, but it should be esthetic and
| functional, not ritual.  This applies also to C and most other languages.

  funny you say that, since "aesthetic and functional" is what indentation
  is all about.  it seems, however, that _you_ think it is a ritual, and
  that sends some fairly strong signals that you're doing something wrong.
  indeed, it seems you format your code as a ritual _today_.

| (2) More specifically in Lisp I try to memorize (and to teach to
| memorize) the shapes which can appear.

  you _teach_ Lisp, too?  those of us who think that Lisp's image among
  young programmers suffers from bad teachers just got a very unwelcome
  confirmation of our worst fears.  really, you're doing your students a
  huge disservice by teaching a view that you admit is really unique.  I'm
  profoundly sorry to see that people who cannot otherwise convince others
  choose to teach those who are unlikely to object to abject silliness.

| For example: "A do has the following structure ... Therefore, when you
| see a do, look first at the assignments, then at the break-condition and
| the result, then at the single instructions."  And so on. In my opinion
| this is a good training, and after little time one has no more need to
| study the indentations, which also takes time and distracts.

  this sounds like a struggling beginner's view, a beginner who struggles
  because he's doing something wrong and don't want to change his ways.

| Of course, when I write on the computer (I'm using Emacs, but always only
| in fundamental mode), I verify the balance of parentheses with the editor.

  "always in fundamental mode"?  there should be a law against that.

| But I find it useful to write simple functions first by hand and to
| control by myself the parentheses.  I don't find it difficult.  With this
| training the )))))))))))))))-boing disappears quickly.

  I use M-( and M-) and move and manipulate complete forms when possible.
  that is, I don't have unbalanced parens to begin with.

| It was on this list (or perhaps in a paper of Kent Pitman) where I read
| some days ago that in computer science sometimes first habits become
| sanctified.

  yes, this often happens to people who don't engage in introspection.

| In part this may be true also for indentation.

  I'm baffled that you don't see the same argument in your non-indentation.

| Perhaps, but this is a personal argument, it is also a question of eyes.
| For me it takes more time to control the indentation (with more rows to
| read) than to examine the structure.

  and this is _why_ first habits become sanctified: it takes some effort to
  change your ways, and lazy people who don't engage in introspection and
  so constantly look for better ways to do what they do, don't ever expend
  that effort.  so, right now, your non-indentation is the easiest for you,
  simply because you have never indented your code, never learned to use
  the power of Emacs and its programmer-friendly modes, and have not seen
  any reason to change your ways despite not being able to convince anyone
  that your ways are superior.

  I'm frankly amazed that you think _others_ are stubborn.

  here's my suggestion: use PPRINT on your forms to see how Common Lisp is
  most commonly formatted.  learn to appreciate what people have done
  before you and try to understand why they have done it that way, instead
  of believing everybody else is doing silly things out of "ritual" and in
  terms of "convictions" and yours is the only reasonable way to do things.

  e.g.,

(pprint '
(defun num-list (a b &optional (d 1))
(do ((x a (+ x d)) (li nil))
((> x b) (nreverse li)) (push x li))))

  produces, with *PRINT-RIGHT-MARGIN* at 40 and *PRINT-CASE* to :DOWNCASE:

(defun num-list (a b &optional (d 1))
  (do ((x a (+ x d)) (li nil))
      ((> x b) (nreverse li))
    (push x li)))

  with *PRINT-RIGHT-MARGIN* set to 72 (the default, sort of), we get

(defun num-list (a b &optional (d 1))
  (do ((x a (+ x d)) (li nil)) ((> x b) (nreverse li))  (push x li)))

  which may not look great, but this is because (1) normal programmers
  don't use one-letter names of variables unless they are temporary
  variables with no particular meaning, anyway, so if a normal Lisp
  programmer would have written this, it'd look more like this, apart from
  the non-obvious utility of the function and the attendant difficulty of
  finding a good name for it:

(defun number-list (from to &optional (step 1))
  (do ((element from (+ element step)) (list nil))
      ((> element to) (nreverse list))
    (push element list)))

  I would expect a seasoned Lisp programmer not to write this as a function
  at all, but rather just write (loop for n from <from> to <to> collect n)
  instead of (number-list <from> <to>), since there is nothing to be gained
  by writing functions that don't do anything to either help read the code
  or partition abstraction.  after all, we expect some of the code in even
  the highest-level source code to use some normal Common Lisp forms; we
  don't write macros and special functions for _everything_.

#:Erik
--
@1999-07-22T00:37:33Z -- pi billion seconds since the turn of the century


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Jun 30 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 1999/06/30
Subject: Re: Indentation
* wise...@cs.uchicago.edu (John Wiseman)
| This seems like a great time for me to ask how to make emacs indent IF
| like this (the way FRED, the Macintosh Common Lisp editor, does it):
|
| (if (...)
|   (...)
|   (...))

  it depends on which Lisp mode you're using.  I have

(put 'if 'lisp-indent-function 1)
(put 'if 'fi:lisp-indent-hook 1)

  somewhere in the setup files.  (Emacs' Lisp indentation code is arcane.)

#:Erik
--
@1999-07-22T00:37:33Z -- pi billion seconds since the turn of the century


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Bradshaw  
View profile  
 More options Jun 30 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Tim Bradshaw <t...@tfeb.org>
Date: 1999/06/30
Subject: Re: Indentation

Erik Naggum <e...@naggum.no> writes:
> (defun number-list (from to &optional (step 1))
>   (do ((element from (+ element step)) (list nil))
>       ((> element to) (nreverse list))
>     (push element list)))

>   I would expect a seasoned Lisp programmer not to write this as a function
>   at all, but rather just write (loop for n from <from> to <to> collect n)
>   instead of (number-list <from> <to>), since there is nothing to be gained
>   by writing functions that don't do anything to either help read the code
>   or partition abstraction.  after all, we expect some of the code in even
>   the highest-level source code to use some normal Common Lisp forms; we
>   don't write macros and special functions for _everything_.

But if you use a code style which makes it very hard to read things
like nested loops, you are likely forced into a whole bunch of tiny
functions like this...

--tim


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Bradshaw  
View profile  
 More options Jun 30 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Tim Bradshaw <t...@tfeb.org>
Date: 1999/06/30
Subject: Re: Indentation

* Josef Eschgfaeller wrote:
>> However, what if there is a DO within a DO? Wouldn't it take
>> time to disentangle one from the other?
> Perhaps it could also be a reason to avoid or reorganize too
> complicated structures.

I think this must be commented on.  Two nested loops (DO or other) are
an extremely common idiom when processing 2d arrays.  You can't in all
seriousness suggest that one should avoid or reorganise structures
this complex: if a programming style is making this hard to read then
it has serious problems.

--tim


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eli Barzilay  
View profile  
 More options Jun 30 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Eli Barzilay <e...@tulare.cs.cornell.edu>
Date: 1999/06/30
Subject: Re: Indentation

Josef Eschgfaeller <e...@felix.unife.it> writes:

 > Perhaps it could also be a reason to avoid or reorganize too
 > complicated structures.
 > ...
 > The danger is, as in natural language, that one does not more read
 > with attention what is written. People who are accustomed to read
 > much, usually can understand easily texts of considerable
 > complexity.

The whole point of comparing natural language to programs is bogus.
When you write English sentences (or any other language), you never
get them too deep.  Try looking at texts that you wrote and find the
longest sentence, then find the longest function you wrote.

Breaking up complicated structures is certainly good, but even very
small functions are much more complex than average natural language
sentences.  Almost any quick experiment will do, something like:

  (defun memo (fn &key (key #'first) (test #'eql) name)
    "Return a memo-function of fn."
    (let ((table (make-hash-table :test test)))
      (setf (get name :memo) table)
      #'(lambda (&rest args)
          (let ((k (funcall key args)))
            (multiple-value-bind (val found-p)
                (gethash k table)
              (if found-p
                val
                (setf (gethash k table) (apply fn args))))))))

translates into an English sentence like:

  The memoization of a function fn using a key which defaults to the
  first function and a test that defaults to eql function and an
  optional name argument is: take table as a new hash table with a
  test as its test function, set the :memo property of the name
  argument to the table and return a function that gets a list of
  arguments and now let k be the result of calling the key argument on
  the given list of arguments, then let val and found-p be the value
  of k in the table and if it was found there, then, if found-p is
  true then return val else set the value associated with k in the
  table to the result of applying fn to the arguments and return this
  value.

I hope that demonstrates the point...  If you write such sentences,
then you probably have no problems reading

(defun memo (fn &key (key #'first) (test #'eql) name) "Return a
memo-function of fn." (let ((table (make-hash-table :test test)))
(setf (get name :memo) table) #'(lambda (&rest args) (let ((k (funcall
key args))) (multiple-value-bind (val found-p) (gethash k table) (if
found-p val (setf (gethash k table) (apply fn args))))))))

This can be added to the point made by Barry Margolin in
<gC8e3.1026$KM3.239358@burlma1-snr2>.

 > >> (defun num-list (a b &optional (d 1))
 > >> (do ((x a (+ x d)) (li nil))
 > >> ((> x b) (nreverse li)) (push x li)))

BTW, if indentation is completely unimportant, why did you put the
newlines in those places?  Why did you put spaces around some parens
where it is not needed?

And if you insist on using this style in public, then why do you put
these "> " prefixes to stuff you quoted?

Last point - I may not have seen too much, but I have a rough rule
that the quality of a programmer is directly related to the style of
his/her programs, and in about 10 years, I never saw a counter
example...  I saw terrible programmers that just added statements
wherever the cursor was placed (which sometime was whatever random
point was clicked to get the window to the front), and I saw amazing
programmers (a lot, especially around Lisp and relatives) that insist
on strict comment style, spacing style not to mention indentation...
--
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
         http://www.cs.cornell.edu/eli/meaning.html        Maze is Life!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kent M Pitman  
View profile  
 More options Jul 1 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Kent M Pitman <pit...@world.std.com>
Date: 1999/07/01
Subject: Re: Indentation

amor...@mclink.it (Paolo Amoroso) writes:
> On Tue, 29 Jun 1999 05:13:05 +0300, Vassil Nikolov <vniko...@poboxes.com>
> wrote:

> > I don't think that writing a program is very similar to writing
> > a letter, or to writing a poem, or a short story, or whatever.

> Incidentally, organizing and writing source code as part of a larger prose
> text documenting the system is the main idea behind Knuth's "literate
> programming".

To state my opinion on this, we need to distinguish between "truth"
and the stronger "necessary truth".  Mere truth being something that
could be false under other circumstances, like "there are 9 planets".
Necessary truth being something that could not be otherwise, like
2+2=4.  It is certainly true that writing a program is not similar
to writing prose, but it is far from necessarily true.  And I don't
think it's desirable that they're different.  One reason programs
are fragile (subject to the most meager bugs that nitpicky computer
scientists revel in but "normal" people have no experience with at all)
is that they use a notation where any single-bit-error is enough to
make a program not work.  Consider how it would be if a novel (or even
a note about what groceries to buy left to a spouse on a refrigerator)
were rendered utterly unreadable by a single misspelling...  Redundancy
is something we have bred a culture to hate, but it is something that
has served nature and humanity quite well.  Although computer people
have a lot to teach the real world, so too does the real world have a
lot to teach computer people.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kent M Pitman  
View profile  
 More options Jul 1 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Kent M Pitman <pit...@world.std.com>
Date: 1999/07/01
Subject: Re: Indentation

This is cute but not a fair example.

English is optimized to have topic sentences in paragraphs.  You can read
the topic sentence and know whether you want to read the other sentences.
At least, when paragraphing is done right.  It is possible to use bad
style in any language.

English also breaks on sentence boundaries that are clearly marked and
does not employ serious nesting--in fact it has rules that work to
make you have to form a new sentence rather than run on except when
the run-on is a tail-call, that is, a subordinate clause or apositive
expression that can be understood in isolation without referring back
structurally, as happens a lot in this sentence.  English with no periods
or commas is more like unground code--losing much of the differentiation
that makes it possible to skim instead of read linearly.

[If you don't know what "unground" means, it means "not pretty printed".
In early Maclisp, years ago, the pretty printer was not very reliable
and there was a function GRIND (named after a meat grinder, I think) that
was willing to try to read a file and pretty-print it back.  It didn't
always come out better for the process, so the name was apt.  Pretty
printing your code was in Maclisp called "grinding your code".]

> It's certainly not *impossible* to read this without any
> indentation. But it's pretty unpleasant. Here's a quick
> test.

>   - What is the role of ITEM in line 4? Function being called,
>     variable being bound, or something else? [etc]

All that you can conclude from questions like this is that if you mess
up the formatting then it's harder to read.  With English, as
with Lisp, grinding your text makes certain relationships more
apparent but makes the text take up more room.  On the other
hand, if you fail to grind your
English, then it doesn't become unreadable, like it does in Lisp.

All that you can conclude from questions like this
 is that
     if you mess up the formatting
     then it's harder to read.
   With English,
as with Lisp,
 grinding your text
     makes certain relationships more apparent
 but makes the text take up more room.
On the other hand,
  if you fail to grind your English,
  then      it doesn't become unreadable,
       like it does in Lisp.

The ANSI CL source is full of weird formattings like this, btw.  It
helped me catch innumerable numbers of errors in parallel construction
because my visual hardware was able to capture what reading could not.
So to some degree the difference isn't in the language, in this case,
nor even the task, but in the convention.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marco Antoniotti  
View profile  
 More options Jul 1 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Marco Antoniotti <marc...@copernico.parades.rm.cnr.it>
Date: 1999/07/01
Subject: Re: Indentation

I *HATE* the space after '(' and the one before ')'.  :)

Let's have a PARENTHESIS fight! :)

Cheers

--
Marco Antoniotti ===========================================
PARADES, Via San Pantaleo 66, I-00186 Rome, ITALY
tel. +39 - 06 68 10 03 17, fax. +39 - 06 68 80 79 26
http://www.parades.rm.cnr.it/~marcoxa


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gareth McCaughan  
View profile  
 More options Jul 1 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Gareth McCaughan <Gareth.McCaug...@pobox.com>
Date: 1999/07/01
Subject: Re: Indentation

Kent Pitman wrote:
[I wrote:]
>> (defun knapsack0 (annotated-set bound min trunc) (when (or (null
>> annotated-set) (<= bound trunc)) (return-from knapsack0 (values nil
>> 0))) (let* ((first-item (car annotated-set)) (remaining-set (cdr ...

> This is cute but not a fair example.

[SNIP: the role of punctuation etc in English]

I'm not sure why that makes what I wrote "not a fair example".
Josef was seriously claiming that indentation in code is useless.
I posted some unindented code and gave some evidence that it
would have been helped by indentation. I don't understand what's
unfair.

(Almost certainly it's I who am missing something here.)

>                                                   English with no periods
> or commas is more like unground code--losing much of the differentiation
> that makes it possible to skim instead of read linearly.

I thought that was exactly what I was claiming.

>> It's certainly not *impossible* to read this without any
>> indentation. But it's pretty unpleasant. Here's a quick
>> test.

>> - What is the role of ITEM in line 4? Function being called,
>> variable being bound, or something else? [etc]

> All that you can conclude from questions like this is that if you mess
> up the formatting then it's harder to read.

I thought that was exactly what I was claiming.

--
Gareth McCaughan            Dept. of Pure Mathematics & Math. Statistics,
Gareth.McCaug...@pobox.com  Cambridge University, England.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Jul 1 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 1999/07/01
Subject: Re: Indentation
* Marco Antoniotti <marc...@copernico.parades.rm.cnr.it>
| Let's have a PARENTHESIS fight! :)

  your parens wear army boots!

#:Erik
--
@1999-07-22T00:37:33Z -- pi billion seconds since the turn of the century


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Hrvoje Niksic  
View profile  
 More options Jul 1 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Hrvoje Niksic <hnik...@srce.hr>
Date: 1999/07/01
Subject: Re: Indentation

Tom Breton <t...@world.std.com> writes:
> Hrvoje Niksic <hnik...@srce.hr> writes:

> > I'm not aware of a canonical description, so I'll try to describe
> > what Emacs does.  There are several cases.

> > * Nesting with one word following open paren; indent by one space
> >   relative to the paren.
> [...]
> > * Nesting with several words following open paren indent; indent by as
> >   much as the first word takes up.

> I sense the beginning of a one-true-indentation-style war.

Why?  The question was about the common Lisp indentations (what a bad
pun!) and I simply tried to provide a fair answer.

> FWIW, Emacs doesn't do that with me, because my lisp hook sets
>   ( setq lisp-indent-offset 2 ) ;;Indent more comfortably.

OK, I should have said "what Emacs does by default."  Happy?

(And parens between after the opening and before the closing paren are
horrible! :-) )


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kent M Pitman  
View profile  
 More options Jul 1 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Kent M Pitman <pit...@world.std.com>
Date: 1999/07/01
Subject: Re: Indentation

Gareth McCaughan <Gareth.McCaug...@pobox.com> writes:
> (Almost certainly it's I who am missing something here.)

Oh, not necessarily.  Might be me.  Sounds like I misinterpreted your
intent.

The basic point I was answering was probably in earlier messages, where
there were assertions that Lisp and English were different, and I thought
it was being proposed that indentation was part of the difference, and that
showing that it didn't work without was an illustration of that.  It was
a long thread and I admit I was skimming.

Sounds like we're not in disagreement on this.  Thanks for the clarification.

> > All that you can conclude from questions like this is that if you mess
> > up the formatting then it's harder to read.

> I thought that was exactly what I was claiming.

Ah, ok.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stig Hemmer  
View profile  
 More options Jul 1 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Stig Hemmer <s...@pvv.ntnu.no>
Date: 1999/07/01
Subject: Re: Indentation
r...@nightfly.apk.net (R. Matthew Emerson) writes:

> If you want others to be able to read your code, you have to conform
> to the standard indenting conventions.  Debate is pointless.  You will
> lose big if you refuse to indent your code in the canonical way.

I feel that this is a bit strong.

I mean, consider:

(defun wobble (x)
  (if (> x 0)
      'positive
    'not-positive))

(defun wobble (x)
  (if (> x 0)
      'positive
      'not-positive))

(defun wobble (x)
  (if (> x 0)
    'positive
    'not-positive))

or even

(defun wobble (x)
        (if (> x 0)
                'positive
                'not-positive))

All these are very readable.  You might stumble for a second if you
are used to a different scheme, but nothing more than that.

However, what is _not_ OK is to not indent at all.  That makes code
unreadable for most of us.  Indent early, indent often.

Stig Hemmer,
Jack of a Few Trades.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Duane Rettig  
View profile  
 More options Jul 1 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Duane Rettig <du...@franz.com>
Date: 1999/07/01
Subject: Re: Indentation

Stig Hemmer <s...@pvv.ntnu.no> writes:
> r...@nightfly.apk.net (R. Matthew Emerson) writes:
> > If you want others to be able to read your code, you have to conform
> > to the standard indenting conventions.  Debate is pointless.  You will
> > lose big if you refuse to indent your code in the canonical way.

> I feel that this is a bit strong.

It is only strong to the extent that you place strength in the
word "conform".  If to you it means to be exactly alike, then it
is of course strong.

However, this thread has not been about "the one, true indentation
style" (in fact, attempts to bring that into the picture were quickly
and appropriately laughed down; perhaps the attempts themselves were
jokes).  Rather, this thread has been about making some effort - any
effort - to make code as readable as possible.

Yes, they are readable, and thus "conform" even though they are not
identical.  

> However, what is _not_ OK is to not indent at all.  That makes code
> unreadable for most of us.  Indent early, indent often.

Precisely.

> Stig Hemmer,
> Jack of a Few Trades.

--
Duane Rettig          Franz Inc.            http://www.franz.com/ (www)
1995 University Ave Suite 275  Berkeley, CA 94704
Phone: (510) 548-3600; FAX: (510) 548-8253   du...@Franz.COM (internet)

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Breton  
View profile  
 More options Jul 1 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Tom Breton <t...@world.std.com>
Date: 1999/07/01
Subject: Re: Indentation

Hrvoje Niksic <hnik...@srce.hr> writes:
> Tom Breton <t...@world.std.com> writes:

> > FWIW, Emacs doesn't do that with me, because my lisp hook sets
> >   ( setq lisp-indent-offset 2 ) ;;Indent more comfortably.

> OK, I should have said "what Emacs does by default."  Happy?

FWIW means "For what it's worth", which is to say, here comes a
tangential comment you may not neccessarily value.

> (And parens between after the opening and before the closing paren are
> horrible! :-) )

It's advice I got from Code Complete some years ago: Use whitespace
liberally to improve legibility.  Whitespace is cheap these days.

--
Tom Breton, http://world.std.com/~tob
Ugh-free Spelling (no "gh") http://world.std.com/~tob/ugh-free.html


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Breton  
View profile  
 More options Jul 1 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Tom Breton <t...@world.std.com>
Date: 1999/07/01
Subject: Re: Indentation

Indeed, my first reaction was "Why'd he write the same exact thing 3
times?"  The 4th is more obviously different, but still easily the
same code.

> (defun wobble (x)
>         (if (> x 0)
>                 'positive
>                 'not-positive))

--
Tom Breton, http://world.std.com/~tob
Ugh-free Spelling (no "gh") http://world.std.com/~tob/ugh-free.html

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marco Antoniotti  
View profile  
 More options Jul 2 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Marco Antoniotti <marc...@copernico.parades.rm.cnr.it>
Date: 1999/07/02
Subject: Re: Indentation

Just to be very annoying :) I claim that example 4 is disgusting.
The VI+tab indentation style - i.e. without any reference to actual
code structure - irks me :)  As a matter of fact you see *a lot* of C
code formatted that way.

Cheers

--
Marco Antoniotti ===========================================
PARADES, Via San Pantaleo 66, I-00186 Rome, ITALY
tel. +39 - 06 68 10 03 17, fax. +39 - 06 68 80 79 26
http://www.parades.rm.cnr.it/~marcoxa


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fernando Mato Mira  
View profile  
 More options Jul 2 1999, 3:00 am
Newsgroups: comp.lang.lisp
From: Fernando Mato Mira <matom...@iname.com>
Date: 1999/07/02
Subject: Re: Indentation

Marco Antoniotti wrote:
> code structure - irks me :)  As a matter of fact you see *a lot* of C
> code formatted that way.

C'mon. Why don't you just say you hate people that use more than 2 spaces as
indentation tab? ;->

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 26 - 50 of 54 < Older  Newer >
« Back to Discussions « Newer topic     Older topic »