[m-dev.] Adding Loops to Mercury

Julien Fischer jfischer at opturion.com
Sun Jan 5 00:02:27 AEDT 2014


Hi,

On Sat, 4 Jan 2014, Paul Bone wrote:
>
> I'm beginning to change my initial opinion.  I think that there are some
> motivating reasons (as Matt showed) about why we would want this (cleaner
> syntax etc).  I think it's also desirable as Peter Wang said for types other
> than lists, for instance integers or other sequence-ish types.
>
> There is another reason I'd like to add in to the discussion, I apologise
> if someone has said this already.  We have many predicates such as foldl,
> foldl2, foldl3 etc in the list module of the standard library. We also have
> map_corresponding and numerous other predicates, each predicate has a
> number of different modes.  It can be painful when you need to use a
> predicate that fits one of these patterns in some ways, but doesn't fit the
> number of accumulators, number of output or input lists (map_corresponding)
> etc.

Arguably that's less of problem now than it has been in the past, mainly
because the implementation of G12 forced us to add many of the missing
modes.

...

> I think that the solution should be something smiliar to Matt's proposal
> (below) that can also work on integers.  Peter Schachte's paper may also be
> useful but I've not read it, John's reference to Visual Prolog might also be
> useful.  Additionally, one case where I've seen this done before was SISAL,
> a pure single assignment language that used loops that looked similar to
> imperative loops http://en.wikipedia.org/wiki/SISAL.  Ultimately SISAL was
> not adopted by the programming community because Fortran programmers found
> it difficult to adjust to declrative programming.  More about SISAL:
> http://www2.cmp.uea.ac.uk/~jrwg/Sisal/00.Contents.html  Matt: is there
> something like this in Mars that we should also read?

The other bit of reading you are missing is:

    Logical Loops by Joachim Schimpf.
    Logic Programming, 18th International Conference,
    ICLP 2002, Copenhagen, Denmark, July/August 2002. Proceedings, LNCS
    2401, pg 224-238, © Springer-Verlag,

(Available from: <http://www.eclipseclp.org/reports/index.html>)

IIRC, Mark Brown did look look at impementing the loops described in
the above at the outset of the G12 project.

Cheers,
Julien.


More information about the developers mailing list