[mercury-users] Adventures in Mercury

Chris King colanderman at gmail.com
Mon Mar 28 13:21:22 AEDT 2011


On Sun, Mar 27, 2011 at 9:22 PM, Paul Bone <pbone at csse.unimelb.edu.au> wrote:
> How do you determine that the accumulator introduction requires the
> associativity promise.  In other words, if I'm writing some other program and
> say --introduce-accumulators, how do I know that mmc didn't introduce the
> accumulator that I expected it to, and how do I know that it needs an
> associativity promise for integer addition.

TBH, I had to read compiler/accumulator.m to find out :)  That and the
paper "Making Mercury programs tail recursive" [1] helped.  The only
way that I knew it was successful was that it produced a warning about
possible performance issues due to swapping the arguments to the
associative predicate, and the only reason I knew that it should
produce this warning is because of the existence of the
--inhibit-accumulator-warnings flag :)

A notice like the ones printed when predicate types are inferred would
be useful.  Also, the way GCC handles loop vectorization sets a useful
precedent -- there is a flag to enable debugging info about the
vectorization process, which indicates on which loops vectorization
was attempted and whether it succeeded.

[1] http://www.mercury.csse.unimelb.edu.au/information/papers.html#tail_lopstr_lncs

> As well as covering the project Euler problems I suggest you look at some
> problems that make use of nondeterminism (such as n-queens).  And some problems
> that show good practices when using the type system.

Yes, thanks for the suggestions.  I will intersperse these and other
examples alongside the PE problems (PE can get a bit repetitive...).

- Chris

--------------------------------------------------------------------------
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the users mailing list