Hello,

on GNU Prolog 1.5.0 tested on Arch Linux with kernel 5.17.8,

with
---------- bugged.pl ----------
:- foreign(magic(term)).
go(X) :-
    X = value(0),
    magic(X).

-------------------------------


and

---------- bugged.c ----------

#include "gprolog.h"
PlBool magic(PlTerm term) {
    int functor, arity;
    PlTerm *args = Pl_Rd_Compound_Check(term, &functor, &arity);
    args[0] = Pl_Mk_Number(1);
    return PL_TRUE;
}

------------------------------



The value of the X variable is modified like this:

-----------------------------

​| ?- go(X).

X = value(1)

-----------------------------


Shouldn't it either fail or leave X at "value(0)" instead of modifying its 
value ?

Thanks,

Jordan Vésy

Reply via email to