CLISP - Conversational LISP

Warren Teitelman

Abstract

CLISP (Conversational LISP) is a pioneering "user-friendly" extension to LISP that introduces ALGOL-like syntax—such as infix operators and IF-THEN statements—without altering LISP's underlying structure. It uniquely leverages an "error-driven" execution model to transparently translate human-readable code into standard LISP on the fly, effectively acting as an invisible "programmer's assistant."

The "Pushing Down" Problem

In the early 1970s, LISP was already a powerhouse for AI research, but it faced a significant usability hurdle often referred to as "parenthesis hell." While LISP’s prefix notation and heavy nesting are mathematically elegant and facilitate program-to-program manipulation, they are notoriously difficult for humans to read and write.

Warren Teitelman identified this as a "pushing down" problem: humans struggle with deep mental stacks of nested parentheses, whereas they excel at recognizing keywords (like IF, THEN, FOR) and infix operators (like + or *). The challenge was to provide these "natural" programming constructs without breaking LISP’s core philosophy or requiring a slow, heavy-handed pre-processor that would force users to choose between "pure" LISP and a new dialect.

Methods: Error-Driven Implementation

CLISP’s most innovative feature is its error-driven implementation. Rather than using a traditional compiler or a separate pre-processing stage, CLISP is integrated directly into the LISP interpreter's error-handling machinery. This process involves several key components:

  1. The DWIM (Do What I Mean) Analyzer: When the LISP interpreter encounters an expression it doesn't recognize (which would normally trigger an error), it hands the expression over to the CLISP analyzer. This analyzer uses a complex decision tree to determine the user's likely intent.
Decision tree for resolving CLISP syntax ambiguities
  1. On-the-Fly Translation: CLISP scans the "erroneous" expression for its own constructs (like A+B*C). If it finds a match, it translates it into standard LISP (e.g., (PLUS A (TIMES B C))) and replaces the original code with the translated version.
  2. Caching: This translation happens only once. Subsequent executions of the same code block run at full LISP speed because the "illegal" CLISP syntax has been replaced by valid LISP.
  3. Robust Error Correction: CLISP doesn't just handle syntax; it handles human messiness. It uses the "DWIM" system to fix misspellings (e.g., IFFN to IF) and missing or misplaced parentheses by looking at the surrounding programming environment and function definitions.

Key Insights: Context-Aware Parsing

Teitelman argues that CLISP isn't just a language; it’s a system that sits between the user and the interpreter. It assumes the user intended to write something meaningful and tries its best to "make sense" of it. A critical aspect of this is context-awareness. CLISP is smarter than a simple macro; it checks the environment to resolve ambiguities. For instance, if FACT is a variable, X*FACT is treated as a multiplication; if FACT is a function, it might be treated as a function call.

Potential LISP translations generated by the CLISP analyzer

Because it is error-driven, users can freely intermix standard LISP and CLISP. If pure LISP is written, the system never invokes CLISP, ensuring zero overhead for legacy code. This transparency is key to its adoption as a "programmer's assistant."

Key Results and Robustness

The paper demonstrates how a recursive factorial function can be written as (IF N=0 THEN 1 ELSE N*(FACTORIAL N-1)), which is significantly more intuitive than the standard LISP COND equivalent.

Furthermore, the system exhibits extreme robustness. It is shown to successfully translate a mangled definition of factorial: (IFFN*0 THENN 1 ESLE N*8FACTTORIALNN-1). CLISP fixes five spelling errors and a parenthesis error to produce a working function. CLISP was fully integrated into INTERLISP, and tools like PRETTYPRINT were updated to display the original CLISP syntax to the user, even if the internal representation had been converted to standard LISP.

Limitations and Future Work

Despite its successes, CLISP has limitations. It is deeply tied to the INTERLISP environment and its specific error-handling hooks, making it difficult to port to other LISP dialects. Additionally, while the system tries to resolve ambiguities, in complex cases, it must ask the user for clarification, which can be intrusive. The author suggests that future work will involve refining the system based on broader user feedback and addressing deeper semantic issues that were bypassed in this initial syntax-focused implementation.

Summary updated

BibTeX
@inproceedings{teitelman1973clisp,
  author = {Warren Teitelman},
  title = {{CLISP - Conversational LISP}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {1973},
}
Figure