Dangling Closing Parentheses vs. Stacked Closing Parentheses 
Author Message
 Dangling Closing Parentheses vs. Stacked Closing Parentheses

Hello,

I have found myself caught in a "discussion" on
the ICAD User's Group mailing list (as most of you
probably know, ICAD/IDL language is a superset of
CL implemented on Allegro CL, used for knowledge-based
engineering mostly in automotive and aerospace
industries).

The person on the other end of the "discussion" is attempting
to defend the use of dangling parentheses, like this:

   ... )
      )
    )
  )

instead of "stacked" (or "clumped" as he puts it), which I
am making a case is the defacto standard for formatting CL,
like this:

    ))))

The "discussion" has started going around in circles -- he gives his
many reasons ("things are easier to insert" "it is closer to other
languages like C and C++" etc.), but most of all his main claim
is that there is no "official standard" which says parens are to
be stacked like this in Lisp, so he will write his code as he
pleases, thank you very much.

Of course I am not too concerned with what this guy does personally,
but I am concerned about the impressions on the dozens or hundreds
of other ICAD/IDL users on the mailing list, many of whom are
rather naive and/or inexperienced about CL outside the context
of ICAD/IDL and might be easily misled.

I referenced the CL FAQ which does mention it ("Don't leave a paren
by itself on a line -- you will annoy programmers who grew up
in Lisp")

But despite copious examples (all published Lisp texts, etc.) the
FAQ is the only explicit reference I have come across, and apparently
this is insufficient for him.

The fact that virtually all published texts do not dangle parens he
dismisses as "well, that's for published books where the code is
printed in hardcopy and never has to be changed."

If necessary I do have permission to cross-post some of our "discussion"
here on c.l.l, but it would largely be noise for this audience. What would
be nice though, would be some explicit reference to a reasonably authoritative
statement about formatting conventions which supports the "stacked closing
parens" style.

Failing that, some good objective arguments as to why the stacked style
is preferable, both for readability and writability, would be welcomed.

Thanks,

Yours,

 -dave

--
David J. Cooper Jr, Chief Engineer      Genworks International

(248) 932-2512 (Genworks HQ/voicemail)  West Bloomfield, MI 48322-2268
(248) 407-0633 (pager)                   http://www.*-*-*.com/



Tue, 10 Sep 2002 03:00:00 GMT  
 Dangling Closing Parentheses vs. Stacked Closing Parentheses
Lets have the compiler send an email to the X3J13 police, where it can be
corrected with immediate and overwhelming force.
Quote:

> Hello,

> I have found myself caught in a "discussion" on
> the ICAD User's Group mailing list (as most of you
> probably know, ICAD/IDL language is a superset of
> CL implemented on Allegro CL, used for knowledge-based
> engineering mostly in automotive and aerospace
> industries).

> The person on the other end of the "discussion" is attempting
> to defend the use of dangling parentheses, like this:

>    ... )
>       )
>     )
>   )

> instead of "stacked" (or "clumped" as he puts it), which I
> am making a case is the defacto standard for formatting CL,
> like this:

>     ))))

> The "discussion" has started going around in circles -- he gives his
> many reasons ("things are easier to insert" "it is closer to other
> languages like C and C++" etc.), but most of all his main claim
> is that there is no "official standard" which says parens are to
> be stacked like this in Lisp, so he will write his code as he
> pleases, thank you very much.

> Of course I am not too concerned with what this guy does personally,
> but I am concerned about the impressions on the dozens or hundreds
> of other ICAD/IDL users on the mailing list, many of whom are
> rather naive and/or inexperienced about CL outside the context
> of ICAD/IDL and might be easily misled.

> I referenced the CL FAQ which does mention it ("Don't leave a paren
> by itself on a line -- you will annoy programmers who grew up
> in Lisp")

> But despite copious examples (all published Lisp texts, etc.) the
> FAQ is the only explicit reference I have come across, and apparently
> this is insufficient for him.

> The fact that virtually all published texts do not dangle parens he
> dismisses as "well, that's for published books where the code is
> printed in hardcopy and never has to be changed."

> If necessary I do have permission to cross-post some of our "discussion"
> here on c.l.l, but it would largely be noise for this audience. What would
> be nice though, would be some explicit reference to a reasonably authoritative
> statement about formatting conventions which supports the "stacked closing
> parens" style.

> Failing that, some good objective arguments as to why the stacked style
> is preferable, both for readability and writability, would be welcomed.

> Thanks,

> Yours,

>  -dave

> --
> David J. Cooper Jr, Chief Engineer      Genworks International

> (248) 932-2512 (Genworks HQ/voicemail)  West Bloomfield, MI 48322-2268
> (248) 407-0633 (pager)                  http://www.genworks.com



Wed, 11 Sep 2002 03:00:00 GMT  
 Dangling Closing Parentheses vs. Stacked Closing Parentheses

[...]

Quote:
> The person on the other end of the "discussion" is attempting
> to defend the use of dangling parentheses, like this:

>    ... )
>       )
>     )
>   )

[...]

     "He who enters into a dispute with a fool can rest assured his
     opponent has done the same."

                              -- ???

Don't won't waste your time on this guy if you can help it. As for his
insertion-speed argument: I'm guessing the Autolisp IDE doesn't have
the s-expression killing, transposing, rapid-navigation, etc.
facilities of Emacs. If you really want to spend your time on pinning
him down and nailing him, you could try getting specific and asking
for concrete examples of why <dangling-whatever> is faster, then put
the smack down and show him how it's done with Emacs.

Christopher



Wed, 11 Sep 2002 03:00:00 GMT  
 Dangling Closing Parentheses vs. Stacked Closing Parentheses

Quote:

>Don't won't waste your time on this guy if you can help it. As for his
>insertion-speed argument: I'm guessing the Autolisp IDE doesn't have
>the s-expression killing, transposing, rapid-navigation, etc.
>facilities of Emacs. If you really want to spend your time on pinning
>him down and nailing him, you could try getting specific and asking
>for concrete examples of why <dangling-whatever> is faster, then put
>the smack down and show him how it's done with Emacs.

ICAD/IDL is not using the AutoLISP IDE. They use the Allegro CL IDE
(not emacs obviously)

The AutoLISP IDE has these above mentioned features: s-expression
killing, transposing, rapid-navigation, etc.
and three closing paren styles:
  1) close at the same line (as in CL)
  2) close at new line with inner indentation (as in emacs)
  3) close at new line with outer indentation (as in typical autolisp
code as well as in david's sample)

coding conventions in various communities differ largely and this is NOT
based on the available tools. (though emacs require 'paren helps of
course)
  emacs supports 1 and 2 and much more by customization,
  VLISP supports just those 3 above, forgot about the ACL IDE now.

the more experience you have the briefer you get.
people without proper editors of course are doomed to use style 3 as
most of non-lisp folks also do. nothing against this style.
I also do it very often so that newbies can read it.

arguments:
brevity needs less scrolling. the more context you see in one page the
more you understand. the problems gets simplier to grasp.

indented closing parens as in algol-like languages are better readable
for the general non-lisp programmer and newbie.
horizontal structures seem to be less important than vertical blocks for
the unexperienced. hmm...
you can also insert and delete easier.

--
Reini Urban
http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.html



Wed, 11 Sep 2002 03:00:00 GMT  
 Dangling Closing Parentheses vs. Stacked Closing Parentheses
An argument can be most easily settled if you manage
to find a case where you can agree with your opponent.

(with-shields-raised
  Myself, I take the risk of being flamed by fundamentalist `stackers' on some
rare
  occassions where I think dangling is the appropriate thing to do, eg:

  ) ; end of eval-when

  ) ; end of progn

  wrapping top-level definitions

  or cases like:

  (declaim (special *foo*
                            ...
                           *bar*
               ))

  and even

  (defstruct
     slot1  ; comment 1
    ...
     slotn  ; comment n
   )

  on things that start getting prone to extension.
  ) ;)

--
Fernando D. Mato Mira
Real-Time SW Eng & Networking
Advanced Systems Engineering Division
CSEM
Jaquet-Droz 1                   email: matomira AT acm DOT org
CH-2007 Neuchatel                 tel:       +41 (32) 720-5157
Switzerland                       FAX:       +41 (32) 720-5720

www.csem.ch      www.vrai.com     ligwww.epfl.ch/matomira.html



Wed, 11 Sep 2002 03:00:00 GMT  
 Dangling Closing Parentheses vs. Stacked Closing Parentheses


Quote:
> The person on the other end of the "discussion" is attempting
> to defend the use of dangling parentheses, like this:
[...]
> The "discussion" has started going around in circles -- he gives his
> many reasons ("things are easier to insert" "it is closer to other
> languages like C and C++" etc.), but most of all his main claim

The fact that the dangling parentheses convention is closer to other
languages like C and C++ may be a good reason not to use it :)

Paolo
--
EncyCMUCLopedia * Extensive collection of CMU Common Lisp documentation
http://cvs2.cons.org:8000/cmucl/doc/EncyCMUCLopedia/



Wed, 11 Sep 2002 03:00:00 GMT  
 Dangling Closing Parentheses vs. Stacked Closing Parentheses
* David J. Cooper
| The "discussion" has started going around in circles -- he gives his many
| reasons ("things are easier to insert" "it is closer to other languages
| like C and C++" etc.), but most of all his main claim is that there is no
| "official standard" which says parens are to be stacked like this in
| Lisp, so he will write his code as he pleases, thank you very much.

  you can't argue for _or_ against excessive whitespace on these grounds.
  at issue is the relative importance of the delimiters.  in C, the block
  structure is very important and the visual clues in indentation are not
  sufficiently perspicuous that they can be trusted for anything, so { and
  } delimiters get extremely visually apparent formatting characteristics,
  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.

  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.

  community standards grow out of such pragmatic optimization parameters,
  and can't _actually_ be defended by reference to authority, because one
  has to trust the authority to be representative of the community.  one
  must instead seek to understand how they got the way they are, and why
  there may be minority and majority communities, as well.  (a community of
  one may be a brilliant loner or a nutcase, and it's hard to tell which is
  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.

#:Erik



Thu, 12 Sep 2002 03:00:00 GMT  
 Dangling Closing Parentheses vs. Stacked Closing Parentheses

Quote:

> Of course I am not too concerned with what this guy does personally,
> but I am concerned about the impressions on the dozens or hundreds
> of other ICAD/IDL users on the mailing list, many of whom are
> rather naive and/or inexperienced about CL outside the context
> of ICAD/IDL and might be easily misled.

Ask what style of C layout he uses. If he goes for things like

if (foo)
{
   stuff

Quote:
}

else
{
   whatever

Quote:
}

instead

of

if (foo) {
  stuff

Quote:
} else {
  whatever
}

that should pretty much discredit him as a newbie loser in a C-oriented context

Quote:
>:-I

--
Fernando D. Mato Mira
Real-Time SW Eng & Networking
Advanced Systems Engineering Division
CSEM
Jaquet-Droz 1                   email: matomira AT acm DOT org
CH-2007 Neuchatel                 tel:       +41 (32) 720-5157
Switzerland                       FAX:       +41 (32) 720-5720

www.csem.ch      www.vrai.com     ligwww.epfl.ch/matomira.html



Thu, 12 Sep 2002 03:00:00 GMT  
 Dangling Closing Parentheses vs. Stacked Closing Parentheses

Quote:

> ICAD/IDL is not using the AutoLISP IDE. They use the Allegro CL IDE
> (not emacs obviously)

 Actually we do use Emacs, with customizations for indenting, colorizing,
etc. of ICAD/IDL (defpart) code. We use a (pretty nice) CLX-based thing
called "the ICAD Browser" for inspecting objects and drawing geometry,
etc.

 In general we don't use the Allegro CL IDE.

Yours,

-dave

--
David J. Cooper Jr, Chief Engineer      Genworks International

(248) 932-2512 (Genworks HQ/voicemail)  West Bloomfield, MI 48322-2268
(248) 407-0633 (pager)                  http://www.genworks.com



Thu, 12 Sep 2002 03:00:00 GMT  
 Dangling Closing Parentheses vs. Stacked Closing Parentheses

Quote:

>      "He who enters into a dispute with a fool can rest assured his
>      opponent has done the same."

You're right -- but saying nothing when someone is spewing potentially
misleading opinions has its disadvantages too (sometimes even at the risk
of seeming foolish). Anyway i think both sides agree that we've pretty
much milked this "discussion" dry, so unless there are any major revelations
it is time to move on anyway.

Quote:

> Don't won't waste your time on this guy if you can help it. As for his
> insertion-speed argument: I'm guessing the Autolisp IDE doesn't have
> the s-expression killing, transposing, rapid-navigation, etc.
> facilities of Emacs.

Note that this is ICAD, not AutoCAD -- completely different kettle o' fish --
it's CL-based, nothing to do with Autolisp. Gnu Emacs is the default environment.

Thanks,

 -dave

--
David J. Cooper Jr, Chief Engineer      Genworks International

(248) 932-2512 (Genworks HQ/voicemail)  West Bloomfield, MI 48322-2268
(248) 407-0633 (pager)                  http://www.genworks.com



Thu, 12 Sep 2002 03:00:00 GMT  
 Dangling Closing Parentheses vs. Stacked Closing Parentheses

Quote:
> The AutoLISP IDE has these above mentioned features: s-expression
> killing, transposing, rapid-navigation, etc.
> and three closing paren styles:
>   1) close at the same line (as in CL)
>   2) close at new line with inner indentation (as in emacs)
>   3) close at new line with outer indentation (as in typical autolisp
> code as well as in david's sample)

So even the AutoLISP IDE seems to not-discourage one-closing-paren-per-line.
So is it really such a bad thing to use this layout?

Quote:
> arguments:
> brevity needs less scrolling. the more context you see in one page the
> more you understand. the problems gets simplier to grasp.

> indented closing parens as in algol-like languages are better readable
> for the general non-lisp programmer and newbie.
> horizontal structures seem to be less important than vertical blocks for
> the unexperienced. hmm...
> you can also insert and delete easier.

Nicely summarised!

The ICAD language we use uses some farily serious macros to turn our source
into real Lisp.  THe stuff we write to define an object is basically a long
p-list of attribute/method/aggregate names and their definitions.  Since
each definition rearly takes more than half a screenful, the problem with
scrolling vertically doesn't really occur.  The ability to insert and delete
easier saves me a great deal of time.

I am not a newbie to ICAD, as I have been writing code in ICAD full time for
the last eight years.

Cheers!

Anthony
------------------
Anthony Cartmell
Application Architect
New Design Paradigm
Worthing, England
Tel. +44 1903 201084



Fri, 13 Sep 2002 03:00:00 GMT  
 Dangling Closing Parentheses vs. Stacked Closing Parentheses

Quote:
> Ask what style of C layout he uses. If he goes for things like

> if (foo)
> {
>    stuff
> }
> else
> {
>    whatever
> }

> instead

> of

> if (foo) {
>   stuff
> } else {
>   whatever
> }

> that should pretty much discredit him as a newbie loser in a C-oriented
context
> >:-I

I use the first layout form, which happens to have been adopted as the
recommended layout for Symbian's EPOC C++ coding (the operating system
that's about to take over the world!).  I'm not sure why my C++ layout has
anything to do with Lisp layout though?

I'm actually an experienced ICAD/Lisp programmer (eight years, successful
applications released to multiple clients) and a newbie in C++.

I'm still waiting for a reason why Lisp people are so against
paren-per-line...

Cheers!

Anthony
------------------
Anthony Cartmell
Application Architect
New Design Paradigm
Worthing, England
Tel. +44 1903 201084



Fri, 13 Sep 2002 03:00:00 GMT  
 Dangling Closing Parentheses vs. Stacked Closing Parentheses

Quote:
> The fact that the dangling parentheses convention is closer to other
> languages like C and C++ may be a good reason not to use it :)

Seems to me that this really is the main reason...  is the Lisp layout
"standard" really this sad?

Cheers!

Anthony
------------------
Anthony Cartmell
Application Architect
New Design Paradigm
Worthing, England
Tel. +44 1903 201084



Fri, 13 Sep 2002 03:00:00 GMT  
 Dangling Closing Parentheses vs. Stacked Closing Parentheses


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

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

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

Does anyone know?

Cheers!

Anthony
------------------
Anthony Cartmell
Application Architect
New Design Paradigm
Worthing, England
Tel. +44 1903 201084



Fri, 13 Sep 2002 03:00:00 GMT  
 Dangling Closing Parentheses vs. Stacked Closing Parentheses
Hi there, I'm the guy you shouldn't waste time on, and I'm still interested
in
the discussion.

Quote:
>     "He who enters into a dispute with a fool can rest assured his
>     opponent has done the same."

This isn't a dispute, and neither of us are fools.  I've used my layout
style efficiently for the last eight years, having abandoned
put-all-close-parens-on-the-same line for reasons of readability and editing
speed.  David pointed out that "real Lisp programmers"(TM) frown on this
style, and I'm trying to find out why.

Quote:
> Don't won't waste your time on this guy if you can help it. As for his
> insertion-speed argument: I'm guessing the Autolisp IDE doesn't have
> the s-expression killing, transposing, rapid-navigation, etc.
> facilities of Emacs. If you really want to spend your time on pinning
> him down and nailing him, you could try getting specific and asking
> for concrete examples of why <dangling-whatever> is faster, then put
> the smack down and show him how it's done with Emacs.

I use Emacs, which as you know, has various keystrokes for cutting out
complete forms, so clumped parens are relatively easily dealt with.

Since I also find myself using vi, I find that whole-line edits are easier
than relying on Emacs tools.

Concrete example of how dangling parens makes my coding more efficient:

Insert (list 1) at the end of the form starting (list 0 ...) in the
following:

(list a
      (list b c d)
      (list 0
            (list e f g
                  (list h))))

Without careful paren-counting or an editor that will match for you, it's
tricky and error prone.  It also seems tricky to me to check that the (list
a ...) has the correct number of close parens without relying on editor
features to indicate this.

(list a
      (list b c d)
      (list 0
            (list e f g
                  (list g)
                  )
            )
      )

With this layout I can see instantly where to insert the new form.  The
insert is easy as in all editors as I only have to add a new line with the
form in it.  No editing of the existing code lines is required at all!  I
can also see straight away that the (list a...) form has balanced parens.

I would have thought that a layout style that depends on a particular type
of editor being available would be frowned upon in purist circles?

Cheers!

Anthony
------------------
Anthony Cartmell
Application Architect
New Design Paradigm
Worthing, England
Tel. +44 1903 201084



Fri, 13 Sep 2002 03:00:00 GMT  
 
 [ 206 post ]  Go to page: [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]

 Relevant Pages 

1. an xemacs func to close parentheses

2. an xemacs func to close parentheses

3. less parentheses --> fewer parentheses

4. less parentheses --> fewer parentheses

5. CW55PE release H when I close a wizard generated application the IDE closes as well

6. mdi app not closing down, some threads just won't close #2

7. Device file not closing on close command

8. to close or not to close?

9. tcl-dp confuses expect's close call with builtin close

10. close of an arbitrary stream may close *terminal-io*

11. Closed file not really closed

12. PUBKAR - parentheses not always first

 

 
Powered by phpBB® Forum Software