[m-dev.] For review: update extras/references

Warwick Harvey wharvey at cs.monash.edu.au
Mon Jan 24 17:30:22 AEDT 2000


Estimated hours taken: 1

Fixed/cleaned up a few things in extras/references:

extras/references/Mmakefile:
        Made the building of the programs in the `samples' subdirectory part 
        of a new `install_check' target (rather than the old `check' 
        target), since the Mmakefile in that directory assumes the library 
        has been installed already.

extras/references/tests/ref_test.m:
        Updated so it works again.  It was trying to do I/O in contexts 
        which weren't det.  Basically introduced a new impure pragma c_code
        predicate for dumping the value of an integer to standard output.


Index: Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/references/Mmakefile,v
retrieving revision 1.2
diff -u -r1.2 Mmakefile
--- Mmakefile   1999/10/21 14:36:38     1.2
+++ Mmakefile   2000/01/24 05:53:30
@@ -21,10 +21,13 @@
        cd tests && mmake $(MMAKEFLAGS) GRADEFLAGS="$(GRADEFLAGS)" depend

 check: libglobal
-       cd samples && mmake $(MMAKEFLAGS) GRADEFLAGS="$(GRADEFLAGS)" check
        cd tests && mmake $(MMAKEFLAGS) GRADEFLAGS="$(GRADEFLAGS)" check

 install: libglobal.install
+
+install_check:
+       cd samples && mmake $(MMAKEFLAGS) GRADEFLAGS="$(GRADEFLAGS)" \
+               EXTRA_LIB_DIRS="$(INSTALL_PREFIX)/lib/mercury" check

 clean: clean_subdirs

Index: tests/ref_test.m
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/references/tests/ref_test.m,v
retrieving revision 1.1
diff -u -r1.1 ref_test.m
--- tests/ref_test.m    1998/06/18 04:30:38     1.1
+++ tests/ref_test.m    2000/01/24 05:53:30
@@ -20,38 +20,32 @@
 :- import_module int.
 :- import_module reference, nb_reference, scoped_update.

-main -->
-       { impure new_reference(3,X) },
-       { impure new_nb_reference(3,Y) },
+main(IO, IO) :-
+       impure new_reference(3, X),
+       impure new_nb_reference(3, Y),
        (
-               { impure update(X, 42) },
-               { impure update(Y, 42) },
-               { semipure value(X,V1) },
-               { semipure value(Y,W1) },
-               print(V1),
-               nl,
-               print(W1),
-               nl,
-               {same(X, X1)},
-               {same(Y, Y1)},
-               { impure update(X1, 7) },
-               { impure update(Y1, 7) },
-               { semipure value(X, V2) },
-               { semipure value(Y, W2) },
-               print(V2),
-               nl,
-               print(W2),
-               nl,
-               { impure scope_test }
+               impure update(X, 42),
+               impure update(Y, 42),
+               semipure value(X, V1),
+               semipure value(Y, W1),
+               impure dump_integer(V1),
+               impure dump_integer(W1),
+               same(X, X1),
+               same(Y, Y1),
+               impure update(X1, 7),
+               impure update(Y1, 7),
+               semipure value(X, V2),
+               semipure value(Y, W2),
+               impure dump_integer(V2),
+               impure dump_integer(W2),
+               impure scope_test
        ;
-               { impure scope_test2 }
+               impure scope_test2
        ;
-               { semipure value(X, V3) },
-               print(V3),
-               nl,
-               { semipure value(Y, W3) },
-               print(W3),
-               nl
+               semipure value(X, V3),
+               impure dump_integer(V3),
+               semipure value(Y, W3),
+               impure dump_integer(W3)
        ).


@@ -142,5 +136,12 @@
                will_not_call_mercury, "
        printf(""%s scope ref = %d; reset to %d\n"", (char *) Prefix,
                        (int) Old, (int) New);
+").
+
+
+:- impure pred dump_integer(int::in) is det.
+
+:- pragma c_code(dump_integer(X::in), will_not_call_mercury, "
+       printf(""%d\n"", X);
 ").



--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list