[mercury-users] announced: libtiff foreign interface (caveats)

Julien Fischer juliensf at csse.unimelb.edu.au
Thu Feb 8 11:50:12 AEDT 2007

On Wed, 7 Feb 2007 doug.auclair at logicaltypes.com wrote:

> Dear Peter and Julien, you wrote:
>> Use pragma foreign_type
> ... and Peter went further:
>> e.g.
>>     :- type image.
>>     :- pragma foreign_type("C", image, "struct image *").
>> BTW, you really should make some of your predicates take I/O states and
>> return error codes.
> Thanks for your comments of the tiff interface module.  I've done a new
> release with the 'pragma foreign_type' change and have put up the
> new version (it's sweet: no cast warnings!).
> Peter, as for using !IO, I understand the idiom well enough within
> pure Mercury code I suppose, but I don't see an application here.
> Moreover, if callers do not have the !IO handle locally, then it seems
> to me to increase the burden on them (requiring them to pass
> around an !IO just to access the protocol).

But they are doing I/O by calling them.

> Would you edify me with
> more detail as to what you mean?  What are the advantages of
> requiring an io state for this protocol?

You need to tell the compiler that these procedures have side effects.
Otherwise, for one thing, it may decide that it can optimize them away
(if for example it deduced that they are logically equivalent to true).

In Mercury there are two main ways of specifying that something has
side effects, threading the I/O state through the calls or by using
impurity annotations.

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