in reply to sub ($self,$var,@arr) {}
Total Savings = 6 keystrokes (not including spaces)sub ($self, $var, @arr) { ... } ## versus sub { my ($self, $var, @arr) = @_; ... }
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..."
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: sub ($self,$var,@arr) {}
by tadman (Prior) on Feb 09, 2001 at 22:54 UTC | |
|
Re: Re: sub ($self,$var,@arr) {}
by raptor (Sexton) on Feb 13, 2001 at 16:38 UTC |