sub ($self, $var, @arr) { ... } ## versus sub { my ($self, $var, @arr) = @_; ... }
Total Savings = 6 keystrokes (not including spaces)

This wouldn't add new functionality, and saving a few keystrokes is less important, IMHO, than maintaining consistency.

Understanding what @_ is, how it works, and how to use it is a Good Thing; it takes some of the mystery out of parameter passing, and is conceptually related to many other important Perlisms that beginners often struggle with (eg. $_, local, aliases). Offering Perl beginners an easy way out by not learning about @_ would be doing them a disservice. @_ allows for many interesting possibilities that fixed parameter lists do not (for instance, "overloaded" subs). It would also be unfortunate if Perl's worth were diluted by encouraging people to code like it's just another scripting language. My gut feeling is that if you were to add such a syntax, newcomers to the language would use it almost exclusively, and @_ would evolve into an unusual, depricated construct of interest primarily to obfuscators.

And I don't want Perl to look any more like C, C++, or Java than it has to ;) Bad memories, you know?

That said, your suggestion is in keeping with the idea that TIMTOWTDI, and I don't see how it could break backwards-compatibility or be difficult to implement. It would also add some sanity, from an aesthetic perspective, to Perl's prototyping system.

So I don't quite know on which end of this issue I sit. Perhaps, I'll just offer the annoying cliche "if it ain't broke..."


In reply to Re: sub ($self,$var,@arr) {} by MeowChow
in thread sub ($self,$var,@arr) {} by raptor

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.