<div dir="ltr"><div>Zoltan and Sean,</div><div><br></div><div>I'm still trying to understand the relationship between Mercury and C#. For example, <a href="https://www.nuget.org/packages/CSProlog/">CSharpProlog</a> is a Prolog implementation written entirely in C#. After including it as a dependency in my project, I access it via a standard C# "using" statement. Then I can assert and retract clauses and query a live Prolog database after compilation, which can target any .NET platform including Android and iOS. An <a href="https://www.mercurylang.org/about/dotnet/objectworld_flyer.html">old Mercury flyer</a> describes "the possibility to interoperate
with code generated by any other compiler on the .NET platform." But, based on your previous answers, this is not like having a C# Prolog library, correct? There is no easy way to maintain a live (dynamic) Prolog database inside my application and target Android and iOS, right?<br></div><div><br></div><div>-david<br></div><div><br></div><div></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 5, 2022 at 10:09 PM Zoltan Somogyi <<a href="mailto:zoltan.somogyi@runbox.com">zoltan.somogyi@runbox.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
On Wed, 5 Jan 2022 21:46:40 +0200, David Epstein <<a href="mailto:davideps@umich.edu" target="_blank">davideps@umich.edu</a>> wrote:<br>
> if the rule *mortal(X):-man(X) * and the predicate *man(X) *could<br>
> be compiled into C# and if new instances such as *man(john)* and *man(bob)*<br>
> could later be created during runtime,<br>
<br>
No, this cannot be done in Mercury, because this would modify<br>
the definition of the "man" predicate at runtime. You cannot do that,<br>
any more than you could replace the code of a C# method after<br>
it has been compiled.<br>
<br>
> Is this the purpose of *mutables* (from<br>
> section 4 in the transition guide)?<br>
<br>
No, it is not. If you want to maintain a changing set of "men",<br>
then the right way to go about it is to use the set module<br>
in the Mercury standard library, and thread a set through your code.<br>
This means threading a succcession of variables through your code,<br>
each standing for *one particular set* of men (because once a<br>
variable is bound to a value, it can never be changed), and each<br>
variable but the first has its value derived from the value of the<br>
previous variable in the sequence, in this case usually by adding<br>
a new element to the previous set, or deleting an old element from it.<br>
<br>
Zoltan.<br>
<br>
<br>
<br>
</blockquote></div>