home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / perl / 6967 < prev    next >
Encoding:
Text File  |  1992-11-13  |  2.0 KB  |  56 lines

  1. Newsgroups: comp.lang.perl
  2. 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
  3. From: mcook@fendahl.dev.cdx.mot.com (Michael Cook)
  4. Subject: Re: explicit sub parameters - a proposal
  5. Message-ID: <mcook.721600211@fendahl.dev.cdx.mot.com>
  6. Sender: news@merlin.dev.cdx.mot.com (USENET News System)
  7. Nntp-Posting-Host: fendahl.dev.cdx.mot.com
  8. Organization: Motorola Codex, Canton, Massachusetts
  9. References: <mcook.721530385@fendahl.dev.cdx.mot.com> <1992Nov12.153941.18318@news.eng.convex.com>
  10. Date: Thu, 12 Nov 1992 20:30:11 GMT
  11. Lines: 43
  12.  
  13. tchrist@convex.COM (Tom Christiansen) writes:
  14.  
  15. >From the keyboard of mcook@fendahl.dev.cdx.mot.com (Michael Cook):
  16. >:What about this idea: perl should allow this construct:
  17. >:
  18. >:    sub foo($a, $b, @rest) {
  19. >:      # ...
  20. >:    }
  21. >:
  22. >:which would be exactly equivalent to
  23. >:
  24. >:    sub foo {
  25. >:      local ($a, $b, @rest) = @_;
  26. >:      # ...
  27. >:    }
  28. >:
  29. >:That would greatly improve the readability of Perl, I think.  (Not to mention
  30. >:the fact that people might be less likely to stumble into all the strange
  31. >:things that can happen when you start playing around with @_.)
  32.  
  33. >Yes, this would help with at least one aspect of variable suicide,
  34. >the one addressed by the first part of FAQ 2.31 as of the last posting.
  35.  
  36. >I agree that it would be an improvement, but some things are left
  37. >unaddressed.  One problem is that what I believe people really expect to
  38. >work is:
  39.  
  40. >    foo(@abc, @xyz) if $blah;
  41.  
  42. >    sub foo(@alpha, @beta) {
  43. >        ....
  44. >    } 
  45.  
  46. I've come to learn that &foo(@abc) means &foo($abc[0], ..., $abc[$#abc]).
  47. I'm sure that changing the rules would break a lot of existing code (but then
  48. there is that clever "version" idea that someone posted a couple days ago...).
  49.  
  50. In the definition ``sub foo(@alpha, @beta, $gamma, %delta)'', perl -w should
  51. warn about the parameters that follow @alpha, since the declaration doesn't
  52. make sense.
  53.  
  54. Michael.
  55. Perl's estranged second cousin-in-law, twice removed.
  56.