Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
it's a common idiom to use map to create listified hashes map { $_ => 0 } LIST

A hash is commonly initialized from a list, e.g.
    my %hash = qw(a 1  b 2  c 3);
Does the quoted idiom do anything other than generate another list with which to initialize a hash? Can a hash so initialized be considered in any way distinct from a hash created in any other way; in particular, can it usefully be distinguished as 'listified'?

orthogonality always makes sense!

A hash is commonly initialized from a list as in the example given above, and a hash is seamlessly 'listified' in list context as in a statement like
    print %hash;
or
    my @array = %hash;
but are lists (and, by extension, arrays) really orthogonal with hashes? Despite certain conceptual similarities, my inclination would be to say no: there are just too many differences:

  • A hash can be assigned to an array and all the information inherent in the hash can be accessed and manipulated using standard array and list operators, but this is rarely anything other than an exercise in masochism;
  • An array can be assigned to a hash, but the information inherent in the array is largely destroyed thereby.

Prototypes are just not mature enough!!!

Amen to that, brother! Or rather, they are just not well-named enough. Had they been better named, people like myself who come from C/C++land and adjacent regions would not know instantly what they are – and be instantly wrong!


In reply to Re^11: Is there any difference between prototype % and @ ? by AnomalousMonk
in thread Is there any difference between prototype % and @ ? by LanX

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (11)
    As of 2014-09-30 13:11 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (369 votes), past polls