[mercury-users] Converting time_t to int using common library?

Julian Fondren ayrnieu at gmail.com
Tue Feb 13 22:44:43 AEDT 2007


On 2/13/07, Julien Fischer <juliensf at csse.unimelb.edu.au> wrote:
> On Tue, 13 Feb 2007, Julian Fondren wrote:
> > :- func random.init = (random.supply::uo) is det.

No, it doesn't.  I had the idea that it would allow random-using
code to not depend on IO, but if anything it should just throw
an error if called more than once.

> BTW, you should avoid using the old foreign language interface (as you did
> in the attached patch) in favour of the new one, e.g.
>
>    pragma foreign_proc("C", ...       instead of pragma c_code
>    pragma foreign_decl("C", ...  instead of pragma c_header_code
>
> The old interface is deprecated and we will be removing support for it
> at some point.  (Also the implementation of pragma c_code is a bit
> unpredictable w.r.t to the purity system.)

Oh.  Although I've used it, I've mainly focused on other areas
of the Mercury Language Reference Manual -- the Purity section,
for instance, which is -really interesting-, and which
accidentally teaches everything you need to know to use... the
old interface to C :-)

http://www.cs.mu.oz.au/research/mercury/information/doc-release/mercury_ref/Impurity-Example.html

The attached patch uses the new interface to only define the
IO-using predicate.

Cheers,
Julian
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: random-moreinit-2.patch
URL: <http://lists.mercurylang.org/archives/users/attachments/20070213/8f389469/attachment.ksh>


More information about the users mailing list