IF indentation styles 
Author Message
 IF indentation styles

Zmacs (as probably all of you know) indents IF statements to look
like:

  (IF (TEST-FORM)
      (THEN-FORM)
      (ELSE-FORM))

And this indentation style can be seen in all the older Lisp code I
see as well.  But GNU Emacs, contrary to other code I see, likes to
indent IF statements to look like:

  (IF (TEST-FORM)
      (THEN-FORM)
    (ELSE-FORM))

I was wondering where GNUEMA got this style from?  And why?



Tue, 26 Aug 1997 00:34:25 GMT  
 IF indentation styles

Quote:

>But GNU Emacs, contrary to other code I see, likes to
>indent IF statements to look like:

>  (IF (TEST-FORM)
>      (THEN-FORM)
>    (ELSE-FORM))

GNU Emacs Lisp allows the else-clause to be an implicit PROGN, e.g.

(if (test-form)
    (then-form)
  (else-form-1)
  (else-form-2)
  ...
  (else-form-N))

In this case, it's useful for all the else-forms to be set off from the
then-form.
--
Barry Margolin
BBN Internet Services Corp.



Tue, 26 Aug 1997 15:17:27 GMT  
 IF indentation styles

Quote:

> Zmacs (as probably all of you know) indents IF statements to look
> like:

>   (IF (TEST-FORM)
>       (THEN-FORM)
>       (ELSE-FORM))

> And this indentation style can be seen in all the older Lisp code I
> see as well.  But GNU Emacs, contrary to other code I see, likes to
> indent IF statements to look like:

>   (IF (TEST-FORM)
>       (THEN-FORM)
>     (ELSE-FORM))

> I was wondering where GNUEMA got this style from?  And why?

Because the E-Lisp syntax is actually

     (if (TEST-FORM)
         (THEN-FORM)
       (ELSE-FORM-1)
       (ELSE-FORM-2)
       ...)

the "else" clause actually being an implicit PROGN of everything after the
"then" clause.   Hence the non-uncommon E-Lisp idiom for WHEN as

    (if (not x)
        nil
      do
      lots
      of
      things)

ZetaLisp also had this "extended-else" syntax (how does Zmacs indent ZL:IF
?), and probably other older Lisp variants as well.

pch



Fri, 29 Aug 1997 21:17:53 GMT  
 IF indentation styles

Quote:

>GNU Emacs Lisp allows the else-clause to be an implicit PROGN, e.g.

>(if (test-form)
>    (then-form)
>  (else-form-1)
>  (else-form-2)
>  ...
>  (else-form-N))

If you use an explicit PROGN, the else-forms coincidentally line up
under the then-form:

(if test-form
    then-form
  (progn
    else-form-1
    ...
    else-form-N))
--

Information Handling Services           Electronic Systems Development
15 Inverness Way East, M/S A203         GO BUFFS!
Englewood CO 80112 USA                  1+ (303) 397-2807[voice]/-2779[fax]



Sat, 30 Aug 1997 06:39:14 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. REXX Indentation Style

2. Indentation style...

3. Indentation style...

4. My style to K@R Tcl style indentation tool

5. -LOOP /was Does -CELL deserve place in comus? /was Indentation Style

6. Converter Space indentation -> Tab indentation

7. Procedural style to functional style question

8. After indention styles comes loop construct styles

9. Newbie: 7210 style and 9914A style controller ??

10. Convert between Windows style paths and POSIX style paths

11. Python-style indentation for Ruby, in 8 lines of Emacs Lisp!

12. Indentation

 

 
Powered by phpBB® Forum Software