diff --git a/trealla/interop.go b/trealla/interop.go index 6672d09..5347da0 100644 --- a/trealla/interop.go +++ b/trealla/interop.go @@ -90,14 +90,14 @@ func sys_coro_next_2(pl Prolog, subquery Subquery, goal Term) Term { if !ok { return throwTerm(domainError("integer", g.Args[0], g.pi())) } - t, ok := plc.CoroNext(subquery, id) - if !ok || t == nil { + result, ok := plc.CoroNext(subquery, id) + if !ok || result == nil { return Atom("fail") } - // call(( Goal = Result ; '$coro_next'(ID, Goal) )) + // call(( wasm_generic:host_rpc_eval(Goal, Result, [], []) ; '$coro_next'(ID, Goal) )) return Atom("call").Of( Atom(";").Of( - Atom("=").Of(g.Args[1], t), + Atom(":").Of(Atom("wasm_generic"), Atom("host_rpc_eval").Of(result, g.Args[1], Atom("[]"), Atom("[]"))), Atom("$coro_next").Of(id, g.Args[1]), ), ) diff --git a/trealla/interop_test.go b/trealla/interop_test.go index 40cc683..105e3be 100644 --- a/trealla/interop_test.go +++ b/trealla/interop_test.go @@ -207,7 +207,9 @@ func BenchmarkInteropNondet(b *testing.B) { b.Fatal("query failed", query.Err()) } } - query.Close() + if err := query.Close(); err != nil { + b.Error("close error:", err) + } if leftovers := len(pl.(*prolog).coros); leftovers > 0 { b.Error("coroutines weren't cleaned up:", leftovers) } diff --git a/trealla/terms/example_test.go b/trealla/terms/example_test.go index d715379..03bf204 100644 --- a/trealla/terms/example_test.go +++ b/trealla/terms/example_test.go @@ -20,7 +20,7 @@ func Example_nondet_predicate() { // betwixt(+Min, +Max, ?N). pl.RegisterNondet(ctx, "betwixt", 3, func(_ trealla.Prolog, _ trealla.Subquery, goal0 trealla.Term) iter.Seq[trealla.Term] { return func(yield func(trealla.Term) bool) { - // goal is the goal called by Prolog, such as: base32("hello", X). + // goal is the goal called by Prolog, such as: betwixt(1, 10, X). // Guaranteed to match up with the registered arity and name. goal := goal0.(trealla.Compound)