[mercury-users] partial instantiation?
Tomas By
tomas at basun.net
Wed Apr 14 11:36:42 AEST 2010
Hi all,
I have a little program that I want to accept optional command line
parameters, so that, for example:
$ ./binary command
$ ./binary command filename
$ ./binary command 100
$ ./binary command filename 100
would all map to `command' (which is implemented by dosomething/2),
with the left out parameters filled in with default values automatically.
A Prologesque solution might be:
|:- 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) ).
where the cmdarg and cmdproc types are fine, but the compiler chokes on
the modes. Am I right in seeming to remember this is not supported, but
that there have been some work on it, but not everybody agrees it is
useful at all?
The last discussion on the mailing list seems to have been in 1999.
Can anybody suggest some simple solution? I cannot really think of anything
that would be easier than just hard coding all the possibilities.
(which I do not like because the sets of commands and parameters are not
static, and I have a online help screen that I want to keep up to date.)
/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