[m-dev.] taking addresses of multi-moded predicates

Ralph Becket rafe at csse.unimelb.edu.au
Thu Apr 10 11:27:05 AEST 2008


Peter Wang, Thursday, 10 April 2008:
> Hi,
> 
> I think the majority of cases where you *really* want to take the
> address of a predicate with multiple modes fall into this sort of pattern:
> 
>     mymap(P, L0, L) :-
> 	map(wrap(P), L0, L).
> 
>     :- pred wrap(...).
>     :- mode wrap(in(pred(...) is det), ...) is det.
>     :- mode wrap(in(pred(...) is cc_multi, ...) is cc_multi.
>     ...
> 
> i.e. wrappers around other higher order predicates.  Explicit lambdas
> don't cut it in this case as you need to write mode-specific versions of
> the wrapper predicate, and perhaps its callers and so on.
> 
> Observations:
> 
> - when taking the address of a multi-moded predicate, there will most
>   likely be one or more higher-order curried arguments provided
> 
> - we should (will?) know the insts of those arguments
> 
> - at the point where the higher order term is constructed, it will
>   nearly always be possible to select the mode of the predicate by
>   only matching the insts of the higher order curried arguments against
>   the predicate's declared modes
> 
> I think that will provide 90% of the benefit with 1% of the effort
> needed for the full solution.
> 
> Have I missed something?

Not that I can see.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions:          mercury-developers-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the developers mailing list