AbstractWhile spending seven months writing a computer game called R4: Rocketman in C++ I ran into some problems with the C++ language. From the lessons learnt from writing this large (approximately 25,000 lines of code) program I have worked out how to eliminate these problems with the C++ language by merging the best of C++ with the best of Lisp to produce a new language which I will call The Lisp++ Programming Language (at the risk of confusion with an unrelated software package called Lisp++) that as its name suggests combines the expressiveness of Lisp with the efficiency of C++. You can view the cover jacket of my book by clicking on the image on the right of this paragraph. You can view the actual book by clicking here. 1. Problems with C++
|
class B; class A { public: int foo(B* b) { return b->x; } }; class B { public: int x; };
To get the above code to compile under C++, the definition of the method body of the foo method needs to be moved down to somewhere after the definition of the body of the B class like so:
int A::foo(B* b) { return b->x; }
Lisp++ code resembles Lisp code. In Lisp++, the Emacs editor is used as a Lisp interpreter which compiles Lisp++ code into C++ code. Then the G++ compiler is used to compile C++ code into machine language code. The basis of the Lisp interpreter is a new Lisp function which I will call lisp++2c++ compiles every file in the directory variable *directory*. Here is an example of some Lisp++ code:
(cfunction (cret void) (cname my_function) (cargs) (s int x = 0;) (s foo(f (123 * 456) hello);) (s bar(f 123 (456 + 789) abc);) (cif (abc) (s dmp::cout << "abc\n";) celseif (def) (s dmp::cout << "def\n";) celseif (ghi) (s dmp::cout << "ghi\n";) celse (s dmp::cout << "jkl\n";)) (cfor ((s int i=0;) (s i<10;) (s i++)) (s dmp::cout << i << "\n";)))which compiles to the following C++ code:
void my_function() { int x = 0; foo((123 * 456),hello); bar(123,(456 + 789),abc); if (abc) { dmp::cout << "abc\n"; } else if (def) { dmp::cout << "def\n"; } else if (ghi) { dmp::cout << "ghi\n"; } else { dmp::cout << "jkl\n"; } for (int i=0; i<10; i++) { dmp::cout << i << '\n'; } }You can download the source code to c++2lisp++ and lisp++2c++.
Back to Research Projects |
This page has the following hit count:
|