[mercury-users] dir class questions

Zoltan Somogyi zs at cs.mu.OZ.AU
Fri Apr 20 13:48:21 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?

Semidet means "zero or one solutions", not "zero or one arguments".

If you call dir__this_directory with an unbound argument, i.e. in the first
(det) mode, dir__this_directory will bind that argument to a string
representing the current directory ("." on Unix). If you call it with a bound
argument, in the second (semidet) mode, dir__this_directory will check whether
the string the argument is bound is the one representing the current directory.
If it is, it succeeds; if it isn't, it fails.

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

There is no state for this predicate, so there is nothing to preserve.

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

The same clause provides the source code for both modes of
dir__directory_separator. The compiler generates different code for the
different modes. See the paper on the execution algorithm of Mercury for
details.

Zoltan Somogyi <zs at cs.mu.OZ.AU> http://www.cs.mu.oz.au/~zs/
Department of Computer Science and Software Engineering, Univ. of Melbourne
--------------------------------------------------------------------------
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