[mercury-users] choicepoint IDs in the C interface
pbi at info.fundp.ac.be
Wed Apr 29 02:25:35 AEST 2009
I have a question about the foreign interface with C. The reference
manual says that the MR_current_choicepoint_id() function returns the ID
of the most recent choicepoint. I tried it with a very simple code, just
wrote a predicate in C that writes the id to the output. If this
predicate called several times, it writes different choicepoint IDs each
time. Since in this code every predicate, including print/3 and nl/2 are
deterministic, I think I should always get the same id. Instead I got
Can you help me on what I think wrong?
:- module cptest.
:- import_module io.
:- pred main(io__state, io__state).
:- mode main(di, uo) is det.
:- pragma foreign_decl("C",
print("a1", !IO), nl(!IO),
print("a2", !IO), nl(!IO),
print("a3", !IO), nl(!IO).
:- pred write_current_choicepoint_id(string, io__state, io__state).
:- mode write_current_choicepoint_id(in, di, uo) is det.
:- pragma promise_pure(write_current_choicepoint_id/3).
:- pragma foreign_proc("C", write_current_choicepoint_id(Key::in,
printf(\"%s: %i\\n\", Key, MR_current_choicepoint_id());
IO = IO0;
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 802 bytes
Desc: not available
More information about the users