<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 02/01/14 16:13, Michael Richter
wrote:<br>
</div>
<blockquote
cite="mid:cf8d7c97c1ed4dbc91004d9cb65be783@000S-EX-HUB-NP1.unimelb.edu.au"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">On 2 January 2014 10:41, John Adams <span
dir="ltr"><<a moz-do-not-send="true"
href="mailto:jpadams78@gmail.com" target="_blank">jpadams78@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div>Is there or plan (maybe already done) to add loops
to Mercury Language?<br>
<br>
</div>
Visual Prolog has loops of the form:<br>
<br>
foreach I=std::fromTo(1,1000) do<br>
%...whatever<br>
end foreach.<br>
</div>
</blockquote>
</div>
<div class="gmail_extra"><br>
</div>
God I hope not!<br>
</div>
</div>
</blockquote>
<br>
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. The trouble
with the fold/filter/map predicates/functions is that they conflate
the construction of the result with the generation of the input and
the control of the loop. When they capture what you want, they're
great, but when they don't, they lead you to ask for yet another
map2fold3filter1 predicate.<br>
<br>
As for the semantics, a generalisation of Mercury's 'all' construct
that can generate output would fit well with Mercury. Here's a
paper I wrote a decade ago doing this for Prolog. At the time,
Fergus Henderson told me there was some shortcoming in Mercury's
type or mode system that would make this difficult to do for
Mercury, but I don't remember the specifics.<br>
<br>
<pre class="moz-signature" cols="72">--
Peter Schachte Politics, n. A strife of interests
University of Melbourne masquerading as a contest of principles.
<a class="moz-txt-link-abbreviated" href="mailto:schachte@unimelb.edu.au">schachte@unimelb.edu.au</a> The conduct of public affairs for private
<a class="moz-txt-link-abbreviated" href="http://www.cs.mu.oz.au/~schachte/">www.cs.mu.oz.au/~schachte/</a> advantage. -- Ambrose Bierce, 1906 (The
Phone: +61 3 8344 1338 Devil's Dictionary)
I support the NTEU's campaign for a fair enterprise agreement.
Find out more: nteu.org.au/melb | facebook.com/nteu.unimelb
</pre>
</body>
</html>