Re: Multiple Classes per File and use



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



Relevant Pages

  • Re: Multiple Classes per File and use
    ... you used a for loop with the implied use of $_ as the loop variable. ... >> ...make a dispatch table... ... XC> jump table is a jump table, no matter what you call it. ... table and none that support using symrefs there. ...
    (comp.lang.perl.misc)
  • Re: Reading sequence of variables with for loop
    ... the evil eval in future on CSSM. ... Can you please recommend the solution to this problem? ... dont advocate the use of evil eval). ... those x number of variables in a loop. ...
    (comp.soft-sys.matlab)
  • Re: MsgWaitForMultipleObjects and Timer
    ... while(PeekMessage(lpmsg, hwndPrincipale, 0,0,PM_REMOVE)); ... Don't you want to, I don't know, maybe dispatch these messages so they ... rather than quietly dropping them on the floor? ...
    (microsoft.public.vc.language)
  • Re: exhaustive switch bound checking
    ... Artem Alimarine a écrit: ... this dispatch is done in a loop. ...
    (microsoft.public.vc.language)
  • Please help wit{h array search technique?
    ... Can someone recommend the best way to search a single dimension array? ... I'm currently using a for loop and it doesn't seem to be working ... Prev by Date: ...
    (comp.lang.php)