[mercury-users] =/2 used as a goal, not as an expression
Goncalo Jorge Coelho e Silva
l10454 at alunos.uevora.pt
Tue May 27 06:02:15 AEST 2003
Hi,
>`yes' and `no' are defined in the bool module in the library.
OK. So I tried to import it and then run the code again with
this predicate in it:
What's wrong here? According to the compiler message,
this should work.
(with ":-import bool." on)
--------------------------
:- pred test(int).
:- mode test(in) is det.
test(Input):- if {Input = 0} then yes else no.
inter.m:660: In clause for predicate `inter:test/1':
inter.m:660: in argument 1 of call to predicate `{}/1':
inter.m:660: error: the language construct =/2 should be
inter.m:660: used as a goal, not as an expression.
inter.m:660: If you are trying to use a goal as a boolean function,
inter.m:660: you should write `if <goal> then yes else no' instead.
inter.m:660: In clause for predicate `inter:test/1':
inter.m:660: error: undefined predicate `{}/1'.
inter.m:660: In clause for predicate `inter:test/1':
inter.m:660: error: undefined predicate `yes/0'.
inter.m:660: In clause for predicate `inter:test/1':
inter.m:660: error: undefined predicate `no/0'.
make: *** [run] Error 1
or using DCGs:
--------------
inter.m:658: Error: no clauses for predicate `inter:test/1'.
inter.m:661: In clause for predicate `inter:test/3':
inter.m:661: error: undefined predicate `yes/2'.
inter.m:661: In clause for predicate `inter:test/3':
inter.m:661: error: undefined predicate `no/2'.
make: *** [run] Error 1
:- pred test(int).
:- mode test(in) is det.
test(Input)--> if {Input = 0} then yes else no.
on the other sample code:
---------------------------
I took some parts of the last sample code off, to
show the least non-relevant code possible. So, yes,
it was a DCG predicate and yes, I made a mistake on
using {..} on IO io__write_string. I use DCG code
with IO because, originaly, most of it is written
with no IO code at all. Eventually I have to pop
some in to test some aspects of it.
Here's a whole predicate with the same problem.
How can I put
if {ModeIn = 0} then
to work?? (I believe there isn't any {...} error
here!)
inter.m:624: In clause for predicate `inter:code_gen/7':
inter.m:624: in argument 1 of call to predicate `{}/1':
inter.m:624: error: the language construct =/2 should be
inter.m:624: used as a goal, not as an expression.
inter.m:624: If you are trying to use a goal as a boolean function,
inter.m:624: you should write `if <goal> then yes else no' instead.
inter.m:624: In clause for predicate `inter:code_gen/7':
inter.m:624: error: undefined predicate `{}/1'.
make: *** [run] Error 1
624: > if {ModeIn = 0} then
code_gen(instruction("unify_variable",Xi,""), HeapIn, HeapOut,
RegistHashIn, RegistHashOut) -->
{
lookup(RegistHashIn, "h") = H,
lookup(RegistHashIn, "mode") = ModeIn,
lookup(RegistHashIn, "s") = S,
(
if {ModeIn = 0} then
array__lookup(HeapIn, S, SContent),
string__det_to_int(SContent) = SConverted,
set(RegistHashIn, Xi, SConverted) = RegistHashOut
%(?)set(RegistHashIn, Xi, SContent) = RegistHash01,
%(?)NewS = S + 1,
%(?)set(RegistHash01, "s", NewS) = RegistHashOut
else
array__set(HeapIn, H, "REF", Heap01),
string__int_to_string(H+1, ConvertedInt),
array__set(Heap02, H+1, ConvertedInt, Heap03),
set(RegistHashIn, Xi, H) = RegistHash01,
set(RegistHash01, "h", NewH) = RegistHash02,
NewH = H + 2,
set(RegistHash02, "h", NewH) = RegistHash03
),
NewS = S + 1,
set(RegistHash03, "s", NewS) = RegistHashOut
}.
Thanks,
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