[mercury-users] dir class questions

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Apr 20 13:44:49 AEST 2001


On 19-Apr-2001, Terrence Brannon <princepawn at earthlink.net> wrote:
> What would be the intended usage of 
> 
> :- mode dir__this_directory(in) is semidet.	 % Implied
> 	% Returns ".".
> 
> 1 - How could this be semidet? Meaning, how could it have 0 or 1
> values? Isn't the one in argument required?

This procedure is used to test whether its argument is "." or not.
"semidet" here means that it could either succeed or fail
(i.e. have 0 or 1 solutions).  Yes, the one in argument is required.

The comment here is slightly misleading -- it was originally written
when the predicate only had the `out' mode

	:- mode dir__this_directory(out) is det.

That mode binds its output argument to (i.e. "returns") the string ".".
The `in' mode

	:- mode dir__this_directory(in) is semidet.

tests whether its argument is ".".

> 2 - I am curious as to how the state for this predicate is preserved:
> 
> :- mode dir__directory_separator(in) is semidet.
> 	% Returns '/'.

Again, the comment is slightly misleading, since it describes the `out' mode.
The `in' mode here just tests whether the argument is '/' or not.

> Furthermore, I only see a functional implementation of this. Where is the
> predicate with an in parm implemented?

The implementations of these predicates is at the top of the module's
`:- implementation' section:

	dir__directory_separator('/').

	dir__this_directory(".").

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