[mercury-users] `with_inst` to avoid (unimplemented) taking address of pred with multiple modes

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Mar 5 03:51:05 AEDT 2004


On 03-Mar-2004, obo at ruk.cuni.cz <obo at ruk.cuni.cz> wrote:
> I'm using rotd-2004-01-19 and I'd like to use often a predicate with
> multiple modes, the explicit lambda expression is kind of too long
> solution to overcome this:
> 
> Software Error: sorry, not implemented: taking address of pred
> `opt/5' with multiple modes.
> (use an explicit lambda expression instead)
> 
> If I understand it correctly, I can give names to a predicate modes:
> 
> :- type opt(Option) == (pred(Option, string, maybe(character),
>                              option_data, maybe(string))).
> :- inst opt_long == (pred(uo, in, uo, uo, uo) is semidet).
> :- inst opt_short == (pred(uo, uo, in, uo, uo) is semidet).
> :- inst opt_defaults == (pred(in, uo, uo, uo, uo) is nondet).
> :- inst opt_dump == (pred(uo, uo, uo, uo, uo) is nondet).
> 
> Until the mmc is capable of finding the correct mode of the predicate
> automatically, one could use `with_inst` hinting:
> 
>  use_the_predicate_opt(opt`with_inst`opt_long)
> 
> where the opt
> 
> :- type my_option.
> :- pred opt `with_type` opt(my_option).
> :- mode opt `with_inst` opt_long.
> :- mode opt `with_inst` opt_short.
> ...
> 
> Would it be easy to implement?

I think it would be reasonably easy.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list