home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / perl / 7507 < prev    next >
Encoding:
Internet Message Format  |  1992-12-18  |  2.3 KB

  1. Path: sparky!uunet!eiffel!eiffel.com
  2. From: ram@eiffel.com (Raphael Manfredi)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: copy() primitive?
  5. Message-ID: <161@eiffel.eiffel.com>
  6. Date: 17 Dec 92 21:45:36 GMT
  7. References: <1gqkqtINN8ne@perv.hal.COM>
  8. Sender: ram@eiffel.com
  9. Organization: Interactive Software Engineering, Santa Barbara CA
  10. Lines: 35
  11.  
  12. Quoting aahz@hal.COM (Tom Wylie) from comp.lang.perl:
  13. >Is there some reason there isn't a primitive for copying files?
  14. >(along the lines of unlink and rename).  firing off backticked /bin/cp's
  15. >seems amazingly inefficient, and while yes I could use filehandles, it
  16. >seems to me that a primitive that just horks in the file and spits it
  17. >out somewhere else would be much faster.  I can't imagine that this
  18. >hasn't come up, so I figure there must be a good reason why there isn't
  19. >a copy() primitive, just wondering what it is.
  20.  
  21. I would say that unlink and rename are system primitives, so they need
  22. to be provided by perl if you want to get the functionality. Ok, rename
  23. is not exactly a primitive since it can be emulated by a serie of link/unlink
  24. but that's close enough to reality.
  25.  
  26. For instance, 'unlink' can offer me something 'rm' will never be able to
  27. provide, namely the ability to "unlink" directories. If I wanted to write
  28. an fsck in perl, I would have to use 'unlink' and not 'rm'. So clearly it
  29. has to be part of perl. (Reality is a bit more complex, this is only for
  30. illustration purpose.)
  31.  
  32. Copying files is another matter. Since it is possible to write a function
  33. based on other language constructs, adding it as a primitive should be
  34. carefully weighed in terms of benefits vs the added complexity. If that
  35. primitive was able to copy files 10 times faster than a library function, then
  36. yes, I would say it should be part of the language. But this is not going to
  37. happen (I'm assuming you are writing an optimal copy function, of course).
  38.  
  39. Therefore, a copy() primitive has not really its place in Perl. Perhaps a
  40. copy.pl library file could be added to the distribution, but it would have
  41. to do complete error checking to report errors accurately.
  42. -- 
  43. Raphael Manfredi <ram@eiffel.com>
  44. Interactive Software Engineering Inc.
  45. 270 Storke Road, Suite #7                      / Tel +1 (805) 685-1006 \
  46. Goleta, California 93117, USA                  \ Fax +1 (805) 685-6869 /
  47.