Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: "Redundant" ne "Bad"

by thunders (Priest)
on Oct 30, 2002 at 20:43 UTC ( #209228=note: print w/replies, xml ) Need Help??

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!

    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); }
    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".

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://209228]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2022-11-30 10:59 GMT
Find Nodes?
    Voting Booth?