The problem is that perls many little idiosyncracies make it difficult to generalize the behaviour of all the built ins. print is another exaple of a keyword whose behaviour cannot be emulated by a user defined function. As are all of the keywords which return undef when passed to prototype.

As I said before prototypes are a hack. So not all of the special behaviour of map/grep is provided by the prototype. My guess is that this has to do with the issues related to providing complete map or print like behaviour to generalized subs. Too many rules are violated by these procedures for it to be worthwhile to support it except in very special cases. Consider that you didnt cover all the ways that map can be called:

print map { "foo $_" } @list; print map({"foo $_"} @list); print map "foo $_", @list; print map("foo $_", @list); print map(sub { "foo $_" },@list); # this doesnt do what you think....
The last one is an example of the troubles that come with map's handling. It parses as
print map { sub { "foo $_" } } @list;
which frankly would seem to be an odd interpretation for a user generated function. Luckily we are trained from the get go to treat map as an unusal keyword.

--- demerphq
my friends call me, usually because I'm late....


In reply to Re: Re: Re: & function prototypes and parens by demerphq
in thread & function prototypes and parens by steves

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.