The class PlFrame provides an interface to discard unused term-references as well as rewinding unifications (data-backtracking). Reclaiming unused term-references is automatically performed after a call to a C#-defined predicate has finished and returns control to Prolog. In this scenario PlFrame is rarely of any use.
This class comes into play if the top level program is defined in C# and calls Prolog multiple times. Setting up arguments to a query requires term-references and using PlFrame is the only way to reclaim them.
Declaration Syntax
C# | Visual Basic | Visual C++ | F# |
public class PlFrame : IDisposable
Public Class PlFrame Implements IDisposable
public ref class PlFrame : IDisposable
type PlFrame = class interface IDisposable end
Members
All Members | Constructors | Methods | |||
Icon | Member | Description |
---|---|---|
PlFrame()()()() |
Creating an instance of this class marks all term-references created afterwards to be valid only in the scope of this instance.
| |
Dispose()()()() | Implement IDisposable. | |
Equals(Object) | (Inherited from Object.) | |
Finalize()()()() |
Reclaims all term-references created after constructing the instance.
(Overrides Object.Finalize()()()().) | |
GetHashCode()()()() | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType()()()() | Gets the type of the current instance. (Inherited from Object.) | |
MemberwiseClone()()()() | Creates a shallow copy of the current Object. (Inherited from Object.) | |
Rewind()()()() |
Discards all term-references and global-stack data created as well as undoing all unifications after the instance was created.
| |
ToString()()()() | Returns a string that represents the current object. (Inherited from Object.) |
Examples
A typical use for PlFrame is the definition of C# methods that call Prolog and may be called repeatedly from C#.
Consider the definition of assertWord(), adding a fact to word/1:
alternatively you can use
Copy | |
---|---|
void AssertWord2(string word) { PlFrame fr = new PlFrame(); PlTermV av = new PlTermV(1); av[0] = PlTerm.PlCompound("word", new PlTermV(new PlTerm(word))); PlQuery q = new PlQuery("assert", av); q.NextSolution(); q.Dispose(); // IMPORTANT ! never forget to free the query before the PlFrame is closed fr.Dispose(); } |
Copy | |
---|---|
void AssertWord(string word) { using (PlFrame fr = new PlFrame()) { PlTermV av = new PlTermV(1); av[0] = PlTerm.PlCompound("word", new PlTermV(new PlTerm(word))); using (PlQuery q = new PlQuery("assert", av)) { q.NextSolution(); } } } |
Caution: |
---|
NOTE: in any case you have to destroy any query object used inside a PlFrame |
Inheritance Hierarchy
Object | |
PlFrame |
Assembly: SwiPlCs (Module: SwiPlCs.dll) Version: 1.1.60601.0 (1.1.60601.0)