develooper Front page | perl.perl6.internals | Postings from August 2001

Re: Final draft: Conventions and Guidelines for Perl Source Code

Thread Previous | Thread Next
From:
Joe McMahon
Date:
August 13, 2001 09:09
Subject:
Re: Final draft: Conventions and Guidelines for Perl Source Code
Message ID:
Pine.LNX.4.33.0108131202100.13266-100000@tribal.metalab.unc.edu
On Mon, 13 Aug 2001, Dave Mitchell wrote:
> Nicholas Clark <nick@ccl4.org> wrote:
> > Does this mean avoid:
> >
> > if (...) {
> >   ...
> > } else {
> >   ...
> > }
> >
> > and instead use:
> >
> > if (...) {
> >   ...
> > }
> > else
> > {
> >   ...
> > }
> >
> > If my interpretation of what it means is correct, why is the latter style
> > preferred over the former style?
>
> Don't ask me guv', I just work here.... :-)
> Or more to the point, I just cribbed it from Porting/patching.pod.
> A similar edict appears in pod/perlstyle.pod (although that refers to Perl,
> not C). Personally I have no objection to cuddling, but it appears frowned
> upon by the Perl community. If that community lets me know otherwise, I'll
> happily change it.
>
> I also assumed that this is allowed:
>
> }
> else {
>
From reading the code in the Camel, and various code I've seen from
Tom C. (who I think was the principle contributor to the style
sections) this seems to be the convention that is being encouraged:

   if (condition) {
   }
   elsif (condition) {
   }
   else {
   }

I prefer it this way myself; I think the idea is to keep items with the
same logical indent at the same physical indent.

 --- Joe M.


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About