[mercury-users] partial instantiation?

Tomas By tomas at basun.net
Mon Apr 19 17:22:48 AEST 2010

On Mon, April 19, 2010 03:13, Ralph Becket wrote:
> Tomas, Wednesday, 14 April 2010:
>> |:- pred cmd(string,list(cmdarg),cmdproc).
>> |:- mode cmd(out,out,out) is nondet.
>> |
>> |cmd( "command", [],              dosomething(0,"filename") ).
>> |cmd( "command", [str(F)],        dosomething(0,F)          ).
>> |cmd( "command", [int(N)],        dosomething(N,"filename") ).
>> |cmd( "command", [str(F),int(N)], dosomething(N,F)          ).
> [...]
> However, looking at your program, it seems to me that you know what
> command you mean and what F and N are at the point where you call cmd/3,
> so why not use this mode:
> :- mode cmd(in, in, out) is nondet.
> You can then do things like
> 	cmd("command", [str("filename")], Cmd1),
> 	cmd("command", [int(N)], Cmd2),
> 	...

Hmm - does this work though? Can "[int(N)]" be just "in"?

And the intention is that cmd/3 lists all the available commands. Then
other code picks the right one depending on whether there is a string
and/or int on the command line, together with the command string.

(But I guess you are right there will never be more than one instance
of a particular command / parameter list combination.)


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