[m-dev.] shims

Peter Wang novalazy at gmail.com
Fri Sep 12 10:38:16 AEST 2014

On Thu, 11 Sep 2014 17:26:04 +1000, Peter Wang <novalazy at gmail.com> wrote:
> Ideally you could update code immediately but maintain a fallback for
> older libraries.  I don't think there is a way to do it currently, so
> perhaps it is time for another pragma, e.g.
>     :- pragma shim(p/1, other.p/1).
>     p(X) :- ...

This could not cope with predicates which just have their arguments
reordered (hopefully a rare occurrence).

Perhaps the user could provide multiple definitions of a predicate,
and the compiler uses the first definition that typechecks.

    :- pred singleton_set(T::in, set(T)::out) is det.

    :- pragma alternatives(singleton_set/2,
	[singleton_set_new, singleton_set_old]).

    singleton_set_new(X, Set) :- set.singleton_set(X, Set).
    singleton_set_old(X, Set) :- set.singleton_set(Set, X).

Some shims may require helper predicates.  The compiler would need to
ignore helper predicates which are not used anywhere except in unused


More information about the developers mailing list