[m-dev.] Adding Loops to Mercury
novalazy at gmail.com
Fri Jan 3 12:52:00 AEDT 2014
On Fri, 03 Jan 2014 10:49:24 +1100, Peter Schachte <pschachte at gmail.com> wrote:
> On 02/01/14 16:13, Michael Richter wrote:
> > On 2 January 2014 10:41, John Adams <jpadams78 at gmail.com
> > <mailto:jpadams78 at gmail.com>> wrote:
> > Is there or plan (maybe already done) to add loops to Mercury
> > Language?
> > Visual Prolog has loops of the form:
> > foreach I=std::fromTo(1,1000) do
> > %...whatever
> > end foreach.
> > God I hope not!
> I'm not sure why everyone takes such a dim view of looping. As long as
> it's given a proper declarative semantics, I see nothing inconsistent
> about loops in Mercury, and they could save us all from the huge number
> of library predicates and functions that map over some (possibly
> filtered lists) while folding over some other lists. The sheer number
> of these suggests that there's some missing modularity, which a looping
> construct could provide.
I want to add my support in this direction.
Lists are quite fleshed out in the standard library so I don't find them
a huge problem, apart from the extra predicate declaration for the loop
body. It is more annoying when looping over integers, or some
lesser-used data structure and the thing you want is not there, or
almost there but not quite.
More information about the developers