[m-users.] STATE_VARIABLE_IO_0 has instantiatedness ddgame.m:042: mostly_unique

emacstheviking objitsu at gmail.com
Sat Aug 17 00:58:32 AEST 2019


Superb!
Julian, that did it for me, the pennies dropped.
Thanks.
Sean.


On Fri, 16 Aug 2019 at 15:54, Julian Fondren <jfondren at minimaltype.com>
wrote:

> On 2019-08-16 09:27, emacstheviking wrote:
> > Julian, thanks.
> >
> > I have refactored / restructured my code and it's all good now...I
> > kind of get the explanation but I kept the bad code so I can go back
> > and study harder later.
> >
> > I'm not really understanding your comment about ,
> >
> >> The !IO there represents IO1 = IO2.
> >
> > Thanks again.
> >
>
> My answer was imprecise in a few other ways too.
>
> 1. !IO maps to a pair of parameters !.IO, !:IO,
>
> 2. which gets translated to (something like) IO1, IO2, where IO1 is
> passed to the predicate and IO2 is a free variable that gets bound
> as a result of the predicate.
>
> 3. all bindings established within conditional code are only still
> set in the 'then' case. Again: if the conditional fails, none of
> these bindings are set, so IO2 in particular isn't set, so you've
> passed the 'io' value to a predicate but didn't get it back.
>
> 4. the 'else' case therefore must reuse IO1 (even if it doesn't
> refer to !IO, because the !:IO paramter of the predicate the
> conditional is in still needs to be satisfied).
>
> the error tells you that IO1 in my explanation is actually named
> STATE_VARIABLE_IO_0.
>
> As a rule, don't use !IO in conditional code. I/O always succeeds,
> even if it successfully reports an error. That you're told the copy
> is 'mostly_unique' instead of 'ground' is a hint about a feature
> (that isn't an option for io state):
>
> https://mercurylang.org/information/doc-latest/mercury_ref/Backtrackable-destructive-update.html
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20190816/e695abec/attachment-0001.html>


More information about the users mailing list