[mercury-users] ok/[01] and file descriptors
Fergus Henderson
fjh at cs.mu.OZ.AU
Mon Apr 16 19:07:33 AEST 2001
On 15-Apr-2001, John Eikenberry <jae at zhar.net> wrote:
>
> 1. Where are ok/1 and ok/0 explained? If they're not, could someone explain
> them. ... They are mentioned in the comments of some declarations
> but never described themselves (that I could find).
ok/1 and ok/0 are alternatives in the io__res, io__result, and io__read_result
types defined in the standard library module `io':
| % Various types used for the result from the access predicates
|
| :- type io__res ---> ok
| ; error(io__error).
|
| :- type io__res(T) ---> ok(T)
| ; error(io__error).
|
| :- type io__result ---> ok
| ; eof
| ; error(io__error).
|
| :- type io__result(T) ---> ok(T)
| ; eof
| ; error(io__error).
|
| :- type io__read_result(T) ---> ok(T)
| ; eof
| ; error(string, int).
| % error message, line number
These types are used as return types for certain I/O operations.
If ok/1 or ok/0 is returned, it means that the I/O operation was
carried out successfully; for ok/1, which is used for input operations,
the argument of ok/1 is the value that was input.
For I/O operations which return one of these types, if the I/O operation
could not be carried out successfully, it will return error/1 or eof/0.
If error/1 is returned, the argument gives the reason why the operation
could not be carried out successfully.
> 2. I'm figuring out the posix module because I need to use select over
> stdin and stdout. select expects file descripter pointers, and I've not
> having much luck in figuring out how to get these for stdin/stdout. Any
> tips?
:- func stdin = posix__fd.
:- func stdout = posix__fd.
:- func stderr = posix__fd.
stdin = posix__fd(0).
stdout = posix__fd(1).
stderr = posix__fd(2).
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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