[mercury-users] ok/[01] and file descriptors

Ralph Becket rbeck at microsoft.com
Mon Apr 16 21:21:57 AEST 2001


> From: John Eikenberry [mailto:jae at zhar.net]
> Sent: 15 April 2001 23:28
> 
> 1. Where are ok/1 and ok/0 explained? If they're not, could 
> someone explain
> them. I've searched the site, mail archives, grepped through 
> the docs and the
> compiler distribution. They are mentioned in the comments of 
> some declarations
> but never described themselves (that I could find).

[This may be a hole in the documentation.]  Typically, preds that
have to return a success indicator return just one item of a type
with (some of) the following constructors:

ok	indicates success, there is no other result (e.g. io__see/4,
	io__tell/4);

ok(X)	indicates success and X is the requested item (e.g. from
	io__read_byte);

eof	indicates end-of-file for IO read operations;

error(E) reports that something went wrong; E is some representation
	of the particular error (e.g. an error code or pointer to a
	location in a file).

For example,

main -->
    io__read_byte(Result),
    (   { Result = ok(X) },     process_byte(X), main
    ;   { Result = eof },       finish_up
    ;   { Result = error(E) },  abandon_ship(E)
    ).

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

I'll be heading in to the office later today where I've got everything
available; I'll get back to you then.

Cheers,

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