Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!oitnews.harvard.edu!purdue!lerc.nasa.gov!magnus.acs.ohio-state.edu!math.ohio-state.edu!cs.utexas.edu!swrinde!tank.news.pipex.net!pipex!newsfeed.internetmci.com!news.mel.aone.net.au!inferno.mpx.com.au!news.unimelb.EDU.AU!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Subject: Re: type checking
Message-ID: <9524100.1410@mulga.cs.mu.OZ.AU>
Sender: news@cs.mu.OZ.AU (CS-Usenet)
Organization: Computer Science, University of Melbourne, Australia
References: <3vkdvq$cpv@newsbf02.news.aol.com> <3vd6t2$lq0@sgi.iunet.it> 	<950803$003535$3280spenkov@ozemail.com.au> 	<505089247wnr@hyperfax.demon.co.uk> <9523000.25882@mulga.cs.mu.OZ.AU> <THOMASL.95Aug22110741@groucho.csd.uu.se>
Date: Mon, 28 Aug 1995 14:34:00 GMT
Lines: 27

thomasl@groucho.csd.uu.se (Thomas Lindgren) writes:

>fjh@munta.cs.mu.OZ.AU (Fergus Henderson) writes:
>   Mercury's type system is pretty similar to Goedel's, but there are
>   a few small but significant extensions which make it much more useable.
>   One extension is a universal type `univ'.  A value of any type can
>   be converted to type `univ' and then back again.  It's a bit like
>   `void *' in C, except that in Mercury the conversion from `univ' back
>   to another type is checked at runtime and will fail if the type
>   you're trying to convert it to is not the same as the original type.
>
>How does one mode declare univ-typed predicates?  "In"/"Out" only?

Yes.  For example, the declaration of `type_to_univ' looks something like this:

	:- pred type_to_univ(T, univ).
	:- mode type_to_univ(in, out) is det.
	:- mode type_to_univ(out, in) is semidet.

The first mode converts from any type T to univ, and is det (cannot fail).
The second mode does the reverse conversion, and is semidet (may fail).

-- 
Fergus Henderson             |  #define x t=a[i],a[i]=a[m],a[m]=t
                             |  char a[]=" 12345678";main(m,i,j,t){for(i=m;i<
fjh@cs.mu.oz.au              |  9;x,i++)for(x,j=m;--j?(t=a[m-j]-a[m])-j&&t+j:
http://www.cs.mu.oz.au/~fjh  |  main(m+1)*0;);m-9||puts(a+1);} /* 8 queens */
