From: Christian Lynbech
Subject: Indentation question
Date: 
Message-ID: <ofoflno1hw.fsf@chl.ted.dk.eu.ericsson.se>
I have the following form (repeated first without linebreaks) in my
code, and I am unsure how to best break it to fit within 80
characters.

(defparameter sp-big-endian (not (member (cdr (assoc :data-syntax swguile-properties)) '(:transputer :intel) :test #'equal)) "true if data is big endian")

The code may not be very pretty, but it seems rather typical of the
indentation problems I keep running into, and I am always trying to
educate myself on style, which is why I want to call upon the powers
of the experienced.

One option could be:

(defparameter sp-big-endian (not (member (cdr (assoc :data-syntax 
						     swguile-properties)) 
					 '(:transputer :intel) 
					 :test #'equal))
  "true if data is big endian")

and another one could be

(defparameter sp-big-endian (not (member 
				  (cdr (assoc :data-syntax swguile-properties))
				  '(:transputer :intel) 
				  :test #'equal))
  "true if data is big endian")

I kind of favor the latter, since it has all arguments to `member' in
the same way and it seems to me that the former has a kind of gap in
the second line with the long stretch of white space with something at
its end. The latter layout is more blockish to my eyes.

Any opinions or suggestions are welcome.


------------------------+-----------------------------------------------------
Christian Lynbech       | Ericsson Telebit, Skanderborgvej 232, DK-8260 Viby J
Phone: +45 8938 5244    | email: ·················@ted.ericsson.dk
Fax:   +45 8938 5101    | web:   www.ericsson.com
------------------------+-----------------------------------------------------
Hit the philistines three times over the head with the Elisp reference manual.
                                        - ·······@hal.com (Michael A. Petonic)

From: Bulent Murtezaoglu
Subject: Re: Indentation question
Date: 
Message-ID: <871yijwfqn.fsf@nkapi.internal>
>>>>> "CL" == Christian Lynbech <·················@ted.ericsson.dk> writes:
[on indenting long lines to fit 80 col]

I like your second one:

(defparameter sp-big-endian (not (member 
				  (cdr (assoc :data-syntax swguile-properties))
				  '(:transputer :intel) 
				  :test #'equal))
  "true if data is big endian")

if it fits to whatever column size I am using.  But I also do sth. like:

(defparameter  sp-big-endian 
                 (not (member 
                       (cdr (assoc :data-syntax swguile-properties))
                       '(:transputer :intel) 
                       :test #'equal))
  "true if data is big endian")

; I may have screwed up the tab/space but the main thing is the line break 
; after sp-big-endian

I usually start doing things like that once the column size becomes
uncofortably wide for me after several resizes (maybe around 100+).  I
dislike being forced (even if semi-consciously) to shorten the names I
use because the hairy stuff that follows would be pushed too far, so
for me inserting the line break after sp-big-endian tends to be the
best solution.  But then again I seem to let lambda lists wrap w/o
even giving it a thought probably because if they are that long, they
most likely contain keywords and I don't _really_ need to read them.

I would like to hear how others do things also.

cheers,

BM
From: Kenny Tilton
Subject: Re: Indentation question
Date: 
Message-ID: <3C0489AD.BA122DF8@nyc.rr.com>
(defparameter sp-little-endian
  (member (cdr (assoc :data-syntax swguile-properties))
          '(:transputer :intel)
          :test #'equal))
  "true if data is big endian")

kenny
clinisys

Christian Lynbech wrote:
> 
> I have the following form (repeated first without linebreaks) in my
> code, and I am unsure how to best break it to fit within 80
> characters.
> 
> (defparameter sp-big-endian (not (member (cdr (assoc :data-syntax swguile-properties)) '(:transputer :intel) :test #'equal)) "true if data is big endian")
> 
> The code may not be very pretty, but it seems rather typical of the
> indentation problems I keep running into, and I am always trying to
> educate myself on style, which is why I want to call upon the powers
> of the experienced.
> 
> One option could be:
> 
> (defparameter sp-big-endian (not (member (cdr (assoc :data-syntax
>                                                      swguile-properties))
>                                          '(:transputer :intel)
>                                          :test #'equal))
>   "true if data is big endian")
> 
> and another one could be
> 
> (defparameter sp-big-endian (not (member
>                                   (cdr (assoc :data-syntax swguile-properties))
>                                   '(:transputer :intel)
>                                   :test #'equal))
>   "true if data is big endian")
> 
> I kind of favor the latter, since it has all arguments to `member' in
> the same way and it seems to me that the former has a kind of gap in
> the second line with the long stretch of white space with something at
> its end. The latter layout is more blockish to my eyes.
> 
> Any opinions or suggestions are welcome.
> 
> ------------------------+-----------------------------------------------------
> Christian Lynbech       | Ericsson Telebit, Skanderborgvej 232, DK-8260 Viby J
> Phone: +45 8938 5244    | email: ·················@ted.ericsson.dk
> Fax:   +45 8938 5101    | web:   www.ericsson.com
> ------------------------+-----------------------------------------------------
> Hit the philistines three times over the head with the Elisp reference manual.
>                                         - ·······@hal.com (Michael A. Petonic)
From: Bruce Hoult
Subject: Re: Indentation question
Date: 
Message-ID: <bruce-BFB78E.19571628112001@news.paradise.net.nz>
In article <·················@nyc.rr.com>, Kenny Tilton 
<·······@nyc.rr.com> wrote:

> (defparameter sp-little-endian
>   (member (cdr (assoc :data-syntax swguile-properties))
>           '(:transputer :intel)
>           :test #'equal))
>   "true if data is big endian")

a) it's not what he asked for

b) you've introduced a bug
From: Kenny Tilton
Subject: Re: Indentation question
Date: 
Message-ID: <3C048FB5.2713B8BA@nyc.rr.com>
Bruce Hoult wrote:
> 
> In article <·················@nyc.rr.com>, Kenny Tilton
> <·······@nyc.rr.com> wrote:
> 
> > (defparameter sp-little-endian
> >   (member (cdr (assoc :data-syntax swguile-properties))
> >           '(:transputer :intel)
> >           :test #'equal))
> >   "true if data is big endian")
> 
> a) it's not what he asked for

sure it is, he asked about indentation, it is how I would indent such a
thing. and i stand by the implicit suggestion that the NOT be lost,
though I gather that may not be possible from...

> 
> b) you've introduced a bug

I had a feeling. :)

btw, why must the test be #'equal?

kenny
clinisys
From: Coby Beck
Subject: Re: Indentation question
Date: 
Message-ID: <e00N7.129467$Yb.34105057@typhoon.tampabay.rr.com>
"Christian Lynbech" <·················@ted.ericsson.dk> wrote in message
···················@chl.ted.dk.eu.ericsson.se...
>
> I have the following form (repeated first without linebreaks) in my
> code, and I am unsure how to best break it to fit within 80
> characters.
>
> (defparameter sp-big-endian (not (member (cdr (assoc :data-syntax
swguile-properties)) '(:transputer :intel) :test #'equal)) "true if data is big
endian")
>
> The code may not be very pretty, but it seems rather typical of the
> indentation problems I keep running into, and I am always trying to
> educate myself on style, which is why I want to call upon the powers
> of the experienced.
>
> One option could be:
>
> (defparameter sp-big-endian (not (member (cdr (assoc :data-syntax
>      swguile-properties))
> '(:transputer :intel)
> :test #'equal))
>   "true if data is big endian")
>
> and another one could be
>
> (defparameter sp-big-endian (not (member
>   (cdr (assoc :data-syntax swguile-properties))
>   '(:transputer :intel)
>   :test #'equal))
>   "true if data is big endian")
>

(defparameter sp-big-endian
  (not (member (cdr (assoc :data-syntax swguile-properties))
                       '(:transputer :intel)
                       :test #'equal))
  "true if data is big endian")

I guess....I would never have anything to the left of the opening paren of its
enclosing expression (as your two versions do)

--
Coby
(remove #\space "coby . beck @ opentechgroup . com")
From: Bruce Hoult
Subject: Re: Indentation question
Date: 
Message-ID: <bruce-7337BE.19405828112001@news.paradise.net.nz>
In article <··············@chl.ted.dk.eu.ericsson.se>, Christian 
Lynbech <·················@ted.ericsson.dk> wrote:

> I have the following form (repeated first without linebreaks) in my
> code, and I am unsure how to best break it to fit within 80
> characters.
> 
> (defparameter sp-big-endian (not (member (cdr (assoc :data-syntax 
> swguile-properties)) '(:transputer :intel) :test #'equal)) "true if data 
> is big endian")

(defparameter sp-big-endian
  (not (member
        (cdr (assoc :data-syntax swguile-properties))
        '(:transputer :intel)
        :test #'equal))
  "true if data is big endian")

-- Bruce
From: Vassil Nikolov
Subject: Re: Indentation question
Date: 
Message-ID: <u4rne4405.fsf@eskimo.com>
    On Wed, 28 Nov 2001 07:25:47 +0100, Christian Lynbech <·················@ted.ericsson.dk> said:

    [on splitting this form into several lines:]

    Christian> (defparameter sp-big-endian (not (member (cdr (assoc :data-syntax swguile-properties)) '(:transputer :intel) :test #'equal)) "true if data is big endian")

In general, in such cases you could:

(1) pretty-print your DEFPARAMETER form and see how you like that
    indentation;

(2) define a function (here of one argument, the properties a-list)
    that does what the initform does, and make the latter just a
    call to that function---much shorter.

As an aside:

* maybe you want asterisks around the name of the variable (and
  also around SWGUILE-PROPERTIES), and maybe a trailing -P;

* it doesn't look like you need EQUAL for the test;

* if another little-endian type of processor comes onto the scene,
  there is nothing to warn you if you forget to update the list
  (which perhaps at least deserves a separate variable (or
  constant) to hold it).

---Vassil.
From: Kenny Tilton
Subject: Re: Indentation question
Date: 
Message-ID: <3C05D185.29176889@nyc.rr.com>
Vassil Nikolov wrote:
> * if another little-endian type of processor comes onto the scene,

Good points. Howsabout:

(defparameter *sp-swguile-data-syntax-endian*
  (or (cdr (assoc (cdr (assoc :data-syntax swguile-properties))
                  '((:transputer . :little)
                    (:intel . :little))))
      (break "*sp-endian* unspecified for swguile data-syntax ~a" ))
  "endian (:big or :little) of swguile data-syntax")