[mercury-users] partial instantiation?
pbone at csse.unimelb.edu.au
Wed Apr 14 13:14:57 AEST 2010
On Wed, Apr 14, 2010 at 05:03:02AM +0200, Tomas By wrote:
> On Wed, April 14, 2010 04:48, Paul Bone wrote:
> > You might find that the modes.
> > :- mode cmd(in, in, out) is semidet.
> > :- mode cmd(out, out, in) is det.
> > do work, because N and P are bound as one of cmd's inputs.
> Well, I only want out/out/out as the cmd/3 predicate is just a list of
> all my command line commands, all nicely collected in one place.
> > Alternatively, if you did want partial instantiation, and I don't think
> > you do,
> > you would have to use a different mode rather than out, out, out that
> > describes
> > the partial instantiation.
> Ok... This is the bit I could use some help with then, if it is possible.
> I tried this:
> |:- type cmdarg ---> str(string) ; int(int).
> |:- inst cmdarg ---> str(free) ; int(free).
> |:- mode calist == free >> cmdarg.
> but just got a bunch of new errors.
This is almost correct.
Instead if the 3rd line above you would write the mode of cmd as:
:- mode cmd(out, out(list(cmdarg)), out(skel_cmdproc)) is multi.
I would also recommend calling the cmdarg instiation skel_cmdarg, or something
else that suggests that it is partially instantiated.
You can also use the list(cmdarg) instantiation inside the in(T) mode, for example:
in(list(cmdarg)), this should expand to list(cmdarg) >> list(cmdarg).
> I suspect I would also need complicated mode declarations for the third
> parameter (cmdproc), as that also has free variables?
Yes, that's right.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 489 bytes
Desc: Digital signature
More information about the users