[m-users.] Accumulator and mode declaration
Sean Charles (emacstheviking)
objitsu at gmail.com
Thu May 6 17:20:27 AEST 2021
I read this page for a good time now:
https://mercurylang.org/information/doc-latest/mercury_ref/Predicate-and-function-mode-declarations.html#Predicate-and-function-mode-declarations
…with the relevant part being:
>A function or predicate mode declaration is an assertion by the programmer that for all possible argument terms and (if applicable) result term for the function or predicate that are approximated (in our technical sense) by the initial instantiatedness trees of the mode declaration and all of whose free variables are distinct, if the function or predicate succeeds, then the resulting binding of those argument terms and (if applicable) result term will in turn be approximated by the final instantiatedness trees of the mode declaration, with all free variables again being distinct. We refer to such assertions as mode declaration constraints. These assertions are checked by the compiler, which rejects programs if it cannot prove that their mode declaration constraints are satisfied.
That’s a wake up call. Up to this point I had not made the connection between the declared determinism and the modes. It’s a lot to take in and it’s too late for my brain. I guess in the morning I will read it again and work on it. I am not schooled in predicate logic or maths; what I know I have taught myself as and when I need to for 35 years and counting but Mercury (and Prolog) continue to be most challenging. When you don’t know what half of the documentation is saying because the language is so hard to interpret into something meaningful to a mere mortal it feels very hard at times. But I haven’t given up thus far, the code I have feels incredibly lean and safe. Very reassuring actually.
Any links to learning resources that might help me on the way would be nice to see.
Good night!
Sean
> On 5 May 2021, at 23:00, Zoltan Somogyi <zoltan.somogyi at runbox.com> wrote:
>
>
>
> On Wed, 5 May 2021 22:55:11 +0100, "Sean Charles (emacstheviking)" <objitsu at gmail.com> wrote:
>> :- pred translate_(
>> command_line.felt_options::in,
>> list(string)::in,
>> list(string)::out,
>> io::di, io::uo) is det.
>
> This promises that when translate_ succeeds, the third arg
> will be ground, but ...
>
>> translate_(_, [], _Acc, !IO) :-
>> trace [
>> run_time(env("FELT_DBG")),
>> io(!Dbg)
>> ]
>> (io.format("translate_: all done\n", [], !Dbg)).
>
> ... as the error message says, this clause does NOT make it ground.
>
> Zoltan.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20210506/1528e4b6/attachment.html>
More information about the users
mailing list