[mercury-users] partial instantiation?
Tomas By
tomas at basun.net
Tue Apr 20 04:30:13 AEST 2010
On Mon, April 19, 2010 19:56, Mark Brown wrote:
> On 19-Apr-2010, Tomas By <tomas at basun.net> wrote:
>> What I get on the command line is ["command","foo","42"],
>
> So cmd is called with the (ground) value [str("foo"), int(42)] as the
> second argument, and dosomething(42, "foo") is returned.
Are you telling me what I should be doing instead of what I want myself?
Good luck with that eh!
Here is the code that calls cmd/3 (in an earlier version that never
worked, but anyway):
|:- pred command(list(string),maybe(cmdproc),errors,errors).
|:- mode command(in,out,in,out) is det.
|
|command(As,MC,!Es) :-
| ( As = [], MC = yes(none)
| ; As = [CS|Ss],
| solutions((pred(P::out) is nondet :-
| cmd(CS,AA,PR), P = AA-PR ),Ps),
| ( Ps = [] ->
| add_error(unknown_command(CS),!Es), MC = no
| ; solutions((pred(X::out) is nondet :-
| member(Zs-X,Ps), cmdargs(Zs,Ss)),Xs),
| ( Xs = [Proc] -> MC = yes(Proc)
| ; add_error(funny_cmdline(As),!Es), MC = no ) ) ).
`As' is what comes out of getopt.process_options, and the `cmdproc' takes
some additional arguments including the io.state.
I'd be interested in ideas about how to do this in Mercury. My only
absolute requirement is that the list of commands (e.g. cmd/3) must be
short and simple.
/Tomas
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to: mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions: mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the users
mailing list