[m-dev.] Why can't we pass a det pred where cc_multi is expected?
Peter Hawkins
peter at hawkins.emu.id.au
Wed Jul 6 14:23:45 AEST 2005
Hi...
Ralph Becket wrote:
>Consider
>
>This seems odd to me. Is this deliberate or just an oversight?
>
>
Incidentally, a not entirely unrelated problem was annoying me recently.
I was writing some command-line argument parsing code like so:
:- type option ---> propagator ; labelling_opt ; allsolns_opt ;
no_combine_opt.
:- pred option_default(option::out, option_data::out) is nondet.
option_default(propagator, string("domain")).
option_default(labelling_opt, string("ffmaxout")).
option_default(allsolns_opt, bool(no)).
option_default(no_combine_opt, bool(no)).
In the main predicate, I have:
getopt.process_options(
option_ops(short_option, long_option, option_default),
Args,
NonOptionArgs,
Result),
When compiling the program, I receive this warning message:
test_steiner.m:185: In `option_default(out, out)':
test_steiner.m:185: warning: determinism declaration could be tighter.
test_steiner.m:185: Declared `nondet', inferred `multi'.
However if I change the determinism of option_default to 'multi', I
receive the following pearl of wisdom:
test_steiner.m:202: In clause for `main(di, uo)':
test_steiner.m:202: in argument 1 of call to predicate
`getopt.process_options/4':
test_steiner.m:202: mode error: variable `V_20' has instantiatedness
`unique(getopt.option_ops(/* unique */(pred((ground >> ground), (free >>
ground)) is semidet), /* unique */(pred((ground >> ground), (free >>
ground)) is semidet), /* unique */(pred((free >> ground), (free >>
ground)) is multi)))',
test_steiner.m:202: expected instantiatedness was
`bound(getopt.option_ops((pred((ground >> ground), (free >> ground)) is
semidet), (pred((ground >> ground),
(free >> ground)) is semidet), (pred((free >> ground), (free >> ground))
is nondet)) ; getopt.option_ops((pred((ground >> ground), (free >>
ground)) is semidet), (pred((ground >> ground), (free >> ground)) is
semidet), (pred((free >> ground), (free >> ground)) is nondet),
(pred((ground >> ground), (ground >> ground), (ground >> ground), (free
>> ground)) is semidet)) ; getopt.option_ops_multi((pred((ground >>
ground), (free >> ground)) is semidet), (pred((ground >> ground), (free
>> ground)) is semidet), (pred((free >> ground), (free >> ground)) is
multi)) ; getopt.option_ops_multi((pred((ground >> ground), (free >>
ground)) is semidet), (pred((ground >> ground), (free >> ground)) is
semidet), (pred((free >> ground), (free >> ground)) is multi),
(pred((ground >> ground), (ground >> ground), (ground >> ground), (free
>> ground)) is semidet)))'.
For more information, try recompiling with `-E'.
Perhaps it should be possible to transparently perform determinism
'up-casts' in cases such as this? Alternatively can the warning message
be suppressed?
=)
Peter
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list