http://qs1969.pair.com?node_id=209228


in reply to "Redundant" ne "Bad"
in thread the "@" indicates plural hence "s" is redundant

i'll agree with that. especially in for loops.
for my $widget(@widgets){ do_somthing($widget); }
reads to me as "for each widget of these widgets, do something with this widget" not perfect english, but the plurals helps me keep the element from being confused with the array. though i guess in some cases i'd use the same name.:-)
for my $deer(@deer){}

Replies are listed 'Best First'.
Re: Re: "Redundant" ne "Bad"
by Acolyte (Hermit) on Oct 31, 2002 at 00:20 UTC

    This makes perfect sense to me - using plurality in context.

    Looking back at the original example, while:

    @int = ( 2 .. 5 ) ;

    might be thought of as "an array of integers", it falls back on Hungarian style notation (int) which denotes a "data type" (singular), not "data types" (plural). Following that line of thinking, it could also be thought of as "an array of values of the integer data type ". Of course this doesn't read as easily as "an array of integers", and just goes to show that programming conventions don't always neatly fit into the syntax of the English language.

    C'est la vie!

    Acolyte
    Studying at the feet of the masters
Re: Re: "Redundant" ne "Bad"
by tomhukins (Curate) on Oct 31, 2002 at 11:48 UTC
    I would rewrite
    for my $widget(@widgets){ do_somthing($widget); }
    as
    foreach (@widget) { do_something($_); }
    because the latter makes sense in English as well as Perl if you realise that Perl uses $_ to say 'it': "For each widget, do something to it".