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
Message from discussion Dangling Closing Parentheses vs. Stacked Closing Parentheses
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
 
Duane Rettig  
View profile  
 More options Mar 28 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Duane Rettig <du...@franz.com>
Date: 2000/03/28
Subject: Re: Dangling Closing Parentheses vs. Stacked Closing Parentheses

"Anthony Cartmell" <AJCartm...@csi.com> writes:
> "Erik Naggum" <e...@naggum.no> wrote in message
> news:3163031395198264@naggum.no...
> >   such as their own lines.  in Common Lisp, the list structure is much
> less
> >   important than the indentation, and the perspicuity of normal
> indentation
> >   rules is sufficiently high that the parens are mainly used there for the
> >   machine to use, not humans.  therefore, humans would tend to get parens
> >   in CL out of the (visual) way, while the braces in C must be very
> visible.

> Sorry for the "newbie" question, but I thought that the indentation was
> based on the list structure, and not the other way round.  If the parens
> were based on the indentation then we wouldn't even need to use them.  My
> whole reason for using dangling parens in my code is to show which
> open-paren each close-paren closes by its indentation.  I don't understand
> why this is such a bad layout style.

It's because you haven't yet separated your IDL writing style from
your Lisp writing style.  In further entries on this thread, it seems
you and David Cooper are coming to an agreement, but the agreement
seems uncertain; it looks to me more like a justification to continue
doing what each of you are doing, and not to understand where the real
problem lies.  I don't know IDL (ICAD Design Language) myself, so I
asked the experts (people at KTI) and got an answer very quickly.
Results below.

> >   different languages have different optimization parameters for almost
> >   every facet of their expression.  trying to optimize CL code layout with
> >   the parameters from C is completely braindamaged and merits nothing but
> a
> >   snort, and people who are _that_ underdeveloped in their understanding
> of
> >   the differences between languages should just be sedated and put away.

> I lay my Lisp code out the way I do for the reason given above, and not
> because of any other language's layout style.

I think you are influenced in your Lisp layout style by your IDL
style, so this statement would not quite be true.  I could not have
argued this yesterday, but now that you are coming to the conclusion
that IDL is not Lisp, it's time to finish off this earlier argument.

> >   which.)  I think the need to understand how things came to be applies to
> >   everything, but retracing the steps of decisions made by large groups of
> >   people is usually quite depressing, so there is wisdom in accepting the
> >   authorities at times.  yet, accepting or rejecting authorities _because_
> >   they are authorities is really retarded and people who are prone to this
> >   should also be sedated and put away.

> Couldn't agree more.  What I'm trying to do, prompted by criticism of my
> code layout in a public place, is to find out *why* the Lisp community
> rejects one-paren-per-line apparently so strongly.  If there's a good reason
> I *may* change the coding layout I've used successfully, with others, for
> the last eight years.

Eight years sheds no light on a person's experience level.  As a musician
since childhood, I was always taught the adage "Practice makes perfect",
but never got any good until I realized that the correct version of this
adage is "Perfect practice makes perfect."  If you practice mistakes,
then you will only perfect the mistakes.  What is the mistake here?
It is the mixing of Lisp layout style with IDL layout style.

> Does anyone know?

When in doubt, ask experts.  I did, and got an answer from Stanley
Knutson of KTI, who gave me permission to post his answer.
He summarized the parenthesis question in a further email exchange
by saying:

>> As I said in the style guide, the only places where a single ) is good
>> is for closing a 'section' of the defpart.

Here is (most of) his original mail to me:

========
Duane,

Thanks for asking.  ICAD style has been hottly debated about every two years
for the last 10+ years.

ICAD Defparts have their own needs that are not reflective of general lisp
usage.
In particular, a defpart has multiple sections for each attribute
and in a normal clos program, each of those attributes would have been a
separate
top-level function.

I've attached a short style guide that I've written for our internal use.
It reflects the basic style I've been using for a while.
At one point I tried to get something like this into our class or
documentation
but it was too controversial.

- Stanley

------=_NextPart_000_0008_01BF97DF.603B6670
Content-Type: application/octet-stream;
        name="style-guide.text"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
        filename="style-guide.text"

ICAD defpart coding style suggestions

3/27/2000 Stanley Knutson

The goal is to enhance readability for large defparts
and to enable grep to find the DEFINITION of a method.

Example:

(defpart my-application (basic-application
                         base-spec-sheet-mixin
                         )
  :part-documentation
  (:description
   "Why this part is useful"

   :examples
   "This shows how to use it:
<pre>
    lisp code
</pre>
"
   )

  :inputs
  (
   :remark "child-object is required"
   :CHILD-OBJECT
   )
  ;; --------------------------------------------------
  :attributes
  (
   :remark ":fancy-width uses the child to center something else"
   :FANCY-WIDTH
   (if (the :foo)
       (if (the :bar)
           (progn
             (do-some-operation
                 with arguments)
             ))
     ;; else (not (the :foo))
     (progn
       (do something else
         )))

   ;; the :%%internal-width is an intermediate
   ;; use ;; (not :remark) since it is not in the generated documentation
   :INTERNAL-WIDTH
   (+ (the :child-object :width) 30)
   )

  ;; --------------------------------------------------
  :pseudo-parts
  (
   (:MY-CHILD
    :remark "Tell why my-child is useful.
This is given as a remark for the :type, that is how the
doc generator wants it."
    :type my-child)
   )
  ;; --------------------------------------------------
  :methods
  (
   (:INITIALIZE-OUTPUT
    (stream)
    :remark "This method writes the first bit
to the output file"
    (write-string "hi there" stream))

   ))

RULES:

1) CAPITALIZE the attribute, method and part names.
It makes them a bit easier to find,
and you can then grep for the capitalized names to find
the locations that define it.

2) Put a comment for almost evey attribute, part or method.
Use :remark if the comment should appear in the generated
reference documentation for this defpart.

3) Put a blank line between each defpart and attribute

4) The closing ) for each section of the defpart
is on a separate line,makes it easier to insert more stuff.

5) Separate the sections with ;;------ lines

6) Put the sections in this order usually:
inputs
optional-inputs
defaulted-inputs
modifiable-optional-inputs
modifiable-defaulted-inputs
modifiable-attributes
attributes
uncached-attributes
combination-attributes
parts
pseudo-parts
methods

7) the very end of the defpart can have the )) to close the last
section and the defpart on the same line.

8) Indent as per emacs ctrl-meta-q WITH THE ICAD INDENT RULES
we customize the Franz-lisp indentation rules to know about defparts.
(the lisp function is fi:indent-sexp)

9) You can group multiple closing )) on one line
but if the block is more than 5 or so lines,
add a ;; comment indicating what block is being closed.
{NOTE: exception rules #4 and #7}

10) name internal methods and defparts with %% so they don't
show up in the documentation or in the ICAD inspector by default.

11) Put one "logical unit" in a file: this usually means
just one defpart per file, with the file name the same as the defpart
name.

The exception is a set of several small closly-related functions.
In this case, they can be grouped into one file.
However, try to keep the file size under 500 lines.  
If it is much bigger than that, you've probably got more than one
group of stuff in the same file, so it merits separation
into different bits.

12) Whenever possible, group the strings that customers will
want to customized into one file of defparameters.
In particular, *think* about what the customer might want to customize.
This will make it easier to document.
In many cases (icad browser for example), we actually ship this
file as part of the reference/example documentation.

As of R7.1, we now have a 'resource string' object
and each major module of ICAD should use that as much as possible
since it allows easier customization on a per-language basis
at runtime.

------=_NextPart_000_0008_01BF97DF.603B6670--

--
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.