[m-rev.] diff: fix lazy evaluation library

Julien Fischer juliensf at csse.unimelb.edu.au
Wed Jul 28 07:04:31 AEST 2010


Branches: main, 10.04

Fix the lazy evaluation library in the extras distribution.

extras/lazy_evaluation/lazy.m:
 	Restore the lazy/1 inst; it's used by the lazy_list module in this
 	directory.

 	Add some missing MR_ prefixes.

extras/lazy_evaluation/lazy_list.m:
 	Use a C foreign_proc pragma instead of a c_code pragma.

Julien.

Index: lazy.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/extras/lazy_evaluation/lazy.m,v
retrieving revision 1.4
diff -u -r1.4 lazy.m
--- lazy.m	11 May 2009 03:05:34 -0000	1.4
+++ lazy.m	27 Jul 2010 20:59:27 -0000
@@ -33,6 +33,7 @@
      % demand.
      %
  :- type lazy(T).
+% :- inst lazy(I).

      % Convert a value from type T to lazy(T)
      %
@@ -83,17 +84,21 @@

  :- implementation.
  :- interface.
-
-:- implementation.
-
+
      % Note that we use a user-defined equality predicate to ensure
      % that unifying two lazy(T) values will do the right thing.
      %
  :- type lazy(T) ---> value(T) ; closure((func) = T)
      where equality is equal_values.
+ 
+:- inst lazy(I)
+    --->    value(I)
+    ;       closure(((func) = out(I) is det)).

  :- pred equal_values(lazy(T)::in, lazy(T)::in) is semidet.

+:- implementation.
+
  equal_values(X, Y) :-
      force(X) = force(Y).

@@ -142,7 +147,7 @@
      [will_not_call_mercury],
  "
      /* strip off tag bits */
-    Word *ptr = (Word *) MR_strip_tag(HeapCell);
+    MR_Word *ptr = (MR_Word *) MR_strip_tag(HeapCell);
      /* destructively update value */
      *ptr = NewValue;
  ").
Index: lazy_list.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/extras/lazy_evaluation/lazy_list.m,v
retrieving revision 1.1
diff -u -r1.1 lazy_list.m
--- lazy_list.m	15 Mar 1999 08:56:58 -0000	1.1
+++ lazy_list.m	27 Jul 2010 20:52:43 -0000
@@ -91,8 +91,12 @@
  :- func list_inst_cast(lazy_list(T)) = lazy_list(T).
  :- mode list_inst_cast(in) = out(lazy_list) is det.

-:- pragma c_code(list_inst_cast(F::in) = (F2::out(lazy_list)),
-	[will_not_call_mercury, thread_safe], "F2 = F;").
+:- pragma foreign_proc("C",
+    list_inst_cast(F::in) = (F2::out(lazy_list)),
+    [promise_pure, will_not_call_mercury, thread_safe],
+" 
+    F2 = F;
+").

  %-----------------------------------------------------------------------------%


--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list