[31132] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 2377 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 29 16:28:03 2009

Date: Wed, 29 Apr 2009 13:14:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 29 Apr 2009     Volume: 11 Number: 2377

Today's topics:
    Re: Sub indentation trouble <uri@stemsystems.com>
    Re: Sub indentation trouble <bozo_le_clown@wherever.you.want.com>
    Re: Sub indentation trouble <uri@stemsystems.com>
    Re: Sub indentation trouble <bozo_le_clown@wherever.you.want.com>
    Re: Sub indentation trouble <uri@stemsystems.com>
    Re: Sub indentation trouble <bozo_le_clown@wherever.you.want.com>
    Re: Sub indentation trouble <nospam-abuse@ilyaz.org>
    Re: Sub indentation trouble <bozo_le_clown@wherever.you.want.com>
    Re: Sub indentation trouble <hjp-usenet2@hjp.at>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 29 Apr 2009 11:26:17 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Sub indentation trouble
Message-Id: <87eivbscpy.fsf@quad.sysarch.com>

>>>>> "JK" == Julien K <bozo_le_clown@wherever.you.want.com> writes:

  JK> sub test
  JK>   { my ($self) = @_ ;
  JK>   }
  JK>   # the commment starts at col 2 instead of col 0

regardless of how you use cprerl mode, that is one fugly indent style!!

:)

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


------------------------------

Date: Wed, 29 Apr 2009 17:39:29 +0200
From: "Julien K." <bozo_le_clown@wherever.you.want.com>
Subject: Re: Sub indentation trouble
Message-Id: <slrngvgt5h.rqi.bozo_le_clown@thabor.lan.ah2d.fr>

On 29-04-2009, Uri Guttman wrote:
>>>>>> "JK" == Julien K <bozo_le_clown@wherever.you.want.com> writes:
>
>  JK> sub test
>  JK>   { my ($self) = @_ ;
>  JK>   }
>  JK>   # the commment starts at col 2 instead of col 0
>
> regardless of how you use cprerl mode, that is one fugly indent style!!

  Hey, this very scheme is what I want to get rid of. Otherwise after six or 
seven "sub" declaration I'll be very close to the right side of the 
screen... ;-)

  BTW what's wrong with this in your opinion:
<<<<<
sub test
  { my ($self) = @_ ;
    # stuff
    return ($var) ;
  }

sub _init
  { my $self = shift ;
    # ...
  }
>>>>>

  I find this indent scheme very easy to read.

  Julien


------------------------------

Date: Wed, 29 Apr 2009 12:01:48 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Sub indentation trouble
Message-Id: <87zldzqwib.fsf@quad.sysarch.com>

>>>>> "JK" == Julien K <bozo_le_clown@wherever.you.want.com> writes:

  JK> On 29-04-2009, Uri Guttman wrote:
  >>>>>>> "JK" == Julien K <bozo_le_clown@wherever.you.want.com> writes:
  >> 
  JK> sub test
  JK> { my ($self) = @_ ;
  JK> }
  JK> # the commment starts at col 2 instead of col 0
  >> 
  >> regardless of how you use cprerl mode, that is one fugly indent style!!

  JK>   Hey, this very scheme is what I want to get rid of. Otherwise after six or 
  JK> seven "sub" declaration I'll be very close to the right side of the 
  JK> screen... ;-)

i wasn't concerned with subs creeping to the right.

  JK>   BTW what's wrong with this in your opinion:
  JK> <<<<<
  JK> sub test
  JK>   { my ($self) = @_ ;
  JK>     # stuff
  JK>     return ($var) ;
  JK>   }

  JK> sub _init
  JK>   { my $self = shift ;
  JK>     # ...
  JK>   }
  >>>>>> 

  JK>   I find this indent scheme very easy to read.

you may find it easy but it is not close to the perl style (also K&R
from WAY back) that is most common on cpan and in the perl
community. but you can't easily argue about style any more than you can
about the usual wars like editors and langs. suffice it to say, you are
in the extreme minority (maybe the only one? :) with that style.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


------------------------------

Date: Wed, 29 Apr 2009 18:29:57 +0200
From: "Julien K." <bozo_le_clown@wherever.you.want.com>
Subject: Re: Sub indentation trouble
Message-Id: <slrngvh045.rqi.bozo_le_clown@thabor.lan.ah2d.fr>

On 29-04-2009, Uri Guttman wrote:
>>>>>> "JK" == Julien K <bozo_le_clown@wherever.you.want.com> writes:
>
>  JK> On 29-04-2009, Uri Guttman wrote:
>  >>>>>>> "JK" == Julien K <bozo_le_clown@wherever.you.want.com> writes:
>  >> 
>  JK> sub test
>  JK> { my ($self) = @_ ;
>  JK> }
>  JK> # the commment starts at col 2 instead of col 0
>  >> 
>  >> regardless of how you use cprerl mode, that is one fugly indent style!!
>
>  JK> Hey, this very scheme is what I want to get rid of. Otherwise after 
>  JK> six or seven "sub" declaration I'll be very close to the right side 
>  JK> of the screen... ;-)
>
> i wasn't concerned with subs creeping to the right.

  I am :-)

>  JK>   BTW what's wrong with this in your opinion:
>  JK> <<<<<
>  JK> sub test
>  JK>   { my ($self) = @_ ;
>  JK>     # stuff
>  JK>     return ($var) ;
>  JK>   }
>
>  JK> sub _init
>  JK>   { my $self = shift ;
>  JK>     # ...
>  JK>   }
>  >>>>>> 
>
>  JK>   I find this indent scheme very easy to read.
>
> you may find it easy but it is not close to the perl style (also K&R from 
> WAY back) that is most common on cpan and in the perl community.

  I'm aware of that point and I don't really mind since nobody else reads my 
code. I've read code from various people, no one has the same indent scheme 
and it doesn't matter: IMHO that's the editor job to indent according to the 
user's needs (as all ident schemes will lead to the same execution).

> but you can't easily argue about style any more than you can about the 
> usual wars like editors and langs.

  or newsreaders... I won't, I'm over 14. You're on your own and so do I.

> suffice it to say, you are in the extreme minority (maybe the only one? :) 
> with that style.

  I'm not the only one, a friend of mine uses that style too, we're at least 
two, beware ;-).

  This is the GNU indent-style from cperl (well, it was until cperl-5.1). 
It's not very different from the perl style one can find in perltoot, except 
that it uses a newline before block opening brace (cperl has that kind of 
feature).

  Anyway, thanks for your advice,

  Julien


------------------------------

Date: Wed, 29 Apr 2009 12:54:26 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Sub indentation trouble
Message-Id: <877i13qu2l.fsf@quad.sysarch.com>

>>>>> "JK" == Julien K <bozo_le_clown@wherever.you.want.com> writes:
  JK> On 29-04-2009, Uri Guttman wrote:

  >> you may find it easy but it is not close to the perl style (also K&R from 
  >> WAY back) that is most common on cpan and in the perl community.

  JK>   I'm aware of that point and I don't really mind since nobody
  JK> else reads my code. I've read code from various people, no one has
  JK> the same indent scheme and it doesn't matter: IMHO that's the
  JK> editor job to indent according to the user's needs (as all ident
  JK> schemes will lead to the same execution).

well, writing code in a vacuum isn't a good idea. having others read
your code is one of the best ways for your code and your skills to get
better. this is one of my biggest issues when i do code review is how
so little code does get reviewed and usually very late in the process
(when it is time to rewrite it from scratch). so formatting your code so
most others will read it easily is a good idea. sure they can use
perltidy to reformat it but that is just more work. as people say here,
proper editing and quoting of posts is good since you save more global
work by letting others do less work. the same applies to coding styles.

  >> suffice it to say, you are in the extreme minority (maybe the only one? :) 
  >> with that style.

  JK>   I'm not the only one, a friend of mine uses that style too,
  JK> we're at least two, beware ;-).

wooh, a growing movement!

  JK>   This is the GNU indent-style from cperl (well, it was until
  JK> cperl-5.1).  It's not very different from the perl style one can
  JK> find in perltoot, except that it uses a newline before block
  JK> opening brace (cperl has that kind of feature).

it isn't K&R which is the 'standard' perl style. open brace on the end
of the code line, code indented one level (and use hard tabs as they can
be displayed/printed to any indent level) and closing brace at the same
indent as the opening line. that is all i care about. well, good white
space use is important too!

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


------------------------------

Date: Wed, 29 Apr 2009 19:10:10 +0200
From: "Julien K." <bozo_le_clown@wherever.you.want.com>
Subject: Re: Sub indentation trouble
Message-Id: <slrngvh2fi.rqi.bozo_le_clown@thabor.lan.ah2d.fr>

On 29-04-2009, Uri Guttman wrote:
>>>>>> "JK" == Julien K <bozo_le_clown@wherever.you.want.com> writes:
>  JK> On 29-04-2009, Uri Guttman wrote:
>
>  >> you may find it easy but it is not close to the perl style (also K&R from 
>  >> WAY back) that is most common on cpan and in the perl community.
>
>  JK>   I'm aware of that point and I don't really mind since nobody
>  JK> else reads my code. I've read code from various people, no one has
>  JK> the same indent scheme and it doesn't matter: IMHO that's the
>  JK> editor job to indent according to the user's needs (as all ident
>  JK> schemes will lead to the same execution).
>
> well, writing code in a vacuum isn't a good idea. having others read
> your code is one of the best ways for your code and your skills to get
> better.

  I agree with you but nobody can review my code in my every day-job, 
because I'm the only one able to write a piece of code (Fortran, Matlab 
Perl...). Programming should not be a part of my job, but it makes me save a 
lot of time (well I like to think so).

> this is one of my biggest issues when i do code review is how so little 
> code does get reviewed and usually very late in the process (when it is 
> time to rewrite it from scratch). so formatting your code so most others 
> will read it easily is a good idea. 

  cperl has an indent-region function that indents the code according to the 
current indent-style. Pretty impressing.

> as people say here, proper editing and quoting of posts is good since you 
> save more global work by letting others do less work. the same applies to 
> coding styles.

  And so does the proper use of uppercase letters. ;-)

  Julien



------------------------------

Date: Wed, 29 Apr 2009 17:37:10 GMT
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Sub indentation trouble
Message-Id: <slrngvh4ev.j6g.nospam-abuse@chorin.math.berkeley.edu>

On 2009-04-29, Julien K. <bozo_le_clown@wherever.you.want.com> wrote:
> sub test
>   { my ($self) = @_ ;
>   }
>   # the commment starts at col 2 instead of col 0

So the indent of `#' happens w.r.t. the `{', not w.r.t. `sub'.

>   The if/else/... blocks don't behave like that:
><<<<
> if (test)
>   { 
>   }
> # comment that starts at col 0 -- ok
>>>>>>

>> And until I know what is the intent, I can't classify this as a bug.
>
>   I'm not sure it is a bug, maybe I didn't understand well the settings of 
> cperl.

As you see, there is some code to detect that `{' follows `if', and
indent accordingly.  Apparently, there is no such code to recognize
that `{' follows `sub'.  This should be considered a bug (all
indentation of continuation lines which CPerl is putting itself should
be "undoable" when it tries to indent following lines).

However, since I hate such indentation styles [*], I try not to pay a lot
of attention when viewing such code.  As a result, I'm not completely
sure EXACTLY WHICH constructs should be recognized before `{' to see
that `{' starts a "continuation line".

  [*]  IMO, the purpose of indentation style is to maintain
       easy-to-visualize matching of paired delimiters, while
       preserving as much as possible the scarce resources - such as
       screen real estate.  (E.g., I cuddle my `else's.)

Yours,
Ilya


------------------------------

Date: Wed, 29 Apr 2009 20:24:23 +0200
From: "Julien K." <bozo_le_clown@wherever.you.want.com>
Subject: Re: Sub indentation trouble
Message-Id: <slrngvh6qn.rqi.bozo_le_clown@thabor.lan.ah2d.fr>

On 29-04-2009, Ilya Zakharevich wrote:
> On 2009-04-29, Julien K. <bozo_le_clown@wherever.you.want.com> wrote:

>>> And until I know what is the intent, I can't classify this as a bug.
>>
>>   I'm not sure it is a bug, maybe I didn't understand well the settings of 
>> cperl.
>
> As you see, there is some code to detect that `{' follows `if', and
> indent accordingly.  Apparently, there is no such code to recognize
> that `{' follows `sub'.

  Like Uri said in another part of the thread, this is not observable when 
one writes:
<<<<<
sub test {
  # stuff
}
>>>>>

>  This should be considered a bug (all indentation of continuation lines 
> which CPerl is putting itself should be "undoable" when it tries to indent 
> following lines).

  Correct me if I'm wrong, but a prototyped 'sub' should behave like a if 
block alone:
<<<<<
sub test ($$)
  { my ($a,$b) = @_ ;
    #...
  }
 
if ($a<0)
  { # ...
  }
>>>>>

> However, since I hate such indentation styles [*], I try not to pay a lot
> of attention when viewing such code.  As a result, I'm not completely
> sure EXACTLY WHICH constructs should be recognized before `{' to see
> that `{' starts a "continuation line".
>
>   [*]  IMO, the purpose of indentation style is to maintain
>        easy-to-visualize matching of paired delimiters, while
>        preserving as much as possible the scarce resources - such as
>        screen real estate.  (E.g., I cuddle my `else's.)

  "easy-to-visualize matching of paired delimiters" is exactly why I like 
this style, the corresponding braces are vertically aligned, as nothing 
crosses their column. Well, having matching delimiters colored helps too...

  Cheers,

  Julien


------------------------------

Date: Wed, 29 Apr 2009 21:32:40 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Sub indentation trouble
Message-Id: <slrngvhaqo.ilb.hjp-usenet2@hrunkner.hjp.at>

On 2009-04-29 16:29, Julien K. <bozo_le_clown@wherever.you.want.com> wrote:
> On 29-04-2009, Uri Guttman wrote:
>>>>>>> "JK" == Julien K <bozo_le_clown@wherever.you.want.com> writes:
>>  JK>   BTW what's wrong with this in your opinion:
>>  JK> <<<<<
>>  JK> sub test
>>  JK>   { my ($self) = @_ ;
>>  JK>     # stuff
>>  JK>     return ($var) ;
>>  JK>   }
>>
[...]
>
>   This is the GNU indent-style from cperl (well, it was until cperl-5.1). 
> It's not very different from the perl style one can find in perltoot,

Hmm?


   sub population {
       my $self = shift;
       if (ref $self) {
           return ${ $self->{"_CENSUS"} };
       } else {
           return $Census;
       }
   }

looks very different to me:

 * The opening brace is at the end of the line with sub/if/...
 * The closing brace is at the same indentation as sub/if/...
 * The first line of the block is in a new line
 
        hp


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 2377
***************************************


home help back first fref pref prev next nref lref last post