[m-users.] Mercury to c# workflow?

David Epstein davideps at umich.edu
Fri Jan 14 17:25:52 AEDT 2022


Zoltan and Sean,

I'm still trying to understand the relationship between Mercury and C#. For
example, CSharpProlog <https://www.nuget.org/packages/CSProlog/> 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 old Mercury flyer
<https://www.mercurylang.org/about/dotnet/objectworld_flyer.html> 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?

-david




On Wed, Jan 5, 2022 at 10:09 PM Zoltan Somogyi <zoltan.somogyi at runbox.com>
wrote:

>
>
> On Wed, 5 Jan 2022 21:46:40 +0200, David Epstein <davideps at umich.edu>
> wrote:
> > if the rule *mortal(X):-man(X) * and the predicate *man(X) *could
> > be compiled into C# and if new instances such as *man(john)* and
> *man(bob)*
> > could later be created during runtime,
>
> No, this cannot be done in Mercury, because this would modify
> the definition of the "man" predicate at runtime. You cannot do that,
> any more than you could replace the code of a C# method after
> it has been compiled.
>
> >  Is this the purpose of *mutables* (from
> > section 4 in the transition guide)?
>
> No, it is not. If you want to maintain a changing set of "men",
> then the right way to go about it is to use the set module
> in the Mercury standard library, and thread a set through your code.
> This means threading a succcession of variables through your code,
> each standing for *one particular set* of men (because once a
> variable is bound to a value, it can never be changed), and each
> variable but the first has its value derived from the value of the
> previous variable in the sequence, in this case usually by adding
> a new element to the previous set, or deleting an old element from it.
>
> Zoltan.
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20220114/ae0715ab/attachment.html>


More information about the users mailing list