[m-rev.] for review: library changes for `mmc --make' on Windows

Simon Taylor stayl at cs.mu.OZ.AU
Mon Jun 23 01:23:18 AEST 2003


On 18-Jun-2003, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 15-Jun-2003, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> > 	Change the determinism of dir.basename and dir.split_name.
> > 	dir.basename now fails for root directories (a new function
> > 	dir.basename_det calls error/1 rather than failing).
> > 	dir.split_name fails for root directories or if the pathname
> > 	passed doesn't contain a directory separator.
 
> Hmm... I'd prefer to avoid changes that break backwards compatibility
> unless there is a strong reason for them.

In my opinion the current interface is broken as designed.
Users who depended on the old behaviour will have to change
their code anyway, and the determinism change will make it
more likely that any compatibility problems are caught.
 
> > +	% Make the given directory, and all parent directories.
> > +	% This will also succeed if the directory already exists
> > +	% and is readable and writable by the current user.
> > +:- pred dir__make_directory(string, io__res, io__state, io__state).
> > +:- mode dir__make_directory(in, out, di, uo) is det.
> 
> This functionality is a bit too high-level.  While I agree that this
> functionality is useful, if we're going to add this, then I think
> we should also add a procedure to just make a single directory,
> without attempting to make any of the parent directories.
> 
> [For the .NET CLI, I think you can create a directory without creating
> all the subdirectories using "(new System.IO.DirectoryInfo(path)).Create();".]

I thought about that, but when is this functionality useful?
 
> > +:- pragma foreign_proc("C#",
> > +	dir__split_name_dotnet(FileName::in, DirName::out, BaseName::out),
> > +	[may_call_mercury, promise_pure, thread_safe],
> > +"
> > +	try {
> > +		DirName = System.IO.Path.GetDirectoryName(FileName);
> > +		if (DirName == null) {
> > +			SUCCESS_INDICATOR = false;
> > +		} else if (DirName == System.String.Empty) {
> > +			SUCCESS_INDICATOR = true;
> > +			DirName = mercury.dir.mercury_code.ML_this_directory();
> > +			BaseName = FileName;
> > +		} else {
> > +			BaseName = System.IO.Path.GetFileName(FileName);
> > +			SUCCESS_INDICATOR = (BaseName != null);
> > +		}
> > +	} catch (System.Exception e) {
> > +		SUCCESS_INDICATOR = false;
> > +	}
> > +").
> 
> Is this really pure?
> 
> For example, 

The example was missing.

Simon.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list