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

Michael Day mikeday at yeslogic.com
Wed Apr 26 20:25:14 AEST 2006

Hi Nicholas,

> To exit from the Zinc compiler when something like a bad option name is
> encountered.  Currently I have to make sure that the if-then-elses are done
> in such a way that if a bad option is encountered then no real code follows
> the bad-option-handling code before the end of main/2 is hit.

main(!IO) :-
    command_line_arguments(Args, !IO),
    parse_options(Args, Res),
        Res = ok(Options),
        main(Options, !IO)
        Res = error(Error),
        write_string(Error++"\n", !IO)

Keep your predicates very small, then no problem :)


Print XML with Prince!
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