[mercury-users] Incomprehensible error output, even with -E.

Michael Richter ttmrichter at gmail.com
Thu Feb 2 03:45:55 AEDT 2012


Code is:

main(!IO) :-
    N = (func(X) = ((func) = X)),
    A = (func(K, X1, X2, X3, X4, X5) =
            (B = ((func) = apply(A, K - 1, B, X1, X2, X3, X4))),
            (K =< 0 ->
                apply(X4) + apply(X5)
            ;
                apply(B)
            )
        ),
    io.write_int(apply(A, 10, apply(N, 1), apply(N, -1), apply(N, -1),
apply(N, 1), apply(N,0)), !IO),
    io.write_string("\n", !IO).


(The line number for main/2 is 28.)

Errors generated from this:

man_or_boy.m:030: In clause for predicate `main'/2:
man_or_boy.m:030:   error: the language construct `,'/2 should be used as a
man_or_boy.m:030:   goal, not as an expression.
man_or_boy.m:030:   If you are trying to use a goal as a boolean function,
you
man_or_boy.m:030:   should write `if <goal> then yes else no' instead.
man_or_boy.m:031: In clause for predicate `main'/2:
man_or_boy.m:031:   in argument 1 of clause head:
man_or_boy.m:031:   error: the language construct `='/2 should be used as a
man_or_boy.m:031:   goal, not as an expression.
man_or_boy.m:031:   If you are trying to use a goal as a boolean function,
you
man_or_boy.m:031:   should write `if <goal> then yes else no' instead.
man_or_boy.m:031: In clause for predicate `main'/2:
man_or_boy.m:031:   in argument 2 of functor `,/2':
man_or_boy.m:031:   error: undefined symbol `+/2'.
man_or_boy.m:031: In clause for predicate `main'/2:
man_or_boy.m:031:   in function result term of clause head:
man_or_boy.m:031:   in argument 2 of functor `apply/7':
man_or_boy.m:031:   error: undefined symbol `-/2'.
man_or_boy.m:031: In clause for predicate `man_or_boy.main'/2:
man_or_boy.m:031:   warning: variable `X5' occurs only once in this scope.
man_or_boy.m:031: In clause for predicate `man_or_boy.main'/2:
man_or_boy.m:031:   warning: variables `K, X4, X5' each have overlapping
man_or_boy.m:031:   scopes.
man_or_boy.m:032: In clause for predicate `main'/2:
man_or_boy.m:032:   error: undefined predicate `=<'/2.
man_or_boy.m:032: In clause for predicate `man_or_boy.main'/2:
man_or_boy.m:032:   warning: variable `K' occurs only once in this scope.
man_or_boy.m:033: In clause for predicate `man_or_boy.main'/2:
man_or_boy.m:033:   warning: variable `X4' occurs only once in this scope.
man_or_boy.m:033: In clause for predicate `man_or_boy.main'/2:
man_or_boy.m:033:   warning: variable `X5' occurs only once in this scope.

If I replace the entire body of the lambda assigned to A with, say, 67 or
an apply(X1) I have no problems (aside from warnings about unused
variables).

How can I do what I want to do?

-- 
"Perhaps people don't believe this, but throughout all of the discussions
of entering China our focus has really been what's best for the Chinese
people. It's not been about our revenue or profit or whatnot."
--Sergey Brin, demonstrating the emptiness of the "don't be evil" mantra.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20120202/3b9cd31c/attachment.html>


More information about the users mailing list