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