I use Corman Lisp for a lot of my projects. It's the scripting language for the game I'm writing. Since I use it so much, I've put together a development environment using Emacs and Corman Lisp. Detailed here is my development environment.
Lisp in general is known for its interactive environments, and so it is with mine. That much said, I have a somewhat unique environment built upon Emacs for Corman Lisp. Corman Lisp, for all its strengths, is deviant enough to not work with SLIME. It has its own IDE, but it only works for 30 days. So, I developed this environment for my game development specifically and lisp development in general.
It probably goes without saying, but I'll make it clear:
THIS SOFTWARE AND THESE INSTRUCTIONS ARE PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE OR THESE INSTRUCTIONS, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
There, that wasn't so bad, was it?
I've come to the party late. It's been several years since I first used Lisp and Scheme. I remember being intrigued by them then, first when reading books on AI, and then in books on functional programming. It really wasn't until I read some of Paul Graham's essays on Lisp that I decided to reexamine Lisp and really try it.
I've always had a penchant for new (to me) languages and concepts, and I've always listened when people made claims about languages and efficiency or productivity. Reading Paul's assertions regarding Lisp certainly wasn't the first time that I had heard similar claims about a language, and I doubt it will be the last.
So I decided to try it out. I've also made similar journeys with Python, Lua, Ruby, and Haskell. Usually when I make this attempt, I take a non trivial but simple project and implement it. Usually this is a ray tracer, though in Python's case it was a protocol stack. I don't just implement the project either, but often tinker with novel ideas I think of or come across while reading newsgroups. I hesitate to call it thorough by any means, but to me it represents an attempt to see how it "rolls off the tongue".
If I like a language, I find myself using it for other projects. So it was with Python. I still implement and use python libraries (such as reStructuredText that I wrote this document with).
So it was with Lisp too. I find myself looking for excuses to use it. It's hard to describe, but it's really a joie de vivre that I experience when using the language.
That, in a nutshell, is "Why Lisp?"
If you would like a more detailed reasoning for using Lisp, see Chapter 1 of Peter Norvig's Paradigms of Artificial Intelligence Programming: Case Studies using Common Lisp, Chapter 1 of Peter Siebel's Practical Common Lisp or read Paul Graham's essays on the subject.
I use Windows. I like Windows. I have nothing against open source or free software, but I find the cost of migrating to an open source OS and its lack of applications too high for me to consider. Which means that I must bring the language to the OS rather than the OS to the language. Which is why I use Corman Lisp.
Corman Lisp is a full featured, native compiled, Win32 compatible Lisp that is free for evaluation and reasonably priced for commercial usage. There are very few restrictions on its use, and it just works.
It has its problems, most notably being lack of 100% ANSI compliance, but overall it's a great package that compares favorably to the other, more expensive, Lisp implementations.
Also, Corman is meant to be embedded. It can be used as a COM server, and it's easy to define callbacks in Lisp to be called from C/C++ code. Lastly, Corman has as good as foreign function interface (FFI) as other Win32 Lisps.
Any true lisper knows that Emacs is the one true development environment for Lisp :). I use Emacs 22 along with a custom setup for Corman Lisp that gives me a very good, interactive development environment. It's not quite SLIME, but considering what it takes to get SLIME working with Corman (which I never did), I opted for a simpler approach.
The setup is relatively easy, the hardest part being the custom listener for Corman. You just need to install the necessary software and then apply the patches.
First, you have to install the software.
After installing all the software, put these modified files over the original files. Make a backup of the original files first.
Start Emacs and type M-x start-lisp. If done correctly, you should see the Corman copyright notice and a familiar question mark prompt. Voila!
To end a session, type :quit, as in clconsole. You should see the message Process inferior-lisp connection broken by remote peer. Sometimes when starting (about 1 in 20), clnetconsole will fail with the same message. Retrying will start the session.
Even though I haven't noticed anything untoward using it in comparison with straight clconsole, I won't guarantee that everything works exactly the same.
These are (lite) instructions for the general use of inferior lisp mode in Emacs and are not specific to my utilities. I figured they might be handy though to those who are new to both to Emacs and Corman Lisp.
There are a couple of ways to load files into the lisp image running in Emacs. The first and most obvious is to type (load <file>) at the ? prompt.
The more convenient method is to visit the file in Emacs, and then type C-c C-l and follow the prompts in the mini-buffer. It will default to the buffer being currently visited, so it's enough to simply type Enter.
Loading files is very useful, but where Lisp really shines is interactivity. Emacs can interactively load a single top level form or a region.
To load a region, highlight the text you want evaluated and type C-c C-r. Even simpler is to compile a single top level form, such as a defun. (The key binding is actually called lisp-compile-defun, though it does a form up to the top level). Use C-c C-c or C-c C-e to do this, with one caveat. Emacs stops evaluating when it gets to a ( in the left most column, not when it really gets to a top level form. You have to make sure that no forms align at the left most column before the (defun (or whatever your outermost form is).
My last word of advice when using interactive compilation is to be wary of which package you're using. Or better yet, just develop your code in a single package (such as :cl-user), and then separate it into packages when it is finalized.
I hope you find this setup useful. I am having a blast using Lisp. If you have any questions or problems with these instructions, drop me an e-mail at corman-setup@hobbit-hole.org and I'll do what I can to help you out.
| [1] | These files for Corman Lisp include both mine and Chris Double's patches. Also included is Edi Weitz's asdf and the unit test from Practical Common Lisp, along with perhaps other people who I am unfortunately neglecting. |
| [2] | The listener (included in the Corman files) is a modified version of Corman's default clconsole. Rather than use stdin/stdout, its communication interface has been replaced with a socket. The socket code was written by Vijay Mathew Pandyalakal for an article at CodeProject and is used with permission. The original clconsole code was written by Roger Corman and is used with permission. To build it, simply load the project files into Visual C++ 2005. Use Standard to build (Standard configuration, not VS2005 Standard). Don't use the Release configuration. It doesn't work. The project files have not been tested with versions other than Visual C++ 2005 Express Edition, but should work in any version of VS2005. |
| [3] | These changes allow inferior lisp to use a network socket instead of a process handle. Most of the functionality was already in Emacs, I just exposed it to inferior lisp. |
| [4] | These functions are to found in the file .emacs, but don't overwrite your .emacs with this one. Simply append them to your own .emacs and you should be fine. |