Basic Lisp Techniques
David J. Cooper, Jr.
September 10, 2000
Foreword1
Computers, and
the software applications that power them, permeate every facet of our daily
lives. From groceries to airline reservations to dental appointments, our
reliance on technology is allencompassing.
And, we want more. Every day, our expectations of technology and software
increase:
l smaller cell phones that surf the net
l better search engines that generate information we actually want
l voice-activated laptops
l cars that know exactly where to go
The list is endless. Unfortunately, there is not an endless
supply of programmers and developers to satisfy our insatiable appetites for
new features and gadgets. "Cheap talent" to help complete the "grunt
work" of an application no longer exists. Further, the days of unlimited
funding are over. Investors want to see results, fast. Every day, hundreds of
magazine and on-line articles focus on the time and people resources needed to
support future technological expectations.
Common Lisp (CL) is one of the few languages
and development options that can meet these challenges. Powerful, exible,
changeable on the fly-increasingly, CL is playing a leading role in areas with
complex problem-solving demands. Engineers in the fields of bioinformatics,
scheduling, data mining, document management, B2B, and E-commerce have all
turned to CL to complete their applications on time and within budget. But CL
is no longer just appropriate for the most complex problems. Applications of
modest complexity, but with demanding needs for fast development cycles and
customization, are also ideal candidates for CL.
Other languages have tried to mimic CL, with
limited success. Perl, Python, Java, C++, C# - they all incorporate some of the
features that give Lisp its power, but their implementations tend to be
brittle.
The purpose of this book is to showcase the
features that make CL so much better than these imitators, and to give you a
"quick-start" guide for using Common Lisp as a development environment. If
you are an experienced programmer in languages other than Lisp, this guide
gives you all the tools you need to begin writing Lisp applications. If you've
had some exposure to Lisp in the past, this guide will help refresh those
memories and shed some new light on CL for you.
But be careful, Lisp can be addicting! This
is why many Fortune 500 companies will use nothing else on their 24/7,
cutting-edge, mission-critical applications. After reading this book, trying
our software, and experiencing a 3 to 10 times increase in productivity, we
believe you will feel the same way.
Contents
1.1 The Past, Present, and Future of Common Lisp
1.2 Convergence of Hardware and Software
1.3 The CL Model of Computation
Operating a CL Development Environment
2.1 Installing a CL Environment
2.2 Running CL in a Shell Window
2.2.1 Starting CL from a Terminal Window
2.2.2 Stopping CL from a Terminal Window
2.3 Running CL inside a Text Editor
2.3.1 A Note on Emacs and Text Editors
2.3.3 Starting, Stopping, and Working With CL inside an Emacs Shell
2.4 Running CL as a subprocess of Emacs
2.4.1 Starting the CL subprocess within Emacs
2.4.2 Working with CL as an Emacs subprocess
2.4.3 Compiling and Loading a File from an Emacs buffer
2.5 Integrated Development Environment
2.7 Using CL as a scripting language
2.8.1 Common debugger commands
2.8.2 Interpreted vs Compiled Code
2.8.3 Use of (break) and C-c to interrupt
2.9 Developing Programs and Applications in CL
2.9.2 Compiling and Loading your Project
2.9.3 Creating an Application "Fasl" File
2.9.6 Using an Application Init File
2.10 Using CL with Other Languages and Environments
2.10.1 Interfacing with the Operating System
2.10.2 Foreign Function Interface
2.10.4 Custom Socket Connections
2.10.5 Interfacing with Windows (COM, DLL, DDE)
2.10.6 Code Generation into Other Languages
3.1 Overview of CL and its Syntax
3.2 The List as a Data Structure
3.2.1 Accessing the Elements of a List
3.2.10 Adding Elements to a List
3.2.11 Removing Elements from a List
3.2.13 Treating a List as a Set
3.2.14 Mapping a Function to a List
3.5 Input, Output, Streams, and Strings
3.6 Hash Tables, Arrays, Structures, and Classes
3.7.1 Importing and Exporting Symbols
3.8.5 Distinguishing Macros from Functions
4.3.2 Making Instances and Sending Messages
4.4 Personal Accounting Application
CL as an Internet Application Server
5.1.2 Generating HTML with AllegroServe's htmlgen
5.2.3 Separating the "View" from the Object
5.3 Web-enabling the Personal Accounting Application