home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!news.centerline.com!noc.near.net!hri.com!spool.mu.edu!darwin.sura.net!convex!convex!tchrist
- From: tchrist@convex.COM (Tom Christiansen)
- Newsgroups: comp.lang.perl
- Subject: Re: explicit sub parameters - a proposal
- Message-ID: <1992Nov12.153941.18318@news.eng.convex.com>
- Date: 12 Nov 92 15:39:41 GMT
- References: <mcook.721530385@fendahl.dev.cdx.mot.com>
- Sender: usenet@news.eng.convex.com (news access account)
- Reply-To: tchrist@convex.COM (Tom Christiansen)
- Organization: Convex Computer Corporation, Colorado Springs, CO
- Lines: 56
- Originator: tchrist@pixel.convex.com
- Nntp-Posting-Host: pixel.convex.com
- X-Disclaimer: This message was written by a user at CONVEX Computer
- Corp. The opinions expressed are those of the user and
- not necessarily those of CONVEX.
-
- 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) {
- ....
- }
-
-
- But the local() semantics above wouldn't help that. This might help
- a little: (using Larry's typed pointers)
-
-
- foo(\@abc, \@xyz) if $blah;
-
- sub foo(\@alpha, \@beta) {
- ...
- }
-
- being like
-
- sub foo {
- local(\@alpha, \@beta) = @_;
- }
-
- Hm... not quite satisfied with that either....
-
- --tom
- --
- Tom Christiansen tchrist@convex.com convex!tchrist
- OOPS! You naughty creature! You didn't run Configure with sh!
- I will attempt to remedy the situation by running sh for you...
- --Larry Wall in Configure from the perl distribution
-