1 A C++ interface to SWI-Prolog (Version 1)
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • A C++ interface to SWI-Prolog
        • A C++ interface to SWI-Prolog (Version 1)
          • Introduction
          • Overview
          • Examples
          • The class PlTerm
          • The class PlTermv
          • Supporting Prolog constants
          • The class PlRegister
          • The class PlQuery
          • The PREDICATE macro
          • Exceptions
          • Embedded applications
          • Considerations
          • Conclusions

1.1 Introduction

C++ provides a number of features that make it possible to define a much more natural and concise interface to dynamically typed languages than plain C does. Using programmable type-conversion (casting), native data-types can be translated automatically into appropriate Prolog types, automatic destructors can be used to deal with most of the cleanup required and C++ exception handling can be used to map Prolog exceptions and interface conversion errors to C++ exceptions, which are automatically mapped to Prolog exceptions as control is turned back to Prolog.

Competing interfaces

Volker Wysk has defined an alternative C++ mapping based on templates and compatible to the STL framework. See http://www.volker-wysk.de/swiprolog-c++/index.html.

Acknowledgements

I would like to thank Anjo Anjewierden for comments on the definition, implementation and documentation of this package.