develooper Front page | perl.perl5.porters | Postings from February 2011

Re: perldoc improvements for map

Thread Previous | Thread Next
From:
vadrer
Date:
February 13, 2011 14:23
Subject:
Re: perldoc improvements for map
Message ID:
1297647183.4753.33.camel@p100
On Sat, 2011-02-12 at 12:50 -0700, Tom Christiansen wrote:
> > -    @chars = map(chr, @nums);
> > +    my @chars = map(chr, @numbers);
> 
> I am of the studied opinion that slavishly added declarations that 
> have no bearing on the semantics of the function demonstrated serve 
> only to make that snippet less clear and more confusing.
> This was a specific principal I followed when last I edited perlfunc.
> 
> Notice that you aren't declaring and initializing @numbers, which
> makes this edit inconsistent and confusing. See where this leads?
> These are not complete programs, and needn't be portrayed as such.
> 
> What's next?  
> 
>     my $decimal = 3.678;
>     my $whole   = int($decimal);

I also dislike patches that blindly add 'use strict;' and 'my' to code
samples in perl documentation,
but in this particular case it could be argued that example demonstrates
collecting values into new-ly created array, so 'my' is fine here,
although not really necessary update.

Regards,
Vadim.


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