[m-rev.] for review: specialise file copying in the compiler

Zoltan Somogyi zoltan.somogyi at runbox.com
Sat Apr 23 22:49:33 AEST 2022


2022-04-23 22:38 GMT+10:00 "Julien Fischer" <jfischer at opturion.com>:
> I agree and when the necessary machinery exists (see below) will do that.
> I will add a comment about that for now.
> 
> Actually, there are a few things that should happen here:
> 
> 1. If the OS or platform provides a file copy operation (e.g. CopyFile()
> on Windows, java.nio.file.Files.copy()) we should use that in preference
> to either calling an external command or using the Mercury implementation.
> 
> 2. We should add a way to tell the compiler not to even try copying a
> file using an external command. (This would be useful on Windows, where
> the copy command is a poor substitute for cp.)

I didn't know either of those things, but they are valid points.

> 3. We should add some sort of copy_file predicate to the standard
> library.  This is slightly iffy since file copy operations in most
> programming language standard libraries are really "copy the file and
> preserve relevant metadata where possible".

In at least some cases, preserving the modification time is something
that we want to *avoid*, though I am not sure you include that in "metadata".

> On balance, I think it would
> be a worthwhile addition and we can make it work well enough on the
> platforms we support.

If you say so; I don't know about non-Unix platforms to say yes or no.

> There was the small matter of the 22.01 release between then and now ;-)

Of course. I was just surprised that you seemed to abandon the agreed-on
approach.

> Do you have any objections to committing this with the added comment?

No objection.

> Another question: should the stream foldls in the stream module be
> modified to reduce stack usage in debug grades (as some of the ones
> in the io module have been)?

I don't think they should be modified; I think there should be separate
versions of the relevant predicates that do chunking, with an extra
chunk size parameter, since that does vary with expected max iteration length.

Zoltan.


More information about the reviews mailing list