[mercury-users] Re: Mercury Tutorial / Functions
Goncalo Jorge Coelho e Silva
l10454 at alunos.uevora.pt
Thu Apr 24 21:32:59 AEST 2003
> > read_strings_2(RevSs, Ss, IO0, IO) :-
> > io__read_line_as_string(Result, IO0, IO1),
> > (
> > Result = ok(S),
> > %io__write_string(S,IO0, IO1),
> > read_strings_2([S | RevSs], Ss, IO1, IO)
> > ;
> > Result = eof,
>
> Here I omitted the goal
>
> IO = IO1,
>
> which is necessary to ensure that IO is instantiated (as we promise in
> the mode declaration) when read_strings_2/4 terminates.
Before:
inter.m:043: In clause for `read_strings_2(in, out, di, uo)':
inter.m:043: mode error in conjunction. The next 3 error messages
inter.m:043: indicate possible causes of this error.
inter.m:043: In clause for `read_strings_2(in, out, di, uo)':
inter.m:043: mode mismatch in disjunction.
inter.m:043: `IO' :: unique, free, not_reached.
inter.m:030: In clause for `read_strings_2(in, out, di, uo)':
inter.m:030: in argument 2 of clause head:
inter.m:030: mode error in unification of `HeadVar__2' and `Ss'.
inter.m:030: Variable `HeadVar__2' has instantiatedness `free',
inter.m:030: variable `Ss' has instantiatedness `free'.
inter.m:030: In clause for `read_strings_2(in, out, di, uo)':
inter.m:030: in argument 4 of clause head:
inter.m:030: mode error in unification of `HeadVar__4' and `IO'.
inter.m:030: Variable `HeadVar__4' has instantiatedness `free',
inter.m:030: variable `IO' has instantiatedness `free'.
make: *** [run] Error 1
After I inserted the goad 'IO = IO' :
inter.m:024: warning: variable `Ss' occurs only once in this scope.
inter.m:043: In clause for `read_strings_2(in, out, di, uo)':
inter.m:043: mode error in conjunction. The next 3 error messages
inter.m:043: indicate possible causes of this error.
inter.m:037: In clause for `read_strings_2(in, out, di, uo)':
inter.m:037: in argument 3 of call to predicate
`inter:read_strings_2/4':
inter.m:037: mode error: variable `IO1' has instantiatedness `ground',
inter.m:037: expected instantiatedness was `unique'.
inter.m:030: In clause for `read_strings_2(in, out, di, uo)':
inter.m:030: in argument 2 of clause head:
inter.m:030: mode error in unification of `HeadVar__2' and `Ss'.
inter.m:030: Variable `HeadVar__2' has instantiatedness `free',
inter.m:030: variable `Ss' has instantiatedness `free'.
inter.m:030: In clause for `read_strings_2(in, out, di, uo)':
inter.m:030: in argument 4 of clause head:
inter.m:030: mode error in unification of `HeadVar__4' and `IO'.
inter.m:030: Variable `HeadVar__4' has instantiatedness `free',
inter.m:030: variable `IO' has instantiatedness `free'.
Not only the problem persists, it still has this
to add:
inter.m:037: mode error: variable `IO1' has instantiatedness `ground',
inter.m:037: expected instantiatedness was `unique'.
Reporting to the problem:
mode error in unification of `HeadVar__2' and `Ss'.
inter.m:030: Variable `HeadVar__2' has instantiatedness `free',
inter.m:030: variable `Ss' has instantiatedness `free'.
I tried adding a goal 'forcing' the unification of Ss
(since it's said to be 'free', when it should be ground).
but it didn't do anything.
Tips?
Thanks.
Cheers,
Goncalo
--------------------------------------------------------------------------
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