[mercury-users] discriminant types, generators and higher-order term+Darwin questions

Matthias Kretschmer mccratch at gmx.net
Mon Jul 14 16:30:14 AEST 2003


Hello!

Thank you for the fast response and help. This makes my life easier :)

Am Sonntag, 13.07.03 um 17:48 Uhr schrieb Fergus Henderson:

> Yes, there is.  The code for mypred/1 does need to explicitly call a
> generator predicate.  But you don't have to write the generator
> predicate by hand for every type.  It's quite simple to use the 
> facilities
> in the `construct' module to write a generator that will work for any
> enumeration type:
>
>     :- import_module construct, list, int, std_util, type_desc.
>
>     gen_enum(Val) :-
> 	Type = type_desc__type_of(Val),
> 	list__member(FunctorNum, 0 `..` (construct__num_functors(Type) - 1)),
> 	Univ = construct__construct(Type, FunctorNum, []),
> 	std_util__det_univ_to_type(Univ, Val).
>
> Then you can use this generic definition of gen_enum/1 in my_pred/1:
>
>     mypred(someint(2, X)) :- gen_enum(X).


And now I came up with two other questions:

1. I was having a predicate using in solutions/2 which I wanted to use 
with two different modes. So the compiler complained. I understand as 
the language reference tells one, that higher order terms are only 
allowed to have one mode. So a workaround would be to make something 
like (pred(X::out) is nondet/multi :- myoldpred(X)). I was just 
wondering if this should be changed in a way, or are there some design 
decissions I am currently not aware of?

2. as one can read in README.MacOS there is currently no support for 
dynamic libraries. I was wondering what is the current problem with 
dynamic libraries on Darwin? One thing I guess is, that the 
Boehm-Weiser garbage-collector used in some modified older version 
isn't capable of supporting garbage-collection with dynamic libraries 
on Darwin. If it is so, what modifications were applied to the garbage 
collector, am I able to exchange it with some more modern version of 
the garbage collector to be one step closer to dynamic libraries on OS 
X?

--
Greetings
Matthias Kretschmer

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



More information about the users mailing list