Re: Multiple Classes per File and use
- From: Uri Guttman <uri@xxxxxxxxxxxxxxx>
- Date: Thu, 08 Feb 2007 12:56:45 -0500
"MD" == Michele Dondi <bik.mido@xxxxxxxxxxxxx> writes:
MD> On Wed, 07 Feb 2007 15:51:57 -0500, Uri Guttman <uri@xxxxxxxxxxxxxxx>
MD> wrote:
>> you used a for loop with the implied use of $_ as the loop variable. it
>> is better to use a named lexical variable instead like this:
>>
>> for my $foo ( @bars ) {
>>
>> it makes the code easier to understand since the loop body will have
>> that name to help document it. i only use $_ in map/grep where it is
>> required and in special cases where it works better.
MD> Oh c'mon! This is just *so* controversial... even slightly
MD> flame-baiting... I use $_ all the time in loops, provided they're
MD> short enough. If possible I cast them in a statement modifier form,
MD> even. If code is self explanatory it is... err, well, self
MD> explanatory. Of course I would never recommend to use $_ with a for
MD> loop having a main block of 25 lines!!
i wouldn't call it controversial or flame baiting. you can disagree with
it but most style guides (PBP included) recommend named variables
whenever possible. sure it is a style issue but i am a strong advocate
of named variables as part of an overall style. and i emphasize choosing
quality names which makes it work even better.
XC> "calculated jump". As I posted, that's the first thing to break. Last
XC> time I tried that for a client on a serious project, was 20 years ago
XC> and I thought I was cool. I only did it because it could be done -- and
XC> because nobody had ever educated me as to why it might be risky.
>>
>> this is very wrong in several ways. it is a symref which you said you
>> don't want to do and no one recommends that you do. it is not testing if
MD> [snip]
MD> I wholeheartedly agree with you, but some details, including the
MD> "calculated jump" one above make me suspect that the OP really
MD> misunderstood the meaning of "dispatch table", in which case I renew
MD> the invite for him to look it up.
well, i took calculated jump as the symref since that is a calculated
name of the sub to call. but later the OP seemed to agree with me so i
am confused as to whether he is going to use a dispatch table.
uri
--
Uri Guttman ------ uri@xxxxxxxxxxxxxxx -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
.
- References:
- OO Perl Online Learning
- From: Xiong Changnian
- Re: OO Perl Online Learning
- From: xhoster
- Multiple Classes per File and use (was: OO Perl...)
- From: Xiong Changnian
- Re: Multiple Classes per File and use (was: OO Perl...)
- From: xhoster
- Re: Multiple Classes per File and use (was: OO Perl...)
- From: Xiong Changnian
- Re: Multiple Classes per File and use
- From: Uri Guttman
- OO Perl Online Learning
- Prev by Date: Problem with system command
- Next by Date: Re: perl subroutine
- Previous by thread: Re: Multiple Classes per File and use
- Next by thread: Re: Multiple Classes per File and use
- Index(es):
Relevant Pages
|