home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!europa.asd.contel.com!gatech!swrinde!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!ftpbox!motsrd!mothost!merlin.dev.cdx.mot.com!fendahl.dev.cdx.mot.com!mcook
- From: mcook@fendahl.dev.cdx.mot.com (Michael Cook)
- Subject: Re: explicit sub parameters - a proposal
- Message-ID: <mcook.721600211@fendahl.dev.cdx.mot.com>
- Sender: news@merlin.dev.cdx.mot.com (USENET News System)
- Nntp-Posting-Host: fendahl.dev.cdx.mot.com
- Organization: Motorola Codex, Canton, Massachusetts
- References: <mcook.721530385@fendahl.dev.cdx.mot.com> <1992Nov12.153941.18318@news.eng.convex.com>
- Date: Thu, 12 Nov 1992 20:30:11 GMT
- Lines: 43
-
- tchrist@convex.COM (Tom Christiansen) writes:
-
- >From the keyboard of mcook@fendahl.dev.cdx.mot.com (Michael Cook):
- >:What about this idea: perl should allow this construct:
- >:
- >: sub foo($a, $b, @rest) {
- >: # ...
- >: }
- >:
- >:which would be exactly equivalent to
- >:
- >: sub foo {
- >: local ($a, $b, @rest) = @_;
- >: # ...
- >: }
- >:
- >:That would greatly improve the readability of Perl, I think. (Not to mention
- >:the fact that people might be less likely to stumble into all the strange
- >:things that can happen when you start playing around with @_.)
-
- >Yes, this would help with at least one aspect of variable suicide,
- >the one addressed by the first part of FAQ 2.31 as of the last posting.
-
- >I agree that it would be an improvement, but some things are left
- >unaddressed. One problem is that what I believe people really expect to
- >work is:
-
- > foo(@abc, @xyz) if $blah;
-
- > sub foo(@alpha, @beta) {
- > ....
- > }
-
- I've come to learn that &foo(@abc) means &foo($abc[0], ..., $abc[$#abc]).
- I'm sure that changing the rules would break a lot of existing code (but then
- there is that clever "version" idea that someone posted a couple days ago...).
-
- In the definition ``sub foo(@alpha, @beta, $gamma, %delta)'', perl -w should
- warn about the parameters that follow @alpha, since the declaration doesn't
- make sense.
-
- Michael.
- Perl's estranged second cousin-in-law, twice removed.
-