[mercury-users] Abstraction barrier

Ralph Becket rafe at cs.mu.OZ.AU
Tue May 13 14:07:54 AEST 2003


Michael Day, Tuesday, 13 May 2003:
> 
> :- pred foo(magic_data, magic_token, magic_token, T, T).
> :- mode foo(in, di, uo, in, out) is det.
> 
> Perhaps this way, and only provide accessor functions for magic_data that
> require a magic_token to operate, such that even if the function returns
> magic_data nothing can be done with it later?

Sounds about right.

> For those who care, the trickiest part of using the Win32 API from Mercury
> is managing the expectations of when pointers go out of scope. It's very
> easy to keep references to strings and other data provided by the
> operating system that go out of scope unexpectedly, leading to trouble.

The same is true of IO stream handles.  Posession of a stream handle is
not sufficient to use it, one must also have an IO state.  The IO state
notionally knows whether the stream handle is valid (i.e. refers to an
open stream) and can report an error if so.

- Ralph
--------------------------------------------------------------------------
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