Loadfuncpp

A Dynamic Library used to aid Adding
External Functions written in C++ to
The Icon Programming Language

Carl Sturtivant, January 2009, version 0.91alpha

Features

  • Works with the existing Icon runtime system with no modification
  • Call Icon with call syntax from C++ and vice-versa, recursively
  • Has a simple way to create new Icon datatypes by inheritance
  • Write new Icon functions in C++ that suspend a sequence of results
  • Iterate in C++ through result sequences generated by Icon
  • All Icon functions, keywords and operators made available in C++
  • Takes care of garbage collection safety automatically

documentation
experimental binaries
compilation options

News

2009/1/20 fixed a bug where a call of any C++ external function that in turn calls Icon and afterIcon returns calls Icon::runerr would not correctly report the name and arguments of said function in the resulting traceback. Upped the version number to 0.91alpha.

2009/1/20 loadfuncpp now searches for a shared object on the path defined by the environment variable FPATH with the icon/bin directory appended if you specify no path. FPATH undefined leads loadfuncpp to search the current directory followed by the icon/bin directory.

2009/1/12 loadfuncpp has been completely overhauled, and the old version is now obsolete. Many small functions have been added to eliminate ambiguities in programs that use loadfuncpp, and the central class has been renamed and a class eliminated. Small pieces of missing functionality have been added. The documentation has been modified accordingly. It is now close to it's final form, and in need of some serious beta testing, and I have someone who has agreed to do that. Once this is done, loadfuncpp will be made available as a pack with the Icon 9.5 source distribution.

2008

I made Sockets (UDP and TCP) and fork successfully available to Icon via loadfunpp as an experiment last fall.

I gave database connectivity (MySQL and PostgeSQL) to Icon via the C APIs of those systems last fall. A novel feature is that a call to execute a SELECT query may be passed an Icon record constructor, and then suspends the query result as a sequence of those records. Oracle is next! Together with a small Icon function I wrote to parse CGI parameters, these libraries made it possible to write web scripts in Icon, something Icon seems ideally suited to.

These libraries will be cleaned up and made available with loadfuncpp after it is released to the public domain for distribution with Icon 9.5.

I was contacted by someone who'd heard of my efforts with databases who was attempting to bind into Icon the functions in the small and portable Iup graphical user interface library, but was stymied by the need for callback functions. Iup is written in C and naturally needs callbacks to be in C, but the user of Iup in Icon needs to write such a callback in Icon. So somewhere in there C has to call Icon, and that's exactly one of the problems solved by loadfuncpp. I was able to make run a small Icon program exemplifying all the difficulties of embedding Iup in Icon, and now await this to be extended into a complete Iup library for Icon by the originator of the inquiry! Exciting! When this occurs, it will be made available after loadfuncpp has been released.

#