[m-users.] [Beginner] Using a functions from 'libs'
Volker Wysk
post at volker-wysk.de
Sun Oct 16 21:40:02 AEDT 2022
You've mixed up the input and output arguments in the declaration of main/2.
Volker
Am Sonntag, dem 16.10.2022 um 16:06 +0530 schrieb Razetime:
> For this program I tried using mmc --make and i got the following error.
>
> :- module a05.
>
> :- interface.
> :- import_module io.
> :- pred main(io::uo,io::di) is det.
>
> :- implementation.
> :- import_module list.
> :- import_module md5.
>
> main(!IO):-
> S0=md5sum("abc3231929"),
> print_line(S0,!IO)
> .
>
>
> $ mmc --make a05 md5
> Making Mercury/int3s/a05.int3
> Making Mercury/ints/a05.int
> Making Mercury/cs/a05.c
> a05.m:013: In clause for `main(uo, di)':
> a05.m:013: in argument 2 of call to predicate `io.print_line'/3:
> a05.m:013: unique-mode error: the called procedure would clobber its
> a05.m:013: argument, but variable `STATE_VARIABLE_IO_0' is still live.
> ** Error making `Mercury/cs/a05.c'.
>
> How do i make sure the variable is not live?
>
> On 10/16/22, Razetime <rraghu.11502 at gmail.com> wrote:
> > Oh, makes sense. The md5.m file is not part of the distribution so i
> > have to compile it along with my program. Thanks.
> >
> > On 10/16/22, Julien Fischer <jfischer at opturion.com> wrote:
> > >
> > >
> > > On Sun, 16 Oct 2022, Razetime wrote:
> > >
> > > > using the name md5 like follows:
> > > > :- module a05.
> > > >
> > > > :- interface.
> > > > :- import_module io.
> > > > :- pred main(io::uo,io::di) is det.
> > > >
> > > > :- implementation.
> > > > :- import_module list.
> > > > :- import_module md5.
> > > >
> > > > main(!IO):-
> > > > S0=md5sum("abc3231929"),
> > > > print_line(S0,!IO)
> > > > .
> > > >
> > > > gives me this error:
> > > > $ mmcb a05.m
> > > > ~
> > > > │mercury_compile:
> > > > cannot find `Mercury/ints/md5.int' in directories .,
> > > > ~
> > > > │
> > > > /usr/lib/mercury/ints
> > >
> > > Using mmc directly like that is only for building single module
> > > programs. To build a program consisting of multiple modules, use
> > > the --make option, e.g.
> > >
> > > $ mmc --make a05
> > >
> > > (See the "Using the Mercury compile" section of the Mercury users's
> > > guide for details.)
> > >
> > > Julien.
> >
> _______________________________________________
> users mailing list
> users at lists.mercurylang.org
> https://lists.mercurylang.org/listinfo/users
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.mercurylang.org/archives/users/attachments/20221016/2cc812c4/attachment.sig>
More information about the users
mailing list