RE: Define consistent and standard
[email protected] (Garrett Goebel) Fri, 11 Aug 2000 10:17:31 -0500
| Newsgroups | perl.perl6.stdlib |
|---|---|
| Message-ID | <71BEC0D4E1DED3118F7A009027B1202835C844@EXCH_MISSION> |
From: [email protected] [mailto:[email protected]] > > What I was trying to get across was that if you're storing > more than one email address per person, you might use > %email_addresses and therefore $email_addresses{Skud}, whereas > if you're limiting it to one email address per person, it would be > $email_address{Skud}. Makes sense after a fashion. Though I'm a little out of fashion ;) Scalar = thing Hash = thing(s) Array = thing(s) That is fundamental an unalterable. Storing a reference to an array in a scalar, is still storing "a" reference. When I see $email_address, I know I'm seeing a single thing. When I see %email_addresses, I know it'll hold one or more things. Determining the plurality of a hash or array's name based on the content of their values as Kirrily/Netizen suggest, is fine so long as the programmer adheres to the naming convention. Still, what's a person to name a hash when it holds something motley like: %email_addresse(s)? = (Skud => [qw([email protected] [email protected] [email protected])], dud => '[email protected]'); On the other hand, if you advise making all scalars singular nouns, and all hashes and arrays plural, then you don't have the self-imposed worry about the contents of your arrays and hashes. If you name your hash %email_addresses, you can fill it hash with scalars values one week and anonymous hashes the next (or mix-and-match). You don't need to go through your code and update $email_address{Skud} to $email_addresses{Skud}. Garrett