Swi-cs-pl - A CSharp class library to connect .NET languages with SWI-Prolog
SwiPlCs interface
SwiPlCs interface
ist in der quelle (class NamespaceDoc) vom namespace SbsSW.SwiPlCs
Namespaces
NamespaceDescription
SbsSW.SwiPlCs

The online documentation home is here.

This namespace SbsSW.SwiPlCs provides an .NET interface to SWI-Prolog

Overview

Prolog variables are dynamically typed and all information is passed around using the C-interface type term_t witch is an int. In C#, term_t is embedded in the lightweight struct PlTerm. Constructors and operator definitions provide flexible operations and integration with important C#-types (string, int and double).

The list below summarises the important classes / struct defined in the C# interface.

class / structShort description
PlEngine
A static class represents the prolog engine.
PlTerm
A struct representing prolog data.
PlTermV
A vector of PlTerm.
PlQuery
A class to query Prolog.

SbsSW.SwiPlCs.Callback

The namespace SbsSW.SwiPlCs.Callback provides the delegates to register .NET methods to be called from SWI-Prolog


SbsSW.SwiPlCs.Exceptions

These are the namespace comments for SbsSW.SwiPlCs.Exceptions.

The namespace SbsSW.SwiPlCs.Exceptions provides the Exception classes to catch a prolog exception see SWI-Prolog Manual - 4.9 ISO compliant Exception handling

Prolog exceptions are mapped to C# exceptions using the subclass PlException of Exception to represent the Prolog exception term.

All type-conversion functions of the interface raise Prolog-compliant exceptions, providing decent error-handling support at no extra work for the programmer.

For some commonly used exceptions, subclasses of PlException have been created to exploit both their constructors for easy creation of these exceptions as well as selective trapping in C#.

Currently, these are PlTypeException and PlDomainException.


SbsSW.SwiPlCs.Streams

The namespace SbsSW.SwiPlCs.Streams provides the delegates to redirect the read and write functions of the SWI-Prolog IO Streams.

When Initialize(array<String>[]()[][]) is called the *Sinput->functions.read is replaced by the .NET method 'Sread_function' and *Sinput->functions.write by 'Swrite_funktion'.

For further examples see the methods SetStreamFunctionWrite(PlStreamType, DelegateStreamWriteFunction) and SetStreamFunctionRead(PlStreamType, DelegateStreamReadFunction)