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

doug.auclair at logicaltypes.com doug.auclair at logicaltypes.com
Tue Feb 13 17:12:04 AEDT 2007


Dear all,

I've run into a small problem, when I wish to initialize
the supply in module random, I turn to the time module
to give me an unique int (the current time).  However,
the time module returns a time_t, and the compiler
(rightly) gripes that time_t is not an int (it's declared
abstract in module time).

You know that it's an int, and so do I.

It appears to me the only way around the compiler's
grumbling is to snap the type to an int with some
deep C hackery around the user-generated

:- func time_t2int(time_t) = int.

but I don't particularly like this at all -- subverting
the type system seems so anti-mercury.

So, is there an elegant way to convert time_t to int
using the supplied modules in the library that I'm
missing?  If not, could module random be modified
to allow a seed to initialize the supply to be a time_t
as well as an int?

Sincerely,
Doug Auclair

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



More information about the users mailing list