[mercury-users] Another Mercury Modes Problem

Ralph Becket rafe at cs.mu.OZ.AU
Wed May 29 10:08:06 AEST 2002


Bob McKay, Tuesday, 28 May 2002:
> Firstly, thanks Ralph (and others). My apologies for the stuff-up
> re list/list_skel; I knew about list_skel, but simply forgot (which I
> guess reinforces Michael's point.

At least some of us think the `_skel' convention was a bad idea.  It may
change when we write version 2 of the library...

> On Tuesday, May 28, 2002, at 02:01 PM, Ralph Becket wrote:
> 
> >You haven't given enough information for us to offer much help.
> 
> Apologies for that; it's kind of hard to guess how much to give, you
> presumably don't want the whole code, and localising is slow because
> I'm still at the stage of being unsure what is relevant.

Some idea of what you're trying to achieve is often helpful.  For
instance, many problems can be solved by finding a different approach,
rather than working around an unfortunate design decision.

> >Why do the lists have to be unique?  This is probably going to be a
> >source of pain.
> 
> Well, they're the GA population; I'm going to want to re-use the
> space presumably, and my understanding is that this is what a
> unique declaration permits the compiler to do (though I think the
> manual says this is currently unimplemented).

At the moment you're best off not worrying about uniqueness (the
compiler doesn't really handle it at the moment, anyway.)  The garbage
collector will do the job you want.

> >Problem: !/0 is an old Prologism, has no meaning in Mercury (it is
> >currently defined as true), and will go away in the near future (it is
> >being used for state variable syntax.)
> >
> >Here's something that should work:
> >
> >eval_population([],            [],          [],            _,     S,  
> >S).
> >
> >eval_population([U | Unevals], [E | Evals], [I, F | Msgs], EvalP, S0, 
> >S) :-
> >    EvalP(U, E, I, F, S0, S1),
> >    eval_population(Unevals, Evals, Msgs, EvalP, S1, S).
> >
> Actually, true is fine for me. Since I'm using DCG's as far as
> possible consistently throughout for passing the random seed (except
> at the top level, where I need to use it for the I/O state), I'd like
> to stick with the DCG notation.

Even so, !/0 is Prolog's cut, which doesn't do anything in Mercury and
says the wrong thing to the reader.  The conventional way of saying
`{ true }' in a DCG is to just write `[]'.

- Ralph
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list