[m-users.] Stuck trying to compile simple program

Charles Shuller charles.shuller at gmail.com
Wed Nov 8 14:54:50 AEDT 2017


I'm pretty sure you need to import the integer library in order to get the
definition for the '+' operator.

":- import_module integer"

The error is actually that it doesn't have a definition for "an add
function accepting two arguments" (+/2) in the compilation unit,  but I
don't have a mercury compiler on the windows box I'm using right now so I
can't test it quickly :/

There are a lot of libraries that have to be included in mercury that you
just sort of get by default in other languages, so it tends to be the first
thing I try with errors like "I don't know how to add" or "I don't know
what a string is" etc...

I suspect the rational is something of a combination of "Keep the actual
language as small as possible" and "speed compilation time by ensuring only
the bare minimum is included" but other's will have to address that
authoritatively (as opposed to my speculation).

Also, looking at your length function, I suspect you don't need it, but I
had to pick up a prologue book to supplement the tutorial.  The two
languages are really similar so it worked out really well for me.


Cheers!

Charles



On Tue, Nov 7, 2017 at 7:32 PM, zeldangit <zeldangit at gmail.com> wrote:

> Hello,
>
> I am currently making my way through Ralph Becket Mercury tutorial and I
> am stuck trying to add a simple length function to my program. Here it is
> along with the error I am having
> <https://gist.github.com/zeldangit/9448809d80f7613d74189feb9f5529ac>. Any
> help would be much appreciated.
>
> Thanks,
>
> _______________________________________________
> users mailing list
> users at lists.mercurylang.org
> https://lists.mercurylang.org/listinfo/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20171107/ef07cb01/attachment.html>


More information about the users mailing list