[mercury-users] Higher order programming

Lee Naish lee at cs.mu.OZ.AU
Thu Apr 22 12:32:53 AEST 1999

In message <19990422031631.B23702 at mundook.cs.mu.OZ.AU>Fergus wrote:
>On 21-Apr-1999, Ralph Becket <rwab1 at cam.sri.com> wrote:
>> I'm a great advocate of higher-order programming, but I find that it's
>> not as easy in Mercury as it ought to be,
>There's several reasons for this, some of which are technical, but
>many of which are just historical.
>> library predicates not being
>> provided in `forward only' versions or not taking `function' HO args.
>> The problem, of course, is that the compiler doesn't like HO arguments
>> that have multiple modes.

I think this problem would be easier to solve if there was less
distinction between predicates and functions.  Treating functions as a
syntactic sugar for det predicates has several advantages, including
having a simpler "core" language (which would be nice for people working
on the semantics).  A predicate can have several modes, one of which (a
det one) can be associated with the "function" of the same name (ie, the
syntactic sugar).  In the case of higher order, you can have a predicate
such as map2 with an identified functional mode which takes a function as
an argument.  Similarly the predicate plus/3 has an identified
functional mode.  A goal map2(plus, As, Bs, Cs) may give the compiler a
hard time (as present), but for a functional expression map2(plus, As, Bs)
the compiler should be able to figure out easily that its the functional
modes of both map2 and plus which must be used.  Maybe I'm missing some
tricky things of course...


More information about the users mailing list