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
Dangling Closing Parentheses vs. Stacked Closing Parentheses
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 76 - 100 of 187 - 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
 
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

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

I've seen most of the style arguments based on philosophy posted
on this thread, but there is one argument I have not yet seen.
The most convincing argument for me to run with the first style is
what the lisp itself says:

user(1): (pprint '(defun build-upward-closures ()
  (loop for k from *maxplay* downto 0 do
    (setf (aref *upward-closures* k)
          (let ((result (ash 1 k)))
            (loop for i from 0 below *n* do
              (let ((k1 (logior k (ash 1 i))))
                (when (> k1 k)
                  (setf result (logior result (aref *upward-closures* k1)))
                )
              )
            )
            result
          )
    )
  )))

(defun build-upward-closures ()
  (loop for k from *maxplay* downto 0 do
        (setf (aref *upward-closures* k)
              (let ((result (ash 1 k)))
                (loop for i from 0 below *n* do
                      (let ((k1 (logior k (ash 1 i))))
                        (when (> k1 k)
                          (setf result
                                (logior result
                                        (aref *upward-closures* k1))))))
                result))))
user(2):

In general, any lisp code that can be manipulated as data is
easier to work with if it matches the result of its pretty-printed
output.  Now it is true that the pretty printer can be customized,
and thus you're not going to get exactly the same output if you
change, say, indentation rules and other attributes.  But for all of
its customizability, I know of no way to tell the pretty-printer to
dangle its closing parens.  Was this an oversight, or by design?

For Anthony Cartmell, I don't know IDL, and I've already posted
the opinion of an ICAD developer, but it seems to me that whether
or not IDL rules should allow for dangling parens should be weighed
heavily on whether or not a defpart is source-only, or whether it
is possible by any means to get hooks into the source (by way of
a code-walker, macroexpansion, or other debugging activity).  If
the former, then it doesn't matter.  If the latter, then unless
there have been extensions to ICAD's pretty-printer over CL's
printer, the intermediate forms will look "wrong", because they
will have no dangling parens.

--
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.
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:
> I'm looking for reasons for *not* using one paren per line.

I don't think that this is true.  Your list below does not
reflect what you had been given at the time of your posting.

>  So far I have:
>  1) Lisp people just don't do it, for reasons lost in the mists of time,
> probably to do with small screens.
>  2) It doesn't look nice for people who are not used to looking at that
> layout style - "visual clutter".
>  3) Errr...
>  4) that's it.

> Can anyone extend my list?

Let's start with correcttions.

The first part of #1 has to do with de-facto standards.  It is
perhaps interesting that almost every lisp programmer disagrees
on something about what lisp should be and do, especially when
dealing with style.  However, it is precisely this tendency to
disagree that makes it so blatanttly obvious when we almost
entirely agree on the issue of dangling parens.

The last part of #1 has to do with screen real estate.  Serious
question: Do you print out your lisp code on paper in order to
look at it?  Or do you have a portrait terminal instead?  Rules
of thumb in any language usually say that you shouldn't have much
more than a pagefull per function, so the question pertains to
your style of viewing code.

#2 looks more like what was said about parens giving no useful
information.  I once read some assembler code from a newbie
programmer that had learned in school that comments must be
used as much as possible.  I don't remember the architecture
that was used, but the code was unreadable because of the
clutter, e.g.

  mov count,r10  ; Move count into register R10
  add 1,r10,r10  ; Increment r10 by 1
  b L4           ; Branch to L4

This programmer's code was full of useful comments like this...

A paren, useful to a compiler should be ignorable to a programmer,
just like a comment line, (sometimes) useful to a programmer,
should be made ignorable by a compiler.  If you fail to add whatever
syntax is required to make a comment invisible to the compiler, the
compiler will barf, because it mistakes the comment for real code.
And if you fail to make parens invisible to the programmers, the
programmers barf, because they are mistaking the parens for real
code.

I will ignore your #3 and #4, and replace them with:

 3) As I posted earlier in this thread, it is the strong opinion
of the lisp that right parens should not dangle.  Just try to get
the lisp printer to print lisp forms with dangling parens; even
setting *print-right-margin* to 1 doesn't help...

 4) Whenever I see lisp code for review, I look for both algorithmic
and/or implementational bugs based on what I see in the code.  One
of the tools I use is to assess the programming level of the programmer
submitting the code.  It involves many factors, most of which are
probably subliminal.  But having thought about it for a day or so,
I can say that whenever I see dangling parens, it contributes to
one of two assessments: "newbie" or "careless".  Note that careless
can apply to me as well; I sometimes see code that I have written
previously which is sloppily formatted, and it is the assessment I
give myself as I correct it.

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

Duane Rettig <du...@franz.com> writes:
> Let's start with correcttions.

=========================^^

Heh, heh, including my own!

--
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.
Anthony Cartmell  
View profile  
 More options Mar 28 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: "Anthony Cartmell" <AJCartm...@csi.com>
Date: 2000/03/28
Subject: Re: Dangling Closing Parentheses vs. Stacked Closing Parentheses

> It's because you haven't yet separated your IDL writing style from
> your Lisp writing style.

Actually it's David who wants to format ICAD with Lisp layout rules. I use
dangling parens.

> Eight years sheds no light on a person's experience level.

Except that they have more experience than someone with one year!

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

Agreed.  I don't let any Lisp style guidelines get into my ICAD layout.
That was David's idea, and I have been trying to find out why he thought
that way.

Once we've decided that dangling close parens are
1) Good for long shallow lists, to allow easy insertion of items, and
2) Bad for short deep lists, because they take up too much space and don't
provide any benefit,
the required rules for ICAD seem obvious to me.  There is some tweaking
possible of course, but the statement that "dangling parens are bad" really
doesn't apply to ICAD code.

I've put together some layout examples of some typical ICAD code for anyone
interested at
http://ourworld.compuserve.com/homepages/AJCartmell/icadparens.html .

Thanks for your comments!

Anthony
------------------
Anthony Cartmell
Application Architect
New Design Paradigm
Worthing, England
Tel. +44 1903 201084
E-mail: AJCartm...@csi.com


 
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.
Anthony Cartmell  
View profile  
 More options Mar 28 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: "Anthony Cartmell" <AJCartm...@csi.com>
Date: 2000/03/28
Subject: Re: Dangling Closing Parentheses vs. Stacked Closing Parentheses

> For Anthony Cartmell, I don't know IDL, and I've already posted
> the opinion of an ICAD developer, but it seems to me that whether
> or not IDL rules should allow for dangling parens should be weighed
> heavily on whether or not a defpart is source-only, or whether it
> is possible by any means to get hooks into the source (by way of
> a code-walker, macroexpansion, or other debugging activity).  If
> the former, then it doesn't matter.  If the latter, then unless
> there have been extensions to ICAD's pretty-printer over CL's
> printer, the intermediate forms will look "wrong", because they
> will have no dangling parens.

ICAD is pretty much source-only (if I understand what you mean about being
able to print the thing to re-generate the source), as the real lisp code is
generated by the compiler from some fairly hefty macros, the main one being
defpart.  As far as I know there is no way to generate the code for a
defpart created object from the Lisp object itself.  You can view the code
in the ICAD browser but think that is done by storing fragments of source,
and I seem to remember it keeps the original layout.  I may be wrong, it's
never seemed to me a very useful thing to do.

ICAD is really an fairly object-oriented language that just happens to be
based on Lisp.  The basic structure of the code is proprietry, and it could
be implemented in any base language.  The only places Lisp appears are in
expressions and function definitions.

An interesting angle on the discussion, thanks!

Anthony
------------------
Anthony Cartmell
Application Architect
New Design Paradigm
Worthing, England
Tel. +44 1903 201084
E-mail: AJCartm...@csi.com


 
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.
Dorai Sitaram  
View profile  
 More options Mar 28 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: d...@goldshoe.gte.com (Dorai Sitaram)
Date: 2000/03/28
Subject: Re: Dangling Closing Parentheses vs. Stacked Closing Parentheses
In article <4u2hrgif8....@beta.franz.com>,
Duane Rettig  <du...@franz.com> wrote:

Well, the CLISP pretty-printer gives this "semi-dangled" output:

(defun build-upward-closures nil
  (loop for k from *maxplay* downto 0 do
    (setf (aref *upward-closures* k)
      (let ((result (ash 1 k)))
        (loop for i from 0 below *n* do
          (let ((k1 (logior k (ash 1 i))))
            (when (> k1 k)
              (setf result (logior result (aref *upward-closures* k1)))
        ) ) )
        result
) ) ) )

Ie, rparens are either on the same line as their
corresponding lparen, or they are clumped together on a
line of their own, where they line up (column-wise)
with an lparen above them.  But if you look closer, you
will realize with a jolt that the lparen that an rparen
lines up with is _not_ its matching lparen...  I guess
the rparens don't quite "disappear" as previous
articles advised, but they do fade into a
quantum-mechanical interchangeability, losing the
identity that we give to the more substantial parts of
the code.

(
  (
    (
) ) )

--d


 
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 Mar 28 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Gareth McCaughan <Gareth.McCaug...@pobox.com>
Date: 2000/03/28
Subject: Re: Dangling Closing Parentheses vs. Stacked Closing Parentheses
Fernando D. Mato Mira wrote:

[I said:]

It's no easier for me than the version with intervening
rparens. I think it's just a matter of the distance.

--
Gareth McCaughan  Gareth.McCaug...@pobox.com
sig under construction


 
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.
David Hanley  
View profile  
 More options Mar 28 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: David Hanley <d...@ncgr.org>
Date: 2000/03/28
Subject: Re: Dangling Closing Parentheses vs. Stacked Closing Parentheses
Without getting into a religous war, there are times when I use
dangling close paranthesis, though I am not a super lisp coder
by any means.

(defstruct person
    name     ; a string
    address ; the person's street address
    gender ; the symbol 'male or 'female if known, nil of otherwise
)

Otherwise, where does the paren go?  Before the comment?
Inconsistent.  Also, if you want to add a field, you just hop
to the end of the last field line, hit crtl-J and type away ( emacs ).
Often while editing and dubugging a function I'll leave naked
parens, then tighten them back in when I know it's perfect.

dave


 
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.
David Hanley  
View profile  
 More options Mar 28 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: David Hanley <d...@ncgr.org>
Date: 2000/03/28
Subject: Re: Dangling Closing Parentheses vs. Stacked Closing Parentheses

"Fernando D. Mato Mira" wrote:

You got it backwards.  The ones who do

if ( b ) {
  foo()
 } else {
    bar();

}

are the ones who haven't learned to program yet.

:)


 
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 Mar 28 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Tom Breton <t...@world.std.com>
Date: 2000/03/28
Subject: Re: Dangling Closing Parentheses vs. Stacked Closing Parentheses

Wow, a C true-indentation-style war here of all places!  }:)

I'm in!  I'm in!  I'll be against K&R style.

--
Tom Breton, http://world.std.com/~tob
Not using "gh" since 1997. http://world.std.com/~tob/ugh-free.html
Rethink some Lisp features, http://world.std.com/~tob/rethink-lisp/index.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.
David Hanley  
View profile  
 More options Mar 28 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: David Hanley <d...@ncgr.org>
Date: 2000/03/28
Subject: Re: Dangling Closing Parentheses vs. Stacked Closing Parentheses

Tom Breton wrote:

> Wow, a C true-indentation-style war here of all places!  }:)

> I'm in!  I'm in!  I'll be against K&R style.

Great.  But for clarity, we call that the "wrong" style.

dave


 
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.
David Hanley  
View profile  
 More options Mar 28 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: David Hanley <d...@ncgr.org>
Date: 2000/03/28
Subject: Re: Dangling Closing Parentheses vs. Stacked Closing Parentheses

I don't think this is a valid argument Humans grow up using language
from birth and have it running through their heads every second of
their lives Also computer code requires much more accuracy while
spoken words an often be muddled through and imprecise which you
know especially well if you are married

The above is parodic in nature.  You can still make out quite well
what it means with no punctuation, partially because of the many
levels of redundancy in spoken language.  While lisp code:

defmethod play-move ttt tic-tac-toe move
  let board board ttt setf square board move  if = to-move ttt 1 'x 'o won? ttt
move switch-players ttt

Is unacceptable.  You don't know if it's a specialized function or not, and if
so, on what,
you don't know what the parameters of the function are, etc.

Yes, editors can help you naviagte through code.  But it is nuch more work to
navigate through code then format it so the eye can see it naturally, especially

when code is complex and under heavy development.

dave


 
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 Mar 28 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 2000/03/28
Subject: Re: Dangling Closing Parentheses vs. Stacked Closing Parentheses
* Charles Hixson
| Lots of Irritating Single Parenthesis.  I believe that there used to be a
| dialect of Lisp where one could signal "close all parenthesis back to the
| root" by using a ] character, but that seems to have disappeared.  I
| guess that it may have been a bit error prone.

* Pierre R. Mai
| It turned out that this functionality belongs in the editor, and not the
| language.  That's why ] will close all outstanding parentheses in many
| Lisp modes.  This way you get the benefits, without the trouble.  ...

  for what it's worth, I have found it significantly easier to write code
  in Emacs with M-( and M-) rather than ( and ).  I guess I picked up that
  habit when I wrote an SGML-mode that automatized the matching between
  start- and end-tags and inserted every character of the element name in
  _both_ the start- and the end-tag.  I generalized this to let, e.g., M-*
  produce ** with the cursor between them, and applied it to "", `', {},
  [], <>, «», ¡!, ¿?, and for that old Common Lisp reader, ||, as well as
  comments with #||#.  in my view, it's a serious mistake to use paired
  delimiters of any kind in a language without _actively_ supporting their
  paired entry when writing.

#:Erik


 
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 Mar 28 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 2000/03/28
Subject: Re: Dangling Closing Parentheses vs. Stacked Closing Parentheses
* "Anthony Cartmell" <AJCartm...@csi.com>
| Sorry for the "newbie" question, but I thought that the indentation was
| based on the list structure, and not the other way round.

  well, this gets a little complicated.  the indentation is automatically
  produced for you based on the list structure by the editor.  the list
  structure, however, becomes visually apparent to us humans through
  indentation.  new Lispers look at the list structure and think they
  understand the indentation.  old Lispers look at the indentation and
  understand the list structure.  new Lispers count parentheses and swear.
  old Lispers reindent their code and immediately spot mistakes and just
  clean them up.  the whole Lisp enlightenment experience is about making a
  fundamental swap between syntax and indentation.  (at least one language
  has made this switch permanent: python.  I'm not sure this is a good
  thing.)

| If the parens were based on the indentation then we wouldn't even need to
| use them.

  this is very naive.  _some_ redundancy is a fundamental characteristic of
  _all_ successful communication, between computers as well as humans.

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

  that's because you have never let yourself get immersed in indentation.
  you don't need to see the parentheses.  (if you start seeing fnords,
  alert your local illuminati.)

#:Erik


 
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 Mar 28 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 2000/03/28
Subject: Re: Dangling Closing Parentheses vs. Stacked Closing Parentheses
* Duane Rettig <du...@franz.com>
| I've seen most of the style arguments based on philosophy posted on this
| thread, but there is one argument I have not yet seen.  [match the
| results of the pretty printer.]

  I like this argument.  I think we can sum it up like this:

    there is no whitespace after an opening parenthesis.
    there is no whitespace before a closing parenthesis.
    this is the law.  if you break it, it is not pretty.

#:Erik


 
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.
thi  
View profile  
 More options Mar 28 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: thi <t...@netcom.com>
Date: 2000/03/28
Subject: Re: Dangling Closing Parentheses vs. Stacked Closing Parentheses

"Anthony Cartmell" <AJCartm...@csi.com> writes:
> 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.

for smashing fruit, a hammer is fine.
why do you smash fruit, what has it done to you?

thi


 
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.
thi  
View profile  
 More options Mar 28 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: thi <t...@netcom.com>
Date: 2000/03/28
Subject: Re: Dangling Closing Parentheses vs. Stacked Closing Parentheses

"Anthony Cartmell" <AJCartm...@csi.com> writes:
> Errr... no, I didn't say it was. I was asking someone to explain where the
> confusion occurs - I'd like someone to enlighten me!  Please!

when one has confusion, why ask others about it?
surely you are the expert?  can others be anything but entertaining?

thi


 
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 Mar 29 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Gareth McCaughan <Gareth.McCaug...@pobox.com>
Date: 2000/03/29
Subject: Re: Dangling Closing Parentheses vs. Stacked Closing Parentheses

Dorai Sitaram wrote:
> Well, the CLISP pretty-printer gives this "semi-dangled" output:
..
> Ie, rparens are either on the same line as their
> corresponding lparen, or they are clumped together on a
> line of their own, where they line up (column-wise)
> with an lparen above them.

I use this style too, sometimes. I've never quite
worked out why :-).

>                             But if you look closer, you
> will realize with a jolt that the lparen that an rparen
> lines up with is _not_ its matching lparen...

This bothers me every time I use that style. Which
is one reason I don't do so very often.

--
Gareth McCaughan  Gareth.McCaug...@pobox.com
sig under construction


 
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 Mar 29 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 2000/03/29
Subject: Re: Dangling Closing Parentheses vs. Stacked Closing Parentheses
* Dorai Sitaram
| Well, the CLISP pretty-printer gives this "semi-dangled" output:
:
| But if you look closer, you will realize with a jolt that the lparen that
| an rparen lines up with is _not_ its matching lparen...

  someone recently said (sorry, I have been skimming news lately) that he
  had a problem starting with Lisp because everything was in uppercase --
  small things like that can effectively block one's entry into new areas.
  back when I was fairly new to Lisp (eons and eons ago, of course), I came
  across CLISP and its unf<beep>ingbelievably braindamaged pretty printer.
  it was immediately obvious that this had been implemented in a vacuum,
  free from influence from all knowledgable programmers on the planet and
  beyond, and it still sucked.  to see code printed like this was such a
  horrible experience I immediately seized upon the source code to try to
  find out how to turn this gut-wrenching abomination off.  but what did I
  find?  the entire source code was formatted like this!  aaaaauuugh!  and
  everything in German, to boot.  the abyss was staring back at me.  <fade>

  CLISP has since improved.  no animals have been hurt in its production.

#:Erik


 
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 Mar 29 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 2000/03/29
Subject: Re: Dangling Closing Parentheses vs. Stacked Closing Parentheses
* Paolo Amoroso
| 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 :)

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

  there is another, deeper reason behind this that you may have overlooked.

  in C, parentheses are used for a number of fundamentally different tasks,
  and in C++ it gets _completely_ insane, but that's another matter.  after
  a student of C has learned the painful precedence rules by rote and is
  still trying to internalize them so he can just _read_ expressions, the
  parentheses enter the picture as a source of pain or a painkiller when
  the precedence rules do not match the requirements of the expression.
  either way, there is pain.  you will often find C programmers battle
  their operators and their precedence rules for hours on end, recompiling
  frequently because they don't have an interactive environment, either.
  the lesson learned by that vestige of primitive brain that keeps us from
  sticking a hand into hot water the second time, is that parentheses are
  painful.  that a C programmer could have gotten rid of the pain by using
  parentheses consistently around his operators and arguments is lost by
  this primitive part of the brain.

  then Lisp comes around and it's all parentheses.  primitive brain shrieks.

  this is probably not restricted to C, but a property of that horrible
  mathematical infix syntax that is supposedly "natural" and which _also_
  has precedence rules in which parentheses play an important role,
  including the implied multiplication in the absence of operators.  it
  could be that early childhood experiences with the utter mindlessness of
  infix syntax and the need for parentheses to escape out of the stupid
  rules they made up is actually exceptionally traumatic on young brains
  who try to trust their ability to understand the world around them.
  parentheses break their trust, so when they see Lisp and it's all
  parentheses, they become psychotic.  this would explain a lot.  a LOT!

  however, the parentheses in Lisp are just like the semicolon in C.

  here's an experiment you can conduct at home: take a piece of C code to
  which a large group of people have contributed, several thousand lines of
  Open Source should do, modify it slightly in some useful and non-trivial
  way that people would probably like, and insert a newline before every
  semicolon and indent the line an extra tab relative to the line it used
  to belong to, ship the code to all the people who have contributed and be
  very enthusiastic about your improvements, but don't comment on the style
  change.  if you do _not_ receive realistic death threats, consider the
  experiment a failure.

#:Erik


 
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 Mar 29 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 2000/03/29
Subject: Re: Dangling Closing Parentheses vs. Stacked Closing Parentheses
* d...@goldshoe.gte.com (Dorai Sitaram)
| Anyway, converting between the dangling and clumped styles is
| automatable.  An Elisp programmer should be able to implement the
| following pseudocode in a few minutes:
|
| Dangling-to-clumped:
|   While there is a line with only right parens,
|   join that line with the previous line.  
|   Reindent.

  watch this code die a horrible flaming death:

(foo a                          ; mumble
     b                          ; frotz
     c                          ; fnord
     )

#:Erik


 
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.
Christopher Browne  
View profile  
 More options Mar 29 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: cbbro...@news.hex.net (Christopher Browne)
Date: 2000/03/29
Subject: Re: Dangling Closing Parentheses vs. Stacked Closing Parentheses
Centuries ago, Nostradamus foresaw a time when Anthony Cartmell would say:

>> It's because you haven't yet separated your IDL writing style from
>> your Lisp writing style.

>Actually it's David who wants to format ICAD with Lisp layout
>rules. I use dangling parens.

>> Eight years sheds no light on a person's experience level.

>Except that they have more experience than someone with one year!

Eight years of practicing poor habits can lead to that "extensive
experience" being a downright Bad Thing.

I have one co-worker who has been programming in various languages for
quite a number of years who has a few such "bad habits" that make him
something a liability despite having extensive "experience."

For this reason, it is unsafe to generalize about the effects of
experience.  *Valuable* experience is valuable; simply "spending time"
isn't.
--
"Bawden is misinformed.  Common Lisp has no philosophy.  We are held
together only by a shared disgust for all the alternatives."
-- Scott Fahlman, explaining why Common Lisp is the way it is....
cbbro...@ntlug.org- <http://www.ntlug.org/~cbbrowne/lsf.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.
Christopher Browne  
View profile  
 More options Mar 29 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: cbbro...@news.hex.net (Christopher Browne)
Date: 2000/03/29
Subject: Re: Dangling Closing Parentheses vs. Stacked Closing Parentheses
Centuries ago, Nostradamus foresaw a time when Anthony Cartmell would say:

It's not that it's "such a bad layout style."  

It's that if you're using a text editor that provides *any* support
for paren matching (just about anything better than MSFT WordPad), or
one that provides indentation support (e.g. - like Emacs), then
there's no *value* to having the parens dangle.

And if it's not really buying you anything, then the cost of having
less on the screen is a real cost, and *THAT* is the Bad Thing.

Because the extra lines and extra whitespace are a *distraction.*

Because screen space is *always* at a premium, regardless of how big
the screen is.  

Wasting a line is a waste of a line, and wasting a whole line for one
lousy parenthesis is just plain silly.  If you have a deeply nested
object, it's going to be followed by potentially a whole screen of
lines that have nothing more than a single parenthesis.
--
"Parentheses?  What  parentheses? I  haven't  noticed any  parentheses
since my  first month of Lisp  programming.  I like to  ask people who
complain about  parentheses in  Lisp if they  are bothered by  all the
spaces between words in a newspaper..."
-- Kenny Tilton <t...@liii.com>
cbbro...@hex.net- <http://www.hex.net/~cbbrowne/lisp.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.
Fernando D. Mato Mira  
View profile  
 More options Mar 29 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: "Fernando D. Mato Mira" <matom...@iname.com>
Date: 2000/03/29
Subject: Re: Dangling Closing Parentheses vs. Stacked Closing Parentheses

Anthony Cartmell wrote:
> I've put together some layout examples of some typical ICAD code for anyone
> interested at
> http://ourworld.compuserve.com/homepages/AJCartmell/icadparens.html .

> Thanks for your comments!

Try this:

"NEVER, NEVER, NEVER dangle a _single_ parentheses"

Even in VI it's easy to add an additional last form:
A <backspace> <enter> <hold space bar>

[I'm sure some vihead will have some better way to do the same]

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


 
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 76 - 100 of 187 < Older  Newer >
« Back to Discussions « Newer topic     Older topic »