InteLib

A library of C++ classes which lets you do Lisp programming within your C++ program
Download

InteLib Ranking & Summary

Advertisement

  • Rating:
  • License:
  • GPL
  • Price:
  • FREE
  • Publisher Name:
  • Andrey V. Stolyarov
  • Publisher web site:
  • http://www.intelib.org/

InteLib Tags


InteLib Description

A library of C++ classes which lets you do Lisp programming within your C++ program InteLib is a library of C++ classes which lets you do Lisp programming within your C++ program even without any additional preprocessing, without all those calling conventions etc.You can write a C++ code (that is, a code which is accepted by your C++ compiler) thinking in a "Lisp mode" and the code you write will look much like Lisp code altough it will be pure C++.To give you the essential feeling, the following example is provided.(defun isomorphic (tree1 tree2) (cond ((atom tree1) (atom tree2)) ((atom tree2) NIL) (t (and (isomorphic (car tree1) (car tree2)) (isomorphic (cdr tree1) (cdr tree2))))))Just a Lisp function, isn't it? Now look at the following code:(L|DEFUN, ISOMORPHIC, (L|TREE1, TREE2), (L|COND, (L|(L|ATOM, TREE1), (L|ATOM, TREE2)), (L|(L|ATOM, TREE2), NIL), (L|T, (L|AND, (L|ISOMORPHIC, (L|CAR, TREE1), (L|CAR, TREE2)), (L|ISOMORPHIC, (L|CDR, TREE1), (L|CDR, TREE2))))))Obviously the code is just the same, the syntax changed a bit, but it's still the same. Well, do I surprise you if I say it is C++ code? If you don't believe, look at the following: // File isomorph.cpp #include "lisp/lisp.hpp" #include "lisp/lsymbol.hpp" #include "lfun_std.hpp" LSymbol ISOMORPHIC("ISOMORPHIC"); static LFunctionalSymbol< LFunctionDefun > DEFUN("DEFUN"); static LFunctionalSymbol< LFunctionCond > COND("COND"); static LFunctionalSymbol< LFunctionAtom > ATOM("ATOM"); static LFunctionalSymbol< LFunctionAnd > AND("AND"); static LFunctionalSymbol< LFunctionCar > CAR("CAR"); static LFunctionalSymbol< LFunctionCdr > CDR("CDR"); LListConstructor L; void LispInit_isomorphic() { static LSymbol TREE1("TREE1"); static LSymbol TREE2("TREE2"); //////////////////////////////////////////////// // (L|DEFUN, ISOMORPHIC, (L|TREE1, TREE2), (L|COND, (L|(L|ATOM, TREE1), (L|ATOM, TREE2)), (L|(L|ATOM, TREE2), NIL), (L|T, (L|AND, (L|ISOMORPHIC, (L|CAR, TREE1), (L|CAR, TREE2)), (L|ISOMORPHIC, (L|CDR, TREE1), (L|CDR, TREE2)) )))).Evaluate(); // //////////////////////////////////////////////// } // end of fileWell, this code is a complete C++ module and it does compile pretty well. No joke, it's real.By the way, don't try to find any use I made out of the macroprocessor. No macros have ever been used by InteLib (except those for conditional compile directives). Instead, just recall that comma is an operator in C++ and can be overloaded for user-invented data types. What's New in This Release: · The version includes an implementation of the Refal computation model significantly reworked by Igor Bronshtein (thanks Igor!). · This implementation seems to be notably faster than the previously-existing one.


InteLib Related Software