[mercury-users] Compiled a library, linked to a program... but no calls are performed

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Mar 7 03:50:21 AEDT 2003

On 06-Mar-2003, Ondrej Bojar <oboj7042 at ss1000.ms.mff.cuni.cz> wrote:
> Then, in the main program, I do:
> :- module chatter.
> ...
> :- import_module debugstr.
> main -->
>   io__write_string("yes\n"),
>   {
>   debugstr("Chatter started.\n"),
>   ...
>   }
>   io__write_string("Done.\n").
> The debugstr module performs unsafe impure io, and should dump the string
> to the stdout.
> As I've said, it compiles and links without errors.
> However, the program produces only this output:
> obo at nats47:chatter $ ./chatter
> yes
> Done
> No routines from the library are ever called. (There are others, not just
> debugstr.)
> Would you please help me?

Firstly, are you compiling with `--no-fully-strict'?
If so, the compiler will rightly optimize away calls to debugstr and
similar procedures, since they are declared `det', pure, and have no outputs.
In general using impure procedures but not marking them as impure is a
recipe for problems.  It is a lot safer to mark such procedures as `impure'.

Secondly, what happens if you enabled debugging, and step through it with
`mdb'.  Do the routines from the library get called then?

Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
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