isabella232 / misc-c-sicstus Goto Github PK
View Code? Open in Web Editor NEWThis project forked from swi-prolog/misc-c-sicstus
Use SWI-Prolog foreign code on SICStus Prolog
This project forked from swi-prolog/misc-c-sicstus
Use SWI-Prolog foreign code on SICStus Prolog
Purpose ======= This module defines a C-library to be used with SICStus Prolog that allows you to use foreign code designed for SWI-Prolog with minimal effort in SICStus. Installation ============ The usual ./configure, make, make install will install the library and header files in /usr/local/lib and /usr/local/include. Use ./configure --help for options. License/Copying =============== This library is distributed under the LGPL-2 (Lesser GNU Public License). For details, please visit www.gnu.org. Very briefly you violate this license if you do not provide the source of this library with executables that include it, but it doesn't act as a virus on the licence terms on the rest of your code. Use === Given a C-source holding C-functions that define predicates for SWI-Prolog you can make it suitable for use with SICStus using the following steps: # Replace #include <SWI-Prolog.h> with #include <swi.h> # Remove the install/uninstall functions # Declare the foreign function and write the wrapper SWI-Prolog foreign functions can fail, succeed or be succeed non-deterministically. They do that by returning 0, 1 or something else. They accept a list of arguments of the SICStus form +term. So, if we have a function foo(), implementing foo/2, we have to write: foreign(c_foo, foo(+term, +term, [-integer])). foreign_resource(mylib, [c_foo]). :- load_foreign_resource(mylib). foo(A, B) :- c_foo(A, B, 1). Non-deterministic (PL_FA_NONDETERMINISTIC) cannot be handled this way (see `Restrictions' below). Meta-predicates (PL_FA_TRANSPARENT) should be declared using :- meta_predicate foo/2. If the foreign code using PL_strip_module() this should work as expected. Restrictions ============ # No context module handling (PL_context()) # No non-debugging call-back support (PL_Q_NODEBUG and friends) # Small differences in exception handling # Poor stream emulation This is the hardest bit. We need a record oriented model for SWI-Prolog, where SICStus provides a character oriented model. Actually the emulated IOSTREAM should be an SP_stream, so we can deal with SICStus streams. But then, there is a lot more high-level functionality to SWI-Prolog streams, which we would have to emulate on top of the SICStus streams. For now, we can create a stream and pass it to Prolog, or play with it in C. Don't do both with the same stream! # No non-deterministic foreign predicates. Though not used very frequently, nothing similar exists in SICStus. You need help on the Prolog site. Either by making the foreign routine return a list with all answers and use member/2 to select the non-deterministically or by storing the state somehow and provide a choicepoint in Prolog.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.