[m-rev.] Added unsafe_promise_unique/1 func

Ralph Becket rafe at cs.mu.OZ.AU
Wed Dec 19 11:25:55 AEDT 2001


Simon Taylor, Tuesday, 18 December 2001:
> On 18-Dec-2001, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> > For review by anybody.
> > 
> > Estimated hours taken: 0.1
> > Branches: main
> > 
> > library/builtin.m:
> > 	Added func version of unsafe_promise_unique.
> > 
> > NEWS:
> > 	Mentioned the new addition.
> > 
> > Index: NEWS
> > ===================================================================
> > @@ -3,6 +3,9 @@
> >  
> >  Changes to the Mercury language:
> >  
> > +* The built-in pred unsafe_promise_unique/2 now has an analagous func,
> > +  unsafe_promise_unique/1.
> 
> That's a change to the library, not the language.
> 
> `builtin__unsafe_promise_unique' should be added to the existing item:
> 
> 	* We've added function versions of `ops__init_op_table'
> 	  and `ops__max_priority'.

Done.

[I thought that since builtin.m is automatically imported into all
modules, it essentially implements predicates etc. that are part of the
*language*.  Indeed, the comment at the head of builtin.m reads:

	% This file is automatically imported into every module.
	% It is intended for things that are part of the language,
	% but which are implemented just as normal user-level code
	% rather than with special coding in the compiler.

].

> > Index: builtin.m
> > ===================================================================
> > @@ -126,6 +126,11 @@
> >  :- pred unsafe_promise_unique(T, T).
> >  :- mode unsafe_promise_unique(in, uo) is det.
> >  
> > +% Func version of unsafe_promise_unique/2.
> > +
> > +:- func unsafe_promise_unique(T) = T.
> > +:- mode unsafe_promise_unique(in) = uo is det.
> 
> I'd suggest removing the comment. It doesn't really add anything. 

Done.

On rechecking my change, I observed that I omitted to include a clause
for unsafe_promise_unique/1 - it is odd that this wasn't spotted by the
compiler since it passed bootcheck...

Having added the following:

@@ -818,6 +821,9 @@
 %-----------------------------------------------------------------------------%

 % unsafe_promise_unique/2 is a compiler builtin.
+
+unsafe_promise_unique(X) = Y :-
+       unsafe_promise_unique(X, Y).

compilation of the library now halts with 
builtin.m:825: Warning: clause for builtin.

This is wrong, surely?  unsafe_promise_unique/*2* is the compiler
builtin.

Can someone give me a pointer as to what I need to do to fix matters?

> There should also be a test case.

Well, unsafe_promise_unique/2 is called from
hard_coded/unused_float_box_test.m; is there any need for a separate
test case involving unsafe_promise_unique/1?

- Ralph
--------------------------------------------------------------------------
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