[mercury-users] Field Update and Field Selection.
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri Oct 11 21:09:11 AEST 2002
On 11-Oct-2002, Noel Pinto <cool4life at rediffmail.com> wrote:
> :- pred get_next(string::in, bool::out, io__state::di,
> io__state::uo) is det.
> get_next(String, More) -->
> io__read_word(get_a), { More = yes},
> if get_a = ok then set_a = get_a else More = no,
> io__read_word(get_b), {More =yes},
> if get_b = ok then set_b = get_b else More = no,
> io__read_word(get_c), {More = yes},
> if get_c = ok then set_c = get_c else More = no.
I have no idea what you are trying to do here.
What did you expect "io__read_word(get_a)" and "set_a = get_a" to do??
Note that "=" in Mercury is unification, not assignment.
If "More" has the value "yes", then the goal "More = no"
will just fail, it won't assign a new value to "More".
Since this procedure is declared as "det", it is not
allowed to fail, so this failure would lead to a determinism error.
> Here are the errors:-
> upd.m:046: Syntax error at token 'if': unexpected token at start
> of (sub)term.
That's because the "if" statement needs to be enclosed in parentheses.
> upd.m:041: In clause for predicate `upd:main/2':
> upd.m:041: in argument 1 of call to predicate `do_while/3':
> upd.m:041: error: undefined symbol `getnext/0'.
That's because you mispelt "get_next" as "getnext".
> upd.m:041: In clause for predicate `upd:main/2':
> upd.m:041: error: undefined predicate `do_while/3'.
That's because you didn't import the "std_util" standard library module.
> upd.m:043: Error: no clauses for predicate `upd:get_next/4'.
This is a spurious flow-on error caused by the syntax error on line 46.
It will go away once you fix the syntax error.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | 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