Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I completely agree with the {sentiment embodied in} the title of your meditation.

However, I think that the word "gratuitous" is important. If prototypes were truely evil, as opposed to just widely misunderstood (Poor things. All say "Ahhh!"), then I think they would have been officially deprecated long ago.

But they haven't. Maybe, because they do allow some things to be done that cannot be done any other way. And whilst you may question the necessity of doing those things, the desirability of them, when they are justified, is enough to keep them included in the langauge.

Example: Remove the prototype from this implementation of zip and then modify the code to compensate and you get a much less readable and useable function.

#! perl -slw use strict; local $, = ' | '; sub zip (&\@\@) { map { $_[ 0 ]->( $_[ 1 ][ $_ ], $_[ 2 ][ $_ ] ) } 0 .. ( @{$_[ 1 ]} < @{$_[ 2 ]} ? $#{ $_[ 1 ] } : $#{ $_[ 2 ] } ); } my @a = 'a' .. 'z'; my @n = 1 .. 10; print zip{ "@_" } @a, @n; print zip{ $_[ 0 ] .= $_[ 1 ] } @a, @n; print zip{ $_[ 0 ] .= $_[ 1 ] } @a, @n; __END__ [ 1:37:32.71] P:\test>406231 a 1 | b 2 | c 3 | d 4 | e 5 | f 6 | g 7 | h 8 | i 9 | j 10 a1 | b2 | c3 | d4 | e5 | f6 | g7 | h8 | i9 | j10 a11 | b22 | c33 | d44 | e55 | f66 | g77 | h88 | i99 | j1010

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

In reply to Re: Gratuitous use of Perl Prototypes by BrowserUk
in thread Gratuitous use of Perl Prototypes by grantm

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 contemplating the Monastery: (7)
    As of 2014-08-20 11:05 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The best computer themed movie is:











      Results (111 votes), past polls