[m-users.] Mercury to c# workflow?
Zoltan Somogyi
zoltan.somogyi at runbox.com
Thu Jan 6 07:09:37 AEDT 2022
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.
More information about the users
mailing list