[mercury-users] Way to exit immediately from a Mercury program?

Julien Fischer juliensf at cs.mu.OZ.AU
Wed Apr 26 17:30:37 AEST 2006


On Wed, 26 Apr 2006, Elmar Haneke wrote:

> > Is there any way to call exit() in a Mercury program?  I've found
> > io.set_exit_status/3, but I thought there might be an io.exit predicate.
>
> You can define it on your own by using the "pragma foreign_proc" to
> call some C-function.

That's what we do in the GLUT binding (see
extras/graphics/mercury_glut/glut.m), defining exit similar to the
following:

	:- pragma foreign_proc("C",
		exit(_IO0::di, _IO::uo),
		[will_not_call_mercury, promise_pure],
	"
		exit(mercury_runtime_terminate());
	").

It should be noted, among other things, that terminating a program this
way will stuff up the deep profiler (and most probably isn't that great
if you wish to use the debugger either).

Julien.
--------------------------------------------------------------------------
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