home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / perl / 6955 < prev    next >
Encoding:
Internet Message Format  |  1992-11-12  |  2.2 KB

  1. Path: sparky!uunet!news.centerline.com!noc.near.net!hri.com!spool.mu.edu!darwin.sura.net!convex!convex!tchrist
  2. From: tchrist@convex.COM (Tom Christiansen)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: explicit sub parameters - a proposal
  5. Message-ID: <1992Nov12.153941.18318@news.eng.convex.com>
  6. Date: 12 Nov 92 15:39:41 GMT
  7. References: <mcook.721530385@fendahl.dev.cdx.mot.com>
  8. Sender: usenet@news.eng.convex.com (news access account)
  9. Reply-To: tchrist@convex.COM (Tom Christiansen)
  10. Organization: Convex Computer Corporation, Colorado Springs, CO
  11. Lines: 56
  12. Originator: tchrist@pixel.convex.com
  13. Nntp-Posting-Host: pixel.convex.com
  14. X-Disclaimer: This message was written by a user at CONVEX Computer
  15.               Corp. The opinions expressed are those of the user and
  16.               not necessarily those of CONVEX.
  17.  
  18. From the keyboard of mcook@fendahl.dev.cdx.mot.com (Michael Cook):
  19. :What about this idea: perl should allow this construct:
  20. :
  21. :    sub foo($a, $b, @rest) {
  22. :      # ...
  23. :    }
  24. :
  25. :which would be exactly equivalent to
  26. :
  27. :    sub foo {
  28. :      local ($a, $b, @rest) = @_;
  29. :      # ...
  30. :    }
  31. :
  32. :That would greatly improve the readability of Perl, I think.  (Not to mention
  33. :the fact that people might be less likely to stumble into all the strange
  34. :things that can happen when you start playing around with @_.)
  35.  
  36. Yes, this would help with at least one aspect of variable suicide,
  37. the one addressed by the first part of FAQ 2.31 as of the last posting.
  38.  
  39. I agree that it would be an improvement, but some things are left
  40. unaddressed.  One problem is that what I believe people really expect to
  41. work is:
  42.  
  43.     foo(@abc, @xyz) if $blah;
  44.  
  45.     sub foo(@alpha, @beta) {
  46.         ....
  47.     } 
  48.  
  49.  
  50. But the local() semantics above wouldn't help that.  This might help 
  51. a little:  (using Larry's typed pointers)
  52.  
  53.  
  54.     foo(\@abc, \@xyz) if $blah;
  55.  
  56.     sub foo(\@alpha, \@beta) {
  57.         ...
  58.     } 
  59.  
  60.     being like 
  61.  
  62.     sub foo {
  63.         local(\@alpha, \@beta) = @_;
  64.     } 
  65.  
  66. Hm... not quite satisfied with that either....
  67.  
  68. --tom
  69. -- 
  70.     Tom Christiansen      tchrist@convex.com      convex!tchrist
  71.     OOPS!  You naughty creature!  You didn't run Configure with sh!
  72.     I will attempt to remedy the situation by running sh for you...
  73.         --Larry Wall in Configure from the perl distribution
  74.