GoLang and external predicates

Hello,

Is it (in principle) possible to use GoLang instead of C++ to write external predicate?

thanks,

Dan

To answer my own question …

Most probably just by importing the c library

https://golang.org/cmd/cgo/

not sure if this is all that is needed – can a go compiler deal with the C marcro’s?

Dan

As long as it can generate a function with C compatible calling conventions and it can call the SWI-Prolog C API (assuming you want to access the predicate arguments). Many languages provide some way to directly call C functions. Many languages can be called from C, but some require some glue code in C. Some bindings can pick the constants and types from SWI-Prolog.h. If you cannot do that you need some conversion script to avoid the typing and make sure you can deal with changes to SWI-Prolog.h.

Changes (except for additions) to SWI-Prolog.h are rare, but the introduction of atomic rational numbers required some renumbering of constants.

1 Like