Table of contents

History ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::

Design goals ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::

Outcome ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Current state of the system :::::::::::::::::::::::::::::::::::::::::::::::

LeLisp Version ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Readers guide ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

Use and installation

LeLisp on various systems ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Starting with LeLisp ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

Starting the LeLisp system under ::::::::::::::::::::::::::::::::::::::::::

Installation of the LeLisp system under Unix ::::::::::::::::::::::::::::::::::::

Installing the system ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Mo dication of the system conguration ::::::::::::::::::::::::::::::::::

Mo dication of data zone sizes ::::::::::::::::::::::::::::::::::::::::::::

Linking the LeLisp system with mo dules :::::::::::::::::::::::::::::::

Calling the shell ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

Starting the LeLisp system under VMS ::::::::::::::::::::::::::::::::::::::::::

Practical advice ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Evaluation

Basic ob jects ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::

Atomic ob jects ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

Comp ound ob jects ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Basic evaluation actions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

Evaluation of atomic ob jects ::::::::::::::::::::::::::::::::::::::::::::::

Evaluation of comp osite ob jects :::::::::::::::::::::::::::::::::::::::::::

Evaluation of functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

Functions of the subr kind :::::::::::::::::::::::::::::::::::::::::::::::

Functions of the fsubr kind ::::::::::::::::::::::::::::::::::::::::::::::

Functions of the msubr kind ::::::::::::::::::::::::::::::::::::::::::::::

Functions of the dmsubr kind :::::::::::::::::::::::::::::::::::::::::::::

Functions of the expr kind :::::::::::::::::::::::::::::::::::::::::::::::

Functions of the expr kind with a nobind argument ::::::::::::::::::::::

Functions of the fexpr kind ::::::::::::::::::::::::::::::::::::::::::::::

Functions of the macro kind ::::::::::::::::::::::::::::::::::::::::::::::

Functions of the dmacro kind :::::::::::::::::::::::::::::::::::::::::::::

Dening functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Packages ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

Extended typ es ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

Metacircular denition of the evaluator ::::::::::::::::::::::::::::::::::::::::::

Predened functions

Evaluation functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::

Application functions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

Simple application functions ::::::::::::::::::::::::::::::::::::::::::::::

Application functions of the map typ e :::::::::::::::::::::::::::::::::::::

Other application functions :::::::::::::::::::::::::::::::::::::::::::::::

Environment manipulation functions :::::::::::::::::::::::::::::::::::::::::::::

Functiondenition functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Static function denitions ::::::::::::::::::::::::::::::::::::::::::::::::

Advanced use of macro functions ::::::::::::::::::::::::::::::::::::::::::

Denition of closures ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Denition of dynamic functions :::::::::::::::::::::::::::::::::::::::::::

Generalized assignment ::::::::::::::::::::::::::::::::::::::::::::::::::

Variable functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Basic control functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

Lexical control functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Primitive lexical control forms ::::::::::::::::::::::::::::::::::::::::::::

Iteration functions of the prog kind :::::::::::::::::::::::::::::::::::::::

Iteration functions of the do kind :::::::::::::::::::::::::::::::::::::::::

Dynamic nonlo cal control functions :::::::::::::::::::::::::::::::::::::::::::::

Basic predicates ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Functions on lists ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Search functions on lists ::::::::::::::::::::::::::::::::::::::::::::::::::

List creation functions :::::::::::::::::::::::::::::::::::::::::::::::::::

Functions on cells of lab elled lists :::::::::::::::::::::::::::::::::::::::::

Physical mo dication functions :::::::::::::::::::::::::::::::::::::::::::

Functions on Alists ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Sorting functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Functions on symb ols ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

Functions that access symb ol values :::::::::::::::::::::::::::::::::::::::

Functions that mo dify symb ol values ::::::::::::::::::::::::::::::::::::::

Functions on Plists ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Access to function denitions :::::::::::::::::::::::::::::::::::::::::::::

Access to symb ol sp ecial elds ::::::::::::::::::::::::::::::::::::::::::::

Symb ol creation functions ::::::::::::::::::::::::::::::::::::::::::::::::

Symb ol management functions ::::::::::::::::::::::::::::::::::::::::::::

Functions on character strings :::::::::::::::::::::::::::::::::::::::::::::::::::

Basic manipulation functions :::::::::::::::::::::::::::::::::::::::::::::

Character string conversion :::::::::::::::::::::::::::::::::::::::::::::::

Comparison of character strings :::::::::::::::::::::::::::::::::::::::::::

Characterstring creation functions ::::::::::::::::::::::::::::::::::::::::

Characterstring access functions ::::::::::::::::::::::::::::::::::::::::::

Functions that physically mo dify strings :::::::::::::::::::::::::::::::::::

Search functions on character strings ::::::::::::::::::::::::::::::::::::::

Functions on characters ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

Functions on vectors ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::

Functions on arrays ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::

Hash tables ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

Hash table creation functions :::::::::::::::::::::::::::::::::::::::::::::

Hash table access functions :::::::::::::::::::::::::::::::::::::::::::::::

Mathematical sets ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Op erations on sets ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Comparisons on sets ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Transitive closure ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Arithmetic functions

Generic arithmetic ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Generic arithmetic interrupt ::::::::::::::::::::::::::::::::::::::::::::::

Typ e tests ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Numeric conversions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Generic arithmetic functions ::::::::::::::::::::::::::::::::::::::::::::::

Predicates of generic arithmetic :::::::::::::::::::::::::::::::::::::::::::

Circular and mathematical functions ::::::::::::::::::::::::::::::::::::::

Extensions to generic arithmetic ::::::::::::::::::::::::::::::::::::::::::

Integer arithmetic ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Integer arithmetic functions ::::::::::::::::::::::::::::::::::::::::::::::

Fixedprecision integer comparison functions :::::::::::::::::::::::::::::::

Bo olean functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Functions on bit elds ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Pseudorandom functions :::::::::::::::::::::::::::::::::::::::::::::::::

Extended integer arithmetic ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Floatingp oint arithmetic ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Floatingp oint arithmetic functions :::::::::::::::::::::::::::::::::::::::

Floatingp oint arithmetic comparisons :::::::::::::::::::::::::::::::::::::

Mixed arithmetic ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Ob jectoriented programming

Structures ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::

Structure denition ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Instance creation ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Access to elds ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

Typ e tests ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Implementation of structures :::::::::::::::::::::::::::::::::::::::::::::

LeLisp typ ology ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Ob jectoriented programming :::::::::::::::::::::::::::::::::::::::::::::::::::

Searching for metho ds ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Invoking metho ds ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Predened metho ds ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Abbreviation functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

MicroCeyx ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::

Sp ecic errors ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

Denition of structures :::::::::::::::::::::::::::::::::::::::::::::::::::

Tclass and record instances :::::::::::::::::::::::::::::::::::::::::::::::

Metho ds and message sending ::::::::::::::::::::::::::::::::::::::::::::

Input and output

Intro duction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

Characters ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Character strings ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Lines ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

Channels ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Programmable IO interrupts :::::::::::::::::::::::::::::::::::::::::::::

Basic input functions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

Inside read ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Use of the terminal for input ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Standard reader ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Reading symb ols ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

Reading character strings :::::::::::::::::::::::::::::::::::::::::::::::::

Reading integer and rational numb ers :::::::::::::::::::::::::::::::::::::

Reading oatingp oint numb ers :::::::::::::::::::::::::::::::::::::::::::

Reading lists ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::

Reading vectors ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

Reading comments ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Typ es of characters ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Macro characters ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Basic output functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

Controlling the output functions :::::::::::::::::::::::::::::::::::::::::::::::::

Limitations on printing :::::::::::::::::::::::::::::::::::::::::::::::::::

Standard printing environment :::::::::::::::::::::::::::::::::::::::::::

Extending the printer ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Inputoutput for lists ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

Inputoutput on character strings ::::::::::::::::::::::::::::::::::::::::::::::::

InputOutput buer management ::::::::::::::::::::::::::::::::::::::::::::::::

Input buer ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::

Output buer ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

Functions on io streams ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Default directories and extensions :::::::::::::::::::::::::::::::::::::::::

Selecting io streams ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Endofle programmable interrupt :::::::::::::::::::::::::::::::::::::::

Functions on les ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

load function and autoload mo de ::::::::::::::::::::::::::::::::::::::::

File access paths ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

Access to libraries ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Event lo op ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::

Functions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Technical notes ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

Precautions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::

Virtual le system ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Pathnames ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Relative access paths ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Pathname manipulation functions :::::::::::::::::::::::::::::::::::::::::

Portability ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Features ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

System functions

Programmable interrupts ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Machine interrupts ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

User interrupt ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

Realtime clo ck ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

Multiple tasks ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

Basic sequencers ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

Errors provoked by the LeLisp system :::::::::::::::::::::::::::::::::::::::::::

Standard error pro cessing ::::::::::::::::::::::::::::::::::::::::::::::::

Explicit call and error test ::::::::::::::::::::::::::::::::::::::::::::::::

Examples of exception handling :::::::::::::::::::::::::::::::::::::::::::

Access to the evaluator ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

Coreimage les ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Installation functions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

Calling and leaving the system ::::::::::::::::::::::::::::::::::::::::::::::::::

Top level ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

Garbage collector ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Date pro cessing ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

Other access to the system ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Sexpression prettyprinter

Prettyprint functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Control of prettyprinter functions ::::::::::::::::::::::::::::::::::::::::

Standard prettyprinter format :::::::::::::::::::::::::::::::::::::::::::

Extending the prettyprinter ::::::::::::::::::::::::::::::::::::::::::::::

Sp ecialized output

Formatted output ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Printformatting function :::::::::::::::::::::::::::::::::::::::::::::::::

Format directives ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Handling circular or shared ob jects ::::::::::::::::::::::::::::::::::::::::::::::

Multilanguage messages ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Languages ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Messages ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Advice ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

Rational and complex arithmetic

Rationals le Q ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Rational numb er IO ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Tests for typ e ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::

Generic rational arithmetic :::::::::::::::::::::::::::::::::::::::::::::::

Functions limited to Z ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Functions limited to rational arguments limited to Q :::::::::::::::::::::

Two examples ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

Complex numb ers the eld C ::::::::::::::::::::::::::::::::::::::::::::::::::

Complex numb er IO ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Tests for typ e ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::

Complex generic arithmetic :::::::::::::::::::::::::::::::::::::::::::::::

Functions limited to the complex numb ers limited to C :::::::::::::::::::

Polar co ordinates ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Hyp erb olic functions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

A complex miniextension of generic arithmetic :::::::::::::::::::::::::::::::::::

Representation ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

IO for C ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Complex arithmetic ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

exp log and sqrt functions :::::::::::::::::::::::::::::::::::::::::::::::

Debugging to ols

Tracing ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::

Stepping functions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Trace parameters ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Trace global variables ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Example of trace use ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Break and debug mo de ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

Insp ection or debug lo op ::::::::::::::::::::::::::::::::::::::::::::::::

Debug mo de functions :::::::::::::::::::::::::::::::::::::::::::::::::::

Stepwise execution ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Loaderassembler LLM

Access to memory and the CPU :::::::::::::::::::::::::::::::::::::::::::::::::

LLM memory loader ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

LLM instruction format ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Mo dules and lab els ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::

LLM instruction op erands ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Pseudoinstructions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::

Basic instructions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Moving p ointers ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

Pointer comparisons ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Control ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

Stack ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::

Management of the stack p ointer :::::::::::::::::::::::::::::::::::::::::

As a control stack ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

As a data stack ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

List cell cons op erations ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Test for list cell typ e ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Access to list cell elds :::::::::::::::::::::::::::::::::::::::::::::::::::

Creation of list cells ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

nil ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::

Symb ols ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::

Test for symb ol typ e ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Access to the elds of a symb ol :::::::::::::::::::::::::::::::::::::::::::

Variables ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Numb ers ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

bit integer numb ers :::::::::::::::::::::::::::::::::::::::::::::::::::

Floatingp oint numb ers ::::::::::::::::::::::::::::::::::::::::::::::::::

Vectors of Lisp p ointers ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

Test for vector of p ointers ::::::::::::::::::::::::::::::::::::::::::::::::

Access to internal elds of a vector of p ointers :::::::::::::::::::::::::::::

Access to elements of a vector of p ointers ::::::::::::::::::::::::::::::::::

Creation ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Character strings ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Test for character string ::::::::::::::::::::::::::::::::::::::::::::::::::

Access to the internal elds of a character string :::::::::::::::::::::::::::

Access to characters ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Creation ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Heap zone ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::

Extending the LoaderAssembler ::::::::::::::::::::::::::::::::::::::::::::::::

Functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::

Typ es of functions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Function calling rules ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Examples ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::

Compilation

Calling the ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

macros ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

Closed macros ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

Op en macros ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::

Mo dules ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

Source les ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Ob ject les ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Controlling evaluation ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Use and manipulation of mo dules ::::::::::::::::::::::::::::::::::::::::::::::::

Functions on mo dules ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Loading and compiling mo dules :::::::::::::::::::::::::::::::::::::::::::

Complice ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

Compatibility messages ::::::::::::::::::::::::::::::::::::::::::::::::::

Errors and warnings ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

General remarks and examples ::::::::::::::::::::::::::::::::::::::::::::

External interfaces

Interface functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Links with external pro cedures under Unix :::::::::::::::::::::::::::::::::::::::

Principles ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Calling functions written in C ::::::::::::::::::::::::::::::::::::::::::::

Calling Lisp from C ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Virtual terminal

Virtual terminal functions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Standard functions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Required functions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Optional functions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Screen functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Using the virtual terminal ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Dening a virtual terminal ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Fullpage editor

Functions to call the fullpage editor :::::::::::::::::::::::::::::::::::::::::::::

Fullpage editor commands ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Extensions to the fullpage editor :::::::::::::::::::::::::::::::::::::::::

Terminalbased line editor

Loading the terminalbased line editor :::::::::::::::::::::::::::::::::::::::::::

Terminalbased lineeditor commands ::::::::::::::::::::::::::::::::::::::::::::

Virtual bitmap display

Loading the description le ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Screen preparation ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Managing a single screen :::::::::::::::::::::::::::::::::::::::::::::::::

Managing several screens :::::::::::::::::::::::::::::::::::::::::::::::::

Functions on screens ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::

Functions on windows ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

Global co ordinates ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Lo cal co ordinates ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Windows ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

Creating windows ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Drawing in windows ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Attaching prop erties to windows ::::::::::::::::::::::::::::::::::::::::::

Functions on windows ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Primitive functions on windows :::::::::::::::::::::::::::::::::::::::::::

Minimal graphics primitives ::::::::::::::::::::::::::::::::::::::::::::::

Character strings ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Virtual mouse

Events ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::

Structure and typ es of events ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Mouse mo des ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::

Events queue ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::

Programmable interrupts ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Synchronous mouse tracking ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Virtual menus ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

Cut and Paste ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

Graphics primitives

Graphics environments ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

Current font ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::

Foreground and background colors ::::::::::::::::::::::::::::::::::::::::

Cursor ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

Line style ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Fill patterns or textures ::::::::::::::::::::::::::::::::::::::::::::::::

Drawing combination mo de :::::::::::::::::::::::::::::::::::::::::::::

Clipping zone ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::

Graphics primitives ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::

Extended graphics functions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Linedrawing functions :::::::::::::::::::::::::::::::::::::::::::::::::::

Fill functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::

Displaying text ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

Bitmaps ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

Compatibility b etween typ es of bitmaps :::::::::::::::::::::::::::::::::::

FOREWORD

LELISP Chailloux et al is a LISP system develop ed at INRIA Institut National de Recherche en

Informatique et en Automatique in France This dialect of the LISP language McCarthy is the

spiritual child of Vlisp Greussay Chailloux from which LELISP gets its conciseness and

interpreter sp eed and the natural child of or more precisely of the PostMacLisp LISPs

such as MIT Weinreb and Mo on NIL White Burke and Carette

and Fo deraro and Sklower to which LELISP owes its strength as a language for the

development of sound and p owerful compiled applications

History

In researchers at INRIA b egan to develop an ambitious vlsi design system using a unique

structure to represent all asp ects of the pro ject graphics simulation etc For the implementation

language LISP was an obvious choice The INRIA designers were thinking more precisely of

one of the p owerful PostMacLisp languages Fortunately or unfortunately as the case may

b e hardware was quickly evolving and the vlsi pro ject called up on many heterogeneous and

incompatible machines Various existing LISP systemsotherwise p erfectly satisfactorywere

simply not available on the required range of machines For instance at that time Franz Lisp

only existed on Vaxen The implementation of the LISP system on a new computer had to b e faster

of course than the translation of the vlsi design system from one LISP dialect to the other Out of

this context grew the LELISP system to full wellidentied goals And to this day p ortability of

the LISP system and its applications has remained a hallmark of LELISP

Design goals

Eciency and exibility

LELISP is designed for maximum eciency b oth in terms of execution resources main memory

and execution time and development resources application development time and

congurations

Extensions and integration

The LELISP system allows you to make full use of existing system facilities by means of the concept

of virtual devices In this way access to lemanagement pro cedures graphic libraries routines

written in other languages and op eratingsystem calls is provided with no sacrice of p ortability

The user can create new instances of such facilities while retaining a standardized interface

Portability of applications

Since all system facilities are accessed via their virtual counterpart user applications are never

required to contain implementationsp ecic detailseven though they might call up on the full

richness of the system

Compatibility among implementations

Since the implementation of LELISP is based up on a virtual machine called LLM only this virtual

machine is p orted from one real machine to another The rest of the system is guaranteed to b e

compatible b ecause all implementations share the same co de A corollary is the rapid availability

of topquality implementations on new machines that app ear on the market

Outcome

All the ab ovementioned goals were attained in the resulting system The rst LELISP system

b egan to runduring the autumn of on an Exormacs Motorolas machine based up on the

That rst implementation formed the basis of a vlsi design workstation that incorp orated

a colored bitmapp ed display and a mouse Chailloux et al The system was then implemented on

the vax under UNIX during the autumn of After its successful b eginnings LELISP simply

went forth and multiplied

Current state of the system

To day LELISP is a rich LISP system that is implemented on more than thirty kinds of machines

based up on more than twelve cpus running under a variety of op erating systems The industrial

availability of all these versions is a reection of the countless enhancements made to LELISP over

the years Indeed since its inception LELISP has b een enlarged to include userextensible generic

arithmetic an ob jectoriented typ e system virtual graphic libraries a mo dular compiler full access

to foreign routines and many other marvels

More imp ortantly environments constructed using LELISP provide a huge array of functionalities

The application environments include numerous exp ertsystem generators simulation to ols

database access to ols graphic development to ols music and acoustic research to ols symb olic

mathematics systems case environments and of course since it was the initial motivation b ehind

the creation of the language vlsi design environments

LeLisp Version

LELISP Version Decemb er is totally compatible as well as backward compatible

with Lisp co de b oth interpreted and compiled

The LLM virtual machine has b een p orted onto the HPPA and DEC ALPHA pro cessors

Some new functions have b een intro duced copyfile createdirectory deletedirectory

mapexpandpathname atend and printf

READERS GUIDE

The information issued from the function gcinfo has b een ne tuned

A new programmable interruption atend is now available

The defextern function systematically creates a test of typ e dynamic

The new functions C CLLFIX LLCFIX CLLFLOAT and LLCFLOAT are available in the

external interface

Readers guide

The present do cument is a reference manual As such it provides precise and complete

informationrather than tutorial materialon the sub ject of LELISP For newcomers to the

language excellent intro ductory b o oks on LELISP exist already in French English and other Europ ean languages

Bibli ography

Ab elson and Sussman Harold Ab elson and The Structure and Interpretation

of Computer Programs The MIT Press McGraw Hill Bo ok Company Cambridge

Allen John Allen The Anatomy of Lisp McGrawHill

Audoire Louis Audoire Un Pro cesseur Specialise mLLM sur SPS Actes des journees

SM Versailles Decembre

Boston First Standardization Meeting Boston Decemb er

Bro ok and Gabriel Ro dney A Bro ok and Richard P Gabriel A Critique of Common Lisp

ACM Symposium and Austin Texas July

Burke and Carette Burke and Carette NIL Notes for Release Massachusetts Institute of

Technology Cambridge Decemb er

Cayrol Michel Cayrol Le langage LISP Cepadues Editions Toulouse

Chailloux Jerome Chailloux Le mo dele Vlisp description evaluation et interpretation

These de eme cycle Universite de Paris VI Paris Avril

Chailloux Jerome Chailloux LeLisp version le manuel de reference Rapp ort technique

INRIA no Ro cquencourt Juillet

Chailloux et al Jerome Chailloux Matthieu Devin et JeanMarie Hullot LeLisp a Portable an

Ecient Lisp System ACM Symposium on Lisp and Functional Programming

Austin July

Chailloux a Jerome Chailloux LeLisp version le manuel de reference Do cumentation

INRIA Ro cquencourt Fevrier

Chailloux b Jerome Chailloux La machine virtuelle LLM Rapp ort technique no INRIA

Ro cquencourt Juin

Cointe Pierre Cointe Fermetures dans les lamb dainterpretes Application aux langages LISP

PLASMA et SMALLTALK These de eme cycle Universite de Paris VI Paris

Dana Michel Dana LeLisp v sous systeme VAXVMS Rapp ort ENST Janvier

Devin a Matthieu Devin Le p ortage du systeme LeLisp mo de demploi Rapp ort Technique

no INRIA Ro cquencourt Mai

Devin b Matthieu Devin La Microprogrammation du systeme LeLisp une premiere

appro che Rapp ort de Recherche no INRIA Ro cquencourt Septembre

BIBLIOGRAPHY

Farreny Henry Farreny LISP Masson Paris

Fo deraro and Sklower Franz Lisp Manual Univ of California Berkeley Septemb er

Gabriel Richard Gabriel The Performance and Evaluation of Lisp Systems MIT Press

Cambridge

Girardot JeanJacques Girardot Les langages et les systemes LISP edi tests Paris

Greussay Patrick Greussay Contribution a la denition interpretative eta limplementation

des lamb dalangages These Universite de Paris VI Paris Novembre

Hullot JeanMarie Hullot Ceyx a Multiformalism Programming Environment IFIP

REA Masson ed North Holland Paris

Hullot a JeanMarie Hullot Programmer en Ceyx Rapp orts techniques no INRIA

Ro cquencourt Fevrier

Hullot b Jean Marie Hullot Alcyone La b oite a outils Ob jets Rapp ort Technique no

INRIA Ro cquencourt Novembre

Kiremitdjian and Roy Georges Kiremitdjian et JeanPaul Roy Lire Lisp le langage de

lIntel ligence Articiel le CedicNathan Paris

Lang and Dup ont Bernard Lang et Francis Dup ont Incremental Incrementally Compacting

Garbage Collection ACMSIGPLAN Symposium on Interpreters and Interpretive

Techniques St Paul June

LMDL Jerome Chailloux editeur Les Comptes Rendus des Mardis du Lisp Rapp orts

internes du pro jet VLSI INRIA Ro cquencourt

McCarthy John McCarthy LISP Programmers Manual MI Press Cambridge

Padget et al Julian Padget Jerome Chailloux Thomas Christaller Matthieu Devin John

Fitch Tim Krumnack Ramon Lop ez Eugen Neidl Stephen Pop e Christian Queinnec

Luc Steels Herb ert Stoyan Desiderata for a standardization of LISP ACM

Conference on Lisp and Functional Programming Boston August

Queinnec Christian Queinnec Lisp langage dun autre type Eyrolles Paris

Queinnec Christian Queinnec Lisp mode demploi Eyrolles Paris

Serp ette et al Bernard Serp ette Jean Vuillemin and JeanClaude Herve BigNum A Portable

and Ecient Package for Arbitrary Precision Arithmetic DEC PRL Paris

Spir Eric Spir Implementation dun Glanneur de Cellules p our LeLisp Version

Rapp ort de DEA dInformatique fondamentale de lUniversite Paris VI I Paris

Septembre

Steele Guy L Steele Jr Common Lisp The Language Digital Press Bedford

Stoyan and Gorz Herb ert Stoyan and Gun ter Gorz Lisp Eine Einfuhrung in die

Programmierung SpringerVerlag Berlin

Stoyan et al Herb ert Stoyan Julian Padget Jerome Chailloux Thomas Christaller Matthieu

Devin John Fitch Tim Krumnack Ramon Lop ez Eugen Neidl Stephen Pop e

Christian Queinnec Luc Steels Towards a LISP standard Pro ceedings of the th

ECAI Brighton July

BIBLIOGRAPHY

Teitelman Warren Teitelman Reference Manual XEROXPARC Palo Alto Octob er

Vuillemin Jean Vuillemin Exact real computer arithmetic with continued fractions Rapp ort

de recherche INRIA no Ro cquencourt Novembre

Weinreb and Mo on Daniel Wienreb and David Mo on Lisp Machine Manual Fourth Edition

Articial Intelligence Lab oratory MIT Cambridge July

Wertz Harald Wertz Lisp une introduction a la programmation Masson Paris

Winston and Horn Henry Winston et Berthold PK Horn Lisp nd Edition Addison Wesley

New York

White Jon L White NIL a p ersp ective Pro c of the Macsyma Users Conference

Washington DC June

BIBLIOGRAPHY

Table of contents

History ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::

Design goals ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::

Outcome ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Current state of the system :::::::::::::::::::::::::::::::::::::::::::::::

LeLisp Version ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Readers guide ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

Table of Contents

Function Index

Chapter

Use and installatio n

LeLisp on various systems

LELISP has b een p orted to the following pro cessors

 Motorola x

 DEC VAX

 Intel Pentium

 Ridge SPS

 IBMRS

 SPARC

 MIPS Rx

 HPPA

 DEC ALPHA

In the following list of machines on which LELISP works at present the name returned by the

system function is indicated b etween square brackets

 APOLLO MCx base under system DomainOS SysV et BSD apollo

 DecStation and MIPS base under ULTRIX decstation

 HP et series MCx base under HPUX hp hp

 HP HPPA base under system HPUX hp

 Silicon Graphics IRIS MIPS base under system IRIX irisd

 Silicon Graphics IRIS MIPS base under system IRIX irix

 PC Compatibles under DOS system msdos

 PC Compatibles under Windows windows

 PC Compatibles under Windows NT nt

CHAPTER USE AND INSTALLATION

 PC Compatibles under UNIX SCO sco

 PC Compatibles under Solaris x solaris

 IBMRS RS base or PowerPC under AIX rs

 SMSPS MC base under sytems SMX et SPIX sm spix

 Ridge SPS under ROS sps

 SUN MCx base under SUN OS sun

 SUN SPARC base under SUN OS sun

 SUN SPARC base under Solaris solaris

 VAX under systems Ultrix and VMS vaxunix vaxvms

 ALPHA under systems OSF et VMS alphaosf alphavms

Starting with LeLisp

To start up LELISP on any of the systems that supp ort it just typ e the command lelisp on the

terminal The system resp onds with

LeLisp by INRIA version ddmmyy system

Standard modular system date of the coreimage

list of the preloaded system features

where ddmmyy is the last systemmo dication date and system is the typ e of the LELISP

system b eing used At this p oint LELISP enters the main interactive lo op which reads an expression

from the terminal evaluates it and prints its value indenitely LELISP indicates that it is waiting

to read an expression by printing the questionmark character on the terminal at the b eginning

of each line The value of an evaluation is printed preceded by an equal sign

Here is an example of a LELISP session run on a Sun

we use the cshell csh

lelisp

LeLisp by INRIA version Nov sun

Standard modular system Sat Dec

bitfloats edlin microceyx abbrev date debug setf pepe

virbitmap virtty compiler pretty loader pathname

defstruct callext module messages

the null list

length oblist number of active symbols

version number of the current version

STARTING THE LELISP SYSTEM UNDER UNIX

system the system type

sun

defun fib n

cond n

n

t fib n fib n

fib

fib

time fib

gcinfo t the initial working space

gc cons symbol string

vector float fix heap code

gc t remaining work space

gc cons symbol string

vector float fix heap code

time gc the time a gc takes

Lhanoi loading a library

usrlocallelispvllibhanoill

hanoi try this its nice

hanoi

end to leave LeLisp

Que LeLisp soit avec vous

Starting the LeLisp system under Unix

The command used to start up LELISP under the UNIX op erating system has the following form

lelisp n r file

The strings in square brackets are optional

 The n argument is the size of the list zone in multiples of K list cells By default n has the

value In other words k list cells are allo cated The theoretical limit on this value is

for a maximum of k list cells The practical limit is the physical memory size of the host

machine or the maximum pro cess size of the host op erating system

 The file argument provides a way to sp ecify the name of a le containing LISP programs to

b e loaded b efore the system enters its main readevalprint lo op

CHAPTER USE AND INSTALLATION

 The r file argument string lets you sp ecify a coreimage le to b e loaded b efore the system

enters its main interactive readevalprint lo op

After loading the standard executable coreimage le LELISP automatically loads the le named

HOMElelisp

Installation of the LeLisp system under Unix

This section covers LELISP systems running under UNIX Vax Ultrix DecStation Ultrix Sun

SunOS HP HPUX etc

Installing the system

The LELISP system version is distributed on magnetic medium bpi tarformat tap e

dma or Streamer cartridge that should b e copied to disk in the systems instal lation directory

Usually this is the usrlocallelisp directory or mayb e the usrlocallelispv

directory when you want to keep several dierent versions of LELISP When installed the system

o ccupies ab out twelve megabytes of disk storage

Since a typical LELISP implementation is lo cked when you receive it make sure that you have

installed the access key that came along with the pro duct

The installation directory contains several subdirectories one of which called the system directory

is named according to the host machine vaxunix sun etc

This system directory must contain a subdirectory called llcore containing coreimage les

appropriate to the system involved

ls F usrlocallelispv

README ceyx llobj vaxunix

LLUSERFILES common lltest virbitmap

TARUSER llib llub virtty

benchmarks llmod manl

It is also necessary for all users to have write p ermission in the virtty subdirectory Use chmod

aw virtty

Installation requires the initialization of some absolute pathnames and the construction of LELISP

coreimage les

Initializi ng some absolute pathnames

Change directories cd to the system directory and execute the newdir command without any

arguments This command is to b e done only once after the system has b een copied from the

magnetic medium onto disk If the LELISP system is ever moved to a new lo cation in the le

system this pro cedure must b e carried out again

INSTALLATION OF THE LELISP SYSTEM UNDER UNIX

cd usrlocallelispvvaxunix

newdir

DIRusrlocallelispv

SYSDIRusrlocallelispvvaxunix

DIRusrlocallelispv

defvar systemdirectory usrlocallelispv

Building LeLisp coreimage les

Change directories to the system directory and execute the make command with the name of the

coreimage le to construct as argument

There are several entry p oints targets in the system makele allowing the construction of dierent

coreimage les lelisp lelisp cmplc lelispX with dierent memory congurations

normal This makele can b e extended to accomo date the construction of new systems

The makele uses the config command which builds a shell script that launches LELISP using

the constructed coreimage le This shell script should b e copied into a command directory the

directory usrlocalbin for instance in the host le system

Coreimage les are stored in the systemllcore directory Since they o ccupy a lot of disk storage

space it might b e advantageous to mount the llcore directory onto a sp ecial disk partition

cd usriloglelispvsun

make lelisp

config lelisp lelispbin Lelispconfll stack code heap

number vector string symbol cons float

LeLisp by INRIA version nov sun

Version

Subversion

unix system

loadstd sav min pepe env ld llcp to load standard environment

loadstm sav min pepe env ld llcp to load modular environment

loadcpl sav min meme env ld cmpl to load complice environment

usriloglelispvllibstartupll

setq systemname quote lelisp

lelisp

progn

loadstm systemname t t t t t

addfeature if eq BITFLOATS

CHAPTER USE AND INSTALLATION

BITFLOATS

Loading loaderlm done

Loading usriloglelispvllmodllpatchlm done

Loading usriloglelispvllmodmessageslm already loaded

Loading usriloglelispvllmodpathlm already loaded

Loading usriloglelispvllmodfileslm already loaded

Loading usriloglelispvllmodmodulelm done

Loading usriloglelispvllmoddefslm done

Loading usriloglelispvllmodgenarithlm done

Loading usriloglelispvllmodtoplevellm done

Loading usriloglelispvllmodcpmaclm done

Loading usriloglelispvllmodllcplm done

Loading usriloglelispvllmodpeepholelm done

Loading usriloglelispvllmodvirttylm done

Loading usriloglelispvllmodvirbitmaplm done

Loading usriloglelispvllmodpepelm done

Loading usriloglelispvllmodsetflm done

Loading usriloglelispvllmoddefstructlm already loaded

Loading usriloglelispvllmodsortlm already loaded

Loading usriloglelispvllmodarraylm done

Loading usriloglelispvllmodcallextlm already loaded

Loading usriloglelispvllmodtracelm done

Loading usriloglelispvllmodprettylm already loaded

Loading usriloglelispvllmoddebuglm done

Loading usriloglelispvllmodttywindowlm done

Loading usriloglelispvllmodabbrevlm done

Loading usriloglelispvllmodmicroceyxlm done

Wait saving Standard modular system

LeLisp by INRIA version Nov sun

Standard modular system Mon Dec

bitfloats microceyx abbrev date debug setf pepe virbitmap virtty

compiler pretty loader pathname defstruct callext module messages

end

May LeLisp be with you

cp lelisp usrlocalbin

The installation is finished

lelisp

LeLisp by INRIA version Jan sun

Standard modular system Sat Dec

bitfloats edlin display date microceyx debug setf pepe virbitmap

virtty compiler pretty abbrev loader callext defstruct pathname messages

INSTALLATION OF THE LELISP SYSTEM UNDER UNIX

Generally the installation just describ ed suces For certain applications it is sometimes necessary

to mo dify the conguration of the system that is the set of LISP les loaded in as the coreimage

or to netune the organization of the LISP memory space

Mo dication of the system conguration

The standard distribution allows the system to b e built in three dierent congurations which are

not exclusive and which corresp ond to dierent makefile entry p oints

 lelisp

Complete environment with debugging to ols an editor and the standard compiler

 cmplc

Complete environment with debugging to ols an editor and the mo dular COMPLICE compiler

used by the complice command

The exact comp osition of each of these system congurations is describ ed in a le in the conf

subdirectory lelispconfll and cmplcconfll You can change a conguration by editing one

of these les It is also p ossible to create a new entry p oint in the makefile describing a new system

conguration

Example

Construction of a coreimage le named mylisp containing the standard environment without an

editor but with the edlin line editor and with the scheduler scheduler functions This new system

can b e started up by the command mylisp

A conguration le for example confmylispconfll must b e created

cat confmylispconfll

loadstd load the environment without backup

t the minimum environment

no editor

t the complete environment

t the loader

t and the compiler

libload edlin load the edlin line editor

libload schedule and the scheduler

progn

llcpstd systemname compilation and construction of the image

edlin execution of edlin after initialization

Welcome to mylisp welcome message

Then add the entry p oint target mylisp to the makele in the system directory The mylisp

system is built using the lelispbin standard system no supplementary C mo dules and the

standard SIZE memory zone sizes

mylisp mylispconfll

config mylisp lelispbin mylispconfll SIZE

CHAPTER USE AND INSTALLATION

After this is done the system can b e built by executing the make mylisp command

make mylisp USERLELISPmonlelisp USERLELISPBINmylispbin

USEROmonco cc o monlelispbin

ollnumbo ollmaino ollstdioo ollfloato

olelispo ogetglobao lelispbino

monco

z x A systypebsd A runtypebsd

config monlelisp monlelispbin monlelispconfll stack code

heap number vector string symbol cons float

LeLisp by INRIA version nov apollo

Version

subversion

herald

defvar

systeme unix

loadstd sav min pepe env ld llcp to load standard environment

loadstm sav min pepe env ld llcp to load modular environment

loadcpl sav min meme env ld cmpl to load complice environment

usriloglelispvllibstartupll

setq systemname quote monlelisp

monlelisp

loadstm load environment without backup

t minimum environment

no editor

t complete environment

t loader

no compiler

Loading loaderlm

Loading usriloglelispvllmodllpatchlm

Loading usriloglelispvllmodmodulelm

Loading usriloglelispvllmoddefslm

Loading usriloglelispvllmodgenarithlm

Loading usriloglelispvllmodtoplevellm

Loading usriloglelispvllmodvirttylm

Loading usriloglelispvllmodvirbitmaplm

Loading usriloglelispvllmodsetflm

Loading usriloglelispvllmoddefstructlm

Loading usriloglelispvllmodsortlm

Loading usriloglelispvllmodarraylm

Loading usriloglelispvllmodcallextlm

Loading usriloglelispvllmodtracelm

Loading usriloglelispvllmodprettylm

Loading usriloglelispvllmoddebuglm

Loading usriloglelispvllmodttywindowlm

Loading usriloglelispvllmodabbrevlm

INSTALLATION OF THE LELISP SYSTEM UNDER UNIX

Loading usriloglelispvllmodmicroceyxlm

libload edlin

usrlocallelispvllibedlinll

libload schedule

usrlocallelispvllibschedulell

progn savestd systemname

edlin

Welcome to my lisp

Wait saving Standard modular system

LeLisp by INRIA version Jan vaxunix

Standard modular system Sat Dec

bitfloats edlin display date microceyx debug setf pepe virbitmap

virtty compiler pretty abbrev loader callext defstruct pathname messages

end

Que LeLisp soit avec vous

cp mylisp usrlocalbin

mylisp

LeLisp by INRIA version Jan vaxunix

Standard modular system Sat Dec

Welcome to my lisp

Mo dication of data zone sizes

The sizes of the dierent system data zones are xed during the construction of each coreimage

le and they cannot b e mo died dynamically It is quite p ossible to saturate one of these zones

which causes one of the fatal errors describ ed in section

fatal error no room for XXXXs

Notice the following p oints

 The size of the list storage zone can b e mo died at each invo cation of the system So it is

not necessary to construct a new coreimage le in order to rectify a situation that causes

the listmemoryzonefull error

 The saturation of a zone could well b e due to an error in a user program

 The LISP function gcinfo gives information on how full memory zones are

The makefile has entry p oints that p ermit the construction of each system conguration lelisp

cmplc with dierent zone sizes For instance the system lelisp is a LELISP system with very

big memory zones

The makeles SIZEx variables contain the values indicating the size of the dierent zones

For example the size of the LELISP system is describ ed by the SIZE variable

CHAPTER USE AND INSTALLATION

SIZE stack code heap vector number float

string symbol cons

Each zone option sets the size of zone Here are the units that describ e these sizes

LELISP memory zones

Name LISP ob ject Unit Real size

stack Stack Kword Kbyte

code Compiled co de Kbyte Kbyte

heap Heap Kbyte Kbyte

vector Vectors Kvector Kvector Kb

float Floatingp oint numb ers Koat Koat Kb

string Character strings Kstring Kstring Kb

symbol Symb ols Ksymb ol Ksymb ol Kb

cons Pairs Kpair Kpair Kb

set to for bit oat system

Strings and vectors take up space in the heap as indicated in the following table

Heap use

nob ject vector n bytes

Character string n bytes

To build a coreimage le with new zone sizes the denitions of the SIZEx variables must b e

changed or new entry p oints targets using other SIZE parameters must b e added to the makele

and then the make command must b e executed again

Example

To add an entry p oint that constructs a system named lelispv with K vectors

SIZEV stack code heap vector number float

string symbol cons

lelispv lelispconfll

config lelispv lelispbin lelispconfll SIZEV

Next the execution of the make command builds the coreimage le for the lelispv system

make lelispv

config lelispv

cp lelispv usrlocalbin

lelispv

LeLisp by INRIA

STARTING THE LELISP SYSTEM UNDER VMS

Linking the LeLisp system with C mo dules

Chapter of this manual describ es how to link the lelispbin system with C programs to make

a new executable le

To p erform this op eration the lelispbino binary le in the system directory must b e used This

le is the result of a link using ld r of all of the LELISP systems constituant mo dules except

the C mo dules These last mo dules are obtained by compiling the C les in the common directory

The generic entries of the Makele allow you to do that in a very homogeneous manner See the

online UNIX information called lelispmanl

Calling the shell

The shel l can b e called by using the comline function and the macro character This will

execute binsh which a lo cal interpretation of the cd command

lelisp

LeLisp by INRIA version Jan vaxunix

Standard modular system Sat Dec

compiler debug defstruct loader pepe pretty virbitmap virtty

pwd

usrlocallelispvvaxunix

t

cd

t

pwd

usrlocallelispv

Starting the LeLisp system under VMS

Complete do cumentation covering the installation and execution of LELISP under vms is available

in Dana The command used to start the LELISP system under the vms op erating system has

the following form

lelisp

Practical advice

Finally here is some practical information that will b e develop ed in detail in the chapters to come

In particular we give hints ab out how to use the system comfortably right from the very start

CHAPTER USE AND INSTALLATION

 To erase a character use the BACKSPACE key or the LEFT arrow The character to the left of

the cursor will b e erased from the screen

 To kill a line of input typ e CONTROLX obtained by holding down the CONTROL key and

pressing the X key We write this key combination as X The line is erased from the screen

You can obtain the same result by typing U

 To return to the main interactive lo op when you are in the midst of typing an expression

provoke an error by typing two dots p erio ds one right after the other If nothing visible

happ ens you are probably within a comment or a character string

 To return to the main interactive lo op when you have lost control of things or LISP is no

longer resp onding typ e BREAK DELETE or C on UNIX hosts or C under vms

 To return to the host OS in really desp erate circumstances enter on UNIX systems or Y

under vms In this case you lo ose your LISP environment

 To send a command line to the host system if the latter p ermits this kind of request typ e

the exclamation p oint character followed by the command as shown here

dir

 To load a previouslycreated le simply typ e

Lfile

To obtain CONTROLL hold down the CONTROL key and typ e L simultaneously Follow this

immediately by the name of the le without its extension which is ll by default

 To edit or create a le call one of the fullscreen editors by simply typing

Efile

To obtain CONTROLE hold down the CONTROL key and typ e E simultaneously Follow this by

the name of the le without its extension which is ll by default

 To see a replay of the commands recently executed use the following command from within

the editor

ESC

 To edit a particular function that is in a le call one of the screen editors by simply typing

Ffunction

To obtain CONTROLF hold down the CONTROL key and typ e F simultaneously Follow this by

the name of the function The system will try to lo cate the le that contains it and will call

one of the available fullscreen editors on this le as with the E command

 To insert a comment into a LISP expression typ e a semicolon The rest of the line up to the

endofline character will b e ignored

Finally you have access to the source co de of a large numb er of utilities that are written in LISP The

editor the prettyprinter debugging to ols visualization to ols etc are included in the distribution

Go ahead and read them try to understand them and do not b e afraid to extend and improve them

Table of contents

Use and installation

LeLisp on various systems ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Starting with LeLisp ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

Starting the LeLisp system under Unix ::::::::::::::::::::::::::::::::::::::::::

Installation of the LeLisp system under Unix ::::::::::::::::::::::::::::::::::::

Installing the system ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Mo dication of the system conguration ::::::::::::::::::::::::::::::::::

Mo dication of data zone sizes ::::::::::::::::::::::::::::::::::::::::::::

Linking the LeLisp system with C mo dules :::::::::::::::::::::::::::::::

Calling the shell ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

Starting the LeLisp system under VMS ::::::::::::::::::::::::::::::::::::::::::

Practical advice ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Table of Contents

Function Index

Chapter

Evaluation

Basic ob jects

The LELISP language op erates on ob jects called symb olic expressions generally referred to as

Sexpressions

An Sexpression can have any one of the following typ es

 Atomic ob jects

Symb ol

Numb er an integer a oatingp oint numb eroften referred to simply as a oat or an

arbitraryprecision numb er

Character string

 Comp osite ob jects

List

Vector

LELISP also allows you to dene new typ es called extended types

Inside the machine every Sexpression is represented by a p ointer to its value You can think of

this p ointer as the address of the value The value of an ob ject is always accessed by means of an

indirection Consequently LELISP is optimized for p ointer manipulation

LELISP runs principally on pro cessors with bit p ointers This allows you to manipulate addresses

up to that is in the fourgigabyte region Hardware limitations sometimes restrict the address

space to only or even bits However in most cases the address space of this kind of pro cessor

is adequate

Atomic ob jects

Symb ols

Symb ols play the role of identiers that are used to name variables functions and lab els They are

created automatically when read from the input stream They can also b e created explicitly by the

CHAPTER EVALUATION

symbol implode concat and gensym functions So they do not need to b e declared

The external name of a symb olreferred to as its print name abbreviated to pnamecan b e

any string of no more than characters containing at least one nonnumeric character You

can include sp ecial characters or delimiters in a pname by surrounding the entire pname by the

character referred to as absolute value bar represented by a vertical bar See the section on the

standard reader

A symb ol is represented in the system by a p ointer to a descriptor stored in a sp ecial memory zone

This descriptor has the following nine intrinsic properties

 cval an abbreviation for cel l value always contains the value asso ciated with a symb ol

that is considered as a variable Access to this value is extremely rapid When a symb ol is

created its cval is undened Any attempt to reference a symb ol that has not had a value

assigned to it raises the errudv error

 plist an abbreviation for property list always contains the prop erty list of the symb ol

These prop erties are managed by the user by means of sp ecial functions that op erate on

Plists addprop putprop getprop remprop and defprop By default the list of prop erties

has the value

 fval an abbreviation for function value always contains the value asso ciated with a symb ol

that is considered as a function This value can b e of two kinds

In the case of subr functions it is a machine address

In the case of expr fexpr macro and dmacro functions it is a list

You can fully access the fval of a symb ol by means of the valfn setfn remfn and getdef

functions If the symb ol has no function denition this prop erty has the value

 ftype an abbreviation for function type contains the typ e of the function stored in

the fval eld Together the fvalftype combination enables the evaluator to execute

function calls very rapidly You can access directly the ftype of symb ols by means of the

typefn and setfn functions When a symb ol do es not have a function denition this prop erty

has the value

 ptype an abbreviation for print type contains necessary information for the edition of the

external representation of the symb ol There are two p ossibilitie s

The symb ol is a variable The pname string can b e enclosed within a pair of absolute

value characters

The symb ol designates a function In this case the prettyprinter uses the appropriate

print format

The ptype cell of a symb ol is accessed by means of the sp ecial ptype function

 oval an abbreviation for object value can contain any Sexpression and can b e used to

hold sp ecial values This eld is particularly useful in the implementation of ob jectoriented extensions

BASIC OBJECTS

 alink an abbreviation for atom link contains the address of the next symb ol in the symb ol

table Among other things this link facilitates the hashing of the symb ol table This attribute

cannot b e accessed directly by the user

 pckgcell an abbreviation for package cel l contains the name of the package to which the

symb ol b elongs The package is accessed by means of the symbol and packagecell functions

 pname an abbreviation for print name contains the address of the character string that

represents the name of the symb ol

These intrinsic prop erties are stored in memory with the following layout

cval symbol pointer

plist

fval

oval

ftype ptype

alink

pckgcell

pname

Certain symb ols are dened at systeminitialization time

 Symb olic constants that contain their own names as values t lambda flambda mlambda

subr subr subr subr nsubr fsubr expr fexpr macro dmacro and quote

 Predened functions

 System variables

Numb ers

LELISP uses bit integers allowing calculations in the range of to that is from

to Floatingp oint numb ers are comp osed of either or bits dep ending

on the implementation LELISP also incorp orates libraries for arbitraryprecision arithmetic

The pname of a numb er is the representation of its value in the output conversion base See the

obase function The value of a numb er is of course the numb er itself

CHAPTER EVALUATION

Character strings

LELISP has character strings which have the sequence of characters enclosed in quote characters as

external representations The quote character can b e represented in strings by inserting a sequence

of two quote characters in a row A character string cannot b e longer than characters in

the current implementation Character strings are stored in a sp ecial memory segment which is

dynamically compacted in by a lineartime garbagecollection algorithm The value of a character

string is the string itself thus there is no need to quote it

Each character string can also have its own particular typ e By default the typ e of a string is

string

foo bar corresp onds to the string foo bar

abc corresp onds to the string abc

corresp onds to the string

All these three examples are of typ e string

fooabc corresp onds to the string abc

In this fourth example on the contrary the typ e is foo

Comp ound ob jects

Ob jects are said to b e compound when they are made up of other LELISP ob jects

Lists

LELISP represents lists in a standard fashion The following diagram shows for example how the

list a b c d e is stored in memory

a e

BASIC EVALUATION ACTIONS

b d

c

A list element is stored in a list cel l made up of a pair of p ointers It is often referred to as a cons

cell The rst memb er or car of this cell contains a p ointer to the list element Its second memb er

or cdr contains a p ointer to the next list element or to a sp ecial endoflist marker LELISP uses

the symb ol whose name has a length of zero as an endoflist marker

LELISP allows a list cell to b e lab elled A lab el is a sp ecial mark that can b e tagged on to any

list cell The lab el can b e removed from the cell to which it is attached Also you can search for

a particular lab elled cell These op erations are carried out by sp ecialized functions such as tcons

tconsp tconsmk and tconscl The mark is invisible to all other listmanipulation functions and

neither slows nor otherwise mo dies normal access to list cell memb ers Among other things these

lab els allow you to dene new user typ es See the section on extended typ es

Vectors of Sexpressions

LELISP has a vector of Sexpressions typ e which allows for indexed access to LISP ob jects The

external representation of a vector is

s s ::: s

n

The vector elements are shown here as s s ::: s Our use of subscripts aims solely at improving

n

the readability of this manual and should not b e taken literally since there are no real subscripts

in LELISP Access to a vector element is very rapid In the current implementation a vector can

contain no more than elements Since vectors are authentic LISP ob jects vectors of vectors

are allowed Vectors are stored in a sp ecial memory space that is dynamically compacted by a

lineartime garbagecollection algorithm Since the value of a vector is the vector itself there is no

need to quote them Each vector can also have its own particular typ e By default the typ e of a

vector is vector

For example a b x y z d e is a vector with ve elements of which the third is a vector

of three elements And foo is a vector of two elements of typ e foo

Basic evaluation actions

Evaluation of atomic ob jects

The value of a symb ol considered as a variable is its cval The evaluation of a symb ol whose

cval is undenedthat is a symb ol that do es not yet have a valueraises the errudv error at

evaluation time Its screen display is

fn undefined variable symb

Here the name of the symb ol at fault is symb and fn is the name of the function that caused the

error Usually it is one of the two evaluation functions eval or symeval

CHAPTER EVALUATION

Variables are used in LISP in three circumstances

 As global variables which are constantly accessible by all functions It is recommended to

initialize them with the defvar function See the following chapter

 As local variables which only retain their values during the execution of a function Indeed

they are the parameters of the function

 Finally they can b e used in the style of the own variables of algol In this case they are lo cal

to a function but they do not lo ose their value b etween successive evaluations of this function

These variables must b e enclosed within a function by means of the closure function

The value of a numb er or a character string is the numb er or character string itself So there is no

need to quote them

Evaluation of comp osite ob jects

The evaluator always considers that a list is a function call The list is referred to as a form The

car of the form is the function and its cdr is the argument list of the function

The value of a form is the value returned when the function is applied to its arguments

The value of a vector of Sexpressions is the vector itself As in the case of numb ers and character

strings it is not necessary to quote vectors which are always treated like constants

Evaluation of functions

A functionthe car of a formcan b e a symb ol or a sp ecial list The cdr of the form is the

argument list of the function If this list of arguments is not terminated by the errbal error is

raised Its screen display is

fn bad arguments list a

Here fn is the name of the function that caused the error and a is the nal cdr of the list of

arguments

cons ) cons bad argument list

if ) if bad argument list

If the function is a symb ol LELISP uses the function asso ciated with the fval of this symb ol

 This asso ciation can b e established at system initialization This is the case for predened

functions which are also called standard functions

 The user can make this asso ciation by means of static or dynamic denition functions

If even after searching through the extended typ es see that section no function has b een

asso ciated with this symb ol the errudf error is raised Its screen display is

EVALUATION OF FUNCTIONS

fn undefined function symb

Here symb is the name of the undened symb ol and fn is the function that caused the error It is

usually one of the functions eval apply or funcall

cons a b ) a b

setq kons cons ) cons

kons x y ) eval undefined function kons

When the function is a numb er a vector or a character string the evaluator also raises the errudf

error whose screen display is the same as in the preceding case

) eval undefined function

When the function is a list an anonymous function is explicitly declared

The rst element of the list must b e one of the sp ecial symb ols lambda flambda or mlambda

lambda x x x )

flambda x x x x ) x x

lambda x x lambda x x ) lambda x x

A calculated function call is made by using the funcall function LISP is one of the rare languages

in which it is p ossible to write convenient calls of the form

funcall if n val

LELISP has two main classes of functions those written in the LLM machine language and those

written in LISP All functions written in LISP can b e translated into LLM machine language by the

compiler Each of these two classes of functions has four typ es of functions

 Functions that evaluate their arguments called subr in LLM and expr in LISP

 Functions that do not evaluate their arguments called fsubr in LLM and fexpr in LISP

 Simple macro functions called msubr in LLM and macro in LISP

 Substitution macro functions called dmsubr in LLM and dmacro in LISP

Functions of the subr kind

Functions of the subr kind are written in LLM machine language The arguments of these functions

are always evaluated Some subr functions have a xed numb ers of arguments Dep ending on the

precise numb er of arguments they are referred to as either subr subr subr or subr Other

subr functions have a variable numb ers of arguments and are sometimes referred to as nsubr

functions In the case of subr functions with a xed numb er of arguments the evaluator checks

whether the correct numb er of arguments has b een passed to the function If not the errwna error

is raised Its screen display is

fn wrong number of arguments n

CHAPTER EVALUATION

Here fn is the name of the subr that was called and n is the numb er of arguments required by

this function

In the case of subr functions with a variable numb er of arguments the evaluator sometimes checks

whether a minimum numb er of arguments required by the nsubr is passed in the function call

If this is not the case the errwna error is raised Its screen display is the same as that for subr

functions

It is p ossible to add subr functions to the system by writing them directly in LLM machine

language or by compiling appropriate expr functions

There are many subr or nsubr functions in the system b etween and dep ending on the

system b eing used

cons ) cons wrong number of arguments

cons a ) cons wrong number of arguments

cons a b ) a b

cons a b c ) cons wrong number of arguments

apply cons ) cons wrong number of arguments

apply cons a ) cons wrong number of arguments

apply cons a b ) a b

apply cons a b c ) cons wrong number of arguments

funcall cons ) cons wrong number of arguments

funcall cons a ) cons wrong number of arguments

funcall cons a b ) a b

funcall cons a b c ) cons wrong number of arguments

Functions of the fsubr kind

fsubrs are also functions written in machine language They are resident in the system from

initialization time onward and they are executed very rapidly These functions take a variable

numb er of arguments which are never evaluated In certain cases though these arguments are

evaluated by the function itself These very sp ecial functions are used primarily as control functions

or for name manipulation and are often referred as special forms There are relatively few fsubr

functions in LELISP

It is p ossible to add functions of this typ e by writing them directly in LLM machine language or

by compiling appropriate fexpr functions

Functions of the msubr kind

Functions of the msubr kind are also written in LLM machine language They are created by

compiling macro functions

These functions have a variable numb er of arguments which are never evaluated

EVALUATION OF FUNCTIONS

Functions of the dmsubr kind

Functions of the dmsubr kind are also written in LLM machine language They are created by

compiling dmacro functions

These functions have a variable numb er of arguments which are never evaluated

Functions of the expr kind

Functions of the expr kind are written in LISP They are evaluated by the functions eval apply

and funcall According to their denition these functions exp ect a certain numb er of arguments

represented by a list or a tree of lvar variables They also exp ect a function b o dy made up of a

sequence of expressions s ::: s to b e evaluated

n

A function of this kind is written by using a list called a lambdaexpression of the form

lambda lvar s ::: s

n

Here the lambda symb ol designates an exprtyp e function lvar is the list or tree of parameters

and s ::: s is the b o dy of the function

n

A typical example is lambda x y cons car x cdr y

The denition of an exprtyp e function consists of asso ciating a lambdaexpression with a symb ol

This is done by means of the defun function

The evaluation of an exprtyp e function call takes place in three steps

After current values of function parameter names are saved on the stack the argument values

are b ound to the function parameter names Calls to exprtyp e functions are by value

The expressions in the function b o dy s ::: s are evaluated The value returned by the

n

function is the value of the last evaluation that is the result of the evaluation of s

n

The bindings p erformed in step are undone The previous values of the parameter names

saved on the stack are restored

The binding of argument values to function parameters is carried out by a recursive pro cedure

that treats the list of lvar parameters as a tree This binding takes place b etween the leaves of

the parameter tree and the list of argument values This kind of binding allows the value of an

argument to b e split when the function is called b etween dierent parameter variables

If there are to o few or to o many elements in the argument list after the binding is p erformed the

errwna error is raised Its screen display is

fn wrong number of arguments s

Here fn is the name of the function that was called or lambda in the case of an anonymous

function If to o many arguments were supplied s is the remainder of the argument list If there

were to o few is displayed

If a value cannot b e b ound to a parameter tree the errilb error is raised This happ ens if an

attempt is made to bind an atomic value of the list of argument values to a nonatomic parameter

The screen display is

CHAPTER EVALUATION

fn illegal binding p v

Here fn is the name of the function that was called or lambda in the case of an anonymous

function and p v is a list of the parameter tree p and the value v that could not b e b ound

If the parameter tree contains no variables the errbpa error is raised Its screen display is

fn bad parameter s

Here fn is the name of the function that was called or lambda in the case of an anonymous

function and s is the faulty parameter

If an error o ccurs during the op eration of the extended binding mechanism no parameter binding

is p erformed

Here is the extended binding mechanism written in LISP

defun bindvar tvar lval

tvar the parameter tree

lval the list of argument values

push using the push function the

value variable pairs

cond null tvar

when lval

error eval errwna lval

variablep tvar

push symeval tvar

push tvar

set tvar lval

consp tvar

if atom lval

error eval errilb list tvar lval

bindvar car tvar car lval

bindvar cdr tvar cdr lval

t error eval errbpa tvar

Here are some examples of expr binding

lambda x y z list x y z

lambda x y z list x y z

lambda wrong number of arguments

lambda x y z list x y z

lambda wrong number of arguments

lambda x x

lambda x y z list x y z

lambda x y z list x y z cons c

c lambda x y z list x y z a b

lambda illegal binding y z b

EVALUATION OF FUNCTIONS

lambda t list x a b

lambda bad parameter t

lambda x list x a b

lambda bad parameter

Functions of the expr kind with a nobind argument

If the argument list of an expr function is made up uniquely of the keyword nobind then binding

is carried out in a dierent manner No variables are b ound The actual numb er of arguments of the

call is returned by the arg function The arguments are retrieved using the arg n function

where n is the numb er of the argument starting with n for the rst argument This feature

allows for the denition of functions with a variable numb er of arguments without the necessity of

building an argument list

This construction resembles lexpr function of MacLisp

defun gog nobind

list arg arg arg

gog gog

gog

defun magog nobind

if arg

error magog unexpected arguments arg

let arg if arg default arg

arg if arg default arg

list arg arg

magog magog

default default magog

default magog

magog

magog unexpected arguments

Functions of the fexpr kind

fexprs are functions written in LISP and evaluated by the standard evaluation functions eval

apply or funcall Just like exprs these functions have a variable numb er of parameters

describ ed in a parameter list or tree lvar and a function b o dy made up of a numb er of expressions

s sN

A function of this typ e is describ ed by using a list called an flambdaexpression of the following

form

flambda lvar s sN

where the symb ol flambda is a function indicator of typ e fexpr lvar is the list or tree of

parameters and s sN make up the b o dy of the function

CHAPTER EVALUATION

Example

flambda var val set var eval val

The denition of fexprtyp e functions that is the asso ciation of a flambdaexpression with a

symb ol is done by means of the df function

These functions dier from exprs only in the way parameters are b ound in fexprs It is the set

of arguments that are not evaluated that is the cdr of the form itself which is b ound to the

parameter list lvar by the same bindvar pro cedure used for exprs

These function calls can raise the same errors as exprs errwna errilb and errbpa

Functions of the macro kind

The evaluator p ermits another typ e of functions the macro functions Just like exprs and fexprs

these functions written in LISP have variable numb ers of parameters which are stored in a list

lvar and function b o dies made up of expressions s sN

macro functions are describ ed by using a list called an mlambdaexpression of the form

mlambda lvar s sN

where the symb ol mlambda is a function indicator of typ e macro lvar is the parameter list and

s sN make up the b o dy of the function

Example

mlambda n var list setq var list cdr var

The denition of macrotyp e functions that is the asso ciation of a mlambdaexpression with a

symb ol is done by means of the dm function

To evaluate a form which has a macro as its function the evaluator rst evaluates the function

asso ciated with this macro using the whole form obviously not evaluated as its argument using

the bindvar pro cedure Then it reevaluates the value returned by this initial evaluation The

evaluation of a macro thus happ ens in two steps

It is the entire macro call which is taken as the argument it is therefore p ossible to physically

mo dify the form itself during the rst evaluation of the macro

The use of macros truly a sp ort in itself allows for easy and p owerful extensions of the language

LISP b eing b oth the macro description language and the target language of macro expansions

macro function calls can raise the same errors as expr calls errwna errlib errbpa

Functions of the dmacro kind

The evaluator accepts a second kind of macro denition the dmacros dmacros are dened with

the defmacro function

The evaluation of a function of this typ e diers from the evaluation of macro functions in two ways

DEFINING FUNCTIONS

 the cdr of the form not evaluated is used as the argument the same as with fexprs

 after the rst evaluation has b een p erformed the entire form is physically replaced by the

value returned by the displace function Whence the name dmacro

Though less general than the macro functions the dmacros are more frequently used In fact most

o ccurrences of macro functions are calls to dmacro

dmacro function calls can raise the same errors as expr calls errwna errlib errbpa

Dening functions

Two kinds of functions are encountered in LELISP

 Global functions

These functions are dened globally and keep their denition as long as they are not explicitly

mo died This kind of denition do es not allow dynamic recovery of previous denitions See

the defun df dm and defmacro functions

 Lo cal functions

The denition of these functions can change during certain evaluations and then assume their

previous denition See the flet and letn functions

Recall that function denitions are stored in the fval and ftype intrinsic prop erties of symb ols

Since direct access to these prop erties is not at all convenient there are a numb er of predened

functions facilitating static and dynamic function denition at very little cost See the Function

Denition section of the next chapter

Packages

LELISP has a multiple namespace Each symb ol unique in the system has an external name

its socalled pname This name is not necessarily unique Each symb ol also has a package name

indicating to which package the symb ol b elongs A package name is also a symb ol which can in

turn have a package name and so on The global package is named It is p ossible to manage

name hierarchies In LELISP packages allow you to p erform the following op erations

 The name space can b e shared among several programs

 Functions can b e invoked within sp ecic names spaces

 Metho d execution within a simple hierarchyof a SmallTalk varietycan b e implemented

in a very ecient manner

Extended typ es

In LELISP you can dene other typ es of ob jects These extended typ es are always built with

a lab elled list cell tcons which contains the symb olic name of the extended typ e in the car

CHAPTER EVALUATION

Its value stored in the cdr is either a typ ed vector or a typ ed string The extended typ es are

recognized by the LELISP evaluator and printer

When the evaluator eval evaluates a form which has a lab elled list cell as the rst element and if

the car of this lab elled list is a symb ol or a typ ed vector or typ ed string to b e evaluated it searches

to see if it can nd a function named eval in the package with the same name as the result of

evaluating the typeof function on its argument If this function exists it is called by eval if not

or if there is no such package an error is raised The search for the eval function in the package

uses the getfn function with third argument equal to The evaluators search up the package

hierarchy stops just b elow the level of the global package thus avoiding an innite evaluation lo op

Warning The search for the evaluation function takes place after the normal evaluation It is

therefore imp ossible in the present implementation to use dened function names as names of

extended typ es

When the printer the function prin prints a LISP ob ject it searches for a function named prin in

the package with the same name as the result of evaluating the typeof function on its argument

If this function exists it is called by prin in place of the standard LELISP prin function The

search for this function in the package uses the getfn function with third argument equal to

The evaluators search up the package hierarchy stops just b elow the level of the global package

thus avoiding an innite print lo op

The functionality of the printer can b e expressed in LISP in the following manner

if getfn typeof x prin

funcall getfn typeof x prin x

prin x

As an example let us dene the listofnumerals extended typ e The input of such a list will

b e done with the macro

cccccccc

where the numerals ccc are surrounded by the delimiters

Here is the LISP denition of the read function

defsharp

list let x c v

while neq setq c readcn

newl x c

setq v apply vector nreverse x

typevector v listofnumerals

v

This function b ehaves as follows

listofnumerals typeof

listofnumerals

Let us now dene the printer for this extended typ e

METACIRCULAR DEFINITION OF THE EVALUATOR

defun listofnumeralsprin x

prin

mapvector princn x

prin

Here is the b ehavior of the new device

cons

Metacircular denition of the evaluator

This nal section prop oses a metacircular description of the LELISP evaluator This description

which provides a global view of the op eration of the evaluatoris obviously incomplete and do es

not represent the actual implementation The style in which the evaluator is really implemented is

far more ecient than what you see here esp ecially in the numb er of cons op erations used in the

evaluator functions and in the management of the stack In fact the LELISP evaluator p erforms

no cons op erations at all for its own use

Special package

defvar syspackagecolon eval

Main loop

defun toplevel

tag error

print toplevel

let stack it

setq it eval with prompt read

print it

toplevel

Handle errors

defvar systemerrorflag t

defvar systemdebug t

defun error f m a

when systemerrorflag

print f m a

exit error

Evaluate a form

CHAPTER EVALUATION

defun eval form

cond

symbolp form

if boundp form

symeval form

error eval errudv form

or fixp form floatp form

form

atom form

if getfn typeof form eval

funcall getfn typeof form eval form

form

t let funct car form lval cdr form

cond

symbolp funct

cond typefn funct

evalinternal form

funct

typefn funct

valfn funct

lval

and tconsp form

getfn funct eval

funcall getfn funct eval form

t error eval errudf funct

atom funct

error eval errudf funct

eq car funct lambda

evalinternal form funct expr cdr funct lval

eq car funct flambda

evalinternal form funct fexpr cdr funct lval

eq car funct mlambda

evalinternal form funct macro cdr funct lval

t error eval errudf funct

Evaluate a function according to its type

defun evalinternal form funct ftype fval lval

if or and atom lval lval

and consp lval cdr last lval

error funct errbal if atom lval lval cdr last lval

selectq ftype

subr if length lval

call fval

error funct errwna

METACIRCULAR DEFINITION OF THE EVALUATOR

subr if length lval

call fval eval car lval

error funct errwna

subr if length lval

call fval eval car lval

eval cadr lval

error funct errwna

subr if length lval

call fval eval car lval

eval cadr lval

eval caddr lval

error funct errwna

nsubr calln fval evlis lval

msubr call fval form

dmsubr displace form call fval cdr form

fsubr

All the FSUBRs are evaluated directly

since they can call EVAL again

Only the most important ones are defined here

selectq funct

quote car lval

lambda form

if if eval car lval

eval cadr lval

eval caddr lval

progn eprogn lval

defun setfn car lval expr cdr lval

df setfn car lval fexpr cdr lval

dm setfn car lval macro cdr lval

defmacro setfn car lval dmacro cdr lval

setq while cddr lval

set nextl lval

eval nextl lval

set nextl lval eval car lval

t error eval errudf funct

expr evalambda fval evlis lval

fexpr evalambda fval lval

macro eval evalambda fval form

dmacro eval displace form

evalambda fval cdr form

t error eval errudf funct

Build the list of values of the evaluations of all list elements

CHAPTER EVALUATION

defun evlis l

if null l

cons eval car l evlis cdr l

Evaluate the body of l

defun eprogn l

if null cdr l

eval car l

eval car l

eprogn cdr l

Apply an FVAL of type lvar s sn

to the list of arguments lval

defun evalambda fval lval

push

bindvar car fval lval

protect eprogn cdr fval

unbindvar

Carry out a generalized tree binding

defun bindvar lvar lval

cond null lvar

when lval

error eval errwna lval

variablep lvar

push if boundp lvar symeval lvar undef

push lvar

set lvar lval

consp lvar

if atom lval

error eval errilb list lvar lval

bindvar car lvar car lval

bindvar cdr lvar cdr lval

t error eval errbpa lvar

defun unbindvar

untilexit done

set or pop exit done pop

With the stack manipulation functions

defun push l while l newl stack nextl l

METACIRCULAR DEFINITION OF THE EVALUATOR

defun pop nextl stack

Apply funct to the lval arguments

defun apply funct lval

cond

symbolp funct

applyinternal funct

typefn funct

valfn funct

lval

atom funct

error apply errudf funct

eq car funct lambda

applyinternal funct expr funct lval

eq car funct flambda

applyinternal funct fexpr funct lval

eq car funct mlambda

applyinternal funct macro funct lval

t error apply errudf funct

Application of a function according to its type

defun applyinternal funct ftype fval lval

selectq ftype

subr if length lval

call fval

error funct errwna

subr if length lval

call fval car lval

error funct errwna

subr if length lval

call fval car lval cadr lval

error funct errwna

subr if length lval

call fval car lval

cadr lval

caddr lval

error funct errwna

nsubr calln fval lval

msubr eval call fval cons funct lval

dmsubr eval call fval lval

fsubr call fval lval

expr evalambda fval lval

CHAPTER EVALUATION

fexpr evalambda fval list lval

macro eval evalambda fval cons funct lval

dmacro eval displace form evalambda fval lval

t error apply errudf funct

Application to funcall

defun funcall funct larg

apply funct larg

Table of contents

Evaluation

Basic ob jects ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::

Atomic ob jects ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

Comp ound ob jects ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Basic evaluation actions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

Evaluation of atomic ob jects ::::::::::::::::::::::::::::::::::::::::::::::

Evaluation of comp osite ob jects :::::::::::::::::::::::::::::::::::::::::::

Evaluation of functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

Functions of the subr kind :::::::::::::::::::::::::::::::::::::::::::::::

Functions of the fsubr kind ::::::::::::::::::::::::::::::::::::::::::::::

Functions of the msubr kind ::::::::::::::::::::::::::::::::::::::::::::::

Functions of the dmsubr kind :::::::::::::::::::::::::::::::::::::::::::::

Functions of the expr kind :::::::::::::::::::::::::::::::::::::::::::::::

Functions of the expr kind with a nobind argument ::::::::::::::::::::::

Functions of the fexpr kind ::::::::::::::::::::::::::::::::::::::::::::::

Functions of the macro kind ::::::::::::::::::::::::::::::::::::::::::::::

Functions of the dmacro kind :::::::::::::::::::::::::::::::::::::::::::::

Dening functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Packages ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

Extended typ es ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

Metacircular denition of the evaluator ::::::::::::::::::::::::::::::::::::::::::

Table of Contents

Function Index

Chapter

Predened functions

The functions describ ed in this lengthy chapter are always resident in all versions of the LELISP

system Each function is listed here with its typ efunction or specialformas well as the

numb er of arguments it exp ects For each argument the requested or required argument typ e is

indicated using the following notation

 s for Sexpressions

 l for lists

 a for atoms symb ols numb ers or character strings

 symb for symb ols

 n for numb ers

 strg for character strings or ob jects that could b e converted to character strings by using

the string function

 vect for vectors of Sexpressions

 ch for characters that is for the rst character of character strings or ob jects that could b e

converted to character strings by using the string function

 cn for internal character co des

 fn for functions symb ols dened as functions and anonymous or named lamb daexpressions

Whenever p ossible functions of the subr typ e are describ ed here in LISP terms in the form of defun

df dm or defmacro denitions These descriptions are merely LISP equivalents of the functions A

description of this kind represents no more than the behavior of the corresp onding function but

not its actual implementation in LELISP

Numerous typ e tests are carried out by the functions presented in this chapter The following errors

can b e raised

 errnaa with the following default screen display

fn not an atom e

CHAPTER PREDEFINED FUNCTIONS

 errnla with the following default screen display

fn not a list e

 errsym with the following default screen display

fn not a symbol e

 errnva with the following default screen display

fn not a variable e

 errnsa with the following default screen display

fn not a string e

In these displays e is name of the the faulty argument and fn is the function that caused the

error

Evaluation functions

eval s env function with one or two arguments

This is the main function of the interpreter eval returns the value of the evaluation of the argument

s See the complete description of this function in the preceding chapter The second argument

env if supplied is a lexical environment passed by the stepeval function See section of chapter

eval )

eval list )

eval list car cdr a b c ) b c

evlis l function with one argument

Returns a list of the values of the evaluations of all the elements of the list l

In LELISP evlis could b e dened in the following manner

defun evlis l

if null l

cons eval car l evlis cdr l

setq l )

evlis l )

EVALUATION FUNCTIONS

eprogn l function with one argument

Sequentially evaluates all the elements in the list l and returns the value of the nal element of l

If l is not a wellformed list the errbal error is raised

In LELISP eprogn could b e dened in the following manner

defun eprogn l

cond consp l

if null cdr l

eval car l

eval car l

eprogn cdr l

null l

t error eprogn errbal l

setq l prin prin prin

prin prin prin eprogn l

prog s ::: s special form

n

Sequentially evaluates the expressions s ::: s and returns the value of the rst evaluation

n

that of s

In LELISP prog could b e dened in the following manner

df prog first rest

let result eval first

eprogn rest

result

Alternatively it could b e dened in the form of an expr

defun prog l car l

prog prin prin prin

prog is always used to generate sideeects

Here is a macro exch var var that exchanges the values of var and var without

using other memory than for var and var

dm exch exch var var

list setq var

CHAPTER PREDEFINED FUNCTIONS

list prog var

list setq var var

A form such as exch v v is expanded to setq v prog v setq v v

prog s s ::: s special form

n

Sequentially evaluates the expressions s s ::: s and returns the value of the second

n

evaluation that of s

In LELISP prog could b e dened in the following manner

df prog first second rest

eval first

let result eval second

eprogn rest

result

Alternatively it could b e dened in the form of an expr

defun prog first second l second

prog prin prin prin

Like prog prog is always used to generate sideeects

progn s ::: s special form

n

Evaluates the expressions s ::: s in sequence and returns the value of the last evaluation

n

that is the evaluation of s

n

progn is the fsubr form of the eprogn function So it can b e describ ed in the form of an

fexpr in the following manner

df progn l eprogn l

Alternatively it could b e dened in the form of an expr

defun progn l car last l

progn prin prin prin

quote s special form

EVALUATION FUNCTIONS

Returns the unevaluated Sexpression s This function is used to inhibit argumentevaluation

in calls to functions

A predened macro character the ap ostrophe sign can b e used in place of the quote primitive

Written as it is often referred to as quote Placed b efore any expression s this ap ostrophe

is read as quote s

For readability reasons output functions print lists of the form quote s as s

In LELISP quote could b e dened in the following manner

df quote s s

quote )

a b c ) a b c

a ) a

a ) a

a ) a

quote quote a ) a

quote a b ) quote a b

function fn special form

If a lexical environment is present this function returns the lexical closure comp osed of the function

fn and this lexical environment If there is no lexical environment present function is equivalent to

quote LELISP Version only builds a lexical environment for the lab els dened by the tagbody

sp ecialform and the blo ck names dened by the block sp ecialform The function function cannot

b e describ ed in LISP

arg n function with an optional argument

This function is used inside an expr nobind Without arguments arg returns the numb er of

arguments of the last expr nobind function call With a numeric argument arg n returns the

th

value of the n argument of the last expr nobind function call If n is greater than the numb er

of arguments the result is indeterminate since arg do es not test the validity of n

identity s function with one argument

As its name indicates this function is the identity function It returns its argument

In LELISP identity could b e dened in the following manner

defun identity s s

identity a ) a

identity )

comment e ::: e special form

n

CHAPTER PREDEFINED FUNCTIONS

Returns the symb ol comment itself and do es not evaluate the arguments This function is very

useful for commenting out an Sexpression in the middle of a le It is not recommended for the

intro duction of program comments which should b e written after the sp ecial semicolon character

Warning This function can only b e inserted into an implicit or explicit progn Otherwise

the evaluation will b e disrupted

In LELISP comment could b e dened in the following manner

df comment l comment

comment foo bar ) comment

comment ) comment

comment but no ) comment

Application functions

lambda l s ::: s special form

n

flambda l s ::: s special form

n

mlambda l s ::: s special form

n

The value of a lambda flambda or mlambda lamb daexpression is the expression itself These new

functions were added to eliminate the need to quote anonymous explicit lamb daexpressions in

application functions

In LELISP lambda could b e dened in the following manner

df lambda l cons lambda l

Alternatively it could b e dened in the form of a macro

dm lambda l kwote l

The second denition is more exact since it preserves the physical address of the lamb da

expression

In LELISP flambda could b e dened in the following manner

df flambda l cons flambda l

In LELISP mlambda could b e dened in the following manner

df mlambda l cons mlambda l

APPLICATION FUNCTIONS

lambda x x

lambda x x mapc lambda x prin x a b c

abc

Simple application functions

apply fn s ::: s l function with a variable number of arguments

n

The arguments s ::: s are optional apply returns the value of the application of the function

n

fn to the list of arguments l with the arguments s ::: s app ended in front if they are present

n

The argument l must b e a list which might b e empty Otherwise the errbal error is raised The

function fn is of one of the following typ es subr nsubr fsubr msubr dmsubr expr fexpr macro

or dmacro

apply cons list )

apply cons list )

apply list )

apply lambda x y x y list )

apply flambda x y cons x y )

funcall fn s ::: s function with a variable number of arguments

n

This is another form of the apply function The form funcall fn s ::: s is equivalent to the

n

form apply fn list s ::: s But funcall do es not really construct any lists Consequently

n

it is much more ecient than apply

In LELISP funcall could b e dened in the following manner

defun funcall fnt larg

apply fnt larg

funcall lambda x y cons x y a b ) a b

funcall )

setq kons cons ) cons

funcall kons )

Application functions of the map typ e

These functions allow for the rep eated application of a function to a set of argument lists The

applied function can have any numb er of arguments and the applications stop when the end of

one of these argument lists is reached To apply invariant arguments include them in a circular

list by using for example the cirlist function Obviously at least one of these arguments lists

must terminate in the context of the evaluation so that these application functions do not lo op

indenitely

CHAPTER PREDEFINED FUNCTIONS

allcar l function with one argument

In the LISP descriptions accompanying these functions we shall use the following auxiliary

functions

defun allcar e

e is a list of lists

This function returns the list of all their cars

if null e cons caar e allcar cdr e

defun allcdr e

e is a list of lists

This function returns a list of all their cdrs

if null e cons cdar e allcdr cdr e

mapl fn l ::: l function with a variable number of arguments

n

map fn l ::: l function with a variable number of arguments

n

These apply the function fn to the lists l then to all the cdrs of these lists until the end of one

i

of the lists is reached

In LELISP mapl and map could b e dened in the following manner

defun mapl f l

when every consp l

apply f l

apply mapl f allcdr l

mapl print a b c d x y z

a b c dx y z

b c dy z

dz

mapc fn l ::: l function with a variable number of arguments

n

Applies the function fn to the cars of the lists l then to all the cadrs of these lists then to

i

the caddrs and so on until the end of one of these lists is reached

In LELISP mapc could b e dened in the following manner

APPLICATION FUNCTIONS

defun mapc f l

when every consp l

apply f allcar l

apply mapc f allcdr l

mapc print a b c d x y z

ax

b cy

dz

maplist fn l ::: l function with a variable number of arguments

n

Applies the function fn to the lists l then to the cdrs of these lists ::: until the end of one

i

of the lists is reached So maplist is functionally similar to the map or mapl functions but

it returns as its value the list of the values of the applications

In LELISP maplist could b e dened in the following manner

defun maplist f l

when every consp l

cons apply f l

apply maplist f allcdr l

maplist length a b c d )

mapcar fn l ::: l function with a variable number of arguments

n

Applies the function fn to the cars of the lists l then to the cadrs of these lists then to their

i

caddrs ::: until the end of one of the lists is reached So mapcar is functionally similar to the mapc

function but it returns as its value the list of values of the applications

In LELISP mapcar could b e dened in the following manner

defun mapcar f l

when every consp l

cons apply f allcar l

apply mapcar f allcdr l

mapcar cons a b c ) a b

mapcar list a b c d e f cirlist ) a b c d e f

mapcon fn l ::: l function with a variable number of arguments

n

Applies the function fn to the lists l then to their cdrs then to their cddrs ::: until the

i

end of one of the lists is reached mapcon is therefore functionally similar to the map function

CHAPTER PREDEFINED FUNCTIONS

However each application must return a list as its value and mapcon returns the list of values

of these applications which are nconced together see the description of this function to give

the return value If one of the returned values is not a list it is ignored and do es not app ear

in the list returned by mapcon

In LELISP mapcon could b e dened in the following manner

defun mapcon f l

when every consp l

nconc apply f l

apply mapcon f allcdr l

mapcon list

mapcon lambda x list car last x a

b c

c c c

The following co de makes the last function lo op the third time

mapcon last a b c )

mapcan fn l ::: l function with a variable number of arguments

n

Applies the function fn to the cars of the lists l then to the cadrs of these lists then to

i

their caddrs ::: until the end of one of these lists is reached mapcan is therefore functionally

similar to the mapc function However each application must return a list as its value and

mapcan returns the list of values of these applications which are nconced together see the

description of this function to give the return value If one of these values is not a list it is

ignored and do es not app ear in the list returned by mapcan

In LELISP mapcan could b e dened in the following manner

defun mapcan f l

when every consp l

nconc apply f allcar l

apply mapcan f allcdr l

mapcan lambda x y list x y

mapcan list a b c d

cirlist

w x y z

cirlist

a w b x c y d z

Other application functions

APPLICATION FUNCTIONS

every fn l ::: l function with a variable number of arguments

n

Applies the function fn to the cars of the lists l then to the cadrs of these lists then to their

i

caddrs ::: until the value returned by one of these applications is or until the end of one of

the lists l is reached In the latter case every returns the value of the last application Due to

i

the way the b o olean functions are represented in LISP with representing false this function is

principally used to apply a predicate to all the elements of a list

In LELISP every could b e dened in the following manner

defun every f l

if caar l

ifn cdar l

apply f allcar l

and apply f allcar l

apply every f allcdr l

t

This description assumes that all list arguments have the same length

every consp )

every eq ) t

every eq ) t

every eq )

any fn l ::: l function with a variable number of arguments

n

Applies the function fn to the cars of the lists l then to the cadrs of these lists then to

i

their caddrs ::: until the value returned by one of these applications is not equal to

or until the end of one of the lists l is reached Due to the way the b o olean functions are

i

represented in LISP with representing false this function is principally used to apply a

predicate to all the elements of a list

In LELISP any could b e dened in the following manner

defun any f l

when car l

or apply f allcar l

apply any f allcdr l

This description assumes that all list arguments have the same length

any consp foo )

any )

mapvecto r fn vect function with two arguments

Applies the function fn which must b e dened to take a single argument to each element of

th

the vector vect b eginning with the zero element mapvector returns as its value

CHAPTER PREDEFINED FUNCTIONS

In LELISP mapvector could b e dened in the following manner

defun mapvector fn vect

for i vlength vect

funcall fn vref vect i

mapvector prin a b c

abc

mapoblis t fn function with one argument

Applies the function fn which must b e dened to take a single argument to all the elements

in turnof the oblist This function is therefore equivalent to mapc fn oblist but it

is much more ecient mainly b ecause it do es not build the entire list of symb ols typically

ab out two thousand elements

Here for example is a function that prints the names of all the nsubrs in the system

defun printnsubr

mapoblist lambda symb

when eq typefn symb nsubr

print symb

mapcobli st fn function with one argument

Applies the function fn which must b e dened to take a single argument to all the elementsin

turnof the oblist Each evaluation returns a list and these are nconced together to give the

return value If one of the values is not a list it is ignored and it do es not app ear in the result

mapcoblist is therefore equivalent to mapcan fn oblist but it is much more ecient mainly

b ecause it do es not build the entire list of symb ols ab out two thousand elements

Here is a function that returns a list of the form symb objval symb objval for all the

symb ols that have an objval

defun findoval

mapcoblist lambda symb

when objval symb

list symb

objval symb

maplobli st fn function with one argument

Applies the function fn which must b e dened to take a single argment to all the elementsin

turnof the oblist Each evaluation returns a b o olean value and maploblist returns the list of

symb ols in the oblist of which the function usually a predicate is true

In LELISP maploblist could b e dened in the following manner

ENVIRONMENT MANIPULATION FUNCTIONS

defun maploblist fn

mapcoblist

lambda s

when funcall fn s list s

To obtain the numb er of functions in the system evaluate

length maploblist typefn

Here is a function that returns the list of all the functions of typ e fsubr in the system

defun findfsubr

maploblist lambda symb

eq typefn symb fsubr

Environment manipulation functions

These functions temp orarily change the dynamic environment Here the term environment means

the variablevalue bindings The initial environment which was current b efore one of these function

calls is automatically restored up on function termination

let lv s ::: s special form

n

By means of let you can make anonymous exprtyp e function calls In other words you can create

lamb daexpressions

lv is a list with elements of the form

 var or

 var val

s ::: s is the b o dy of the function

n

The let function binds the variables var dynamically and simultaneously with the values

i

val if the latter are supplied or with by default It then executes the b o dy of the function

i

s ::: s After completing this execution let unbinds the variables and binds them to their

n

previous values let simplies the denition and initialization of lo cal variables

let is an abbreviated form of anonymous exprtyp e function call and can therefore raise the

same errors errbpa errlib or errbal

The form

let var val s ::: s

n

corresp onds to the call

lambda var s ::: s val

n and the form

CHAPTER PREDEFINED FUNCTIONS

let var val var val

n n

s ::: s

m

corresp onds to the call

lambda var ::: var s ::: s

n m

val ::: val

n

In LELISP let could b e dened in the following manner

defmacro let lv body

cond null lv

cons cons lambda cons body

t cons cons lambda

cons mapcar

lambda l

if consp l

car l

l

lv

body

mapcar lambda l

if consp l

cadr l

lv

Here is a more readable denition

defmacro let lv body

if null lv

lambda body

lambda mapcar lambda l if consp l car l l

lv

body

mapcar lambda l if consp l cadr l

lv

let i j i j )

let a foo b c cons list a b c ) foo

let i j k list i j k )

letv lvar lval s ::: s special form

n

This function is identical to the let function but allows for the calculation of the variable names

to b e b ound lvar is an argument that should result when evaluated in a tree of symb ols lval

is an argument that should result when evaluated in a list of values letv links the symb ols of

the lvar tree with the values of the lval list and then evaluates the expressions s ::: s in this

n

ENVIRONMENT MANIPULATION FUNCTIONS

new environment letv returns the value of the last evaluation that of s and then restores the

n

environment to the state it was in b efore the call letv can raise the same errors errbpa errilb

errwna or errbal as the evaluation of an anonymous function

In LELISP letv could b e dened in the following manner

defmacro letv lvar lval body

lambda eval lvar body lval

letv a b c d list a b c d )

letvq lvar lval s ::: s special form

n

This function is identical to the preceding one except that the rst argument lvar the tree of

variables is not evaluated

In LELISP letvq could b e dened in the following manner

defmacro letvq lvar lval body

lambda lvar body lval

letvq a b list a b )

lets lv s ::: s special form

n

slet lv s ::: s special form

n

let lv s ::: s special form

n

These functions are identical to the let function but the arguments are b ound sequentially not

in parallel They dier from let in the same way that psetq diers from setq So a value already

b ound in the lets can b e used to calculate the value of another expression in the list lv There is

no dierence b etween lets slet and let

The form

lets var val var val ::: var val

n n

s ::: s

n

corresp onds therefore to

let var val

let var val

::::::

let var val

n n

s ::: s :::

n and also to

CHAPTER PREDEFINED FUNCTIONS

lambda var

lambda var

::::::

lambda var

n

s ::: s

n

val :::

n

val

val

let i slet i j i i list i j )

letn symb lv s ::: s special form

n

Makes it p ossible to call named exprtyp e functions symb is the temp orary function name

lv is a list of variablevalue pairs as in the let function and s ::: s is a function b o dy

n

The letn function will dynamically and in parallel bind the variables with the values in the

list lv It will then execute the b o dy of the function s ::: s after having asso ciated during

n

the evaluation of the b o dy the same lamb daexpression as in the let function to the name

symb letn therefore simplies the dynamic denition and call of a recursive function

The form

letn symb var val var val s s

n n n

is equivalent to

flet symb var var s s symb val val

n n n

In LELISP letn could b e dened in the following manner

defmacro letn name lv body

flet name mapcar car lv body

name mapcar cadr lv

Let us lo ok at an example that uses letn the index function It returns the index of the

substring pname of the string pname starting at index n

defun index pname pname n

letn inxaux p pname pname

p nthcdr n pname pname

n n

cond length p length p

car p car p

inxaux p cdr p n

t letn inxaux pp cdr p

pp cdr p

cond null pp n

car pp car pp

inxaux cdr pp

cdr pp

t inxaux p cdr p

n

FUNCTIONDEFINITION FUNCTIONS

Functiondenition functions

These functions allow for the denition of new functions All of them test the validity of their

arguments

 Names of functions must b e symb ols

 All the variables in the list or in the parameter tree must also b e symb ols

These symb ols can only app ear once in the list or in the parameter tree

If not the errbdf or errbpa errors are raised with default screen displays

fn bad definition symb

fn bad parameter e

There are two typ es of function denition static denitions and dynamic denitions See the

preceding chapter on the op eration of the interpreter

Static function denitions

All these functions will p ermanently change the functions asso ciated with the symb ols These

changes are controlled by the following variables

system pre vi ous d ef fla g variable

system pre vi ous d ef property

All function redenitions can b e preceded by a save of the previous denition asso ciated with the

symb olif it had oneon its Plist by use of the systempreviousdef prop erty This save

is controlled by the systempreviousdefflag variable If it is truethat is if its value is

dierent from the save takes place If it is false no save is p erformed By default the value of

this variable is

system red ef fl ag variable

The systemredefflag ag allows for warning on function redenition

If systemredefflag is falsethat is equal to as it is by defaulta warning message is

printed on any attempt to redene a function If this ag is truedierent from function

redenitions cause no warning messages Such a message will have the form

fn redefined function symb

where fn is the denition function that was called and symb is the name of the function that

was just redened

CHAPTER PREDEFINED FUNCTIONS

system loa de df ro mf ile variable

system loa de df ro mf ile property

Moreover all the following denition functions add to the Plist of the newly dened symb ols

by use of the systemloadedfromfile prop erty the name of the le from which the

function was loaded This name will b e found in the systemloadedfromfile variable

If the value of this variable is nothing is added on to the Plist of the function name

symb ol

defun symb lvar s ::: s special form

n

de symb lvar s ::: s special form

n

defun allows for the static denition of new exprs symb is the name of the symb ol to which a

lamb daexpression of the typ e

lambda lvar s s

n

will b e attached

defun returns the name of the function symb as its value There is no dierence b etween de

and defun

Up to validity checks the form

defun symb lvar s s

n

is equivalent to

setfn symb expr lvar s s

n

defun foo x if null cdr x x foo cdr x ) foo

valfn foo ) x if null cdr x x foo cdr x

typefn foo ) expr

foo a b c ) c

df symb lvar s ::: s special form

n

Allows for the static denition of new fexprs symb is the name of the symb ol to which a

lamb da expression of the typ e

flambda lvar s s

n

will b e attached

df returns the name of the dened function symb as its value

Up to validity checks

df symb lvar s s

n

is equivalent to

FUNCTIONDEFINITION FUNCTIONS

setfn symb fexpr lvar s s

n

df increm var val

set var if consp val

eval var eval car val

eval var

increm typefn increm

fexpr setq nb

increm nb

nb

dm symb lvar s ::: s special form

n

Allows for the static denition of new macros symb is the name of the symb ol to which a

lamb da expression of the typ e

mlambda lvar s s

n

will b e attached

dm returns the name of the dened function symb as its value

Up to validity checks the form

dm symb lvar s s

n

is equivalent to

setfn symb macro lvar s s

n

dm decr decr var val

list setq var

if val

list var car val

list var

decr setq n

decr n

defmacro symb lvar s ::: s special form

n

dmd symb lvar s ::: s special form

n

defmacro allows for the static denition of a new dmacro named symb that accepts a tree of

variables lvar This tree of variables will b e b ound to the cdr of the call to this macro defmacro

returns symb as its value There is no dierence b etween defmacro and dmd

In LELISP defmacro could b e dened in the following manner

df defmacro name larg corps

CHAPTER PREDEFINED FUNCTIONS

eval dm name l

letvq larg cdr l

displace l

if and consp corps

consp car corps

null cdr corps

car corps

cons progn corps

l

Up to validity checks the form

defmacro symb lvar s s

n

is equivalent to

setfn symb dmacro lvar s s

n

Here is an example

defmacro if test then else elsen

cond test then t else elsen

ds symb type adr special form

Allows for the static denition of functions whose typ e is subr or fsubr symb is the name of

a symb ol to which a machinelanguage function b eginning at address adr will b e attached Its

typ e is given by the argument type This function which is little used but included for reasons of

homogeneity is an fsubr variant of setfn

Up to validity tests the form

ds symb type adr

is equivalent to

setfn symb type adr

Advanced use of macro functions

Writing macro functions is a challenging activity LELISP encourages their use over fexprs which

cause variable capture In order to facilitate the writing of macros the backquote macrocharacter

is provided describ ed in the chapter on inputoutput along with the next two functions which

allow for control of the results of macroexpansions

macroexp and s function with one argument

If the expression s is a macro dmacro msubr or dmsubr call macroexpand returns the expanded

value of this macro This is obviously very useful for testing your own macros

In LELISP macroexpand could b e dened in the following manner

FUNCTIONDEFINITION FUNCTIONS

defun macroexpand x

expands a macro one level

cond eq typefn car x macro

apply cons lambda valfn car x x

eq typefn car x dmacro

apply cons lambda valfn car x cdr x

eq typefn car x msubr

call valfn car x x

eq typefn car x dmsubr

call valfn car x cdr x

t x

defmacro foo x x mcons x foo x ) foo

macroexpand foo ) mcons foo

macroexp and s function with one argument

Allows for the multilevel expansion of macro dmacro msubr or dmsubr calls in the expression s

In LELISP macroexpand could b e dened in the following manner

defun macroexpand x

expand a call until no macros remain

cond atom x x

symbolp car x

cond eq typefn car x macro

macroexpand

apply cons lambda valfn car x

x

eq typefn car x dmacro

macroexpand

apply cons lambda valfn car x

cdr x

eq typefn car x msubr

macroexpand

call valfn car x x

eq typefn car x dmsubr

macroexpand

call valfn car x cdr x

eq car x quote x

t let s

while consp x

newl s macroexpand nextl x

prog nreverse s rplacd s x

t let s

while consp x

newl s macroexpand nextl x

CHAPTER PREDEFINED FUNCTIONS

prog nreverse s rplacd s x

defmacro foo x x mcons x foo x ) foo

dm bar bar x foo x ) bar

macroexpand bar foo ) mcons mcons foo foo

Denition of closures

closure lvar fn function with two arguments

Allows for the denition of a closure made up of a list of variables lvar and a function fn Each

variable in the list lvar must have a nonindenite value that will b e used to construct the closure

In LELISP closure could b e dened in the following manner

defun closure lvarclot fnt

let listval mapcar lambda val

kwote eval val

lvarclot

lvar cadr fnt

corps cddr fnt

lambda lvar

lambda lvarclot

protect progn corps

mapcar

lambda slot var

rplaca

cdr quote slot

var

listval lvarclot

listval

For example here is a natural numb er generator

setfn nextint expr

let n

cdr closure n

lambda setq n n

Here is a Fib onacci numb er generator

setfn fib expr

let x y

cdr closure x y

lambda

setq y prog x y

setq x y

FUNCTIONDEFINITION FUNCTIONS

nextint )

nextint )

n ) eval undefined variable n

fib )

fib )

fib )

Denition of dynamic functions

flet l s ::: s special form

n

Allows for the denition of dynamic functionsanalogous to the let function for variables

The argument l is a list of lists Each sublist has the form symb l e e

n

The arguments s ::: s represent the function b o dy

n

The flet function binds a new function to each symb ol symb during the evaluation of s ::: s

n

Each of these functionswhich are themselves exprtyp e expressionshas an argument list l and

a b o dy e ::: e The return value of flet is the evaluation of the last function b o dy in the flet

n

that of s After the flet the symb ols symb retrieve their previous denitions ::: if they had one

n

Due to the intro duction of programmable interrupts flet is not used very often Moreover its

use leads to p o or p erformance in compiled co de b ecause of the totally dynamic nature of the

redenition Consequently it should b e avoided

flet car x cdr x car a b c

b c car a b c

a flet car x cdr x

cdr x cddr x

cdr car a b c d e

e

Generalized assignment

LISP allows assignment of values to variables by means of functions such as setq set and psetq

Often however values are stored in dierent kinds of data structures lists vectors and structures

For each typ e of storage two functions need to b e dened an access function and an assignment

function They are akin to the vref and vset functions for reading from and writing to vector

storage

Generalized assignment allows you to use the access function to carry out an assignment by means

of the setf macro

The advantage of generalized assignment is the economy gained in the initial assignment of values

to symb ols It also provides a uniform means of writing such assignment functions

setf loc val ::: loc val macro

n n

CHAPTER PREDEFINED FUNCTIONS

Up dates the lo cations loc ::: loc with the values of the expressions val ::: val As in the

n n

case of the setq function the assignments are carried out sequentially setf returns the value of

the last assignment that was p erformed

setf is a macro that is expanded into assignment functions for the lo cations loc

i

The lo cations loc must b e one of the following

i

 A variable name In this case the setf macro is equivalent to the setq function

 A predened lo cations with one of the following forms car x cdr x caar x

cadr x cadar x cddr x getprop s i vref v i and nth i l The list

can b e extended by using the defsetf macro which is ab out to b e presented

 One of the access functions of any dened structure

setf vref v i x is equivalent to vset v i x

defsetf access lparams store body macro

Lets you dene the assignment function asso ciated with the form access lparams The

store argument is a singleelement list the up dated value is b ound to the contents of store

The body argument is a macro b o dy that must return the form that do es the up dating

defsetf vref v i x vset v i x

defsetf cdr lst val

progn rplacd lst val

val because rplacd does not return the right value

Variable functions

A function with a variable numb er of arguments that gives read and write access getset to a

LISP datum will b e referred to as a variable function Read access takes place by calling this function

with n arguments Write access takes place by calling it with n arguments In the write call the

last argument is the new value of the variable function The typ e of the LISP datum manipulated

by these variable functions can b e one of the following

 An internal LELISP system typ e for example the numerical output conversion base or

inputoutput stamps

 Sp ecic to a particular program in which case any LISP ob ject whatever can b e used

A variable function has all the prop erties of a function Indeed it is a function But it can also b e

dynamical ly bound in the same way as LISP variablesby using the following function

with l s ::: s special form

n

VARIABLE FUNCTIONS

The argument l is a list of the form

symb arg arg symb arg arg

n n n nn

where the symb are the names of the variable functions and arg arg are their write

i i in

access arguments with p erforms these writes after saving the values of calls to these variable

functions in the read mo de then evaluating the expressions s ::: s and returning the value

n

of s as its result But in the spirit of dynamic binding with calls these function variables

n

again in write mo de with the values of the variable functions previously saved as arguments

The reconstitution of these values is protected in the manner of the protect function

In LELISP with could b e dened in the following manner

defmacro with l body

let var

let n

mapcar lambda x

symbol with

concat arg incr n

l

let mapcar

lambda var l

list var

or consp firstn length l

l

error with errsxt l

var

l

protect

progn l body

mapcar

lambda var l

append firstn length l l

var

var

l

For example obase is the system variablefunction for accessing the numeric base of numb ers

b eing printed out

obase

prin

with obase prin

obase

with obase prin is equivalent to

CHAPTER PREDEFINED FUNCTIONS

let xxx obase

protect progn obase

prin

obase xxx

Here is another example

defun monindic pl n

ifn consp n

getprop pl indic

putprop pl car n indic

car n

monindic x a ) a

monindic x ) a

with monindic x monindic x )

monindic x ) a

Basic control functions

All the functions describ ed in this section allow the sequential chain of evaluations to b e broken

That is why they are all of typ e fsubr The arguments are not evaluated by eval but by the

functions themselves Even then this is not always the case

The simplest control function is the conditional if function This function will b e used with the

while function to describ e all the other control functions in LISP in the form of fexprs

if s s s ::: s special form

n

If the value of the evaluation of s diers from if returns the value of the evaluation of the

expression s Otherwise if evaluates the expressions s ::: s in turn and returns the value of

n

the last evaluation s if allows for the construction of a control structure of the form if s then

n

s else s ::: s

n

if t )

if )

Here is Ackermanns function describ ed with the use of the if function

defun ack x y

if x

y

ack x

if y

ack x y

ifn s s s ::: s special form

n

BASIC CONTROL FUNCTIONS

If the value of the evaluation of s is equal to ifn returns the value of the evaluation of the

expression s Otherwise ifn evaluates the expressions s ::: s in turn and returns the value of

n

the last evaluation that of s ifn allows for the construction of a control structure of the form if

n

not s then s else s ::: s

n

ifn is therefore equivalent to if not s s s ::: s

n

In LELISP ifn could b e dened in the following manner

df ifn test then else

if null eval test

eval then

eprogn else

ifn t )

ifn )

when s s ::: s special form

n

If the value of the evaluation of s diers from when evaluates the expressions s ::: s in turn

n

and returns the value of the last evaluation that of s If the value of s is when returns

n

when gives rise to a control structure of the form if s then s ::: s else

n

In LELISP when could b e dened in the following manner

df when test body

if eval test

eprogn body

when t )

when )

unless s s ::: s special form

n

If the value of the evaluation of s is equal to unless evaluates the expressions s ::: s in

n

turn and returns the value of the last evaluation that of s If the value of s diers from

n

unless returns unless allows for the construction of a control structure of the form if s then

else s ::: s

n

In LELISP unless could b e dened in the following manner

df unless test body

if eval test

eprogn body

unless t )

unless )

CHAPTER PREDEFINED FUNCTIONS

or s ::: s special form

n

Evaluates the expressions s ::: s in turn until one of these evaluations has a value dierent

n

than or returns this value If no expression is given as argument this function returns

In LELISP or could b e dened in the following manner

df or l

letn oreval l l

if null cdr l

eval car l

let resul eval car l

if resul

resul

oreval cdr l

or )

or )

or )

or )

and s ::: s special form

n

Evaluates the expressions s ::: s in turn until the value of one of these evaluations is equal

n

to and then returns If this do es not o ccurthat is if all the expressions when evaluated

dier from and returns the value of the last evaluation that of s If no expressions are given

n

as arguments this function returns t and allows for the construction of control structures of the

form if s then if s then if ::: then s

n

In LELISP and could b e dened in the following manner

df and l

if null l

t

letn andeval l l

if null cdr l

eval car l

if eval car l

andeval cdr l

and ) t

and )

and )

and )

cond l ::: l special form

n

BASIC CONTROL FUNCTIONS

The famous cond primitive is the most general conditional function in LISP The arguments l :::

l are lists called clauses each of which has the structure ss s ::: s

n n

ss is any expression and s ::: s are the b o dy of the clause cond evaluates the b o dy of

n

the rst clause whose rst element ss evaluates to something other than cond evaluates

sequentially the expressions of the b o dy s ::: s and returns the value of the last evaluation

n

that of s If the clause in question has only one element ss cond returns the value of ss

n

that is the value that caused the clause to b e chosen for evaluation cond allows for the

construction of control structures of the form if then else if then

If no clause is chosen for evaluation cond returns In order to force the selection of the

last clause it is customary to use the symb olic constant t as the selector since its value is

always dierent to See the section on predicates

In LELISP cond could b e dened in the following manner

df cond l

letn condeval l l

when l

if or atom l atom car l

error cond errsxt l

let select eval caar l

if select

if cdar l

eprogn cdar l

select

condeval cdr l

The form

cond

p e e e

p e e

p

p e

is therefore equivalent to

cond

p progn e e e

p progn e e

let aux p aux

p e

cond t )

selectq s l ::: l special form

n

Like the cond function selectq cho oses one of the clauses l ::: l The selector of these clauses

n

is the value of the evaluation of s the selection b eing accomplished by the comparison of this

evaluation with one of the following

CHAPTER PREDEFINED FUNCTIONS

 The unevaluated car of the clause if this is an atom This comparison uses the equal

predicate

 The elements of the unevaluated car of the clause if this is a list In this case the

comparison uses the member search function This option allows for the selection to take

place b etween s and an arbitrary numb er of ob jects

Up on the selection of a clause selectq evaluates the rest of the clause in order and returns

the value of the last evaluation

If none of the clauses l ::: l is selected selectq returns

n

selectq therefore allows for the construction of switches on constant values

As in the cond function it is p ossible to force the selection of the last clause by using the

symb olic constant t as its rst element

In LELISP selectq could b e dened in the following manner

df selectq sel cl

letn sel sel eval sel cl cl

cond

null cl

no more clauses

or atom cl atom car cl

bad clause

error selectq errsxt cl

eq caar cl t

selection of the always true clause

eprogn cdar cl

and atomp caar cl equal sel caar cl

simple selection

eprogn cdar cl

member sel caar cl

general selection

eprogn cdar cl

t sel sel cdr cl

selectq red

green hope

red ok

t no

ok selectq red

blue green red color

rose iris flower

t dunno

color

BASIC CONTROL FUNCTIONS

while s s ::: s special form

n

As long as the value of s diers from while evaluates the expressions s ::: s in turn

n

while always returns as its value This is the value of the last evaluation of s The lo op

terminates at this p oint This function allows for the construction of innite lo ops with the

form while t since the symb olic constant t always has a value dierent to

In LELISP while could b e dened in the following manner

df while test body

letn while

if null eval test

eprogn body

while

while is equivalent to the following LISP form

letn while ifn s s s while

n

Here is an example of this function

setq s a b c d

a b c d while s prin nextl s

abcd

until s s ::: s special form

n

As long as the value of the evaluation of s is equal to until evaluates all the expressions

s ::: s in turn until returns the value of the rst evaluation of s that diers from This

n

is the value that causes the exit from the until lo op Like the preceding function while

until provides a very convenient way to construct conditional lo ops as well as innite lo ops

with the form until

In LELISP until could b e dened in the following manner

df until test body

letn until

or eval test

progn eprogn body until

until is equivalentup to the return valueto the following LISP form

while not s s s

n

Here is an example of this function

setq s a b c d

a b c d until null s prin nextl s

CHAPTER PREDEFINED FUNCTIONS

abcd

t

repeat m s ::: s special form

n

repeat evaluates the expression m The resulting value must b e a whole numb er repeat then

p erforms m evaluations of the expressions s ::: s If the value of m is not a numb er the errnia

n

error is raised If m is not strictly greater than zero the lo op is not executed In any case repeat

returns t as its value

In LELISP repeat could b e dened in the following manner

df repeat n l

let n eval n

if fixp n

while n eprogn l decr n

error repeat errnia n

t

repeat prin

t repeat prin

t

for var in ic ntl e ::: e s ::: s special form

m n

Allows nostalgic programmers to implement a lo op of the Algol variety The argument var

must b e a symb ol It is the numeric control variable for the lo op The in argument is the

initial numeric value of var at the b eginning of the lo op and ic is the numeric increment

added to var each time round the lo op Finally ntl is the maximal valueor minimal value

dep ending on the sign of icthat the control variable can receive It is the limit value of

var The for function returns the value of the evaluation of progn e e

m

In LELISP for could b e dened in the following manner

defmacro for var init step end res body

unless variablep var

error for errnva var

unless and init step end

error for errsxt list var init step end

let endvar concat for gensym

test if numberp step

if step

if step

if step

error for increment nul

let var init

LEXICAL CONTROL FUNCTIONS

endvar end

while test var endvar

body

incr var step

res

for i ok prin i

ok

Lexical control functions

LELISP version intro duces the notion of lexical or textual control The control structures

describ ed in this section have a strictly lexical scop e Incorrect use of one of them can raise the

errnab or errxia errors which have the default screen displays

fn no lexical scope e

fn inactive lexical scope e

Primitive lexical control forms

block symb e ::: e special form

n

symb is the unevaluated symb olic name of a lexical blo ck that evaluates the expressions e :::

e By default block returns the value of the last evaluation that is that of e However these

n n

sequential evaluations can b e interrupted by the next function

returnf rom symb e special form

symb must b e the name of a lexical blo ck of typ e block and it is not evaluated returnfrom exits

from this lexical blo ck and returns the value of the evaluation of e If this function o ccurs outside

the lexical scop e of the blo ck in question the errnab error is raised

return e special form

This function is the same as the following form

returnfrom e

tagbody ec ::: ec special form

n

ec ::: ec are either symb ols considered as lab els or lists that are forms to b e evaluated tagbody

n

evaluates the forms in turn and returns by default The sequential evaluation of these forms

can b e interrupted by the next function

CHAPTER PREDEFINED FUNCTIONS

go symb special form

symb is the name of a lab el in the current tagbody The go function called with symb as its

argument allows you to restart the sequential evaluation from the p oint at which symb app ears in

the tagbody If symb is not a lab el in a lexical tagbody the errnab error is raised

Here are examples of the use of lexical control functions

block commonality returnfrom commonality

block block portability return

block consistency eval returnfrom consistency

returnfrom no lexical scope consistency

block expressiveness

let y lambda returnfrom expressiveness

funcall y

let y block compatibility

setq y lambda returnfrom compatibility

funcall y

returnfrom inactive lexical scope compatibility

let n l

tagbody

efficiency if n

go power

newl l decr n

go efficiency

power

l

The following example is inspired by a wellknown source Steele

defun cex f g x

if x

funcall f

block here

cex g

lambda returnfrom here

x

cex )

Iteration functions of the prog kind

prog l ec ::: ec macro

n

Allows you to combine the block let and tagbody functions

In LELISP prog could b e dened in the following manner

defmacro prog l body

LEXICAL CONTROL FUNCTIONS

block

let l

tagbody body

prog l ec ::: ec macro

n

prog is equivalent to the preceding function prog except that the variable bindings take place

in sequencenot in paralleldue to the use of the let form

In LELISP prog could b e dened in the following manner

defmacro prog l body

block

let l

tagbody body

Iteration functions of the do kind

do lv lr ec ::: ec macro

n

This macro b orrowed from MacLisp is a very general iteration function with one or several control

variables It to o is a combination of the let block and tagbody functions enriched by an iteration

structure

 lv is a list of triples each of which describ es a control variable as symb val inc

 symb is the name of the control variable

 The expression val is its initial value b efore entering the lo op By default it is

 inc is the expression indicating its increment value added after each iteration If this

expression is not supplied the variable do es not change values during lo op execution lr

the second argument of a do is a list of the form

test e ::: e

n

where test is the endofiteration expression and e ::: e constitute the value to return

n

at the end of the iterations This argument is analogous to a cond clause If the value of

test is equal to the b o dy of the do is executed If not the expressions e ::: e are

n

evaluated and the value of the evaluation of e is the return value of the do

n

 ec ::: ec is the b o dy of the do the analog of the tagbody function

n

The evaluation of a do pro ceeds in the following manner

 The expressions val ::: val of the triples are evaluated and are used to bind the

n

control variables sym ::: sym This is done in parallel in the style of let or psetq

n

 test is evaluated If its value is dierent to the expressions e ::: e are evaluated

n

and do returns the value of e n

CHAPTER PREDEFINED FUNCTIONS

 If the test returns the do b o dy ec ::: ec is executed as in a prog

n

 At the end of the do b o dy the expressions inc ::: inc in the triples are evaluated and

n

are usedif they existto bind the control variables sym ::: sym The pro cess then

n

continues at the second step

In LELISP do could b e dened in the following manner

defmacro do lv test resul body

block

let mapcar lambda x list car x cadr x

lv

until test

tagbody body

psetq mapcan lambda x

when consp cddr x

list car x caddr x

lv

resul

Notice that this denition is not optimized for empty blo cks or tagbody forms

Let us lo ok at some examples of the use of do without a b o dy Here is a way of writing the

length function

defun lngt l

do x l cdr x

j j

atom x j

This function is transformed as follows

defun lngt l

let x l j

until atom x

psetq x cdr x j j

j

Here is a of writing the reverse function

defun rev l

do x l cdr x

y cons car x y

atom x y

This function is transformed as follows

defun rev l

let x l y

until atom x

psetq x cdr x y cons car x y y

DYNAMIC NONLOCAL CONTROL FUNCTIONS

do lv lr ec ::: ec macro

n

do is identical to the preceding function do except that the bindings take place sequentially and

not in parallel The relationship b etween do and do is the same as that b etween let and let

In LELISP do could b e dened in the following manner

defmacro do lv test resul body

block

let mapcar lambda x list car x cadr x

lv

until test

tagbody body

setq mapcan lambda x

when consp cddr x

list car x caddr x

lv

resul

Notice that this denition is not optimized for empty blo cks or tagbody forms

Here is an example of an exp onentiation function

defun expt m n

do result m m result

exponent n exponent

counter exponent exponent

counter result

This function is transformed as follows

defun expt m n

let result m

exponent n

counter exponent

until counter

setq result m result

exponent exponent

counter exponent

result

Dynamic nonlo cal control functions

The following control functions are p owerful and rapid b oth in compiled and interpreted co de

They are necessary comp onents of more sophisticated control structures and their use is strongly

recommended

A dynamicallydened lab el is referred to as an escape LELISP asso ciates symb ols with these

escap es These asso ciations initialize neither the values of symb ols nor the functions asso ciated with them

CHAPTER PREDEFINED FUNCTIONS

tag symb s ::: s special form

n

This lets you dene an escap e named symb This name is not evaluated but s ::: s are evaluated

n

in turn If there is no exit function call executed during these evaluations tag returns the value

of the last evaluation that is the evaluation of s On the other hand if a call of the form exit

n

symb s ::: s is encountered among s ::: s the evaluations inside the tag are terminated

n n

the expressions e ::: e are evaluated in turn and tag returns the value of the evaluation of e

n n

as its value

defun present l e

tag find

letn auxfn l l

cond null l

eq l e exit find l

consp l

auxfn car l

auxfn cdr l

t

present )

present )

evtag s s ::: s special form

n

evtag is similar to the preceding function tag except that the name of the escap e is evaluated

evtag therefore provides the means to dene computed escap es

exit symb s ::: s special form

n

Can b e used to leave escap es After evaluating the expressions s ::: s in the environment of the

n

exit it returns to the last dynamically dened tag symb or evtag symb

If symb is not the name of a dynamicallyaccessibl e escap e the exit from the escap e can b e captured

by a lock form It is up to this form to raise the errudt error in certain cases This error has the

screen display

fn undefined tag symb

where symb is the name of the escap e and fn is the typ e of the lock form that caught the

escap e By default the main interaction lo op has a lock form and raises the following error

toplevel undefined tag symb

evexit s s ::: s special form

n

evexit is similar to exit except that the name of the escap e is evaluated

DYNAMIC NONLOCAL CONTROL FUNCTIONS

unexit symb s ::: s special form

n

Can b e used to leave escap es It returns to the last dynamicallydene d tag symb or evtag

symb It also evaluates the expressions s ::: s in the environment of the corresp onding tag

n

or evtag

let i tag out let i exit out i )

let i tag out let i evexit out i )

let i tag out let i unexit out i )

untilexi t symb e ::: e special form

n

Provides the means to create lo ops that are controlled by escap es symb is the name of an escap e

The expressions e ::: e are rep eated indenitely until the o ccurrence of an explicit call to exit

n

the escap e symb or an escap e for which symb lies in its dynamic scop e

The form untilexit symb s s therefore corresp onds to the following call

n

tag symb while t s s

n

lock fn s ::: s special form

n

First lock evaluates the argument fn which must return a twoargument function as its

value This function is called the lock function

Then lock evaluates the expressions s ::: s as a progn If an escap e o ccurs in the course

n

of these evaluations the lo ck function is automatically called with two arguments The rst

is the name of the current escap e and the second is the value which this escap e returns

The value returned by this lo ck function fn if it returns one b ecomes the value of the lock

function Even if the evaluation of the b o dy of the lock terminates normally the lo ck function

is called but with as the name of the escap e and with the value of the evaluation of s as

n

its second argument In this case to o the value returned by lock is the value returned by

the lo ck function fn

Here is a lock function that is useless b ecause it reactivates an escap e with the same name

and the same value

lambda tag val if tag evexit tag val val

Here is a lock function that stops all escap es and raises an error

lambda tag val

if tag

error lock errudt tag

val

protect s s ::: s special form

n

Evaluates the expressions s ::: s and returns the value of the rst evaluation that of s In this

n

simple case it b ehaves like the prog function However if an escap e o ccurs during the evaluation

CHAPTER PREDEFINED FUNCTIONS

of s the expressions s ::: s are evaluated during the restoration of the exit context of the

n

escap e This functionneeded for the construction of LISP subsystemsallows for the automatic

restoration of complex environments in the case of exceptional exits or errors

In LELISP protect could b e dened in the following manner

df protect e l

lock lambda tag val

eprogn l

if tag

evexit tag val

val

eval e

Let us lo ok at a function that prints the hexadecimal value of a numb er The numb er is

shifted left by two bits That is it is multiplied by four

defun prinhex n

protect progn obase

print n

obase

prinhex prinhex

prinhex foo

not a number foo

The output base has been restored

unwind n s ::: s special form

n

After having unstacked n activation blo cks from the dynamic execution stack see the

cstack function unwind evaluates the expressions s ::: s and returns the value of the

n

last evaluation that is of s These evaluations are p erformed therefore in a previous

n

environment If there are not at least n activation blo cks still on the dynamic execution

stack the fatal errfsud is raised and the following default screen is displayed

Fatal error stack underflow

This function cannot b e describ ed in LELISP in a simple manner

let x let x a unwind x

let x

protect let x a unwind x

print ok

ok

DYNAMIC NONLOCAL CONTROL FUNCTIONS

catchal lb ut l s ::: s special form

n

l is a list of escap e names During the evaluation of the expressions s ::: s if there is an escap e

n

callthat is a call to exit or to evexitthat causes an exit from the catchallbut then the

function searches the list l for an o ccurrence of the escap e name in question If it o ccurs in l the

escap e takes place normally If not the errudt errorundened escap eis raised This function

therefore provides a way of ltering escap es

In LELISP catchallbut could b e dened in the following manner

defmacro catchallbut l body

lock lambda tag val

cond null tag val

memq tag l evexit tag val

t error catchallbut

errudt

tag

body

backtrac k symb l e ::: e special form

n

Provides a means of executing backup control structures symb is a symb ol that has the backtrack

name as its value l is a list of variables to b e guarded e ::: e are the various actions of the

n

backtrack Unless interrupted backtrack evaluates e and returns its value During this evaluation

if an escap e with the name symb o ccurs the evaluation of e is abandonned the values of the

variables in the list l are restored and evaluation of e is undertaken It to o can eect an escap e by

p erforming an exit or evexit with symb as its rst argument Evaluation of e is then undertaken

after the variables are restored as describ ed ab ove The same actions take place for e ::: e To

n

quit a backtrack structure exceptionally use the form

exit backtrack return value

In LELISP backtrack could b e dened in the following manner

defmacro backtrack name lvar body

unless symbolp name

error backtrack errnaa name

tag backtrack

if null lvar

mapcar lambda e

tag name e

exit backtrack

body

let backtrack list lvar

mapcan

lambda e

tag name e

CHAPTER PREDEFINED FUNCTIONS

exit backtrack

desetq lvar backtrack

body

pprint macroexpand

backtrack re

s s

try s

try s

try s s

tag backtrack

let backtrack list s s

tag re try s exit backtrack

desetq s s backtrack

tag re try s exit backtrack

desetq s s backtrack

tag re try s s exit backtrack

desetq s s backtrack

Basic predicates

In LISP the b o olean value false is equivalent to the value and the b o olean value true is equivalent

to any value other than The latter fact allows you to cho ose any kind of representation

Certain predicates that must return the b o olean value true use the symb olic constant t By

denition this constant is dierent to since the value of the symb ol t is the symb ol t itself

All predicates which are false of the value return their rst argument if the predicate is armed

of that argument and otherwise all predicates which are true of the value return t if the

predicate is armed of its argument and otherwise

The ma jority of the names of these functions end with the letter p which is meant to stand for

predicate

This section only describ es the basic predicates Tests on integer and mixedarithmetic expressions

are describ ed elsewhere in this manual

false e ::: e function with a variable number of arguments

n

Returns the b o olean value false that is regardless of the numb er or values of its arguments

true e ::: e function with a variable number of arguments

n

Returns the b o olean value true that is the symb olic constant tregardless of the numb er or

values of its arguments

null s function with one argument

Tests whether s is equal to If so null returns t Otherwise it returns

BASIC PREDICATES

In LELISP null could b e dened in the following manner

defun null s

if eq s t

null ) t

null t )

not s function with one argument

Inverts the b o olean value of s Due to the implementation of the b o olean values in LISP this

function is identical to the function null To make your programs more readable it is preferable

to use null to test whether a list is empty and not to invert a logical value

atom s function with one argument

atomp s function with one argument

These predicates test whether s is an atom that is either a symb ol a numb er or a character string

atom returns t if this is the case Otherwise it returns In order to handle the relation atom

x not consp x atom returns t when its argument is a vector of Sexpressions atomp

b ehaves in the same manner it is merely another name for atom

atom ) t

atom argh ) t

atom ) t

atom oops ) t

atom ) t

atom a b )

constant p s function with one argument

Tests whether s is a constant that is the sp ecial nil or an ob ject that returns when evaluated

the same ob ject Basic numb ers character strings vectors of Sexpressions and symb ols of which

variablep are not true are all constants constantp returns t if the test is p ositive and if not

In LELISP constantp could b e dened in the following manner

defun constantp s

if or fixp s

floatp s

vectorp s

stringp s

and symbolp s not variablep s

t

CHAPTER PREDEFINED FUNCTIONS

constantp ) t

constantp nil ) t

constantp nil ) t

constantp ) t

constantp ) t

constantp barf ) t

constantp ) t

constantp argh )

constantp a b )

symbolp s function with one argument

Tests whether s is a symb ol symbolp returns t if so and if not

symbolp ) t

symbolp argh ) t

symbolp )

symbolp oops )

symbolp )

symbolp a b )

variable p s function with one argument

Tests whether s is a symb ol that is not a symb olic constant that is whether it is a symb ol dierent

from nil and t It returns s if this is so and if not

variablep )

variablep nil )

variablep nil )

variablep argh ) argh

variablep )

variablep barf )

variablep )

variablep a b )

numberp s function with one argument

Tests whether s is a numb er numberp returns the numb er s if the test is p ositive Otherwise it

returns Tests on dierent typ es of numb ers are describ ed in chapter

numberp )

numberp argh )

numberp )

numberp oops )

numberp )

numberp a b )

BASIC PREDICATES

vectorp s function with one argument

Tests whether s is a vector vectorp returns s if this is so and if not

vectorp )

vectorp argh )

vectorp )

vectorp oops )

vectorp )

vectorp a b )

stringp s function with one argument

Tests whether s is a character string stringp returns s if this is so and if not

stringp )

stringp argh )

stringp )

stringp oops ) oops

stringp )

stringp a b )

consp s function with one argument

Tests whether s is a nonempty list consp returns s if the test is p ositive Otherwise it returns

consp is the inverse predicate of atom

consp )

consp nil )

consp nil )

consp argh )

consp )

consp oops )

consp )

consp a b ) a b

listp s function with one argument

Tests whether s is a list The test includes the p ossibility of the empty list written as listp

returns the symb ol t if the test is p ositive Otherwise it returns

The representation of the empty list as or as a symb ol p oses the problem of the status of

this symb ol is simultaneuosly a symb ol and the representation of the empty list LELISPlike

most p ostMacLisp versions of LISPresolves this ambiguity by calling up on two functions to test

lists consp and listp

listp ) t

listp ) t

listp ) t

CHAPTER PREDEFINED FUNCTIONS

listp nil ) t

listp nil )

listp argh )

listp )

listp oops )

listp )

listp a b ) t

nlistp s function with one argument

Tests whether s is neither a list nor the symb ol for the empty list In LELISP the latter is written

as the symb ol If the test is p ositive nlistp returns the argument s Otherwise it returns

Up to the return value this function is the inverse of the preceding one

In LELISP nlistp could b e dened in the following manner

defun nlistp x

if or null x consp x

x

nlistp )

nlistp nil )

nlistp nil ) nil

nlistp argh ) argh

nlistp )

nlistp oops ) oops

nlistp )

nlistp a b )

eq s s function with two arguments

eq tests whether the two symb ols s and s are equal and returns t if this is the case Otherwise

it returns When the arguments are not symb ols the eq function tests for the equality of the

internal representations of s and s In fact eq tests for the equality of the physical addresses of

its two arguments

Since the internal representation of numb ers vectors and character strings varies with dierent

implementations of the system it is recommended that the function which is describ ed with

the numeric predicates b e used to test for the equality of numeric values Similarly the eqvector

function should b e used for the same test on vectors and eqstring should b e used to test for

equality b etween two strings

eq nil ) t

eq nil nil )

eq a car a ) t

eq ) or t depending on the implementation

eq strr strr ) or t depending on the implementation

BASIC PREDICATES

eq ) t or depending on the implementation

eq a b a b )

setq l x y ) x y

eq l l ) t

neq s s function with two arguments

neq is equivalent to not eq s s

In LELISP neq could b e dened in the following manner

defun neq s s

if eq s s t

equal s s function with two arguments

This functions carries out the most general kind of comparison that is available in LELISP and

must b e used if the exact typ e of the ob jects to b e compared is not known Up to the return value

when s and s are symb ols equal is identical to the eq function equal is identical to eqn in

the case of integer numb ers and to feqn in the case of oatingp oint numb ers If s and s are

vectors equal is identical to the eqvector function If the arguments are character strings equal

is identical to the eqstring function If they are lists equal tests whether they have the same

structure that is whether they have the same elements In all cases if the test is p ositive equal

returns t Otherwise it returns

To compare extended arithmetic numb ers the function must b e used

In LELISP equal could b e dened in the following manner

defun equal s s

tag no if equalaux s s t

defun equalaux s s

cond symbolp s

if symbolp s

eq s s

exit no

or fixp s floatp s

if or fixp s floatp s

s s

exit no

vectorp s

if vectorp s

eqvector s s

exit no

stringp s

if stringp s

eqstring s s

CHAPTER PREDEFINED FUNCTIONS

exit no

t if consp s

and equalaux car s car s

equalaux cdr s cdr s

exit no

equal ) t

equal a a ) t

equal ) t

equal ) t

equal ) t

equal )

equal foo bar foo bar ) t

equal a b c d a b c d ) t

equal a b c a b c d )

John McCarthy p osed an interesting problem Can we nd nontrivial solutions for s such

that equal s eval s Here are three prop osed solutions due to Christian Queinnec

Solution

setq s lambda s list car s

subst s cadr s

lambda s

list car s

subst s cadr s

equal s eval s ) t

Solution

setq s lambda s list car s kwote s

lambda s list car s kwote s

equal s eval s ) t

Solution

setq s flambda s s s

flambda s s s

equal s eval s ) t

nequal s s function with two arguments

The form nequal s s is equivalent to not equal s s

In LELISP nequal could b e dened in the following manner

defun nequal s s

if equal s s t

FUNCTIONS ON LISTS

Functions on lists

Search functions on lists

All these functions accept a single list l as their argument It can b e the empty list If any other

typ e or numb er of arguments is given the errnla error is raised

car l function with one argument

If l is a list car returns its rst element If l equals car returns The car of a symb ol other

than of a numb er a vector or a character string is undened and therefore raises the errnla

error This error is not generated by compiled co de

car a b c ) a

setq x u p ) u p

car x ) u

car x ) car not a list x

cdr l function with one argument

If l is a list cdr returns this list without its rst element The cdr of is by denition

The cdr of a symb ol other than of a numb er a vector or a character string is undened and

raisesas in the case of the previous function carthe errnla error under the interpreter In

compiled co de this error do es not o ccur for bad arguments to cdr

cdr a b c ) b c

cdr x y ) y

cdr )

cr l functions of one argument

There are overlapping combinations of car and cdr with up to four letters b etween the c and the

r This gives rise to dierent functions

 cadr l is equivalent to car cdr l

 cdaar l is equivalent to cdr car car l

 cadaar l is equivalent to car cdr car car l

memq symb l function with two arguments

If the symb ol symb is an element of the list l memq returns the sublist of l that b egins at the rst

o ccurrence of the symb ol symb Otherwise it returns This function uses the eq predicate to

test for the presence of symb in the list l This function is often used as a predicate to test for the

presence of an element in a given list

In LELISP memq could b e dened in the following manner

CHAPTER PREDEFINED FUNCTIONS

defun memq at l

cond atom l

eq at car l l

t memq at cdr l

memq c a b c d e ) c d e

memq z a b c d e )

memq f a f )

member s l function with two arguments

If the expression s is an element of the list l member returns the sublist of l that b egins at the

rst o ccurrence of symb in l Otherwise it returns This function uses the equal predicate and

so facilitates searches for elements of any typ e whatso ever in a list

In LELISP member could b e dened in the following manner

defun member s l

cond atom l

equal s car l l

t member s cdr l

member c a b c d e ) c d e

member z a b c d e )

member f a f )

member a b a a b c ) a b c

tailp s l function with two arguments

If s is one of the cdrs of l tailp returns s Otherwise it returns

In LELISP tailp could b e dened in the following manner

defun tailp s l

cond atom l

eq s l s

t tailp s cdr l

setq l a b c d ll cddr l ) c d

tailp ll l ) c d

tailp c d a b c d ) tailp uses eq

nthcdr n l function with two arguments

th

Returns the sublist of l that b egins with its n cdr If l is not a list or if length l is less than

n nthcdr returns If n is less than or equal to zero nthcdr returns the entire list l

In LELISP nthcdr could b e dened in the following manner

FUNCTIONS ON LISTS

defun nthcdr n l

if n

l

nthcdr n cdr l

nthcdr a b c d e ) d e

nthcdr a b ) a b

nthcdr a b )

nth n l function with two arguments

th th

Returns the n element of the list l counting the car of l as its zero element nth is equivalent

to

car nthcdr n l

In LELISP nth could b e dened in the following manner

defun nth n l

if n

car l

nth n cdr l

nth a b c d e f ) d

nth a b c )

last s function with one argument

If s is a list last returns the list comp osed of its nal element If s is not a list last returns s

In LELISP last could b e dened in the following manner

defun last s

if or atom s atom cdr s

s

last cdr s

last a b c d e ) e

last a b c d ) c d

last )

length s function with one argument

If s is a list length returns the numb er of elements in s If s is not a listthat is if s is an

atomlength returns zero

In LELISP length could b e dened in the following manner

defun length s

CHAPTER PREDEFINED FUNCTIONS

if atom s

length cdr s

length a b c d e )

length a b c )

length esar )

List creation functions

All the functions that are describ ed in this subsection build new lists The management of memory

allo cated to lists is dynamic and automatic See the section on the garbage collector

cons s s function with two arguments

Builds a list that has s as its rst element and s as the rest If s is an atom cons builds the

dotted pair s s

If we supp ose that the variable free contains the list of available memory cells cons could b e

describ ed in LELISP in the following manner

defun cons x y

rplaca free x

rplacd prog free setq free cdr free y

cons a b c ) a b c

cons x ) x

setq s x y z ) x y z

equal cons car s cdr s s ) t

xcons s s function with two arguments

This function is equivalent to cons s s The order of the arguments is simply reversed

xcons )

setq x )

xcons incr x incr x )

ncons s function with one argument

This function is the equivalent of cons s or list s

mcons s ::: s function with a variable number of arguments

n

This function p erforms a multiple cons The form

mcons s s ::: s s

n n

is equivalent to the form

FUNCTIONS ON LISTS

cons s cons s ::: cons s s :::

n n

In LELISP mcons could b e dened in the following manner

df mcons l

cons eval car l

eval if null cddr l

cadr l

cons mcons cdr l

mcons has b een dened here in the form of an fexpr assuming the presence of at least two

arguments Alternatively it could b e dened in the form of a macro

dm mcons mcons l

list cons cadr l

if null cdddr l

caddr l

cons mcons cddr l

mcons )

mcons a ) a

mcons a b ) a b

mcons a b c ) a b c

list s ::: s function with a variable number of arguments

n

Returns the list of the values of the expressions s ::: s In terms of cons the call

n

list s s ::: s s

n n

is equivalent to

cons s cons s ::: cons s cons s :::

n n

In LELISP list could b e dened in the following manner

defun list l l

list has b een dened here in the form of an expr Alternatively we could dene it in the

form of an fexpr

df list l

let r

while l newr r eval nextl l

r

list a b c ) a b c

list )

CHAPTER PREDEFINED FUNCTIONS

kwote s function with one argument

Builds a twoelement list that has the symb ol quote as its rst element and the value of s as its

second argument

In LELISP kwote could b e dened in the following manner

defun kwote s

list quote s

kwote a ) a

kwote cdr a b ) b

makelist n s function with two arguments

Returns a list of n elements each one having the value of s as its own value This function is useful

for building lists of a given length

In LELISP makelist could b e dened in the following manner

defun makelist n s

if n

cons s makelist n s

makelist a ) a a a a

append l ::: l function with a variable number of arguments

n

Returns the concatenation of a copy of the rst level of all the lists l ::: l to the list l

n n

Arguments that are not lists are ignored except that l if atomic b ecomes the last cdr of the

n

resulting list To copy the rst level of a list l use the form append l

In LELISP append could b e dened in the following manner

defun append l

append car l

if null cddr l

cadr l

apply append cdr l

defun append l l

if null l

l

cons car l append cdr l l

append a b c x y ) a b c x y

append x y z ) x y z

append a b c ) a b c

append a b c ) a b c

FUNCTIONS ON LISTS

setq l a b c ) a b c

eq l append l ) t

setq l append l ) a b c

eq l append l )

append l s function with two arguments

The form append l s is equivalent to append l list s

This allows you to copy the rst level of the list l and add the element s to its tail

In LELISP append could b e dened in the following manner

defun append l s

append l list s

append a b c ) a b c

reverse s function with one argument

Returns a reversed copy of the rst level of the list s

In LELISP reverse could b e dened in the following manner

defun reverse s

letn rev s s r

if atom s

r

rev cdr s cons car s r

reverse a b c d ) d b c a

It is sometimes claimed that the following function also reverses its argument

defun rev l

if null cdr l

l

cons car rev cdr l

rev cons car l

rev cdr rev cdr l

copylist l function with one argument

Builds a new copy of l in its entirety In this function the copying takes place at every level of

nesting within l To copy character strings the cells of lab elled lists and vectors of Sexpressions

use the next function to b e describ ed

In LELISP copylist could b e dened in the following manner

defun copylist s

CHAPTER PREDEFINED FUNCTIONS

if atom s

s

cons copylist car s copylist cdr s

copylist a ) a

copylist a b c d ) a b c d

copylist a b d ) a b d

This function do es not handle circular or shared lists To solve this problem use the following

function

defun circopylist l

let d e

letn circ l l

cond atom l l

cdr assq l d

t setq e cons

d acons l e d

rplac e

circ car l

circ cdr l

copy s function with one argument

Returns a distinct copy of the ob ject s This is true for character strings cells of lab elled lists and

vectors of Sexpressions

In LELISP copy could b e dened in the following manner

defun copy s

cond atom s

cond

stringp s substring s

vectorp s

let v makevector vlength s

for i vlength s

vset v i

copy vref s i

v

t s

tconsp s

tcons copy car s copy cdr s

t cons copy car s copy cdr s

setq strg gdy jest ) gdy jest

eq strg strg ) t

eq strg copy strg )

equal strg copy strg ) t

FUNCTIONS ON LISTS

setq vect )

eq vect vect ) t

eq vect copy vect )

equal vect copy vect ) t

copy a b d ) a b d

firstn n l function with two arguments

Returns a copy of the rst n elements of the list l It might happ en that l contains fewer than n

elements In other words n is greater than length l In this case firstn returns a copy of the

entire list l

In LELISP firstn could b e dened in the following manner

defun firstn n l

cond null l

n

t cons car l firstn n cdr l

firstn a b c d e f ) a b c

firstn a b c d ) a b c d

firstn a b c )

lastn n l function with two arguments

Returns a copy of the last n elements of the list l It might happ en that the list contains fewer

than the numb er of elements requested In other words length l is less than n In this case

lastn returns a copy of the entire list l

In LELISP lastn could b e dened in the following manner

defun lastn n l

reverse firstn n reverse l

lastn a b c d e ) d e

lastn a b c ) a b c

lastn a )

subst s s s function with three arguments

Builds a new copy of the expression s substituting the expression s for each o ccurrence of the

expression s in s The substitution takes place at every level of s This function uses the equal

predicate to p erform the test and builds a new expression by sharing the greatest p ossible numb er

of list cells with the original expression s

Use the form nsubst s s copy s to obtain a distinct copy of the expression By this we

mean a copy that shares no cells whatso ever with the original list s

In LELISP subst could b e dened in the following manner

CHAPTER PREDEFINED FUNCTIONS

defun subst new old s

cond equal s old new

atom s s

t let car subst new old car s

cdr subst new old cdr s

if and eq car car s

eq cdr cdr s

s

cons car cdr

subst x y z a a c d a ) x y z c d x y z

remq symb l function with two arguments

Returns a copy of l in which o ccurrences of the symb ol symb have b een removed This mo dication

is eected only at the rst level of l

In LELISP remq could b e dened in the following manner

defun remq symb l

cond atom l l

eq symb car l remq symb cdr l

t cons car l remq symb cdr l

remq a a b a c a b d a s ) b c a b d s

remq a a b ) b

remq a a b a ) b a

remq a a a a )

remove s l function with two arguments

This function is identical to the last one describ ed except that it uses equal to test for o ccurrences

of s in l

In LELISP remove could b e dened in the following manner

defun remove s l

cond atom l l

equal s car l remove s cdr l

t cons car l remove s cdr l

remove a a b a c a b a s ) a b c a b s

remove a a a a )

Functions on cells of lab elled lists

These functions use an invisible bit that can b e set and tested for each list cell By default the

external representation of a lab elled list cellone whose invisible bit is setis car cdr for

FUNCTIONS ON LISTS

input and output functions However it is p ossible to eect the evaluation and the printing of these

lab elled list cells by means of user functions See the section on extended typ es in chapter

tconsp s function with one argument

Returns s if s is a lab elled cons and if this is not the case This function cannot b e describ ed

in LISP

tconsmk s function with one argument

Sets the invisible bit for the cons referred to as s The nal letters in the name of this function

mk stand for mark a synonym of set This function cannot b e describ ed in LISP

setq x a b ) a b

tconsmk x ) a b

x ) a b

tconscl s function with one argument

Clears the invisible bit for the cons referred to as s This function cannot b e describ ed in LISP

setq x a b ) a b

tconscl x ) a b

x ) a b

tcons s s function with two arguments

Creates a lab elled cons with s as its car and s as its cdr

In LELISP tcons could b e dened in the following manner

defun tcons car cdr

tconsmk cons car cdr

setq x tcons a b c ) a b c

tcons d cons e x ) d e a b c

Physical mo dication functions

All the functions presented in this subsection must b e used with caution and exactly as describ ed

Otherwise you might run into serious problems These functions enable you to physically mo dify

LISP structures Be esp ecially careful whenever you set out to physically mo dify shared lists This

p ossibility of op erating up on the internal representations of lists means that LISP oers the same

p ower that you nd in machine languages

rplaca l s function with two arguments

CHAPTER PREDEFINED FUNCTIONS

Replaces the car of the list l by s It returns the mo died list l as its value If the argument l is

not a list the errnla error o ccurs

rplaca a b c x y ) x y b c

rplaca x foo ) rplaca not a list x

rplacd l s function with two arguments

Replaces the cdr of the list l with s It returns the new list l as its value If the argument l is not

a list the errnla error o ccurs

rplacd a b c x y z ) a x y z

rplacd t ) rplacd not a list

rplac l s s function with three arguments

Replaces the car of the list l with s and its cdr with s and returns the mo died list If the

argument l is not a list the errnla error o ccurs

In LELISP rplac could b e dened in the following manner

defun rplac l s s

if atom l

error rplac errnla l

rplaca l s

rplacd l s

l

setq l a b l l ) a b

rplac l )

l )

l )

displace l ln function with two arguments

Replaces the car of the list l with the car of ln and the cdr of l with the cdr of ln If ln is not a

list it is transformed into progn ln This function is often used in macros to physically mo dify

the macro call itself

In LELISP displace could b e dened in the following manner

defun displace l ln

if atom l

error displace errnla l

if atom ln

rplac l progn list ln

rplac l car ln cdr ln

setq l a b c ) a b c

FUNCTIONS ON LISTS

setq l l ) a b c

displace l x y ) x y

l ) x y

displace l z ) progn z

l ) progn z

placdl l s function with two arguments

Lets you attach a new cell to the cdr of the list l This new cell has s as its car placdl returns

this new cell as its value This function is used extensively to build listsin the right orderin

one single nonrecursive pass

In LELISP placdl could b e dened in the following manner

defun placdl l s

cdr rplacd l cons s

evlis l function with one argument

Returns a list comp osed of the values of the evaluations of all the elements of l

In LELISP evlis could b e dened in the following manner

defun evlis l

cond null l

null cdr l list eval car l

t let head list eval car l

evlisaux cdr l head

head

defun evlisaux rest current

when rest

evlisaux cdr rest

placdl current eval car rest

nconc l ::: l function with a variable number of arguments

n

Physically concatenates all the lists l In other words it places a p ointer to the list l in the cdr

i i

of the last element of the list l It returns the new list l as its value If two of the l lists are

i i

the same physical p ointers nconc builds a circular list by forcing the last cdr of the list to p oint

to the rst element of this same list Arguments that are not lists are ignored except for the nal

argument l If this last argument is atomic it b ecomes the nal cdr of the resulting list

n

In LELISP nconc could b e dened in the following manner

defun nconc l l Assume that l and l are wellformed lists

let l l

CHAPTER PREDEFINED FUNCTIONS

while consp cdr l nextl l

rplacd l l

l

setq x a b c x x ) a b c

nconc x d e f g ) a b c d e f g

x ) a b c d e f g

nconc a b ) a b

setq x a b c ) a b c

nconc x x ) a b c a b c a b

nconc l s function with two arguments

Physically adds the new element s to the end of the list l

In LELISP nconc could b e dened in the following manner

defun nconc l a

nconc l list a

setq l a b c l l ) a b c

nconc l d ) a b c d

l ) a b c d

cirlist e ::: e function with a variable number of arguments

n

Builds a circular list comp osed of the elements e ::: e Since this function builds a new list it

n

do es not mo dify the elements Among other things cirlist provides the means to build invariants

in maptyp e functions

In LELISP cirlist could b e dened in the following manner

defun cirlist l

nconc l l

cirlist a ) a a a a a a

cirlist a b c ) a b c a b c a b c

nreverse l function with one argument

Reverses physically and rapidly the list l This function must b e used with caution since it

physically mo dies the whole list This brings ab out a disaster if the list was shared

In LELISP nreverse could b e dened in the following manner

defun nreverse l

if consp l

letn nr l l r

if null cdr l

FUNCTIONS ON LISTS

rplacd l r

nr cdr l rplacd l r

l

setq l a b c d e ) a b c d e

setq l cdr l ) b c d e

setq l last l ) e

nreverse l ) e d c b a

l ) a

l ) b a

l ) e d c b a

nreconc l s function with two arguments

Reverses physically and rapidly the list l and addsby means of a physical nconcthe list s

This function therefore corresp onds to nconc nreverse l s

This function must b e used with caution for it physically mo dies LELISP structures Op erations

on shared structures can b e particularly confusing On the other hand this function is far more

rapid than the conventional reverse

In LELISP nreconc could b e dened in the following manner

defun nreconc l s

if consp l

nconc nreverse l s

s

setq l a b c d e ) a b c d e

setq l cdr l ) b c d e

setq l last l ) e

nreconc l x y ) e d c b a x y

l ) a x y

l ) b a x y

l ) e d c b a x y

nsubst s s l function with three arguments

Physically mo dies the list l by substituting the expression s for each o ccurrence of the expression

s in l This function uses the equal predicate to test for o ccurences of s in l To obtain a copy

of the mo died list instead of changing l physically use the subst function

In LELISP nsubst could b e dened in the following manner

defun nsubst new old s

cond equal s old new

atom s s

t rplac s

CHAPTER PREDEFINED FUNCTIONS

nsubst new old car s

nsubst new old cdr s

setq l a c d a ) a c d a

nsubst x y z a l ) x y z c d x y z

l ) x y z c d x y z

delq symb l function with two arguments

Physically removes all o ccurrences of the symb ol symb from the rst level of the list l and returns

the mo died list If this list was sharedfor example if a variable p ointed at or into itthe values

in p ointers that previously eected this sharing will b e p ossibly invalid This function uses the eq

predicate In order to get a physically distinct copy of such a mo died list use the remq function

In LELISP delq could b e dened in the following manner

defun delq symb l

cond atom l l

eq symb car l delq symb cdr l

t rplacd l delq symb cdr l

setq l a b c b b d ) a b c b b d

setq l delq b l ) a c d

delq a l ) c d

l ) a c d

setq l delq a l ) c d

l ) c d

delete s l function with two arguments

Physically removes all o ccurrences of the expression s from the rst level of the list l and returns

the mo died list If this list was sharedfor example if a variable p ointed at or into itthe values

in p ointers that previously eected this sharing will b e p ossibly invalid This function uses the

equal predicate In order to get a physically distinct copy of such a mo died list use the remove

function

In LELISP delete could b e dened in the following manner

defun delete s l

cond atom l l

equal s car l delete s cdr l

t rplacd l delete s cdr l

setq l a b c b b d ) a b c b b d

setq l delete b l ) a c b d

l ) a c b d

FUNCTIONS ON LISTS

Functions on Alists

The term Alists stands for asso ciation lists which are tablesin the snobol sensethat have

the following structure

key val key val ::: key val

n n

Each element of an Alist is a pair comp osed of a key and a value The key is the car of the table

element and the corresp onding value is its cdr A value is accessed by means of its key

In all the functions to b e describ ed here the argument al is an Alist For Alist access functions

that use the eq predicate the keys must b e symb ols For access functions that use equal these

keys must b e Sexpressions All elements of an Alist that are not of a cons nature are ignored

acons s s al function with three arguments

Adds an element to the Alist al The element is comp osed of the key s and its value is s acons

returns the newlymo died Alist as its value

In LELISP acons could b e dened in the following manner

defun acons s s al

cons cons s s al

acons a b z ) a b z

pairlis l l al function with three arguments

Here l is a list of keys and l is a list of values pairlis returns a new Alist comp osed of the

keys in l and the asso ciated values in l If a third argument al is supplied it is added to the

end of the newlycreated Alist

In LELISP pairlis could b e dened in the following manner

defun pairlis l l al

if and consp l listp l

acons car l

car l

pairlis cdr l cdr l al

al

pairlis the big tree le grand arbre ) the le big grand tree arbre

pairlis x y z a b a x b y ) x a y b z a x b y

assq symb al function with two arguments

Returns the element of the Alist al whose keythat is whose caris equal to the symb ol symb

If there is no such element assq returns

In LELISP assq could b e dened in the following manner

CHAPTER PREDEFINED FUNCTIONS

defun assq symb al

cond atom al

and consp car al

eq caar al symb

car al

t assq symb cdr al

assq b a b c d e ) b

cassq symb al function with two arguments

cassq is identical to assq except that it returns only the valueor cdrof the element of the

Alist al whose key matches symb

So cassq symb al is equivalent to cdr assq symb al

Warning The value could b e returned as the successful result of a match on a key with

which it is asso ciated in al On the other hand this same value could b e returned b ecause

there was no match on the given key value symb It is not p ossible to distinguish b etween

these two cases

cassq c a b c d e ) d e

rassq symb al function with two arguments

Returns the element of the Alist al whose valueor cdris equal to the symb ol symb If

there is no such element rassq returns

In LELISP rassq could b e dened in the following manner

defun rassq symb al

cond atom al

and consp car al

eq cdar al symb

car al

t rassq symb cdr al

rassq a b c d e ) b

assoc s al function with two arguments

This function is identical to rassq except that it uses the equal predicate to test for matches

b etween s and the keys of the elements in al These keys can therefore b e of any typ e whatso ever

In LELISP assoc could b e dened in the following manner

defun assoc s al

cond

atom al

and consp car al

FUNCTIONS ON LISTS

equal s caar al

car al

t assoc s cdr al

assoc b a b c d e ) b

cassoc s al function with two arguments

This function is identical to the cassq function except that it uses the equal predicate to test for

matches b etween s and the keys of the elements in al These keys can therefore b e of any typ e

whatso ever

cassoc s l is therefore equivalent to cdr assoc s l

cassoc c a b c d e ) d e

rassoc s al function with two arguments

This function is equivalent to the rassq function except that it uses the equal predicate to

test for matches b etween s and the values of the elements in al

In LELISP rassoc could b e dened in the following manner

defun rassoc s al

cond atom al

and consp car al

equal s cdar al

car al

t rassoc a cdr al

rassoc d e a b c d e ) c d e

sublis al s function with two arguments

sublis returns a copy of the expression s in which all o ccurrences of the keys of the Alist al have

b een replaced by their asso ciated values The returned copy sharesas far as p ossiblethe cells

of the initial expression This function uses the assq predicate

In LELISP sublis could b e dened in the following manner

defun sublis al s

if atom s

let x assq s al

if x cdr x s

let car sublis al car s

cdr sublis al cdr s

if and eq car car s

eq cdr cdr s

s

cons car cdr

CHAPTER PREDEFINED FUNCTIONS

sublis a z b a b a c d b b ) z z c d

Sorting functions

sort feature

This feature indicates whether the sorting functions are loaded into memory

sort fn l function with two arguments

Physically sorts the list l The elements of the list are compared by using the twoargument function

fn If this list was sharedfor example if a variable p ointed at or into itthe values in p ointers

that previously eected this sharing will b e p ossibly invalid sort returns the mo died list l as its

value The sort eected by sort is unstable Identical elements in the original list might not b e in

the same physical lo cation in the resulting list

In LELISP sort could b e dened in the following manner

defun sort fn l

if null cdr l

l

let l l l

setq l nthcdr div length l l

l cdr l

rplacd l

ffusion sort fn l

sort fn l

defun ffusion l l Physically merge two sorted lists

unless funcall fn car l car l

psetq l l l l

prog l

while and cdr l l

when funcall fn car l cadr l

rplacd l

prog l

setq l cdr l

nextl l

when l rplacd l l

sortl l function with one argument

Performs a physical alphab etic sort of the list l

In LELISP sortl could b e dened in the following manner

defun sortl l sort alphalessp l

FUNCTIONS ON SYMBOLS

mapcar sortl

requiem aeternam dona eis domine

et lux perpetua luceat eis

in memoria aeterna eris justus

ab auditione mala non timebit

aeternam domine dona eis requiem

eis et luceat lux perpetua

aeterna eris in justus memoria

ab auditione mala non timebit

sortp l function with one argument

Performs a physical sort of the symb ols in the list l including packages

In LELISP sortp could b e dened in the following manner

defun sortp l sort pkgcmp l

defun pkgcmp s s

if eq packagecell s packagecell s

alphalessp s s

pkgcmp packagecell s packagecell s

sortp a ba z bca y ) a y z ba bca

sortn l function with one argument

Performs a physical numeric sort of the list l

In LELISP sortn could b e dened in the following manner

defun sortn l sort l

sortn )

Functions on symb ols

Functions that access symb ol values

The value cells of a symb ol are usually accessed by eval when it evaluates the symb ol eval always

checks whether a symb ol p ossesses a value If not it raises the errudv error The following two

sp ecial functions also allow access to symb ol values

boundp symb function with one argument

This functions checks whether the argument symb is a symb ol that has a value If so boundp

returns t Otherwise it returns With boundp you can avoid the raise of the errudv error for

CHAPTER PREDEFINED FUNCTIONS

an undened variable If the argument symb is not a symb ol boundp returns This function

cannot b e represented in LISP which has no means for representing undened values

boundp t ) t

boundp ) t because is identical to

boundp foofoo ) if foofoo has no value

symeval symb function with one argument

symeval returns the value of the symb ol symb This function is therefore equivalent to a call to

eval but it is a lot more ecient particularly for the compiler symeval has the same b ehavior as

eval and it raises the same errudv error if its argument is undened

setq foo bar ) bar

boundp foo ) t

symeval foo ) bar

symeval niema ) symeval undefined variable niema

In the last example it is assumed that niema has no value

Functions that mo dify symb ol values

defvar symb e special form

Even though variables do not need to b e declared it is go o d practice to dene global variables with

this function It assigns the value of e to the value of symb The expression e is evaluated but not

symb defvar returns symb as its value As with all other denition functions if the value of the

systemloadedfromfile symb ol is not it is added to the Plist of the symb ol symb under

the systemloadedfromfile prop erty

system loa de df ro mf ile variable

In LELISP defvar could b e dened in the following manner

df defvar var val

set var eval val

when systemloadedfromfile

putprop var

systemloadedfromfile

systemloadedfromfile

var

defvar foo ) foo

foo )

makunbou nd symb function with one argument

FUNCTIONS ON SYMBOLS

Changes the value of the symb ol symb in such a way that all future attempts to access its value

will raise the errudv error indicating an undened variable makunbound returns s as its value

setq x )

x )

makunbound x ) x

x ) eval undefined variable x

set symb s function with two arguments

Changes the value of the symb ol symb into s set returns s as its value

set x )

x )

setq sym s ::: sym s special form

n n

sym ::: sym are symb ols that are not evaluated

n

s ::: s are expressions that are evaluated setq is the initialization function that is used

n

most often in LISP Each symb ol sym is initialized with the value of the corresp onding

i

expression s The initializations and evaluations of the expressions s are carried out in

i i

sequence setq returns the result of the evaluation of s as its value

n

setq l a b c ) a b c

setq l l ) a b c

setq l l l foo ) foo

l ) a b c

setqq sym e ::: sym e special form

n n

setqq is identical to setq except that the values assigned to the symb olsthat is the expressions

e are not evaluated

i

setqq a b x y z c b ) b

b ) x y z

c ) b

psetq sym s ::: sym s special form

n n

psetq is identical to setq except that the assignments take place in paral lel It is very useful for

p ermuting variable values psetq returns s as its value

In LELISP psetq could b e dened in the following manner

df psetq l

let lvar lval

while l newl lvar nextl l

newl lval eval nextl l

CHAPTER PREDEFINED FUNCTIONS

while lvar set nextl lvar nextl lval

setq x y z )

psetq x y y z z x )

x )

y )

z )

deset l l function with two arguments

deset implements the destructuring set of the nil system White The argument l is a tree of

variables and l is a list of values deset assigns the values in the tree of values to the corresp onding

variables in the tree of variables

deset uses the same algorithm as the evaluator for binding a tree of parameters to a list of

values deset always returns t as its value

In LELISP deset could b e dened in the following manner

defun deset l l

cond null l

or null l

error deset errwna l

variablep l set l l t

atom l error deset errbpa l

and consp l consp l

deset car l car l

deset cdr l cdr l

t error deset errilb list l l

deset a b c ) t

a )

b )

c )

desetq l l special form

desetq is equivalent to the preceding function except that the rst argument is not evaluated :::

as in setq

The form

desetq l l

is therefore equivalent to

deset quote l l

nextl sym sym special form

FUNCTIONS ON SYMBOLS

sym must b e a symb ol and its value must b e a list It is not evaluated nextl returns the car of

this list as its value and assigns the cdr of this list to the value cell of sym If the second argument

sym is supplied it to o must b e a symb ol which is not evaluated In this case the return value of

nextlthe car of symis assigned to sym

This function is useful for moving down through a list that is the value of a certain symb ol

With a single argument this function corresp onds to

prog car symb setq symb cdr symb

With two arguments it corresp onds to

prog setq sym car sym

setq sym cdr sym

setq a x y z ) x y z

nextl a ) x

a ) y z

nextl a b ) y

a ) z

b ) y

newl symb s special form

symb must b e a symb ol and its value must b e a list It is not evaluated newl puts the value of s

at the head of this list and returns the resulting list as its value The combined use of the nextl

and newl functions makes it easy to implement stacks as lists

In LELISP newl could b e dened in the following manner

defmacro newl symb s

setq symb cons s symb

setq a x y z ) x y z

newl a w ) w x y z

a ) w x y z

newr symb s special form

symb must b e a symb ol and its value must b e a list It is not evaluated newr adds the value of s

to the tail of this list and returns the resulting list as its value If the value of symb is not a list

newr creates the list s and assigns it to the value cell of symb

In LELISP newr could b e dened in the following manner

defmacro newr symb s

setq symb nconc symb ncons s

setq a x y z ) x y z

newr a w ) x y z w

CHAPTER PREDEFINED FUNCTIONS

a ) x y z w

setq b )

newr b z ) z

b ) z

incr symb n special form

symb must b e the name of a symb ol that has a numeric value If the argument n is supplied incr

increments the value of symb by the value of the expression n Otherwise it increments symb by

one This function uses generic arithmetic incr raises an error if symb is not a variable

incr symb n is equivalent to setq symb symb n

incr symb is equivalent to setq symb symb

In LELISP incr could b e dened in the following manner

df incr var val

if variablep var

set var

if consp val

symeval var eval car val

symeval var

error incr errnva var

setq x )

incr x )

x )

incr x )

incr x )

incr x )

x )

decr symb n special form

symb must b e the name of a symb ol that has a numeric value If the argument n is supplied decr

decrements the value of symb by the value of the expression n Otherwise it decrements symb by

one This function uses generic arithmetic decr raises an error if symb is not a variable

decr symb n is equivalent to setq symb symb n

decr symb is equivalent to setq symb symb

In LELISP decr could b e dened in the following manner

df decr var val

if variablep var

set var

if consp val

symeval var eval car val

FUNCTIONS ON SYMBOLS

symeval var

error decr errnva var

setq x )

decr x )

x )

decr x )

decr x )

decr x )

Functions on Plists

The term Plists stands for prop erty lists which are comp osed of indicators and values that have

the following structure

indic val indic val ::: indic val

n n

Each indicator indic is followed immediately in the Plist by its asso ciated value val Searches

i i

on Plists therefore take place in a twoelementsatatime fashion

Each symb ol has its own Plist which is initialize d to the value at the creation of the symb ol

The arguments of functions on Plists can b e describ ed as follows

 pl is a symb ol whose Plist is to b e accessed Functions on Plists raise the errnaa or errnva

errors if this argument is not a symb ol or if it is equal to

 ind is an indicator It must b e a symb ol since searches on indicators are carried out with the

eq predicate

 pval can b e any expression

plist pl l function with one or two arguments

If the argument l is not supplied plist returns the Plist asso ciated with the symb ol pl If pl has

no Plist plist returns If the argument l is supplied it b ecomes the new value of the Plist

of the symb ol pl and is returned by plist as its value

plist cannot b e describ ed in LELISP in a simple manner

plist computer tool scientific toy expensive ) tool scientific toy expensive

plist computer ) tool scientific toy expensive

getprop pl ind function with two arguments

get pl ind function with two arguments

These functions return the value in the Plist of the symb ol pl that is asso ciated with

the indicator ind If there is no such indicator in the Plist getprop and getwhich are

identicalreturn

CHAPTER PREDEFINED FUNCTIONS

Warning A value of would b e returned if it is the value asso ciated with an indicator in a

Plist On the other hand this same value might b e returned b ecause getprop did not nd

a given indicator in the Plist There is no way of distinguishing b etween these two cases

Concerning this problem see the following function

In LELISP getprop could b e dened in the following manner

defun getprop pl ind

letn get pl plist pl

cond atom pl

eq car pl ind cadr pl

t when consp cdr pl

get cddr pl

plist computer ) tool scientific toy expensive

getprop computer tool ) scientific

getprop computer intelligence )

getl pl l function with two arguments

l must b e a list of indicators getl determines whether one of the indicators in l exists in the Plist

of the symb ol pl If so getl returns the sublist of the Plist b eginning with this indicator This

b eing the case getl provides the means to resolve the p otential ambiguity arising with the use of

the previous function

In LELISP getl could b e dened in the following manner

defun getl pl l

pl a plist

l a list of indicators

letn getl pl plist pl

cond

atom pl

memq car pl l pl

t when consp cdr pl

getl cddr pl

plist rose noun common nature flower ) noun common nature flower

getl rose nature noun ) noun common nature flower

getl rose size nature ) nature flower

getl rose type size )

addprop pl pval ind function with three arguments

addprop adds the indicator ind and its asso ciated value pval to the head of the Plist of the symb ol

pl It returns pval as its value

In LELISP addprop could b e dened in the following manner

FUNCTIONS ON SYMBOLS

defun addprop pl pval ind

plist pl mcons ind pval plist pl

plist plt i a i b ) i a i b

addprop plt c i ) c

plist plt ) i c i a i b

putprop pl pval ind function with three arguments

If the indicator ind already app ears in the Plist of the symb ol pl its asso ciated value is changed

to pval Otherwise the indicator ind and the value pval are addedin that orderto the head

of the Plist ::: in the same manner as for addprop putprop returns pval as its value

In LELISP putprop could b e dened in the following manner

defun putprop pl pval ind

letn put p plist pl

cond atom p addprop pl pval ind

eq car p ind

rplaca cdr p pval pval

t put when consp cdr p

cddr p

pval

plist plt i a i b ) i a i b

putprop plt c i ) c

plist plt ) i c i b

putprop plt i )

plist plt ) i i c i b

defprop pl pval ind special form

defprop is the fsubr version of the preceding function In other words it is the same as defprop

except for the fact that it do es not evaluate its arguments It is useful in the case of arguments

that are all constants

plist pink )

defprop pink price )

defprop pink red color ) red

plist pink ) color red price

remprop pl ind function with two arguments

remprop removes the indicator ind and its asso ciated value from the Plist asso ciated with the

symb ol pl This removal only takes place of course if ind was present in the Plist In this case

remprop returns the sublist of the original Plist b eginning with ind Otherwise it returns

The combined use of the remprop and addprop functions facilitates the use of Plists as prop erty

value stacks

CHAPTER PREDEFINED FUNCTIONS

In LELISP remprop could b e dened in the following manner

defun remprop pl ind

letn rem pl pl pl plist pl

cond atom pl

eq car pl ind

if atom pl

plist pl

when consp cdr pl

cddr pl

rplacd pl

when consp cdr pl

cddr pl

t rem pl

when consp cdr pl

cddr pl

plist plt i a i b ) i a i b

remprop plt i ) i b

plist plt ) i a

Access to function denitions

LELISP manages function denitions by means of two intrinsic prop erties asso ciated with each

symb ol

 ftype the function type

 fval the function value

The functions in this section are indep endent of packages For an explanation of how to access a

function in a particular package see the entries for the getfn and getfn functions

typefn symb function with one argument

typefn returns the typ e of the function asso ciated with the symb ol symb or if the symb ol has no

function denition The typ e of a function can b e one of the following symb ols expr fexpr macro

dmacro subr subr subr subr nsubr fsubr msubr or dmsubr This function provides a

means of determining whether the error errudf will b e raised when the symb ol symb is used as

a function typefn cannot b e represented in LISP which is incapable of representing undened

functions

typefn cond ) fsubr

typefn foofoo ) if foofoo has no function value

valfn symb function with one argument

FUNCTIONS ON SYMBOLS

valfn returns the function value asso ciated with the symb ol symb or if it has none This value

is an address for subr or fsubrtyp e functions and a list in the case of exprs fexprs macros

and dmacros

setfn symb ftype fval function with three arguments

setfn allows you to initialize the function typ e ftype and the function value fval asso ciated

with the symb ol symb setfn is used as a denition function in the case of computed function

names

Warning setfn p erforms only limited validity testing on its arguments Whenever p ossible

it is preferable to use true denition functions that verify the validity of the function

setfn foo expr x x x ) foo

typefn foo ) expr

valfn foo ) x x x

resetfn symb ftype fval function with three arguments

resetfn allows you to change the typ e ftype and the value fval of the function asso ciated

with the symb ol symb It also assures that they are b oth compatible with the previous function

denition If this is not the case and if the systemredefflag ag is equal to which is the

default value the following message is printed

resetfn incompatible function symb

resetfn is used by the standard denition functions to assure the compatibility of calls

b etween compiled and interpreted functions

resetfn foo expr x x x ) foo

typefn foo ) expr

valfn foo ) x x x

findfn s function with one argument

findfn searches the entire oblist for the symb ol whose function value is equal to s If found it

returns this symb ol Otherwise it returns

In LELISP findfn could b e dened in the following manner

defun findfn s

tag found

mapoblist

lambda symb

when eq valfn symb s

exit found symb

defun foo x x ) foo

CHAPTER PREDEFINED FUNCTIONS

valfn foo ) x x

findfn valfn foo ) foo

remfn symb function with one argument

remfn removes the function denition asso ciated with the symb ol symb It returns symb as its value

defun foo x x x ) foo

foo )

remfn foo ) foo

foo ) eval undefined function foo

makedef symb ftyp fval function with three arguments

makedef builds the denition of the function named symb using the ftyp and fval comp onents

within a denitionthat is within a call to one of the de df dm defmacro or ds functions

In LELISP makedef could b e dened in the following manner

defun makedef x typefn valfn

selectq typefn x

subr subr subr subr nsubr fsubr msubr dmsubr

list ds x typefn valfn

expr mcons defun x valfn

fexpr mcons df x valfn

macro mcons dm x valfn

dmacro mcons defmacro x valfn

t

makedef f expr x x x ) defun f x x x

getdef symb function with one argument

getdef allows you to retrieve the denition of the function asso ciated with the symb ol symb in the

form of its denition that is in the form of a call to one of the defun df dm defmacro or ds

functions

In LELISP getdef could b e dened in the following manner

defun getdef x

if symbolp x

makedef x typefn x valfn x

error getdef errsym x

defun bar n n n ) bar

typefn bar ) expr

getdef bar ) defun bar n n n

FUNCTIONS ON SYMBOLS

revert symb function with one argument

revert allows you to retrieve the former denition asso ciated with a symb ol symb if this denition

was previously saved by a static denition function See the description of these functions

In LELISP revert could b e dened in the following manner

defun revert symb

let oldef getprop symb systempreviousdef

when oldef eval oldef

synonym sym sym function with two arguments

synonym lets you assign to the symb ol sym the typ e and value of the function asso ciated with the

symb ol sym

In LELISP synonym could b e dened in the following manner

defun synonym at at

let ftype typefn at fval valfn at

if ftype

setfn at ftype fval

error synonym errudf at

synonym kons cons ) kons

kons a b ) a b

synonymq sym sym special form

This function is the fsubr form of the preceding function In other words it is identical except for

the fact that it do es not evaluate its arguments

In LELISP synonymq could b e dened in the following manner

df synonymq sym sym

synonym sym sym

There is an alternative denition

defmacro synonymq sym sym

list synonym sym sym

synonymq foo bar is equivalent to synonym foo bar

Access to symb ol sp ecial elds

objval symb s function with one or two arguments

CHAPTER PREDEFINED FUNCTIONS

objval retrieves the oval eld of the symb ol symb If the second argument s is supplied it

b ecomes the new value of this eld This function cannot b e describ ed in LELISP in an easy

manner

objval gee )

objval gee haugh ) haugh

objval gee ) haugh

packagec ell symb pkgc function with one or two arguments

If the second argument is not supplied this function reads the package eld pkgc of the symb ol

symb If this argument is supplied it b ecomes the new package of the symb ol This function cannot

b e describ ed in LELISP in an easy manner

defvar x satorarepotenetoperarotas ) x

packagecell x ) satorarepotenetopera

packagecell packagecell x ) satorarepotenet

packagecell packagecell packagecell x ) satorarepo

packagecell x entopan ) entopan

x ) entopanrotas

getfn pkgc symb function with two arguments

getfn returns the symb ol pkgcsymb if the symb ol symb has a function denition in the package

pkgc

In LELISP getfn could b e dened in the following manner

defun getfn pkgc symb

let nom symbol pkgc symb

if typefn nom

nom

getfn car ) car

defun foobar ) foobar

getfn foo bar ) foobar

getfn gee bar )

getfn pkgc symb lastpkgc function with two or three arguments

getfn searches in the package pkgc for a symb ol named symb that has an asso ciated function

denition It it nds none it continues searching through the package hierarchy up to but excluding

the package lastpkgc or to the top of the hierarchyto the global package if lastpkgc is

not sp ecied getfn returns the name of this function if it was found or if not If found the

function name could then b e used as the rst argument to the apply or funcall functions for

example getfn is used inside the interpreter to manage programmable interrupts the starting up

of macros and the control of the virtual terminal

FUNCTIONS ON SYMBOLS

In LELISP getfn could b e dened in the following manner

defun getfn pkgc symb lastpkgc

let name symbol pkgc symb

cond typefn name name

null pkgc

and consp lastpkgc

eq packagecell pkgc

car lastpkgc

t getfn packagecell pkgc

symb lastpkgc

defun foo ) foo

defun barfoo ) barfoo

defun bargeebuzfoo ) bargeebuzfoo

getfn bargeebuz foo ) bargeebuzfoo

getfn bargee foo ) barfoo

getfn bar foo ) barfoo

getfn foo ) foo

getfn potopteraz foo ) foo

getfn bargee foo ) barfoo

getfn bar foo ) barfoo

getfn gee foo )

getfn bargeebuz foo bar ) bargeebuzfoo

getfn bargee foo bar )

Symb ol creation functions

Symb ols are managed by means of a hash table shared among all the packages The external

representation of a symb ol outside the current package is packagesymbol See the information

on inputoutput functions

symbol pkgc strg function with two arguments

symbol creates a new symb ol named strg in the package named pkgc If the pkgc argument is

the ro ot package is used This function cannot b e describ ed in LELISP in an easy manner

symbol foo bar ) foobar

symbol fuu ) fuu

concat str ::: str function with a variable number of arguments

n

Creates a new symb ol whose pname is built by concatenating all the strings str ::: str

n

In LELISP concat could b e dened in the following manner

CHAPTER PREDEFINED FUNCTIONS

defun concat lpname

symbol mapcan pname lpname

concat foo bar ) foobar

concat foo nil bar ) foobar

gensym function with no arguments

Each time it is called gensym returns a new symb ol of typ e Gxxx In this typ e name G is a string

stored in the systemgensymstring system variable and xxx is a numb er that is incremented

by one after each call to gensym This numb er is the value of the gensym counter which is stored in

the systemgensymcounter system variable When the interpreter starts up G and xxx have

the resp ective values of g and

In LELISP gensym could b e dened in the following manner

defvar systemgensymstring g

defvar systemgensymcounter

defun gensym

concat systemgensymstring

incr systemgensymcounter

gensym ) g

gensym ) g

gensym ) g

let systemgensymstring etiq gensym ) etiq

Symb ol management functions

oblist pkgc symb function with zero one or two arguments

If oblist is called with no arguments it returns the lengthy list of all the symb ols present in

the system At system initialization this list contains the names of all predened functions and

variables Since this list is very long often of the order of two thousand symb ols you are advised

to use the mapoblist mapcoblist or maploblist functions to sequentially access these symb ols

The two optional arguments provide means of ltering the oblist

If the rst argument pkgc is supplied it must b e a symb ol that designates the package from

which the symb ols are to b e extracted If the second argument symb is supplied it to o must b e

a symb ol that designates the name of the symb ols since there could b e multiple instances of symb

in the oblist in dierent packages A call such as oblist pkgc symb is therefore an eective

means of testing whether a symb ol is present in a certain package without creating it if it was not

already there It is not p ossible to dene this function in LISP To do so we would need a means of

accessing the alink and pname intrinsic prop erties of the symb ols and only the functions loc

and memory provide such a means

oblist )

FUNCTIONS ON SYMBOLS

assoc sin cadadr funcall typecn eqn tracend plist

systemvar var nom symbolp get addadr load letvq

curread false plength cddadr fileout pairlis ex

libload systemlengthfloat quo inbuf untilexit xdef

oblist sharp )

sharp sharpvalue sharp sharp sharp

sharp sharp sharp sharp sharp

sharp sharp sharp sharp

lhoblist strg function with one argument

lhoblist returns the list of all the symb ols that contain strg as a substring in their name This

function therefore provides a way of ltering the symb ols of the oblist It is useful for nding the

exact sp elling of a function name

In LELISP lhoblist could b e dened in the following manner

defun lhoblist pname

maploblist lambda symb index pname symb

lhoblist apc ) mapc mapcon mapcan mapcar mapcoblist

lhoblist string )

string duplstring makestring fillstring eqstring

prinstring spanstring readstring bltstring substring

systemgensymstring scanstring stringp

boblist n function with an optional argument

If the argument n is not present boblist returns the list of buckets of the global symb ol hash table

th

of the system If the argument n is provided boblist returns the n bucket This function cannot

b e describ ed easily in LISP

 To obtain the size of the hash tablethat is the numb er of bucketstyp e

length boblist

 To obtain a list of the sizes of all the buckets typ e

mapcar length boblist

 To obtain the size of the largest bucket typ e

apply max mapcar length boblist

 To obtain a copy of the bucket where a symb ol lives typ e

boblist hash symb

CHAPTER PREDEFINED FUNCTIONS

remob symb function with one argument

remob removes the values of all the intrinsic prop erties of the symb ol symb so that it b e destroyed

during the next garbage collection ::: provided that there are no other p ointers to symb

In LELISP remob could b e dened in the following manner

defun remob symb

makunbound symb

plist symb

remfn symb

objval symb

symb

To recover all the symb ols of a package enter

mapc remob oblist pkgc

The mapoblist mapcoblist and maploblist functions are describ ed in the section on

application functions

Functions on character strings

A character string is a collection of characters accessible by their index which is a numb er Indexes

of character strings b egin at zero Each character string also p ossesses its own symb olic typ e By

default this typ e is string but it can b e changed with the typestring function

The external representation of a character string of typ e string is xxxxxxxxx The external

representation of a character string of any other typ e is typexxxxxxxxx

For all these functions the strg argument must b e of the typ e known as character string If it is

not of this typ e it will b e automatically converted to an ob ject of this typ e by the string function

This conversion do es not o ccur in the case of the basic stringmanipulation functions slen sref

sset typestring and exchstring

If the conversion is not p ossible the errnsa error is raised Its default screen display is

fn non string argument s

where the faulty ob ject s is displayed along with the name of the function fn that raised the

error

The functions makestring fillstring set chset and chrpos used for the manipulation of

character strings take as argument a character in the range In other words a mo dulo

op eration is p erformed automatically

Since the size of a string is limited to k characters the catenate and duplstring string

creation functions might raise the errstl error which has the following default screen display

fn string too long s

FUNCTIONS ON CHARACTER STRINGS

Here the maximum size s is displayed along with the name of the function fn that raised the

error

In the case of the basic functions attempts to access a character b eyond the string b oundaryits

maximum legal index valueraises the erroob error which has the following default screen display

fn out of bounds s

where the faulty index s is printed along with the name of the function fn that raised the error

The characterstring test predicate stringp is describ ed in the section on basic predicates

To describ e these functions in LISP we shall use the basic pname function which provides a way of

converting from the internal representation of a pname to its representation in the form of internal

character co des These descriptions do not reect the real implementation details of the functions

which obviously involve no list cells

Basic manipulation functions

These functions are the basic primitives for use on character strings They are sucient to dene

all other functions on character strings

slen strg function with one argument

slen returns the length of the character string strg The typ e test on the argument is not p erformed

after compilation in op en mo de For reasons of eciency slen compiles into a single LLM

instruction This function cannot b e describ ed easily in LISP

slen abc )

slen )

slen t ) slen non string argument t

sref strg n function with two arguments

th

sref returns the n character in the string strg If n is b eyond the limit of strg the erroob error

is raised This test for overow as well as the typ e test are not p erformed however after co de is

compiled in op en mo de For reasons of eciency sref compiles into a single LLM instruction

This function cannot b e describ ed easily in LISP

setq x abcdef ) abcdef

sref x ) that is a

sref x ) that is f

sref t ) sref non string argument t

sref x ) sref argument out of bounds

sref x ) sref argument out of bounds

sset strg n cn function with three arguments

CHAPTER PREDEFINED FUNCTIONS

th

sset sets the value if the n character in the string strg to cn If n is b eyond the limit of the

string strg the erroob error is raised This test for overow as well as the typ e test are not

p erformed however after co de is compiled in op en mo de For reasons of eciency sset compiles

into a single LLM instruction This function cannot b e describ ed in LELISP in an easy manner

setq x abcdef ) abcdef

sset x y ) that is y

sset x z ) that is z

x ) ayczef

sset x t ) sset argument out of bounds

sset x t ) sset argument out of bounds

typestri ng strg symb function with one or two arguments

The second argument if supplied b ecomes the new typ e of the character string strg In general

this symb typ e is a symb ol But it could b e a list of symb ols allowing you to carry out multiple

inheritance For further details lo ok up the topic of ob jectoriented programming The typestring

function returns the new typ e of strg

The typeof function applied to a string returns the value of typestring applied to the string

The typestring function cannot b e describ ed easily in LISP

setq s abc ) abc

typestring s ) string

typeof s ) string

typestring s foo ) foo

typestring s ) foo

s ) fooabc

typeof s ) foo

typestring t ) typestring non string argument t

typestring v bar ) typestring not a symbol bar

exchstri ng strg strg function with two arguments

This rather esoteric function provides a means of physically exchanging the values and typ es of the

strings strg and strg exchstring returns the mo died strg string that is the one that was

initially called strg This function cannot b e describ ed easily in LISP

setq v abc w de ) de

typestring v foo ) foo

setq y v z w ) de

exchstring v w ) de

v ) de

w ) fooabc

y ) de

z ) fooabc

FUNCTIONS ON CHARACTER STRINGS

Character string conversion

string s function with one argument

string converts the argument s into a character string The sequence of characters of this string

is determined by the following rules

 If s is the empty listthat is the sequence is empty

 If s is a symb ol the sequence is nothing other than the sequence of characters of the

symb ols external name its pname

 If s is a character string the sequence is just this sequence of characters

 If s is a list it is assumed to b e a list of internal character co des and must not b e more

than in length

If one of these conditions is not met the errnsa error is raised

string )

string )

string foo ) foo

string bar ) bar

string )

string )

string abc ) abc

string makelist x ) xxxxx

pname strg function with one argument

pname returns the string strg in the form of a list of internal character co des This function which

dep ends on internal LISP representations cannot b e simply describ ed in LISP

pname )

pname nil )

pname nil )

pname foobar )

pname )

pname abcdef )

pname abc )

plength strg function with one argument

slength strg function with one argument

These functions return the numb er of characters in the string strg as their values There is

no dierence b etween the two

In LELISP plength could b e dened in the following manner

CHAPTER PREDEFINED FUNCTIONS

defun plength strg

length pname strg

plength )

plength nil )

plength nil )

plength foobar )

plength )

plength sobota )

plength dzien )

hash strg function with one argument

Returns the internal hash algorithm key for the string strg The p erformance of this algorithm

can b e measured by using the boblist function The following description is only given by way of

explanation and the actual implementation is much sp eedier

In LELISP hash could b e dened in the following manner

defun hash strg

rem logand hashaux pname strg fff

length boblist

defun hashaux pn

if length pn

hashcount length pn pn length pn

hashcount

lastn pn

hashcount

firstn pn

length pn

defun hashcount count pn val

setq pn reverse pn

repeat count

setq val add logshift val nextl pn

val

hash )

hash nil )

hash foobar )

hash )

hash abcdef )

hash galamantdelareine )

hash abcd )

FUNCTIONS ON CHARACTER STRINGS

Comparison of character strings

eqstring str str function with two arguments

Tests whether the two argumentsof typ e character string are equal If they are eqstring

returns str If not it returns

In LELISP eqstring could b e dened in the following manner

defun eqstring str str

and slength str slength str

eq typestring str typestring str

equal pname str pname str

eqstring foo bar )

eqstring foo foo ) foo

eqstring Foo foo )

eqstring string catenate )

alphales sp str str function with two arguments

Returns t if the pname of str is lexicographically less than or equal to the pname of str

Otherwise it returns This function is used to p erform alphab etic sorts See the sortl function

In LELISP alphalessp could b e dened in the following manner

defun alphalessp str str

letn alphal lst pname str lst pname str

cond null lst t

null lst

car lst car lst

alphal cdr lst cdr lst

t if car lst car lst t

alphalessp a a ) t

alphalessp b a )

alphalessp a b ) t

alphalessp zzz zzzz ) t

Characterstring creation functions

catenate str ::: str function with a variable number of arguments

n

catenate builds a new string the result of the concatenation of the strings str ::: str

n

The newlyformed string cannot b e longer than k characters or the errstl error will

b e raised

This function is not to b e confused with the concat function which creates a symb ol

CHAPTER PREDEFINED FUNCTIONS

In LELISP catenate could b e dened in the following manner

defun catenate lst

string mapcan pname lst

catenate foo bar ) foobar

catenate )

catenate nil )

makestri ng n cn function with two arguments

Returns a string of n characters each of which has cn as its internal character co de

In LELISP makestring could b e dened in the following manner

defun makestring n cn

string makelist n cn

makestring a )

makestring a ) aaaa

makestring a )

substrin g strg n n function with two or three arguments

Returns a copy of the substring of strg that starts at p osition nstarting with count zeroand

has length n If this last argument is not supplied the returned substring is the maximal substring

b eginning at p osition n That is it extends to the end of strg

In LELISP substring could b e dened in the following manner

defun substring strg n n

string firstn if consp n

car n

plength strg

n

nthcdr n pname strg

substring abcde ) abc

substring abcde ) bc

substring abcde ) cde

substring abcde )

duplstri ng n strg function with two arguments

Makes a string of n copies of the string strg

The resulting string cannot b e longer than k characters long otherwise the errstl error

is raised

In LELISP duplstring could b e dened in the following manner

FUNCTIONS ON CHARACTER STRINGS

defun duplstring n strg

if n

catenate strg duplstring n strg

duplstring ab ) ababab

duplstring )

duplstring abc ) abc

duplstring abc )

Characterstring access functions

These functions provide means to manipulate single characters within a character string

chrpos cn strg pos function with two or three arguments

chrpos returns the p osition of the internal character co de cn in the string strg If the third

argument is not supplied the p osition of the rst character in strg is presumed to b e zero

Otherwise it is presumed to b e pos If the co de cn do es not o ccur in the string chrpos returns

chrpos can therefore b e used as a predicate for testing the presence of a character in a string

In LELISP chrpos could b e dened in the following manner

defun chrpos cn strg pos

letn chrp lcn pname strg

n if consp pos

car pos

cond null lcn

eq car lcn cn n

t chrp cdr lcn n

chrpos y otyoty )

chrpos n oty )

chrpos d abcdef )

chrpos a abc )

chrnth n strg function with two arguments

th

chrnth returns the internal character co de of the n character in the string strg The p osition

th

or index of the rst character is zero not one So there is no n character in the string when n

> length strg or n < In such a case chrnth returns

In LELISP chrnth could b e dened in the following manner

defun chrnth n strg

nth n pname strg

CHAPTER PREDEFINED FUNCTIONS

chrnth Fob ) that is F

chrnth FoB ) that is B

chrnth fob )

chrnth fob )

chrnth ABcdE ) that is A

chrset n strg cn function with three arguments

th

chrset provides a means of changing the n character in the string strg to the character with

internal character co de cn This internal character co de is returned by chrset as its value The

p osition or index of the rst character in a string is zero This function which physically mo dies

the string cannot b e describ ed in LISP

setq x abc ) abc

chrset x A ) that is A

x ) Abc

Functions that physically mo dify strings

These physicalmo dication functions can b e describ ed in LISP using the chrset function

bltstrin g str n str n n function with four or ve arguments

Copies n characters from the string str b eginning at p osition n into the string str b eginning

at p osition n All indexes are relative to zero If the n argument is not included the whole of

str b eginning at p osition n will b e transferred This happ ens up to the limit of str which is

never extended by this function bltstring returns the mo died str string str and str can

b e the same physical string So it is p ossible to write over the contents of a string with the string

itself using any combination of valid index values

In LELISP bltstring could b e dened in the following manner

defun bltstring str n str n n

Does not treat the shared strings nor limit cases

repeat min if consp n

car n

slength str n

slength str n

chrset n str chrnth n str

incr n

incr n

str

bltstring foobar xyz ) fzobar

bltstring foobar xyz ) fxyzar

bltstring foobar toto ) ftotor

bltstring foobar toto ) footot

FUNCTIONS ON CHARACTER STRINGS

setq strt abcdefghij ) abcdefghij

bltstring strt strt ) adefgfghij

bltstring strt strt ) adefgfadij

bltstring strt strt ) gfadgfadij

fillstri ng strg n cn n function with three or four arguments

th

Fills the string strg with n characters having internal character co de cn b eginning at the n

character If the argument n is not given or if n n is longer than the length of the string the

string will b e lled only through its last character p osition and not extended fillstring returns

the mo died string as its value

In LELISP fillstring could b e dened in the following manner

defun fillstring strg n cn n

repeat if consp n

min car n slength strg n

slength strg n

chrset n strg cn incr n

fillstring foobar x ) fxxbar

fillstring foobar y ) yyybar

fillstring foobar x ) foxxxx

fillstring foobar x ) foxxxx

Search functions on character strings

index str str n function with two or three arguments

Determines whether the argument str is a substring of the tail of str that b egins at character

p osition n If so index returns the index counting from zero in str of the rst instance of this

substring Otherwise it returns

If the n argument is not supplied the search starts with zero

In LELISP index could b e dened in the following manner

defun index str str n

letn inxaux p pname str

p nthcdr or car n

pname str

n n

cond length p length p

car p car p

inxaux p cdr p n

t letn inxaux pp cdr p

pp cdr p

CHAPTER PREDEFINED FUNCTIONS

cond null pp n

car pp car pp

inxaux cdr pp

cdr pp

t inxaux p cdr p

n

index foo foobar )

index bar foobar )

index foo xfoobar )

index foo xfoobar )

index foo xfoobar )

index foo )

index foo )

substrin ge qu al size strg pos strg pos function with ve arguments

Compares the substring of length size b eginning at p osition pos in strg with the substring

of the same length b eginning at p osition pos in strg This comparison is carried out without

creating a new string substringequal returns size if the comparison succeeds or if it do es

not substringequal can raise the erroob errnia and errnsa errors

In LELISP substringequal could b e dened in the following manner

defun substringequal size strg pos strg pos

this description includes no tests for value validity

letn substrgeq count size

cond eq count size

eq sref strg pos sref strg pos

substrgeq sub count strg add pos

strg add pos

t

substringequal fobar gezu )

substringequal fobar fobar )

substringequal fobara fobar )

substringequal fobar fobara )

substringequal fobar afob )

substringequal fobar afab )

substringequal fobar afar )

scanstri ng str str n function with two or three arguments

Searches from character p osition n relative to zero the default value of this argument in the string

str for characters o ccurring in the string str scanstring returns the indexagain relative to

zeroof the rst character in str that matches any of those in str or if no such thing exists

scanstring abcd sbe )

FUNCTIONS ON CHARACTERS

scanstring abcd efg )

scanstring abcd a )

scanstring abc defghc )

scanstring foo )

spanstri ng str str n function with two or three arguments

Searches from character p osition nrelative to zero the default value of this argumentin the

string str for a character not o ccurring in the string str spanstring returns the indexagain

relative to zeroof the rst character of str that do es not o ccur in str or if no such thing

exists

spanstring abcb ab )

spanstring abcd aabbccdd )

spanstring abcd bcd )

spanstring foo )

Functions on characters

These functions manipulate internal character co des Throughout this section an internal character

co de is denoted by cn Character co ding used in LELISP is mainly ascii

ascii cn function with one argument

Returns the character whose ascii co de is cn mo dulo A character is a LELISP ob ject with a

singlecharacter pname

ascii ) C

ascii ) c

ascii )

cascii ch function with one argument

Returns the ascii co de of the character ch

cascii c )

cascii )

uppercas e cn function with one argument

If cn is the internal character co de of a lowercase character then uppercase returns the co de of

the corresp onding upp ercase character If not the function returns cn unchanged

uppercase a ) that is A

uppercase A ) that is A

uppercase ) that is

CHAPTER PREDEFINED FUNCTIONS

lowercas e cn function with one argument

If cn is the internal character co de of a upp ercase character then lowercase returns the co de of

the corresp onding lowercase character If not the function returns cn unchanged

lowercase ) that is

lowercase A ) that is a

lowercase z ) that is z

asciip cn function with one argument

Tests whether cn is in fact an internal character co de that is a small integer in the range

inclusive If so it returns the co de itself If not it returns

asciip )

asciip )

asciip )

asciip )

asciip )

digitp cn function with one argument

Tests whether cn is the internal character co de of a decimal numeral If so it returns the co de If

not it returns

digitp ) that is

digitp ) that is

digitp )

digitp )

letterp cn function with one argument

Tests whether cn is the internal character co de of a letter If so it returns the co de If not it

returns

letterp a ) that is a

letterp z ) that is z

letterp A ) that is A

letterp Z ) that is Z

letterp sp )

letterp )

letterp )

Functions on vectors

The nal typ e of LELISP to b e presented is the vector of Sexpressions

FUNCTIONS ON VECTORS

A vector is a collection of LISP ob jects accessible by their index or ob ject numb er Vector indexes

b egin at zero

Each vector has its own symb olic typ e By default this typ e is vector but it can b e changed by

means of the typevector function

By default this typ e is vector but it can b e changed by using the typevector function

The external representation of a vector of any other typ e is

types s ::: s

n

In the following descriptions of functions the arguments designated by vect must b e of the vector

typ e Otherwise the errvec error is raised and the following default error screen will b e displayed

fn not a vector v

Here v is the faulty ob ject and fn is the name of the function that raised the error

Outofb ounds access attempts raise the erroob error which has the following default screen

display

fn out of bounds v

Here v is the faulty index and fn is the name of the function that raised the error

The vector test predicate vectorp is describ ed in the section on basic predicates

makevect or n s function with two arguments

Creates a new vector of typ e vector comprising n elements Each of these elements is initialized

with the value s If n is not a p ositive integer the errnia and erroob errors are raised makevector

returns the newlycreated vector as its value This function cannot b e describ ed satisfactorily in

LISP

makevector )

makevector a b ) a b a b a b

makevector a )

makevector ) makevector argument out of bounds

makevector t ) makevector not a fixnum t

vector s ::: s function with a variable number of arguments

n

Creates a new vector of typ e vector comprising n elements where n is the numb er of arguments

provided in the function call The elements are initialize d with the values s ::: s vector returns

n

this newlycreated vector as its value

In LELISP vector could b e dened in the following manner

defun vector lst

let vect makevector length lst

CHAPTER PREDEFINED FUNCTIONS

for i vlength vect

vset vect i nextl lst

vect

vector )

vector )

apply vector a b c ) a b c

vector foo a b c ) foo a b c

vlength vect function with one argument

Returns the numb er of elements in the vector vect This function cannot b e satisfactorily describ ed

in LISP The typ e test on the argument which is p erformed by the interpreter is not carried out

when co de is compiled in op en mo de For reasons of eciency vlength compiles into a single

LLM instruction

vlength )

vlength )

vlength t ) vlength not a vector t

vref vect n function with two arguments

th

Returns the n element of the vector vect If n go es b eyond the b oundary of vect the erroob error

is raised This b oundary check is not carried out however once the function has b een compiled in

op en mo de For reasons of eciency vref compiles into a single LLM instruction This function

cannot b e satisfactorily describ ed in LISP

setq x a b c d e f ) a b c d e f

vref x ) a

vref x ) f

vref t ) vref not a vector t

vref x ) vref argument out of bounds

vref x ) vref argument out of bounds

vset vect n e function with three arguments

th

Sets the value of the n element of the vector vect to the ob ject e If n go es b eyond the b oundary

of vect the erroob error is raised This b oundary check will not b e p erformed however when the

function has b een compiled in op en mo de For reasons of eciency vref compiles into a single

LLM instruction vset returns the new value of the element that is e This function cannot b e

describ ed in LELISP in a simple manner

setq x a b c d e f ) a b c d e f

vset x x y ) x y

vset x h i ) h i

x ) a x y c h i e f

vset x ) vset argument out of bounds

FUNCTIONS ON VECTORS

vset x ) vset argument out of bounds

typevect or vect symb function with one or two arguments

The second argument if it is supplied b ecomes the new typ e of the vector vect In general

this symb typ e is a symb ol But it could b e a list of symb ols allowing you to carry out multiple

inheritance For further details lo ok up the topic of ob jectoriented programming The typevector

function returns the new typ e of vect

The typeof function applied to a vector returns the value of typevector applied to the vector

This function cannot b e satisfactorily describ ed in LISP

setq v a b c ) a b c

typevector v ) vector

typeof v ) vector

typevector v foo ) foo

typevector v ) foo

v ) fooa b c

typeof v ) foo

typevector t ) typevector not a vector t

typevector v bar ) typevector not a symbol bar

eqvector vect vect function with two arguments

Tests whether the two argumentsb oth of which are vectorsare equal That is it tests whether

they b oth have the same typ e and the same numb er of elements and whether their elements are

equal according to the equal predicate

In LELISP eqvector could b e dened in the following manner

defun eqvector vect vect

cond not vectorp vect

error eqvector errvec vect

not vectorp vect

error eqvector errvec vect

and vlength vect vlength vect

eq typevector vect typevector vect

tag no

for i vlength vect

unless equal vref vect i

vref vect i

exit no

vect

t

eqvector )

eqvector )

eqvector foo )

CHAPTER PREDEFINED FUNCTIONS

eqvector foo foo ) foo

bltvecto r vect n vect n n function with ve arguments

Copies n elements of the vector vect b eginning at p osition n into the vector vect b eginning

at p osition n Both index values start at zero The vector vect is never extended bltvector

returns the mo died vect

In LELISP bltvector could b e dened in the following manner

defun bltvector vect n vect n n

Does not treat the shared vector nor limit cases

repeat n

vset vect n vref vect n

incr n

incr n

vect

bltvector f o o b a r x y z ) f z o b a r

bltvector f o o b a r t o t o ) f t o t o r

bltvector f o o b a r t o t o t a ) f o o t o t

bltvector setq v a b c d v ) c d c d

v ) c d c d

fillvect or vect n e n function with three or four arguments

Fills the vector vect b eginning at p osition n counting from zero with n expressions e of whatever

description If n is not supplied or if the sum of n and n is larger than the length of the vector

fillvector lls up to the end of vect and do es not extend it fillvector returns the mo died

vect as its value

In LELISP fillvector could b e dened in the following manner

defun fillvector vect n s n

repeat if consp n

min car n vlength vect n

vlength vect n

vset vect n s incr n

fillvector f o o b a r x ) f x x b a r

fillvector f o o b a r y ) y y y b a r

fillvector f o o b a r x ) f o x x x x

fillvector f o o b a r x ) f o x x x x

exchvect or vect vect function with two arguments

This rather esoteric function provides a way of physically exchanging the values and the typ es of

the vectors vect and vect It returns the mo died value of vect that is the previous value of

vect

FUNCTIONS ON ARRAYS

setq v a b c w d e ) d e

typevector v foo ) foo

v ) fooa b c

setq y v z w ) d e

exchvector v w ) d e

v ) d e

w ) fooa b c

y ) d e

z ) fooa b c

The mapvector function is describ ed in the section on application functions

Functions on arrays

array feature

This feature indicates whether the functions on array are loaded into memory

It is easy to implement multidimensional arrays with the functions of the preceding section

makearra y a ::: a s function with a variable number of arguments

n

Makes an array of a  a  :::  a  a elements all initialize d to the value s

n n

In LELISP makearray could b e dened in the following manner

defun makearray arg args

if consp args

let result makevector arg

for i arg

vset result i apply makearray args

result

arg

aref array i ::: i function with a variable number of arguments

n

Returns the value of the array array that has the index i ::: i Each index is relative to zero

n

In LELISP aref could b e dened in the following manner

defmacro aref inst args

cond null args inst

atom args error aref errwna args

t vref aref inst nreverse cdr reverse args

car last args

CHAPTER PREDEFINED FUNCTIONS

aset array i ::: i e function with a variable number of arguments

n

Provides a means of setting the value of the element of the array array to the value e The index

values are relative to zero aset returns e as its value

In LELISP aset could b e dened in the following manner

defmacro aset inst args

cond atom args error aref errwna args

consp cdr args

vset aref inst

nreverse cddr reverse args

cadr reverse args

car last args

t inst

setq x makearray )

aset x )

aref x )

x )

Hash tables

hash feature

This feature indicates whether the functions on hash tables are loaded into memory

LELISP version incorp orates a new data structure called hash tables for pro cessing pairs

comp osed of a key and a value These pairs are managed in a more ecient manner than in the

case of asso ciation lists Asso ciation lists cf section use a higher numb er of keys With the

hash table implementation search time is not a function of the numb er of elements in the table

but rather of a constant that dep ends only on the state of the hash table These hash tables are

adaptive They automatically minimize the search time constant as a function of the numb er of

currently active asso ciations and at the same time optimize the use of the memory space dedicated

to storing keyvalue asso ciations

There are two kinds of hash tables according to the function that is used to p erform key lo okups

 Tables using the eq predicate

 Hash tables using the equal predicate

The value of a hash tabletyp e ob ject is the hash table itself so there is no need to quote it

The external representation of a hash table dep ends on the systemprintforread ag If this

ag is false equal to the printed image of a table is

entriesHelements

where entries is the numb er of table entries and elements is the numb er of asso ciations actually

stored in the table If the ag is true not equal to the printed image of a hash table is

HASH TABLES

entriesHtype key value key value

n n

This imagewhich explicitly represents every asso ciation in the table and can in some cases b e

very longallows for the saving of a hash table ob ject so that it can b e subsequently read

In the description of each function presented in this section the ht argument must b e of the

hashtable typ e or else the errnht error will b e raised The default screen display of this latter is

fn not an hash table s

where s is the faulty argument and fn is the name of the function that raised the error

Similarly if the typ e of the hash table is incorrect the errbht error is raised Its default screen

display is

fn bad type for an hash table s

where s is the faulty ob ject and fn is the name of the function that raised the error

Hash table creation functions

There are currently two kinds of hash tables which dier according to how keys are retrieved One

kind uses the builtin eq predicate The other kind uses the equal predicate

makehas ht ab le eq function with no arguments

Returns a new hash table that tests keys using the eq predicate

makehas ht ab le eq ual function with no arguments

Returns a new hash table that tests keys using the equal predicate

hashtab le p obj function with one argument

This predicate returns obj if it is a hashtable ob ject of any typ e Otherwise it returns

Hash table access functions

gethash key ht default function with two or three arguments

Returns the value asso ciated with the key in the hash table ht If no key in ht matches key

gethash returns the value default if it is provided or if not

puthash key ht value function with three arguments

Adds the keyvalue pair comp osed of key and value to the hash table ht If the key existed already

in ht its value is changed to value puthash always returns value

CHAPTER PREDEFINED FUNCTIONS

remhash key ht function with two arguments

Removes the key and its asso ciated value from the hash table ht The function returns t if the key

existed in ht and if not

maphash fnt ht function with two arguments

Applies the function fnt to all the pairs in the hash table ht This function fnt exp ects to receive

two arguments The rst is a hashpair key and the second is its asso ciated value

clrhash ht function with one argument

Removes the entire contents of the hash table ht

hashtab le co unt ht function with one argument

Returns the numb er of keyvalue pairs stored in the table ht

setq ht makehashtableeq

H puthash k ht v

v gethash k ht

v gethash k ht

gethash k ht ko

ko ht

H

Mathematical sets

sets feature

This feature indicates whether the functions on sets are loaded into memory

LELISP includes functions that let you handle lists as if they were sets They enable you to p erform

op erations of the following kinds

 Add an element to a set

 Obtain the union of two sets

 Obtain the intersection of two sets

 Obtain the dierence b etween two sets

 Obtain the symmetric dierence b etween two sets

 Compare two sets to see if they are identical or if one is a subset of the other

MATHEMATICAL SETS

In a list argument that is meant to b e handled as a set the order of the elements is of no signicance

When such a list happ ens to b e returned as a function value the order of its elements is in fact

unpredictable

All the functions describ ed b elow use the eq predicate but they allow you to sp ecifyby means of

an optional argumentanother kind of equality test If sp eed is imp ortant for you it is preferable

not to use this facility Using eq execution of tests takes place directly without the need for a

funcall The implementation also calls up on rapid functions such as memq and delq If you are

forced to use the optional argument it is b etter to cho ose the equal predicate rather than say

eqstring since the implementation optimizes execution time by avoiding calls to funcall and by

using the appropriate functions member and delete

Any function whose name starts with n physically mo dies its arguments While its eects are

destructive for the arguments such a function has the advantage of never calling up on cons

Op erations on sets

adjoin item list eqfunc function with two or three arguments

If item is not already a memb er of the list called list it is added to this list If this addition

takes place item app ears at the head of the new list The optional argument eqfunc allows you

to cho ose a dierent equality op erator to the default primitive which is eq

adjoin a b q f a g ) b q f a g

adjoin c b q f a g ) c b q f a g

adjoin abc dw abc ) abc dw abc

adjoin abc dw abc equal ) dw abc

union list list eqfunc function with two or three arguments

Takes a pair of lists and pro duces a new list in which each element b elongs to one or other or

mayb e b oth of the initial lists The optional argument eqfunc allows you to cho ose a dierent

equality op erator to the default primitive which is eq

union a b c f b h a q ) c f b h a q

nunion list list eqfunc function with two or three arguments

This is the destructive version of the previous function It returns a new list that is built directly

from the cells of list and list which can no longer b e used as b efore The optional argument

eqfunc allows you to cho ose a dierent equality op erator to the default primitive which is eq

intersec tio n list list eqfunc function with two or three arguments

Takes a pair of lists and returns a new list containing all the elements that app ear in b oth of the

initial lists The optional argument eqfunc allows you to cho ose a dierent equality op erator to

the default primitive which is eq

CHAPTER PREDEFINED FUNCTIONS

intersection a b c f b h a q ) b a

ninterse cti on list list eqfunc function with two or three arguments

This is the destructive version of the previous function It returns a new list that is built by using

the cells of list On the other hand list is not altered by this function The optional argument

eqfunc allows you to cho ose a dierent equality op erator to the default primitive which is eq

setdiff ere nc e list list eqfunc function with two or three arguments

Returns a list comprising all the elements of list that do not app ear in list The optional

argument eqfunc allows you to cho ose a dierent equality op erator to the default primitive

which is eq

setdifference a b c f h a q ) c b

nsetdif fer en ce list list eqfunc function with two or three arguments

This is the destructive version of the previous function It returns a new list that is built by using

the cells of list On the other hand list is not altered by this function The optional argument

eqfunc allows you to cho ose a dierent equality op erator to the default primitive which is eq

setexcl usi ve or list list eqfunc function with two or three arguments

Returns the symmetric dierence b etween list and list This is a list containing all elements

that o ccur in only one of the initial lists The optional argument eqfunc allows you to cho ose a

dierent equality op erator to the default primitive which is eq

setexclusiveor a b c f h a q ) q h f b c

setexclusiveor a b c f g h ) h g f a b c

setexclusiveor s b s ) b

nsetexc lus iv eo r list list eqfunc function with two or three arguments

This is the destructive version of the previous function It returns a new list that is built directly

from the cells of list and list which can no longer b e used as b efore The optional argument

eqfunc allows you to cho ose a dierent equality op erator to the default primitive which is eq

powerse t set function with one argument

Creates the p ower set of set

powerset )

powerset a b c ) c b b c a a c a b a b c

cartesia np ro duc t set set function with two arguments

MATHEMATICAL SETS

Creates the Cartesian pro duct of set and set The elements of the resulting set are p ointed

pairs built from the elements of set and set

cartesianproduct a b )

cartesianproduct a b c d ) a c a d b c b d

Comparisons on sets

subsetp list list eqfunc function with two or three arguments

Returns t if list is a subset of list For this to b e the case every element of list must also

app ear in list If this is not the case the function returns The optional argument eqfunc

allows you to cho ose a dierent equality op erator to the default primitive which is eq

subsetp a b b c f )

subsetp a b b f a q ) t

subsetp asd xhg asd )

subsetp asd xhg asd equal ) t

setequa l list list eqfunc function with two or three arguments

Returns t if list and list are identical lists The optional argument eqfunc allows you to

cho ose a dierent equality op erator to the default primitive which is eq

In LELISP setequal could b e dened in the following manner

defun setequal list list

and subsetp list list subsetp list list

setequal a b c b a c ) t

setequal a b c d c d a b )

setequal a b c d c d a b equal ) t

setequal a b c d a b d c equal )

setequal a b c d a b d c setequal ) t

Transitive closure

Consider f to b e an arbitrary singleargument function that returns as its value a set The unique

argument of f is a set element The transitive closure of a set E by the f function is dened to b e

a minimal subset of E called F such that for each element x in F fx is a subset of F

Transitive closure can b e a useful op eration when you need to search say for all the descendents

of a summit in a tree or a graph

transiti ve cl osu re fn list eqfunc function with two or three arguments

CHAPTER PREDEFINED FUNCTIONS

Returns a list that represents the transitive closure of list by the function fn The optional

argument eqfunc allows you to cho ose a dierent equality op erator to the default primitive

which is eq

defun test elt

cassq elt b a f c d e b c q

transitiveclosure test a ) a

transitiveclosure test b ) a f q c b

transitiveclosure test d g ) g e a f q c b d

The following example shows a p ossible use for transitiveclosure

defun submodules mod

getdefmodule readdefmodule mod import

submodules complice ) files module loader

submodules files ) path

submodules module ) files

submodules loader ) files

transitiveclosure submodules complice ) path files module loader complice

The next example demonstrates the way in which a bad choice for the equalitytest predicate

can cause a function to lo op

defun test s

list substring s sub slen s

transitiveclosure test hip hop eqstring ) ho hop h hi hip

transitiveclosure test hip hop )

Fatal error no room for strings

The transitiveclosure function could b e implementedbut not very successfullyi n the

following manner

defun transitiveclosure fn list

let oldlist list

newlist list

while list

setq newlist union newlist funcall fn nextl list

if setequal oldlist newlist

oldlist

transitiveclosure fn newlist

Table of contents

Predened functions

Evaluation functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::

Application functions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

Simple application functions ::::::::::::::::::::::::::::::::::::::::::::::

Application functions of the map typ e :::::::::::::::::::::::::::::::::::::

Other application functions :::::::::::::::::::::::::::::::::::::::::::::::

Environment manipulation functions :::::::::::::::::::::::::::::::::::::::::::::

Functiondenition functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Static function denitions ::::::::::::::::::::::::::::::::::::::::::::::::

Advanced use of macro functions ::::::::::::::::::::::::::::::::::::::::::

Denition of closures ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Denition of dynamic functions :::::::::::::::::::::::::::::::::::::::::::

Generalized assignment ::::::::::::::::::::::::::::::::::::::::::::::::::

Variable functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Basic control functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

Lexical control functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Primitive lexical control forms ::::::::::::::::::::::::::::::::::::::::::::

Iteration functions of the prog kind :::::::::::::::::::::::::::::::::::::::

Iteration functions of the do kind :::::::::::::::::::::::::::::::::::::::::

Dynamic nonlo cal control functions :::::::::::::::::::::::::::::::::::::::::::::

Basic predicates ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Functions on lists ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Search functions on lists ::::::::::::::::::::::::::::::::::::::::::::::::::

List creation functions :::::::::::::::::::::::::::::::::::::::::::::::::::

Functions on cells of lab elled lists :::::::::::::::::::::::::::::::::::::::::

Table of Contents

Physical mo dication functions :::::::::::::::::::::::::::::::::::::::::::

Functions on Alists ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Sorting functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Functions on symb ols ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

Functions that access symb ol values :::::::::::::::::::::::::::::::::::::::

Functions that mo dify symb ol values ::::::::::::::::::::::::::::::::::::::

Functions on Plists ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Access to function denitions :::::::::::::::::::::::::::::::::::::::::::::

Access to symb ol sp ecial elds ::::::::::::::::::::::::::::::::::::::::::::

Symb ol creation functions ::::::::::::::::::::::::::::::::::::::::::::::::

Symb ol management functions ::::::::::::::::::::::::::::::::::::::::::::

Functions on character strings :::::::::::::::::::::::::::::::::::::::::::::::::::

Basic manipulation functions :::::::::::::::::::::::::::::::::::::::::::::

Character string conversion :::::::::::::::::::::::::::::::::::::::::::::::

Comparison of character strings :::::::::::::::::::::::::::::::::::::::::::

Characterstring creation functions ::::::::::::::::::::::::::::::::::::::::

Characterstring access functions ::::::::::::::::::::::::::::::::::::::::::

Functions that physically mo dify strings :::::::::::::::::::::::::::::::::::

Search functions on character strings ::::::::::::::::::::::::::::::::::::::

Functions on characters ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

Functions on vectors ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::

Functions on arrays ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::

Hash tables ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

Hash table creation functions :::::::::::::::::::::::::::::::::::::::::::::

Hash table access functions :::::::::::::::::::::::::::::::::::::::::::::::

Mathematical sets ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Op erations on sets ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Comparisons on sets ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Transitive closure ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Function Index

eval s env function with one or two arguments ::::::::::::::::::::::::::::::::::::

evlis l function with one argument :::::::::::::::::::::::::::::::::::::::::::::::

eprogn l function with one argument :::::::::::::::::::::::::::::::::::::::::::::

prog s ::: s special form ::::::::::::::::::::::::::::::::::::::::::::::::::: :

n

prog s s ::: s special form :::::::::::::::::::::::::::::::::::::::::::::::::

n

progn s ::: s special form ::::::::::::::::::::::::::::::::::::::::::::::::::: :

n

quote s special form ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::

function fn special form ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

arg n function with an optional argument ::::::::::::::::::::::::::::::::::::::::::

identity s function with one argument :::::::::::::::::::::::::::::::::::::::::::

comment e ::: e special form :::::::::::::::::::::::::::::::::::::::::::::::::

n

lambda l s ::: s special form ::::::::::::::::::::::::::::::::::::::::::::::::

n

flambda l s ::: s special form :::::::::::::::::::::::::::::::::::::::::::::::

n

mlambda l s ::: s special form :::::::::::::::::::::::::::::::::::::::::::::::

n

apply fn s ::: s l function with a variable number of arguments :::::::::::::::::

n

funcall fn s ::: s function with a variable number of arguments :::::::::::::::::

n

allcar l function with one argument :::::::::::::::::::::::::::::::::::::::::::::

mapl fn l ::: l function with a variable number of arguments :::::::::::::::::::::

n

map fn l ::: l function with a variable number of arguments ::::::::::::::::::::::

n

mapc fn l ::: l function with a variable number of arguments :::::::::::::::::::::

n

maplist fn l ::: l function with a variable number of arguments :::::::::::::::::

n

mapcar fn l ::: l function with a variable number of arguments ::::::::::::::::::

n

mapcon fn l ::: l function with a variable number of arguments ::::::::::::::::::

n

mapcan fn l ::: l function with a variable number of arguments ::::::::::::::::::

n

every fn l ::: l function with a variable number of arguments ::::::::::::::::::::

n

any fn l ::: l function with a variable number of arguments ::::::::::::::::::::::

n

FUNCTION INDEX

mapvector fn vect function with two arguments ::::::::::::::::::::::::::::::::::

mapoblist fn function with one argument :::::::::::::::::::::::::::::::::::::::::

mapcoblist fn function with one argument :::::::::::::::::::::::::::::::::::::::

maploblist fn function with one argument :::::::::::::::::::::::::::::::::::::::

let lv s ::: s special form :::::::::::::::::::::::::::::::::::::::::::::::::::

n

letv lvar lval s ::: s special form ::::::::::::::::::::::::::::::::::::::::::

n

letvq lvar lval s ::: s special form :::::::::::::::::::::::::::::::::::::::::

n

lets lv s ::: s special form ::::::::::::::::::::::::::::::::::::::::::::::::::

n

slet lv s ::: s special form ::::::::::::::::::::::::::::::::::::::::::::::::::

n

let lv s ::: s special form ::::::::::::::::::::::::::::::::::::::::::::::::::

n

letn symb lv s ::: s special form ::::::::::::::::::::::::::::::::::::::::::::

n

systempreviousdefflag variable :::::::::::::::::::::::::::::::::::::::::::

systempreviousdef property :::::::::::::::::::::::::::::::::::::::::::::::::

systemredefflag variable :::::::::::::::::::::::::::::::::::::::::::::::::::

systemloadedfromfile variable ::::::::::::::::::::::::::::::::::::::::::::

systemloadedfromfile property ::::::::::::::::::::::::::::::::::::::::::::

defun symb lvar s ::: s special form :::::::::::::::::::::::::::::::::::::::::

n

de symb lvar s ::: s special form ::::::::::::::::::::::::::::::::::::::::::::

n

df symb lvar s ::: s special form ::::::::::::::::::::::::::::::::::::::::::::

n

dm symb lvar s ::: s special form ::::::::::::::::::::::::::::::::::::::::::::

n

defmacro symb lvar s ::: s special form :::::::::::::::::::::::::::::::::::::

n

dmd symb lvar s ::: s special form :::::::::::::::::::::::::::::::::::::::::::

n

ds symb type adr special form ::::::::::::::::::::::::::::::::::::::::::::::::::

macroexpand s function with one argument ::::::::::::::::::::::::::::::::::::::

macroexpand s function with one argument :::::::::::::::::::::::::::::::::::::::

closure lvar fn function with two arguments :::::::::::::::::::::::::::::::::::::

flet l s ::: s special form :::::::::::::::::::::::::::::::::::::::::::::::::::

n

setf loc val ::: loc val macro :::::::::::::::::::::::::::::::::::::::::::

n n

defsetf access lparams store body macro :::::::::::::::::::::::::::::::::

with l s ::: s special form :::::::::::::::::::::::::::::::::::::::::::::::::::

n

if s s s ::: s special form :::::::::::::::::::::::::::::::::::::::::::::::::

n

ifn s s s ::: s special form ::::::::::::::::::::::::::::::::::::::::::::::::

n

when s s ::: s special form ::::::::::::::::::::::::::::::::::::::::::::::::::

n

unless s s ::: s special form ::::::::::::::::::::::::::::::::::::::::::::::::

n

FUNCTION INDEX

or s ::: s special form ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

n

and s ::: s special form ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

n

cond l ::: l special form ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

n

selectq s l ::: l special form :::::::::::::::::::::::::::::::::::::::::::::::

n

while s s ::: s special form ::::::::::::::::::::::::::::::::::::::::::::::::::

n

until s s ::: s special form ::::::::::::::::::::::::::::::::::::::::::::::::::

n

repeat m s ::: s special form ::::::::::::::::::::::::::::::::::::::::::::::::

n

for var in ic ntl e ::: e s ::: s special form ::::::::::::::::::::::::::

m n

block symb e ::: e special form ::::::::::::::::::::::::::::::::::::::::::::::

n

returnfrom symb e special form :::::::::::::::::::::::::::::::::::::::::::::::

return e special form ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

tagbody ec ::: ec special form :::::::::::::::::::::::::::::::::::::::::::::::

n

go symb special form ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::

prog l ec ::: ec macro ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

n

prog l ec ::: ec macro ::::::::::::::::::::::::::::::::::::::::::::::::::: :

n

do lv lr ec ::: ec macro :::::::::::::::::::::::::::::::::::::::::::::::::::

n

do lv lr ec ::: ec macro ::::::::::::::::::::::::::::::::::::::::::::::::::

n

tag symb s ::: s special form :::::::::::::::::::::::::::::::::::::::::::::::::

n

evtag s s ::: s special form ::::::::::::::::::::::::::::::::::::::::::::::::::

n

exit symb s ::: s special form :::::::::::::::::::::::::::::::::::::::::::::::

n

evexit s s ::: s special form ::::::::::::::::::::::::::::::::::::::::::::::::

n

unexit symb s ::: s special form :::::::::::::::::::::::::::::::::::::::::::::

n

untilexit symb e ::: e special form :::::::::::::::::::::::::::::::::::::::::

n

lock fn s ::: s special form ::::::::::::::::::::::::::::::::::::::::::::::::::

n

protect s s ::: s special form ::::::::::::::::::::::::::::::::::::::::::::::

n

unwind n s ::: s special form ::::::::::::::::::::::::::::::::::::::::::::::::

n

catchallbut l s ::: s special form ::::::::::::::::::::::::::::::::::::::::

n

backtrack symb l e ::: e special form :::::::::::::::::::::::::::::::::::::::

n

false e ::: e function with a variable number of arguments :::::::::::::::::::::::

n

true e ::: e function with a variable number of arguments ::::::::::::::::::::::::

n

null s function with one argument ::::::::::::::::::::::::::::::::::::::::::::::::

not s function with one argument :::::::::::::::::::::::::::::::::::::::::::::::::

atom s function with one argument ::::::::::::::::::::::::::::::::::::::::::::::::

atomp s function with one argument :::::::::::::::::::::::::::::::::::::::::::::::

FUNCTION INDEX

constantp s function with one argument ::::::::::::::::::::::::::::::::::::::::::

symbolp s function with one argument ::::::::::::::::::::::::::::::::::::::::::::

variablep s function with one argument ::::::::::::::::::::::::::::::::::::::::::

numberp s function with one argument ::::::::::::::::::::::::::::::::::::::::::::

vectorp s function with one argument ::::::::::::::::::::::::::::::::::::::::::::

stringp s function with one argument ::::::::::::::::::::::::::::::::::::::::::::

consp s function with one argument :::::::::::::::::::::::::::::::::::::::::::::::

listp s function with one argument :::::::::::::::::::::::::::::::::::::::::::::::

nlistp s function with one argument :::::::::::::::::::::::::::::::::::::::::::::

eq s s function with two arguments :::::::::::::::::::::::::::::::::::::::::::::

neq s s function with two arguments ::::::::::::::::::::::::::::::::::::::::::::

equal s s function with two arguments :::::::::::::::::::::::::::::::::::::::::

nequal s s function with two arguments ::::::::::::::::::::::::::::::::::::::::

car l function with one argument :::::::::::::::::::::::::::::::::::::::::::::::::

cdr l function with one argument :::::::::::::::::::::::::::::::::::::::::::::::::

cr l functions of one argument :::::::::::::::::::::::::::::::::::::::::::::::

memq symb l function with two arguments :::::::::::::::::::::::::::::::::::::::::

member s l function with two arguments ::::::::::::::::::::::::::::::::::::::::::

tailp s l function with two arguments ::::::::::::::::::::::::::::::::::::::::::::

nthcdr n l function with two arguments ::::::::::::::::::::::::::::::::::::::::::

nth n l function with two arguments ::::::::::::::::::::::::::::::::::::::::::::::

last s function with one argument ::::::::::::::::::::::::::::::::::::::::::::::::

length s function with one argument :::::::::::::::::::::::::::::::::::::::::::::

cons s s function with two arguments :::::::::::::::::::::::::::::::::::::::::::

xcons s s function with two arguments :::::::::::::::::::::::::::::::::::::::::

ncons s function with one argument :::::::::::::::::::::::::::::::::::::::::::::::

mcons s ::: s function with a variable number of arguments :::::::::::::::::::::::

n

list s ::: s function with a variable number of arguments ::::::::::::::::::::::::

n

kwote s function with one argument :::::::::::::::::::::::::::::::::::::::::::::::

makelist n s function with two arguments ::::::::::::::::::::::::::::::::::::::::

append l ::: l function with a variable number of arguments ::::::::::::::::::::::

n

append l s function with two arguments :::::::::::::::::::::::::::::::::::::::::

reverse s function with one argument ::::::::::::::::::::::::::::::::::::::::::::

copylist l function with one argument :::::::::::::::::::::::::::::::::::::::::::

FUNCTION INDEX

copy s function with one argument ::::::::::::::::::::::::::::::::::::::::::::::::

firstn n l function with two arguments ::::::::::::::::::::::::::::::::::::::::::

lastn n l function with two arguments ::::::::::::::::::::::::::::::::::::::::::::

subst s s s function with three arguments ::::::::::::::::::::::::::::::::::::::

remq symb l function with two arguments :::::::::::::::::::::::::::::::::::::::::

remove s l function with two arguments ::::::::::::::::::::::::::::::::::::::::::

tconsp s function with one argument :::::::::::::::::::::::::::::::::::::::::::::

tconsmk s function with one argument ::::::::::::::::::::::::::::::::::::::::::::

tconscl s function with one argument ::::::::::::::::::::::::::::::::::::::::::::

tcons s s function with two arguments :::::::::::::::::::::::::::::::::::::::::

rplaca l s function with two arguments ::::::::::::::::::::::::::::::::::::::::::

rplacd l s function with two arguments ::::::::::::::::::::::::::::::::::::::::::

rplac l s s function with three arguments ::::::::::::::::::::::::::::::::::::::

displace l ln function with two arguments :::::::::::::::::::::::::::::::::::::::

placdl l s function with two arguments ::::::::::::::::::::::::::::::::::::::::::

evlis l function with one argument :::::::::::::::::::::::::::::::::::::::::::::::

nconc l ::: l function with a variable number of arguments :::::::::::::::::::::::

n

nconc l s function with two arguments ::::::::::::::::::::::::::::::::::::::::::

cirlist e ::: e function with a variable number of arguments :::::::::::::::::::::

n

nreverse l function with one argument :::::::::::::::::::::::::::::::::::::::::::

nreconc l s function with two arguments :::::::::::::::::::::::::::::::::::::::::

nsubst s s l function with three arguments :::::::::::::::::::::::::::::::::::::

delq symb l function with two arguments :::::::::::::::::::::::::::::::::::::::::

delete s l function with two arguments ::::::::::::::::::::::::::::::::::::::::::

acons s s al function with three arguments :::::::::::::::::::::::::::::::::::::

pairlis l l al function with three arguments ::::::::::::::::::::::::::::::::::

assq symb al function with two arguments ::::::::::::::::::::::::::::::::::::::::

cassq symb al function with two arguments :::::::::::::::::::::::::::::::::::::::

rassq symb al function with two arguments :::::::::::::::::::::::::::::::::::::::

assoc s al function with two arguments ::::::::::::::::::::::::::::::::::::::::::

cassoc s al function with two arguments :::::::::::::::::::::::::::::::::::::::::

rassoc s al function with two arguments :::::::::::::::::::::::::::::::::::::::::

sublis al s function with two arguments :::::::::::::::::::::::::::::::::::::::::

sort feature ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::

FUNCTION INDEX

sort fn l function with two arguments ::::::::::::::::::::::::::::::::::::::::::::

sortl l function with one argument :::::::::::::::::::::::::::::::::::::::::::::::

sortp l function with one argument :::::::::::::::::::::::::::::::::::::::::::::::

sortn l function with one argument :::::::::::::::::::::::::::::::::::::::::::::::

boundp symb function with one argument ::::::::::::::::::::::::::::::::::::::::::

symeval symb function with one argument :::::::::::::::::::::::::::::::::::::::::

defvar symb e special form ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

systemloadedfromfile variable ::::::::::::::::::::::::::::::::::::::::::::

makunbound symb function with one argument :::::::::::::::::::::::::::::::::::::

set symb s function with two arguments :::::::::::::::::::::::::::::::::::::::::::

setq sym s ::: sym s special form ::::::::::::::::::::::::::::::::::::::::::

n n

setqq sym e ::: sym e special form :::::::::::::::::::::::::::::::::::::::::

n n

psetq sym s ::: sym s special form :::::::::::::::::::::::::::::::::::::::::

n n

deset l l function with two arguments :::::::::::::::::::::::::::::::::::::::::

desetq l l special form ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

nextl sym sym special form :::::::::::::::::::::::::::::::::::::::::::::::::::

newl symb s special form ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

newr symb s special form ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

incr symb n special form ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

decr symb n special form ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

plist pl l function with one or two arguments ::::::::::::::::::::::::::::::::::::

getprop pl ind function with two arguments ::::::::::::::::::::::::::::::::::::::

get pl ind function with two arguments :::::::::::::::::::::::::::::::::::::::::::

getl pl l function with two arguments ::::::::::::::::::::::::::::::::::::::::::::

addprop pl pval ind function with three arguments :::::::::::::::::::::::::::::::

putprop pl pval ind function with three arguments :::::::::::::::::::::::::::::::

defprop pl pval ind special form ::::::::::::::::::::::::::::::::::::::::::::::

remprop pl ind function with two arguments ::::::::::::::::::::::::::::::::::::::

typefn symb function with one argument ::::::::::::::::::::::::::::::::::::::::::

valfn symb function with one argument :::::::::::::::::::::::::::::::::::::::::::

setfn symb ftype fval function with three arguments :::::::::::::::::::::::::::::

resetfn symb ftype fval function with three arguments :::::::::::::::::::::::::::

findfn s function with one argument :::::::::::::::::::::::::::::::::::::::::::::

remfn symb function with one argument :::::::::::::::::::::::::::::::::::::::::::

FUNCTION INDEX

makedef symb ftyp fval function with three arguments ::::::::::::::::::::::::::::

getdef symb function with one argument ::::::::::::::::::::::::::::::::::::::::::

revert symb function with one argument ::::::::::::::::::::::::::::::::::::::::::

synonym sym sym function with two arguments ::::::::::::::::::::::::::::::::::

synonymq sym sym special form :::::::::::::::::::::::::::::::::::::::::::::::

objval symb s function with one or two arguments :::::::::::::::::::::::::::::::::

packagecell symb pkgc function with one or two arguments :::::::::::::::::::::::

getfn pkgc symb function with two arguments ::::::::::::::::::::::::::::::::::::

getfn pkgc symb lastpkgc function with two or three arguments :::::::::::::::::::

symbol pkgc strg function with two arguments ::::::::::::::::::::::::::::::::::::

concat str ::: str function with a variable number of arguments :::::::::::::::::

n

gensym function with no arguments ::::::::::::::::::::::::::::::::::::::::::::::::

oblist pkgc symb function with zero one or two arguments :::::::::::::::::::::::::

lhoblist strg function with one argument ::::::::::::::::::::::::::::::::::::::::

boblist n function with an optional argument ::::::::::::::::::::::::::::::::::::::

remob symb function with one argument :::::::::::::::::::::::::::::::::::::::::::

slen strg function with one argument ::::::::::::::::::::::::::::::::::::::::::::

sref strg n function with two arguments :::::::::::::::::::::::::::::::::::::::::

sset strg n cn function with three arguments :::::::::::::::::::::::::::::::::::::

typestring strg symb function with one or two arguments :::::::::::::::::::::::::

exchstring strg strg function with two arguments :::::::::::::::::::::::::::::

string s function with one argument :::::::::::::::::::::::::::::::::::::::::::::

pname strg function with one argument :::::::::::::::::::::::::::::::::::::::::::

plength strg function with one argument :::::::::::::::::::::::::::::::::::::::::

slength strg function with one argument :::::::::::::::::::::::::::::::::::::::::

hash strg function with one argument ::::::::::::::::::::::::::::::::::::::::::::

eqstring str str function with two arguments :::::::::::::::::::::::::::::::::

alphalessp str str function with two arguments :::::::::::::::::::::::::::::::

catenate str ::: str function with a variable number of arguments :::::::::::::::

n

makestring n cn function with two arguments ::::::::::::::::::::::::::::::::::::

substring strg n n function with two or three arguments ::::::::::::::::::::::::

duplstring n strg function with two arguments ::::::::::::::::::::::::::::::::::

chrpos cn strg pos function with two or three arguments ::::::::::::::::::::::::::

chrnth n strg function with two arguments :::::::::::::::::::::::::::::::::::::::

FUNCTION INDEX

chrset n strg cn function with three arguments :::::::::::::::::::::::::::::::::::

bltstring str n str n n function with four or ve arguments :::::::::::::::

fillstring strg n cn n function with three or four arguments ::::::::::::::::::

index str str n function with two or three arguments :::::::::::::::::::::::::::

substringequal size strg pos strg pos function with ve arguments ::::::

scanstring str str n function with two or three arguments :::::::::::::::::::::

spanstring str str n function with two or three arguments :::::::::::::::::::::

ascii cn function with one argument :::::::::::::::::::::::::::::::::::::::::::::

cascii ch function with one argument ::::::::::::::::::::::::::::::::::::::::::::

uppercase cn function with one argument :::::::::::::::::::::::::::::::::::::::::

lowercase cn function with one argument :::::::::::::::::::::::::::::::::::::::::

asciip cn function with one argument ::::::::::::::::::::::::::::::::::::::::::::

digitp cn function with one argument ::::::::::::::::::::::::::::::::::::::::::::

letterp cn function with one argument :::::::::::::::::::::::::::::::::::::::::::

makevector n s function with two arguments ::::::::::::::::::::::::::::::::::::::

vector s ::: s function with a variable number of arguments ::::::::::::::::::::::

n

vlength vect function with one argument :::::::::::::::::::::::::::::::::::::::::

vref vect n function with two arguments :::::::::::::::::::::::::::::::::::::::::

vset vect n e function with three arguments ::::::::::::::::::::::::::::::::::::::

typevector vect symb function with one or two arguments :::::::::::::::::::::::::

eqvector vect vect function with two arguments :::::::::::::::::::::::::::::::

bltvector vect n vect n n function with ve arguments ::::::::::::::::::::

fillvector vect n e n function with three or four arguments ::::::::::::::::::::

exchvector vect vect function with two arguments :::::::::::::::::::::::::::::

array feature ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::

makearray a ::: a s function with a variable number of arguments ::::::::::::::::

n

aref array i ::: i function with a variable number of arguments ::::::::::::::::::

n

aset array i ::: i e function with a variable number of arguments :::::::::::::::

n

hash feature ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::

makehashtableeq function with no arguments :::::::::::::::::::::::::::::::::

makehashtableequal function with no arguments ::::::::::::::::::::::::::::::

hashtablep obj function with one argument ::::::::::::::::::::::::::::::::::::

gethash key ht default function with two or three arguments ::::::::::::::::::::::

puthash key ht value function with three arguments ::::::::::::::::::::::::::::::

FUNCTION INDEX

remhash key ht function with two arguments ::::::::::::::::::::::::::::::::::::::

maphash fnt ht function with two arguments ::::::::::::::::::::::::::::::::::::::

clrhash ht function with one argument :::::::::::::::::::::::::::::::::::::::::::

hashtablecount ht function with one argument ::::::::::::::::::::::::::::::::

sets feature ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::

adjoin item list eqfunc function with two or three arguments :::::::::::::::::::

union list list eqfunc function with two or three arguments ::::::::::::::::::

nunion list list eqfunc function with two or three arguments :::::::::::::::::

intersection list list eqfunc function with two or three arguments ::::::::::

nintersection list list eqfunc function with two or three arguments :::::::::

setdifference list list eqfunc function with two or three arguments :::::::

nsetdifference list list eqfunc function with two or three arguments ::::::

setexclusiveor list list eqfunc function with two or three arguments :::::

nsetexclusiveor list list eqfunc function with two or three arguments ::::

powerset set function with one argument :::::::::::::::::::::::::::::::::::::::

cartesianproduct set set function with two arguments ::::::::::::::::::::::

subsetp list list eqfunc function with two or three arguments ::::::::::::::::

setequal list list eqfunc function with two or three arguments :::::::::::::

transitiveclosure fn list eqfunc function with two or three arguments :::::::

Chapter

Arithmetic functions

LELISP uses several typ es of numb ers

 Fixedprecision numb ers

 Integers of bits

 Floatingp oint numb ers with or bits dep ending on the system In this manual

we often refer to oatingp oint numb ers as oats

 Arbitraryprecision numb ers supp orted by a LELISP library

LELISP also prop oses ve typ es of arithmetic

 Generic arithmetic

 Integer arithmetic

 Extended integer arithmetic

 Floatingp oint arithmetic

 Mixed arithmetic

Functions describ ed in this chapter only treat bit integers and oatingp oint numb ers Chapter

describ es rational and complex arithmetic which use extended numeric typ es

Division by zero invariably raises the errdv error which has the following default screen display

function division by zero

where function is the name of the function that raised the error

Generic arithmetic

Arguments to the functions describ ed here can b e integer numb ers oats or numb ers of an extended

typ e If one of the arguments is a oat the result will also b e a oat If all the arguments are integers

the result is an integer If a calculation overows or if one of the functions arguments is neither

an integer nor a oat the genarith interrupt is called

CHAPTER ARITHMETIC FUNCTIONS

While it is advisable to use the functions describ ed here due to their generality they are not

particularly fast in execution If eciency is imp ortant sp ecialized arithmetic functions can b e

used on integers or on oats

Generic arithmetic interrupt

genarith arithmetic interrupt

This interrupt is called if a calculation cannot b e p erformed by a generic arithmetic function It

invokes a function whose name is the value of the following expression

or getfn typeof arg fn

1

getfn syspackagegenarith fn

where fn is the name of the generic function that cannot p erform the calculation and arg is

1

the value of its rst argument This function is called with one or two arguments dep ending

on its typ e see section If the function do es not exist the errgen error is raised Its

default screen display is

function cant compute argumentlist

where function is the name of the function that could not b e found and argumentlist is the

list of evaluated arguments of the unsuccessful function call This escap e mechanism provides

a way to easily build interfaces to other arithmetic packages written entirely in LISP

syspac kag e gen ar ith variable

This variable holds the name of the package in which generic functions will b e searched for in

the case that a function asso ciated with the typ e of the rst argument supplied is not found

By default its value is genarith

Typ e tests

Only the rst function describ ed here numberp calls the genarith interrupt on error

numberp x function with one argument

numberp determines whether x is a numb er If this is so it returns x If not it returns

numberp )

numberp )

fixp x function with one argument

If x is a xedprecision integer numb er fixp returns x If not it returns

fixp )

fixp )

GENERIC ARITHMETIC

floatp x function with one argument

If x is a xedprecision oatingp oint numb er floatp returns x If not it returns

floatp )

floatp )

Numeric conversions

Even though certain numeric functions do their own argument conversion it is also p ossible to

explicitly convert numeric values by means of the following three functions

truncate x function with one argument

fix x function with one argument

If the argument x is an integer truncate returns it as its value If x is a oatingp oint numb er it

will b e converted into an integer if p ossible and this value will b e returned If the conversion cannot

b e carried out truncate calls the genarith interrupt The conversion is a truncation The result is

an integer with the same sign as the argument x Its absolute value is equal to the greatest integer

less than or equal to the absolute value of the argument fix is simply another nameretained for

reasons of compatibilityfor the same function

truncate )

truncate )

truncate )

truncate )

truncate )

truncate )

truncate )

truncate ) call to genarith

floor n function with one argument

If the argument n is an integer floor returns it If n is a oat it is converted if p ossible into an

integer If not floor raises the genarith interrupt This conversion is a downwards truncation

The result is an integer with the same sign as the n argument Its value is the largest integer that

is smaller than n

floor )

floor )

floor )

floor )

floor )

floor )

CHAPTER ARITHMETIC FUNCTIONS

ceiling n function with one argument

If the argument n is an integer ceiling returns it If n is a oat it is converted if p ossible into an

integer If not ceiling raises the genarith interrupt This conversion is an upwards truncation

The result is an integer with the same sign as the n argument Its value is the smallest integer that

is larger than n

ceiling )

ceiling )

ceiling )

ceiling )

ceiling )

ceiling )

round n d function with two arguments

Carries out a division of n by d The function returns the integer that is closest to the result of the

division When d is one round simply returns the integer that is closest to n

round )

round )

round )

round )

round )

round )

float x function with one argument

If the argument x is a oatingp oint numb er float returns it as its value If x is an integer it is

converted into a oat and this value is returned Otherwise float calls the genarith interrupt

float )

Generic arithmetic functions

x ::: x function with a variable number of arguments

1 n

This function referred to as plus returns the value of the sum x x ::: x If no argument

1 2 n

is given it returns the additive identity

)

)

)

)

) call to genarith

)

GENERIC ARITHMETIC

)

x function with one argument

The form x is equivalent to x

x ::: x function with a variable number of arguments

1 n

This function referred to as minus returns the value of the dierence x x ::: x If no

1 2 n

argument is given it returns the additive identity If a single argument is given this function

returns the additive inverse of its argument that is x

)

)

)

)

)

)

) call to genarith

x function with one argument

The form x is equivalent to x

abs x function with one argument

The abs function returns the absolute value of its argument x that is x

abs )

abs )

abs )

abs )

To calculate the square of x without changing its sign use x abs x

x ::: x function with a variable number of arguments

1 n

The function returns the value of the pro duct x  x  :::  x If no argument is given

1 2 n

returns the multiplicative identity that is

)

)

)

)

)

) call to genarith

)

CHAPTER ARITHMETIC FUNCTIONS

x y function with one or two arguments

x y function with one or two arguments

These identical functions return the value of the division of x by y If a single argument is

given the inverse x is calculated and returned If two integer arguments are given and their

quotient is not exact a call to genarith takes place and genarith attempts to pro duce

a rational numb er as result To pro duce a oatingp oint result the divide function must

b e used To pro duce a rounded integer result the quotient function should b e used If the

argument y is zero the errdv error is raised

)

) call to genarith

)

) call to genarith

)

)

quo x y function with two arguments

quotient x y function with two arguments

These two identical functions return the value of the whole division of x by y More precisely

they return an integer value that we shall refer to here as q If n and d are two integers then

the quotient q and the remainder r satisfy the relation n q d r where r lies b etween

zero and the absolute value of d If the argument y is zero the errdv error is raised

quotient )

quotient )

quotient )

quotient )

quotient )

quotient )

modulo x y function with two arguments

Returns the value of the remainder of the integer division of x by y If one of the arguments

is not an integer the genarith interrupt is raised The remainder of an integer division

represented by the formula in the description of the preceding functionis always p ositive

The result aects the exmod variable

modulo )

modulo )

modulo )

modulo )

GENERIC ARITHMETIC

modulo )

modulo ) call to genarith

modulo ) call to genarith

quomod x y function with two arguments

exmod variable

This function combines the functionality of the two preceding functions It returns the same

value as quotient and writes the result of applying the modulo function to x and y into the

exmod global variable

In LELISP quomod could b e dened in the following manner

defun quomod n n

The actual implementation is much more efficient

setq exmod modulo n n

quotient n n

min x ::: x function with a variable number of arguments

1 n

The symb ol min stands for minimum This function returns the smallest numeric value from among

x ::: x

1 n

min )

min )

min )

min )

min )

max x ::: x function with a variable number of arguments

1 n

The symb ol max stands for maximum This function returns the numerically largest value from

among x ::: x

1 n

max )

max )

max )

max )

max )

Predicates of generic arithmetic

These functions generally accept a variable numb er of arguments which can b e numb ers of any

typ e integers oats or extended numerics If one of the arguments is a oat these functions do

CHAPTER ARITHMETIC FUNCTIONS

oatingp oint comparisons If all the arguments are integers they do integer comparisons There

is automatic conversion b etween the arguments with priority given to oatingp oint numb ers

All these functions return their rst argument if the predicate holds true and if not

In the event of a call to the genarith interrupt the function must b e dened since all the

other functions are dened as functions of

x y function with two arguments

The function returns if x is strictly less than y if x equals y and if x is strictly greater

than y

)

)

)

x x ::: x function with a variable number of arguments

1 2 n

If x is equal to x and x is equal to x and ::: and x is equal to x then the function

1 2 2 3 n{1 n

returns x Otherwise it returns

1

)

)

)

)

)

x y function with two arguments

x y function with two arguments

These two functions are identical If the value of x is dierent to that of y they return x Otherwise

they return This function is binary since the function not equal to is not transitive

)

)

)

x x ::: x function with a variable number of arguments

1 2 n

If the value of x is greater than or equal to that of x and the value of x is greater than or equal

1 2 2

to that of x and ::: and the value of x is greater than or equal to that of x then the

3 n{1 n

function returns x as its value If such is not the case the function returns This function can

1

b e used to test intervals

)

)

GENERIC ARITHMETIC

)

)

)

x x ::: x function with a variable number of arguments

1 2 n

If the value of x is strictly greater than the value of x and the value of x is strictly greater than

1 2 2

the value of x and ::: and the value of x is strictly greater than the value of x then the

3 n{1 n

function returns the value of x If this is not the case it returns

1

)

)

)

)

)

x x ::: x function with a variable number of arguments

1 2 n

If the value of x is less than or equal to that of x and the value of x is less than or equal to that

1 2 2

of x and ::: and the value of x is less than or equal to that of x then the function returns

3 n{1 n

the value of x If this is not the case it returns

1

)

)

)

)

)

x x ::: x function with a variable number of arguments

1 2 n

If the value of x is less than that of x and the value of x is less than that of x and ::: and the

1 2 2 3

value of x is less than that of x the function returns the value of x If this is not the case

n{1 n 1

it returns

)

)

)

)

)

zerop x function with one argument

zerop x is equivalent to x

plusp x function with one argument

plusp x is equivalent to x

CHAPTER ARITHMETIC FUNCTIONS

minusp x function with one argument

minusp x is equivalent to x

Circular and mathematical functions

All these functions exp ect oatingp oint or integer arguments If an argument of some other typ e

is passed to one of them the genarith interrupt is raised

sin x function with one argument

cos x function with one argument

asin x function with one argument

acos x function with one argument

atan x function with one argument

setq pi )

setq pi pi )

setq pi pi )

sin )

sin pi )

sin pi )

asin sin )

cos )

cos pi )

cos pi )

acos cos )

atan )

defun fnt x y

nf cos x nd cos y nd

defun pattern nl nf nd

let x y

repeat nl

setq x y y

repeat

princn

chrnth fix fnt incr x y

terpri

GENERIC ARITHMETIC

The evaluation of pattern pro duces

exp x function with one argument

log x function with one argument

log x function with one argument

power x y function with two arguments

sqrt x function with one argument

power )

power )

power ) e

power )

power )

power ) e

exp )

exp )

log )

log )

log exp )

log )

log )

log )

log )

sqrt )

sqrt )

setq x )

sqrt power sin x power cos x )

CHAPTER ARITHMETIC FUNCTIONS

Extensions to generic arithmetic

To create new generic arithmetic facilities the following functions should b e dened in the extended

arithmetic package called ext in the list that follows These functions are all unary or binary and

the system handles multiple arguments

extnumberp s

extfloat s

exttruncate s

ext s s

ext s s

ext s

ext s s

ext s

extquomod s s

extabs n

ext s s

extsin s

extcos s

extasin s

extacos s

extatan s

extexp s

extlog s

extlog s

extpower s

extsqrt s

To dene a new extended typ e the following two functions are needed

exteval n

extprin n

An example of the creation of extended arithmetic functions is given in chapter section

Integer arithmetic

Integer arithmetic functions use op erands n in the following descriptions that followthat must

necessarily b e bit xedprecision integertyp e ob jects These functions only do typ e validity

checking in the interpreted mo de and never do overow checks If the arguments received by one

of them are not integers the results will b e unpredictable and can even cause errors in the host

op erating system or hardware All these functions are almost always compiled into a single LLM

instruction

In the interpreter if one of the arguments is not an integer the errnia error is raised Its default screen is

INTEGER ARITHMETIC

function not a fix argument

where function is the name of the function that raised the error and argument is the faulty

argument

Integer arithmetic functions

add x function with one argument

Returns the value x

add )

add )

sub x function with one argument

Returns the value x

sub )

sub )

add x y function with two arguments

Returns the value of the sum x y

add )

sub x y function with two arguments

Returns the value of the dierence x y

sub )

mul x y function with two arguments

Returns the value of the pro duct x  y

mul )

div x y function with two arguments

Returns the integer value of the quotient x  y truncated to the integer value div do es an integer

division on integer arguments If the argument y is zero the errdv error is raised

div )

div )

CHAPTER ARITHMETIC FUNCTIONS

rem x y function with two arguments

Returns the value of the remainder of the integer division of x by y

rem )

rem )

scale x y z function with three arguments

Returns the value of the calculation of x  y  z

So scale x y z is equivalent to div mul x y z

The intermediate value is stored in doubleprecision integer memory dep ending somewhat on the

host machine but in at least bits of storage in order to avoid overow in the intermediate

calculation The nal result is an integer truncatedif necessaryto bits

scale )

scale )

scale )

Fixedprecision integer comparison functions

These functions have either one or two arguments written as x and y which must b e integer

numb er expressions The functions carry out typ e checking only in the interpreted mo de If the

arguments given in a call to one of them are not integers the results are meaningless in compiled

co de All of these functions are almost always compiled into a single LLM instruction

Each of these functions returns its rst argument if the test is true of the arguments If not is

returned

evenp x function with one argument

If the value of the argument x is even evenp returns it as its value Otherwise it returns

oddp x function with one argument

If the value of the argument x is o dd oddp returns it as its value Otherwise it returns

eqn x y function with two arguments

If the value of x is equal to the value of y eqn returns the value of x Otherwise it returns

eqn )

eqn )

neqn x y function with two arguments

INTEGER ARITHMETIC

If the value of x is not equal to the value of y neqn returns the value of x Otherwise it returns

neqn )

neqn )

ge x y function with two arguments

If the value of x is greater than or equal to the value of y ge returns the value of x Otherwise it

returns

ge )

ge )

gt x y function with two arguments

If the value of x is greater than the value of y gt returns the value of x Otherwise it returns

gt )

gt )

le x y function with two arguments

If the value of x is less than or equal to the value of y le returns the value of x Otherwise it

returns

le )

le )

lt x y function with two arguments

If the value of x is less than the value of y lt returns the value of x Otherwise it returns

lt )

lt )

imin x y function with two arguments

If the value of x is less than or equal to the value of y imin returns the value of x Otherwise it

returns the value of y

In LELISP imin could b e dened in the following manner

defun imin x y

if le x y

x

y

imin )

CHAPTER ARITHMETIC FUNCTIONS

imin )

imin )

imin )

imin )

imin )

imax x y function with two arguments

If the value of x is greater than or equal to the value of y imax returns the value of x Otherwise

it returns the value of y

In LELISP imax could b e dened in the following manner

defun imax x y

if ge x y

x

y

imax )

imax )

imax )

imax )

imax )

imax )

Bo olean functions

In all the function descriptions that follow the arguments x and y must b e integers These functions

only work on bit words do no typ e conversion and never cause numeric overow exceptions

They are all compiled from single LLM instructions

lognot x function with one argument

Returns the logical complement of its argument n

The form lognot x is equivalent to logxor x ffff

lognot ) That is hexadecimal ffff

lognot )

logand x y function with two arguments

Returns the logical AND of the values of x and y

logand )

To determine whether x is a p ower of evaluate

x logand x x

INTEGER ARITHMETIC

logor x y function with two arguments

Returns the logical OR of the values of x and y

logor )

logxor x y function with two arguments

Returns the logical exclusive OR of the values of x and y

logxor )

logshift x y function with two arguments

Logically shifts the value x by y bit p ositions If the value of y is p ositive the shift is

towards the left that is towards the most signicant bitthe msb p erforming in eect

a multiplication on x If the value of y is negative the shift is rightwards towards the least

signicant bitthe lsb p erforming in eect a division on x

In LELISP logshift could b e dened in the following manner

defun logshift n nb This definition assumes n positive

if nb

n

if nb

logshift div n nb

logshift mul n nb

logshift )

logshift )

logshift )

logshift )

logshift )

Functions on bit elds

All these functions work on bit words and provide various means to manipulate arbitrary bit

elds within these words Throughout this section a bit eld is describ ed by two numb ers

 np is the numb er of the rst bit of the eld counting from zero

 nl is the length of the bit eld

n function with one argument

Returns the value of two raised to the p ower n This is the value that corresp onds to a word with

th

only the n bit set

In LELISP could b e dened in the following manner

CHAPTER ARITHMETIC FUNCTIONS

defun n

logshift n

)

)

)

maskfie ld n np nl function with three arguments

Returns the bit eld of length nl b eginning at bit np in the word n

In LELISP maskfield could b e dened in the following manner

defun maskfield n np nl

logand logshift sub nl np n

maskfield f )

loadbyt e n np nl function with three arguments

Extracts the bit eld of length nl b eginning at the bit np from the word n

In LELISP loadbyte could b e dened in the following manner

defun loadbyte n np nl

logshift maskfield n np nl sub np

loadbyte f ) c

deposit byt e n np nl m function with four arguments

Returns the value of the word n after the bit eld of length nl b eginning at bit np has b een replaced

by the value m

In LELISP depositbyte could b e dened in the following manner

defun depositbyte n np nl m

let n maskfield logshift m np np nl

n logand n sub np

n logand n lognot sub add np nl

logor n logor n n

depositbyte f ) cc

deposit fie ld n np nl m function with four arguments

Returns the value of the word n after the biteld of length nl b eginning at bit np has b een replaced

by the corresp onding bit eld in the word m

In LELISP depositfield could b e dened in the following manner

EXTENDED INTEGER ARITHMETIC

defun depositfield n np nl m

let n maskfield m np nl

n logand n sub np

n logand n lognot sub add np nl

logor n logor n n

depositfield f c ) cc

loadbyt et es t n np nl function with three arguments

The loadbytetest function tests whether the bit eld of length nl b eginning at p osition np is

nonzero If so the bit eld is returned as value Otherwise loadbytetest returns

In LELISP loadbytetest could b e dened in the following manner

defun loadbytetest n np nl

neqn loadbyte n np nl

loadbytetest f )

loadbytetest f ) c

Pseudorandom functions

srandom x function with an optional argument

Initializes the internal accumulator the seed of the pseudorandom numb er generator with the

numb er x If the argument is not provided srandom returns the current accumulator value

random x y function with two arguments

Returns a numb er from the interval x ::: y This function uses the metho d of linear congruence

describ ed in Knuth vol The internal accumulator g is calculated according to the formula

gn a gn c modulo m

with m a and c prime

This gives a sequence of accumulators with p erio d m ranging across the segment

::: m The random numb er is then calculated by means of the following formula

r n g n n m

This avoids the uneven distribution of the least signicant gures of the results of the

accumulator mo dulo or

Extended integer arithmetic

In order to implement arbitraryprecision numb ers a group of extended xedprecision integer

functions is available For all these functions argumentsexpressed here as x y or zare bit

CHAPTER ARITHMETIC FUNCTIONS

integers All calculations are carried out up on unsigned bit quantities For reasons of eciency

these functions do not test the typ es of their arguments nor do they raise any errors The

carryover of return values when these are longer than bits is always stored in the system

variable exregret

exregr et variable

This variable always contains the most signicant bytes of extended xedprecision integer

functions in the form of a bit integer

ex x y function with two arguments

Returns the leastsignicant bytes a total of bits of the sum

x y exregret

The new overow is found in the exregret variable

setq exregret )

ex )

exregret )

setq exregret )

ex )

exregret )

setq exregret )

ex ffff ffff )

exregret )

setq exregret )

ex ffff ffff )

exregret )

ex x function with one argument

Returns the leastsignicant bytes a total of bits of the sum

x exregret

It is therefore equivalent to ex x

The new overow is found in the exregret variable

setq exregret )

ex )

exregret )

ex ffff )

exregret )

ex x function with one argument

Returns the unsigned bit inverse of x

EXTENDED INTEGER ARITHMETIC

ex )

ex )

ex )

ex )

ex )

ex x y z function with three arguments

Returns the leastsignicant bytes bits total of the calculation

x y z exregret

The mostsignicant bytes bits total are found in the exregret variable

setq exregret )

ex )

exregret )

setq exregret )

ex )

exregret )

setq exregret )

ex )

exregret )

ex x y function with two arguments

The exregret variable should contain the mostsignicant bytes of the dividend and

x should contain the leastsignicant bytes of this same dividend ex returns the least

signicant bytes bits total of the division of this dividend by the divisor y and the

remainder is stored in the exregret variable

exregretx y is returned as the value of ex

exregret gets set to exregretx rem y

setq exregret )

ex )

exregret )

setq exregret )

ex )

exregret )

setq exregret )

ex )

exregret )

setq exregret )

ex )

exregret )

CHAPTER ARITHMETIC FUNCTIONS

ex x y function with two arguments

Returns if the value of x is strictly less than the value of y if these values are equal and

if the value of x is strictly greater than the value of y The comparisons are carried out on

bit unsigned quantities

ex )

ex )

ex )

ex )

ex )

ex )

ex )

Floatingp oint arithmetic

Functions describ ed here take argumentsx and y in the descriptions that followthat must b e

oats They p erform typ e checking only in the interpreted mo de If the arguments given in a

call to one of them are not oatingp oint numb ers the results will b e undened and might cause

errors in the host op erating system or hardware All these functions are compiled into single LLM

instructions

In the interpreter if one of the arguments is not a oatingp oint numb er the errnfa error is raised

Its default screen display is

function not a float argument

where function is the name of the function that raised the error and argument is the faulty

argument

Floatingp oint arithmetic functions

fadd x y function with two arguments

Returns the value of the sum x y

fadd )

fsub x y function with two arguments

Returns the value of the dierence x y

fsub )

fmul x y function with two arguments

Returns the value of the pro duct x  y

FLOATINGPOINT ARITHMETIC

fmul )

fdiv x y function with two arguments

Returns the quotient x  y If the argument y is the errdv error is raised

fdiv )

fdiv )

Floatingp oint arithmetic comparisons

Each of these functions takes two argumentsx and y in the descriptions that followwhich must

b e oatingp oint numb ers They only p erform typ e checks on their arguments in the interpreted

mo de If the arguments passed to these functions are not oatingp oint numb ers the results are

meaningless for compiled functions

All these functions return their rst argument if the test succeeds and if not

feqn x y function with two arguments

If the value of x is equal to the value of y feqn returns x Otherwise it returns

feqn )

feqn )

fneqn x y function with two arguments

If the value of x is not equal to the value of y fneqn returns x Otherwise it returns

fneqn )

fneqn )

fge x y function with two arguments

If the value of x is greater than or equal to the value of y fge returns x Otherwise it returns

fge )

fge )

fgt x y function with two arguments

If the value of x is greater than the value of y fgt returns x Otherwise it returns

fgt )

fgt )

fle x y function with two arguments

CHAPTER ARITHMETIC FUNCTIONS

If the value of x is less than or equal to the value of y fle returns x Otherwise it returns

fle )

fle )

flt x y function with two arguments

If the value of x is less than the value of y flt returns x Otherwise it returns

flt )

flt )

fmin x y function with two arguments

If the value of x is less than or equal to the value of y fmin returns x Otherwise it returns n

In LELISP fmin could b e dened in the following manner

defun fmin x y

if fle x y

x

y

fmin )

fmin )

fmin )

fmin )

fmin )

fmin )

fmax x y function with two arguments

If the value of x is greater than or equal to the value of y fmax returns x Otherwise it returns y

In LELISP fmax could b e dened in the following manner

defun fmax x y

if fge x y

x

y

fmax )

fmax )

fmax )

fmax )

fmax )

fmax )

MIXED ARITHMETIC

Mixed arithmetic

Arguments to these functions can b e either integers or oatingp oint numb ers If one of their

arguments is a oat or if an integer arithmetic op eration overows the result is a oat If all

the arguments are integers the result is an integer Therefore the functions carry out automatic

argument conversion giving priority to oatingp oint numb ers If one of the arguments is neither

an integer nor a oatingp oint numb er the errnna error is raised Its default screen display is

function not a number argument

where function is the name of the function that raised the error and argument is the faulty

argument

There are no sp ecial comparison functions for this kind of arithmetic The generic comparisons are

sucient

Mixed arithmetic is just a kind of oatingp oint arithmetic in which integers can b e used

plus x ::: x function with a variable number of arguments

1 n

Returns the value of the sum x x ::: x If no argument is given plus returns the additive

1 2 n

identity

plus )

plus )

plus )

plus )

plus )

plus )

differ x ::: x function with a variable number of arguments

1 n

differen ce x ::: x function with a variable number of arguments

1 n

These two identical functions return the value of the dierence x x ::: x If no argument

1 2 n

is given they return the right subtractive identity Given a single argument they return its

additive inverse

difference )

difference )

difference )

difference )

difference )

difference )

times x ::: x function with a variable number of arguments

1 n

Returns the value of the pro duct x  x  :::  x If no argument is given times returns the

1 2 n

CHAPTER ARITHMETIC FUNCTIONS

multiplicative identity

times )

times )

times )

times )

times )

times )

times ) e

divide x y function with two arguments

Returns the value of the quotient x  y If the two arguments are b oth integers and their quotient

is not exact divide returns a oatingp oint value If the argument y is zero the errdv error is

raised

divide )

divide )

divide )

divide )

divide )

Table of contents

Arithmetic functions

Generic arithmetic ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Generic arithmetic interrupt ::::::::::::::::::::::::::::::::::::::::::::::

Typ e tests ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Numeric conversions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Generic arithmetic functions ::::::::::::::::::::::::::::::::::::::::::::::

Predicates of generic arithmetic :::::::::::::::::::::::::::::::::::::::::::

Circular and mathematical functions ::::::::::::::::::::::::::::::::::::::

Extensions to generic arithmetic ::::::::::::::::::::::::::::::::::::::::::

Integer arithmetic ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Integer arithmetic functions ::::::::::::::::::::::::::::::::::::::::::::::

Fixedprecision integer comparison functions :::::::::::::::::::::::::::::::

Bo olean functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Functions on bit elds ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Pseudorandom functions :::::::::::::::::::::::::::::::::::::::::::::::::

Extended integer arithmetic ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Floatingp oint arithmetic ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Floatingp oint arithmetic functions :::::::::::::::::::::::::::::::::::::::

Floatingp oint arithmetic comparisons :::::::::::::::::::::::::::::::::::::

Mixed arithmetic ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Table of Contents

Function Index

genarith arithmetic interrupt ::::::::::::::::::::::::::::::::::::::::::::::::::: :

syspackagegenarith variable ::::::::::::::::::::::::::::::::::::::::::::::::

numberp x function with one argument ::::::::::::::::::::::::::::::::::::::::::::

fixp x function with one argument ::::::::::::::::::::::::::::::::::::::::::::::::

floatp x function with one argument :::::::::::::::::::::::::::::::::::::::::::::

truncate x function with one argument :::::::::::::::::::::::::::::::::::::::::::

fix x function with one argument :::::::::::::::::::::::::::::::::::::::::::::::::

floor n function with one argument :::::::::::::::::::::::::::::::::::::::::::::::

ceiling n function with one argument ::::::::::::::::::::::::::::::::::::::::::::

round n d function with two arguments ::::::::::::::::::::::::::::::::::::::::::::

float x function with one argument :::::::::::::::::::::::::::::::::::::::::::::::

x ::: x function with a variable number of arguments ::::::::::::::::::::::::::::

1 n

x function with one argument ::::::::::::::::::::::::::::::::::::::::::::::::::

x ::: x function with a variable number of arguments ::::::::::::::::::::::::::::

1 n

x function with one argument ::::::::::::::::::::::::::::::::::::::::::::::::::

abs x function with one argument :::::::::::::::::::::::::::::::::::::::::::::::::

x ::: x function with a variable number of arguments ::::::::::::::::::::::::::::

1 n

x y function with one or two arguments ::::::::::::::::::::::::::::::::::::::::::

x y function with one or two arguments :::::::::::::::::::::::::::::::::::::::::

quo x y function with two arguments ::::::::::::::::::::::::::::::::::::::::::::::

quotient x y function with two arguments ::::::::::::::::::::::::::::::::::::::::

modulo x y function with two arguments ::::::::::::::::::::::::::::::::::::::::::

quomod x y function with two arguments ::::::::::::::::::::::::::::::::::::::::::

exmod variable ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

min x ::: x function with a variable number of arguments :::::::::::::::::::::::::

1 n

max x ::: x function with a variable number of arguments :::::::::::::::::::::::::

1 n

FUNCTION INDEX

x y function with two arguments ::::::::::::::::::::::::::::::::::::::::::::::

x x ::: x function with a variable number of arguments :::::::::::::::::::::::::

1 2 n

x y function with two arguments :::::::::::::::::::::::::::::::::::::::::::::::

x y function with two arguments :::::::::::::::::::::::::::::::::::::::::::::::

x x ::: x function with a variable number of arguments ::::::::::::::::::::::::

1 2 n

x x ::: x function with a variable number of arguments :::::::::::::::::::::::::

1 2 n

x x ::: x function with a variable number of arguments ::::::::::::::::::::::::

1 2 n

x x ::: x function with a variable number of arguments :::::::::::::::::::::::::

1 2 n

zerop x function with one argument :::::::::::::::::::::::::::::::::::::::::::::::

plusp x function with one argument :::::::::::::::::::::::::::::::::::::::::::::::

minusp x function with one argument :::::::::::::::::::::::::::::::::::::::::::::

sin x function with one argument :::::::::::::::::::::::::::::::::::::::::::::::::

cos x function with one argument :::::::::::::::::::::::::::::::::::::::::::::::::

asin x function with one argument ::::::::::::::::::::::::::::::::::::::::::::::::

acos x function with one argument ::::::::::::::::::::::::::::::::::::::::::::::::

atan x function with one argument ::::::::::::::::::::::::::::::::::::::::::::::::

exp x function with one argument :::::::::::::::::::::::::::::::::::::::::::::::::

log x function with one argument :::::::::::::::::::::::::::::::::::::::::::::::::

log x function with one argument :::::::::::::::::::::::::::::::::::::::::::::::

power x y function with two arguments ::::::::::::::::::::::::::::::::::::::::::::

sqrt x function with one argument ::::::::::::::::::::::::::::::::::::::::::::::::

add x function with one argument ::::::::::::::::::::::::::::::::::::::::::::::::

sub x function with one argument ::::::::::::::::::::::::::::::::::::::::::::::::

add x y function with two arguments ::::::::::::::::::::::::::::::::::::::::::::::

sub x y function with two arguments ::::::::::::::::::::::::::::::::::::::::::::::

mul x y function with two arguments ::::::::::::::::::::::::::::::::::::::::::::::

div x y function with two arguments ::::::::::::::::::::::::::::::::::::::::::::::

rem x y function with two arguments ::::::::::::::::::::::::::::::::::::::::::::::

scale x y z function with three arguments ::::::::::::::::::::::::::::::::::::::::

evenp x function with one argument :::::::::::::::::::::::::::::::::::::::::::::::

oddp x function with one argument ::::::::::::::::::::::::::::::::::::::::::::::::

eqn x y function with two arguments ::::::::::::::::::::::::::::::::::::::::::::::

neqn x y function with two arguments :::::::::::::::::::::::::::::::::::::::::::::

ge x y function with two arguments :::::::::::::::::::::::::::::::::::::::::::::::

FUNCTION INDEX

gt x y function with two arguments :::::::::::::::::::::::::::::::::::::::::::::::

le x y function with two arguments :::::::::::::::::::::::::::::::::::::::::::::::

lt x y function with two arguments :::::::::::::::::::::::::::::::::::::::::::::::

imin x y function with two arguments :::::::::::::::::::::::::::::::::::::::::::::

imax x y function with two arguments :::::::::::::::::::::::::::::::::::::::::::::

lognot x function with one argument :::::::::::::::::::::::::::::::::::::::::::::

logand x y function with two arguments ::::::::::::::::::::::::::::::::::::::::::

logor x y function with two arguments ::::::::::::::::::::::::::::::::::::::::::::

logxor x y function with two arguments ::::::::::::::::::::::::::::::::::::::::::

logshift x y function with two arguments ::::::::::::::::::::::::::::::::::::::::

n function with one argument :::::::::::::::::::::::::::::::::::::::::::::::::

maskfield n np nl function with three arguments ::::::::::::::::::::::::::::::::

loadbyte n np nl function with three arguments :::::::::::::::::::::::::::::::::

depositbyte n np nl m function with four arguments ::::::::::::::::::::::::::::

depositfield n np nl m function with four arguments :::::::::::::::::::::::::::

loadbytetest n np nl function with three arguments :::::::::::::::::::::::::::

srandom x function with an optional argument ::::::::::::::::::::::::::::::::::::::

random x y function with two arguments ::::::::::::::::::::::::::::::::::::::::::

exregret variable ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::

ex x y function with two arguments ::::::::::::::::::::::::::::::::::::::::::::::

ex x function with one argument ::::::::::::::::::::::::::::::::::::::::::::::::

ex x function with one argument :::::::::::::::::::::::::::::::::::::::::::::::::

ex x y z function with three arguments :::::::::::::::::::::::::::::::::::::::::::

ex x y function with two arguments ::::::::::::::::::::::::::::::::::::::::::::::

ex x y function with two arguments ::::::::::::::::::::::::::::::::::::::::::::::

fadd x y function with two arguments :::::::::::::::::::::::::::::::::::::::::::::

fsub x y function with two arguments :::::::::::::::::::::::::::::::::::::::::::::

fmul x y function with two arguments :::::::::::::::::::::::::::::::::::::::::::::

fdiv x y function with two arguments :::::::::::::::::::::::::::::::::::::::::::::

feqn x y function with two arguments :::::::::::::::::::::::::::::::::::::::::::::

fneqn x y function with two arguments ::::::::::::::::::::::::::::::::::::::::::::

fge x y function with two arguments ::::::::::::::::::::::::::::::::::::::::::::::

fgt x y function with two arguments ::::::::::::::::::::::::::::::::::::::::::::::

fle x y function with two arguments ::::::::::::::::::::::::::::::::::::::::::::::

FUNCTION INDEX

flt x y function with two arguments ::::::::::::::::::::::::::::::::::::::::::::::

fmin x y function with two arguments :::::::::::::::::::::::::::::::::::::::::::::

fmax x y function with two arguments :::::::::::::::::::::::::::::::::::::::::::::

plus x ::: x function with a variable number of arguments ::::::::::::::::::::::::

1 n

differ x ::: x function with a variable number of arguments ::::::::::::::::::::::

1 n

difference x ::: x function with a variable number of arguments :::::::::::::::::

1 n

times x ::: x function with a variable number of arguments :::::::::::::::::::::::

1 n

divide x y function with two arguments ::::::::::::::::::::::::::::::::::::::::::

Chapter

Ob jectoriented programming

This chapter rst describ es functions that provide ways to create structured ob jects in LISP These

ob jects are analogous to Pascal records In addition LISP allows you to create a hierarchy of

structure typ es

The second section is a description of the basic LISP typ e hierarchy and the means provided for

extending it typ ed vectors typ ed strings and tagged pairs Since they are implemented as typ ed

vectors structures provide the most immediate way to extend the LELISP typ e scheme

The third section explains how to use the primitive oblist search functions and the typing functions

to implement an ob jectoriented language of the SmallTalk variety

The fourth section presents an abbreviation facility for describing typ ed ob jects

The nal section describ es a minimal kernel on which ob jectoriented extensions can b e built This

kernel called MicroCeyx b enets from exp erience acquired in the creation at INRIA of earlier

ob jectoriented pro ducts called Ceyx and Alcyone

Structures

The defstruct primitive provides the means to dene new typ es of structured ob jects structures

analogous to Pascal records The new function facilitates the creation of instances of these typ es of

ob jects

Structured ob jects are made up of a numb er of named elds Each eld can contain any kind of

LISP ob ject These elds are not typ ed You can examine and mo dify the contents of the elds of

a structured ob ject by means of eldaccess functions which are dened along with structures

You can dene a structure as a substructure of a previously dened structure In this case in

addition to the elds explicitly declared within its denition the substructure will inherit all the

elds of the original parent structure

defstruct feature

This feature indicates that functions on structures are loaded into the system

CHAPTER OBJECTORIENTED PROGRAMMING

Structure denition

defstruc t struct field field macro

1 n

Denes a structure named struct which is a symb ol containing the elds field field

1 n

struct b ecomes a new typ e of LISP ob ject See the typeof function

field field are the names of the structures elds They are either symb ols or two

1 n

element lists In the second case the rst element in the list is the eld name and the second

element is a LISP form that is evaluated to assign an initial value to the eld when instances

are created This evaluation takes place each time an instance of the structure is created

When a structure is dened readaccess and writeaccess functions as well as a sp ecic

instance creation function are dened simultaneously These functions are describ ed further

on in this do cument

If struct is of the form superstructurestructure where superstructure is the

name of a structure previously dened in the system struct will have in addition to

the elds field field all the elds of superstructure In this case the typ e

1 n

superstructurestructure is a subtyp e of the superstructure typ e

system def st ruc t all ac ce ss fl ag variable

The defstruct macro examines this ag to determine whether access functions dened for

inherited elds should b e made available for use with the structure currently b eing dened

By default this ag is true In other words it has the value t If it is false then the only

access functions dened and available for use with this structure will b e those for elds that

are supplied explicitly as arguments to the relevant defstruct macro

Instance creation

new struct function with one argument

struct ma ke function with no arguments

These two functions create a new instance of the struct structure and return it as their value

The structmake function is the creation functionconstructor for the struct structure It

is automatically dened by the defstruct macro Ob jects created with this constructor will have

typ e struct See the typeof function

The elds of the ob ject so created are optionally initialized with the initialization forms included

in the structure denition These forms are evaluated when the ob ject is created The order of

evaluation of the initialization forms is not fully determined Fields for which no initialization

forms are provided are initialize d with the value

If the argument to the new function is not the name of a structure already dened in the system

the errstc error is raised and this screen is displayed

STRUCTURES

fn not a structure s

where fn is the name of the function that raised the error in this case new and s is the

bad argument

In LELISP new could b e dened in the following manner

defun new type

if structurep type

apply symbol type make

error new errstc type

Access to elds

struct fi el d o e function with one or two arguments

struct is the name of a structure and field is the name of one of the structures elds The

structfield functions are the access functions to the elds of instances of the structure struct

and they are automatically dened by the defstruct function

If the ob ject o is not an instance of the struct structure see the typep function the errstc

error is raised Given a single argument an access function returns the value of the eld field of

the ob ject o If a second argument is given its value is stored in the eld field of the ob ject o

and is also returned as the value of the access function

Supp ose that the LELISP compiler is active when the structure is dened Consequently the form

featurep compiler is true In this case eldaccess functions are dened to b e compiler

macros See the defmacroopen function Compilation of calls to these functions pro duces

extremely ecient co de After b eing compiled access functions will not do typ e checks on their

rst arguments

Typ e tests

structur ep o function with one argument

This predicate is true if the ob ject o is an instance of a dened structure See also the typep

function

Here for example is the denition of a structure person with two elds age and weight The

second eld is initialized with the value

defstruct person

age

weight

person

CHAPTER OBJECTORIENTED PROGRAMMING

Creation of an instance

setq person personmake

person

Assign the value to the age eld of the person ob ject

personage person

Extract the weight eld

personweight person

Use the structurep function

structurep person

t

Next we lo ok at an example of a substructure Extend the person structure into a

researcher structure

defstruct personresearcher

project

articles

personresearcher

Creation of a researcher and automatic initialization of a eld

setq r personresearchermake

personresearcher personresearcherarticles r

confproc thesis

confproc thesis

The researcher inherits the elds of the person structure

personweight r

personage r

personresearcherweight r

personresearcherage r

Implementation of structures

Instances of a structure are implemented as typ ed vectors whose typ e is the name of the structure

The values of the ob jects elds are stored in vector cells

LeLisp typ ology

LELISP ob ject typ es are represented by symb ols The LISP package hierarchy provides a way to

organize these typ es The symb ol personresearcher represents the researcher subtyp e of

the person typ e

LELISP TYPOLOGY

It is not strictly necessary to explicitly create new typ es Simply invoking the symb ol foobar

results in a successful mention of the typ e foo and its subtyp e bar Any LISP symb ol can therefore

b e interpreted as b eing a typ e

In practice the interesting typ es are those capable of b eing returned as values of the typeof

function either a predened system typ e or a user type that is the typ e of a typ ed vector a

typ ed string or a tagged pair

The basic LISP typ es are predened In other words they are already present at system startup

They all have the empty typ e the typ e which is the universal typ e

The basic LISP typ es are

fix small integers

float oatingp oint numb ers

symbol symb ols

null the endoflist marker

string character strings

vector vectors of p ointers

cons list cells

typeof s function with one argument

This function determines the typ e of any LISP ob ject If the argument is a string or a vector typeof

returns the typ e of the ob ject in question In these cases typeof is equivalent to typestring or

typevector resp ectively If the argument is a tagged pair typeof returns its car provided that

this is an atom or a list whose car is an atom In all other casesexcept the error condition

asso ciated with tagged pairs see b elowtypeof returns the LISP typ e of the ob ject fix float

cons etc

If the car of a tagged pair argument is neither a symb ol nor the symb ol of a list the result of

typeof is undened

In LELISP typeof could b e dened in the following manner

defun typeof s

cond fixp s fix

floatp s float

null s null

symbolp s symbol

consp s

if tconsp s

when or atom car s symbolp caar s

car s

cons

vectorp s typevector s

CHAPTER OBJECTORIENTED PROGRAMMING

stringp s typestring s

t

typeof

fix typeof

float typeof

null typeof asd

symbol typeof assasa

string typeof

vector typeof foobarhello mamma

foobar typeof person

person typeof

cons typeof foo a

foo

subtypep type type function with two arguments

type and type are two symb ols representing LISP typ es The predicate subtypep is true if type

is a subtyp e of type and false otherwise

In LELISP subtypep could b e dened in the following manner

defun subtypep type type

or eq type type

ifn packagecell type

null type

subtypep packagecell type type

subtypep personresearcher person

t subtypep symbol symbol

t subtypep personresearcher persondiscoverer

subtypep fix

t

typep s type function with two arguments

This predicate is true if the typ e of the ob ject s is a subtyp e of type

In LELISP typep could b e dened in the following manner

defun typep s type

subtypep typeof s type

typep personresearchermake person

t typep foo symbol

t typep personresearchermake persondiscoverer

typep

t

OBJECTORIENTED PROGRAMMING

Ob jectoriented programming

The LELISP package hierarchy is used to enco de the hierarchy of data typ es In an ob jectoriented

language of the SmallTalk varietysuch as Ceyx or Alcyone for exampleone wants to b e able

to attach methods to ob ject typ es

In LELISP these metho ds are LISP functions dened in the packages to whose typ es they are

attached So the function persondescribe is considered to b e the describe metho d attached

to the person typ e

The goal is for the subtyp es of a given typ e to inherit the metho ds attached to this typ e For

example the ob jects of typ e personresearcher should inherit the describe metho d of the

person ob ject The predened getfn function provides a way to do this metho d search accounting

for inheritance

Sometimes it is desirable to have an ob ject typ e inherit metho ds from several LISP typ es This is

multiple inheritance The getfn function searches for a function in a list of packages by rst doing

a depthrst search in the parent sup erior packages of those in the list

Finally you sometimes need metho ds asso ciated with a mixture of several typ es of ob jects For

instance to implement a generic arithmetic package metho ds would have to b e dened that allow

you to add together dierent typ es of numb ers such as float fix bignum and rational In LE

LISP the metho ds of the product of typ es t and t are lo cated in the product package designated

as t t An addition metho d of the desired kind would b e written as t tadd The

predened getfn function provides a means of searching for pro duct metho ds

Searching for metho ds

The following functions are predened search functions that op erate on metho ds

getfn pkgc fn function with two arguments

Searches for a function named fn in the pkgc package If this function exists it is returned as the

value of getfn If not the function returns

In LELISP getfn could b e dened in the following manner

defun getfn pkgc fn

let nom symbol pkgc fn

if typefn nom

nom

getfn car car

defun foobar foobar

getfn foo bar foobar

getfn gee bar

CHAPTER OBJECTORIENTED PROGRAMMING

getfn pkgc fn pkgc function with two or three arguments

Searches for a function named fn in the pkgc package or in one of the packages that is sup erior

to pkgc in the package hierarchy If the optional pkgc argument is given it is excluded from

the search On the search up the package tree if pkgc is encountered the search is terminated

immediately pkgc is not searched If the function is found it is returned as the value of getfn If

not getfn returns

If pkgc is a list of packages the search b egins in the rst package in the list and in all its parent

packages then in the second package in the list and in all its parent packages and so on until

either the function is found or the list of packages names is exhausted This depthsearch also takes

place if one of the parents of pkgc is a list This mechanism can b e used to implement multiple

inheritance of metho ds In this case the third argument if present provides a way to stop the

search for each package in the list

In LELISP getfn could b e dened in the following manner

defun getfn pkgc symb lastpkgc

let nom symbol pkgc symb

cond typefn nom nom

null pkgc

and consp lastpkgc

eq packagecell pkgc

car lastpkgc

t getfn packagecell pkgc

symb lastpkgc

Let us dene some functions

defun foo foo

defun barfoo barfoo

defun bargeebuzfoo bargeebuzfoo

getfn bargeebuz foo bargeebuzfoo

getfn bargee foo barfoo

getfn bar foo barfoo

getfn foo foo

getfn potopteraz foo foo

getfn bargee foo barfoo

getfn bar foo barfoo

getfn gee foo

getfn bargeebuz foo bar bargeebuzfoo

getfn bargee foo bar

getfn pkgc pkgc fn function with three arguments

Allows you to search for the function fn in the pro duct package pkgc pkgc or in one of

the pro duct packages that is sup erior to this one The pro duct package hierarchy is built from the

OBJECTORIENTED PROGRAMMING

package hierarchy by imp osing a lexicographic ordering on the combinations of p ossible pairs The

climb up the pro duct package hierarchy is always stopp ed b efore reaching the ro ot package for one

of the two memb ers of the pro duct

The packages sup erior to the package ab cd are in order

ab cd ab c a cd a c

Invoking metho ds

The combination of typ edeterminating functions and metho d search functions provides a way to

implement message transmission functions

send symb o p p function with a variable number of arguments

1 n

senderr or symb rest function with two arguments

The send function searches for and invokes the metho d symb assso ciated with the typ e of the ob ject

o This metho d must b e a LISP function that takes n arguments It is called with the list of

arguments formed by the ob ject o and the n arguments p p

1 n

The intended metho d is the LISP function named symb in the package that is the typ e of the ob ject

o or in one of its parent packages up to and excluding the ro ot package If no such metho d is

found send calls the senderror function By default this function raises the errudm error and

displays the following error screen

fn undefined method l

where l is the list of arguments supplied to send and fn is the name of the function that

raises the error here send

In LELISP send could b e dened in the following manner

defun send m o larg

let fn getfn typeof o m

if fn

apply fn o larg

funcall senderror m cons o larg

In LELISP senderror could b e dened in the following manner

defun senderror m rest

error send errudm cons m rest

Here is a denition of the hello metho d for ob jects of typ e fix

defun fixhello n

repeat n print hello

fixhello

CHAPTER OBJECTORIENTED PROGRAMMING

Search for this metho d and invoke it

send hello

hello

hello

hello

t

And here is a denition of the hello metho d for ob jects of the typ e person

defun personhello pers

print I am a person

print I weigh personweight pers pounds

personhello send hello personmake

I am a person

I weigh pounds

pounds send hello personresearchermake

I am a person

I weigh pounds

pounds

sendsup er type symb o p p function with a variable number of arguments

1 n

The function b ehaves very much like the send function except that the metho d is sought

b eginning with but excluding the package type and not b eginning with the typ e of the

ob ject o type must however b e the name of one of the parent typ esthat is parent

packagesof the typ e or package of ob ject o If not an error will b e raised

sendsuper is used primarily inside metho ds to invoke a metho d of the same name but

dened at a higher level in the typ e hierarchy

In the following example the describe metho d is dened for ob jects of typ e person It is

redened for ob jects of the subtyp e personresearcher so that it invokes the describe

metho d at the level immediately ab ove personresearcher in the typ e hierarchy and then

do es some pro cessing sp ecic to ob jects of the personresearcher typ e

defun persondescribe p

print A person personage p years old who weighs

personweight p pounds

persondescribe

defun personresearcherdescribe r

sendsuper personresearcher describe r

print who has written

length personresearcherarticles r

articles

personresearcherdescribe

send describe personresearchermake

A person years old who weighs pounds

who has written articles

OBJECTORIENTED PROGRAMMING

articles

CHAPTER OBJECTORIENTED PROGRAMMING

csend fndef symb o p p function with a variable number of arguments

1 n

This function is similar to the send function If the search for the metho d fails instead of

rising an error csend calls the fndef function with all the arguments of csend except the

rst

This function is particularly useful for redening the search for metho ds One can dene

metho ds by default in a sp ecial package for instance or implement another multiple

inheritance

In LELISP csend could b e dened in the following manner

defun csend default s o largs

let fun getfn typeof o s

if fun

apply fun o largs

apply default s o largs

Use the package as a default

defun default m para

apply getfn m jj para

default

defun describe o

print An unknown object

describe

csend default describe

An unknown object

An unknown object csend default describe personmake

A person years old who weighs pounds

pounds

send symb o o p p function with a variable number of arguments

1 n

This function searches for and invokes the metho d symb asso ciated with the pro duct typ e of

the ob jects o and o Searching is done by the getfn function see its description The

function if it is found is invoked with o o and p p as arguments

1 n

Here are some denitions of metho ds for pro duct typ es

defun a afoo o o

aa

a afoo

defun a abfoo o o

ab

a abfoo

defun ab afoo o o

ba

ab afoo

OBJECTORIENTED PROGRAMMING

defun a acfoo o o

ac

a acfoo

We can invoke these metho ds The ob jects here are tagged pairs

send foo a a

aa send foo a ab

ab send foo ab a

ba send foo ab ab

ba send foo ac ab

ab send foo ab ac

ba send foo ac ac

ac

Predened metho ds

LELISP uses the send function internally to print and evaluate LISP ob jects

Commands to print LISP ob jects that are implemented as typ ed vectors typ ed character strings

and tagged pairs cause a prin message to b e sent to these ob jects This message should cause the

ob ject to b e printed onto the output channel without any endofline character If no print metho d

exists for the ob ject the default print format is used

Print metho ds are used by all the printing functions such as print prin prinflush and explode

They will b e used for instance when the parameters of a traced function entire functions or error

messages are printed

The following warning applies in the last of these cases If the print metho d raises an error it is

very probable the error pro cedure reuses the same print metho d and raises the same error You

therefore run the risk of getting the famous lo oping error in the error handler error It is therefore

suggested that the print metho ds for an ob ject b e implemented under a name other than prin

Name them prin only when they seem to have b een completely debugged

The evaluation metho ds are used for typ ed vectors The evaluation of a typ ed vector causes the

eval message to b e sent to the vector If no eval metho d exists for the vector the evaluation of

the vector returns the vector itself as its value Otherwise if an eval metho d exists it is the result

of the vectors eval metho d that is returned as a value

In the following example the ob jects of person typ e will b e printed as Page weight The

macro provides a means of rereading this form of output

defun personprin p

prin m personage p personweight p

personprin

new person

m

defsharp m

let ageweight read

person new person

CHAPTER OBJECTORIENTED PROGRAMMING

personage person car ageweight

personweight person cadr ageweight

list person

h

m

m

Abbreviation functions

This section describ es a set of functions that allow the programmer to use abbreviations while

addressing the LELISP reader Once instantiated these abbreviations are used by the LELISP

reader if the systemprintwithabbrevflag ag is set

In the worst of cases this feature can raise the following errors

errsxtacc which has the following default screen display

fn bad abbreviation e

errsxtclosingacc which has the following default screen display

fn not within e

errnotanabbrev which has the following default screen display

fn not an abbreviation e

abbrev feature

This ag indicates that the abbreviation package has b een loaded into the system

putabbr ev sym sym function with two arguments

defabbre v sym sym macro

These two functions dene the symb ol sym to b e an abbreviation of the symb ol sym After calling

one of these functions the o ccurrence of the symb ol sym b etween bracesthe characters and

is exactly equivalent for the LISP reader to the o ccurrence of the symb ol sym If a previous

abbreviation existed it is changed

defabbrev is identical to putabbrev except that it do es not evaluate its arguments

Consider for instance the following denition

defabbrev foo bargee

foo

ABBREVIATION FUNCTIONS

foo is read as bargee

foomuu is read as bargeemuu

foo is read as bargee

getabbr ev symb function with one argument

Returns the symb ol that has symb as its abbreviation If symb is not an abbreviation it raises the

errnotanabbrev error

getabbrev foo bargee

getabbrev bar getabbrev not an abbreviation bar

abbrevp symb function with one argument

Returns t if symb is an abbreviation If not it returns

abbrevp foo t

abbrevp bar

hasana bbr ev symb function with one argument

Returns the abbreviation of the symb ol symb

hasanabbrev bargee foo

remabbr ev symb function with one argument

Removes the abbreviation asso ciated with the symb ol symb and returns symb as its value

remabbrev foo foo

fsymbg macro character

The macro characters and facilitate the reading of abbreviations A symb ol b etween braces is

read as though it were the symb ol it abbreviates If symb is not an abbreviation then symb is read

as or If symb is not a symb ol or if there are several LISP ob jects b etween a single pair of

braces the errsxtacc error is raised

system pri nt wi th ab bre v fla g variable

If this ag is setthat is if it is truethe standard printer unabbreviates abbreviated symb ols on

output By default this ag has the value true

Here is a denition of the print metho d for symb ols with abbreviations

defun symbolprin symb

if and systemprintwithabbrevflag

CHAPTER OBJECTORIENTED PROGRAMMING

hasanabbrev packagecell symb

progn let systemprintforread

pratom

pratom hasanabbrev packagecell symb

let systemprintforread

pratom

let systemprintpackageflag

pratom symb

pratom symb

MicroCeyx

This section describ es the MicroCeyx ob ject layer which is a smaller version of the original Ceyx

All the MicroCeyx structures are subtyp es of a ro ot class called tclass which will b e mentioned

frequently in the rest of this chapter

microceyx feature

This feature indicates whether or not MicroCeyx is loaded into the system

Sp ecic errors

All the MicroCeyx functions check the typ e and form of their arguments They can raise one of the

errors listed b elow

defvar errnotafield

argument not a field of a microceyx tclass

defvar errnotatclass

argument not a name of a microceyx tclass

defvar errtclassabbrev

abbrev of microceyx tclass already defined

defvar errrecordabbrev

abbrev of microceyx record already defined

defvar errbadfield

syntax error in field

defvar errrecordtoolong

fields maximum per record

defvar errnotarecordoratclass

MICROCEYX

argument not a name of microceyx tclass or record

Denition of structures

deftclas s symbol field field macro

1 n

This function is identical to the defstruct function the only dierence b eing that the typ e it

denes is a subtyp e of tclass if this was not already the case Moreover the symb ol symbol

of the ro ot package is dened as b eing the abbreviation for symbol in its entirety

The form

deftclass foo a b c

tclassfoo

corresp onds to

progn let systemdefstructallaccessflag

defstruct tclassfoo a b c

defabbrev foo tclassfoo

Likewise the form

deftclass ffoogbar d

ffoogbar

corresp onds to

progn let systemdefstructallaccessflag

defstruct tclassfoobar d

defabbrev bar tclassfoobar

defrecor d symbol field field macro

1 n

This function is similar to the defstruct function except that the instances it creates are

implemented in the form of balanced binary trees of lists cells Moreover the instances contain

no typ e information They only satisfy the consp and listp predicates

symbol must b e in the ro ot package There is no inheritance for the records For consistency

with the deftclass function the abbreviation symbolstanding for symbol itselfis

dened

A record cannot have more than elds otherwise the errrecordtoolong error is raised

defrecord recfoo a b

recfoo

tclassn ame p symbol function with one argument

This predicate is true if its argument is the name of a class dened by the deftclass function

CHAPTER OBJECTORIENTED PROGRAMMING

tclassnamep tclassfoo t

tclassnamep fbarg t

tclassnamep foothebarre

tclassnamep foo bar

recordn ame p symbol function with one argument

This predicate is true if its argument is the name of a record dened by defrecord

recordnamep recfoo t

recordnamep bar

recordnamep

fieldli st symbol function with one argument

Returns the list of the eld names of instances of the tclass referred to as symbol which

must b e a valid tclass name and not an abbreviation

fieldlist ffoog a b c

fieldlist tclassfoobar a b c d

Tclass and record instances

defmake type fn field field macro

1 n

Denes the function fn to b e an instance constructor function for the tclass or record referred to

as type The function fn takes n arguments which are the values of the elds named field of

i

the instance that is created

defmake ffoog makefoo c a

makefoo setq x makefoo

tclassfoo ffooga x

ffoogc x

omakeq type field val field val macro

1 1 n n

Returns an instance of the tclass referred to as type Within this instance each field has

i

the value val Neither type nor the field are evaluated

i i

omakeq fbarg tclassfoobar

omakeq fbarg a tclassfoobar

ogetq tclassorrecord field obj macro

MICROCEYX

oputq tclassorrecord field obj val macro

omatchq tclass obj macro

These functions are identical to the corresp onding Ceyx functions

ogetq ffoog b omakeq ffoog

ogetq frecfoog b omakeq frecfoog b

omatchq ffoog omakeq fbarg t

Metho ds and message sending

demethod ftclassgname obj p p f f body macro

1 n 1 n

f f are elds of tclass

1 n

demethod foogee obj x y z a b

body

is equivalent to

defun foogee obj x y z

let a fooa obj

b foob obj

body

send message objet par par function with a variable number of arguments

1 n

sendq message object par par macro

1 n

This function is similar to the standard send function except that in MicroCeyx it searches for

metho ds up to but excluding the ro ot package In the case of no match it searches in the package

and then in the package

sendq is like send except that it do es not evaluate its rst argument

In LELISP sendq could b e dened in the following manner

defmacro sendq message rest

send message rest

The search for metho ds carried out by the send function is implemented by redening the

senderror function in the following manner

defun senderror sem argslist

let fun getfn sem

if fun

CHAPTER OBJECTORIENTED PROGRAMMING

apply fun argslist

error send errudm cons sem argslist

sendf message par par macro

1 n

sendfq message par par macro

1 n

Generates a oneargument function that transmits to its argument the message message with the

parameters par This function is esp ecially useful for mapping the send function

i

sendfq is like sendf except that it do es not evaluate its rst argument

defun ffooggoo o a

print ffooggoo ffoogb o a

ffooggoo mapc sendf goo

list omakeq ffoog b omakeq ffoog b

ffooggoo

ffooggoo

Table of contents

Ob jectoriented programming

Structures

Structure denition

Instance creation

Access to elds

Typ e tests

Implementation of structures

LeLisp typ ology

Ob jectoriented programming

Searching for metho ds

Invoking metho ds

Predened metho ds

Abbreviation functions

MicroCeyx

Sp ecic errors

Denition of structures

Tclass and record instances

Metho ds and message sending

Table of Contents

Function Index

defstruct feature

defstruct struct field field macro

1 n

systemdefstructallaccessflag variable

new struct function with one argument

structmake function with no arguments

structfield o e function with one or two arguments

structurep o function with one argument

typeof s function with one argument

subtypep type type function with two arguments

typep s type function with two arguments

getfn pkgc fn function with two arguments

getfn pkgc fn pkgc function with two or three arguments

getfn pkgc pkgc fn function with three arguments

send symb o p p function with a variable number of arguments

1 n

senderror symb rest function with two arguments

sendsuper type symb o p p function with a variable number of arguments

1 n

csend fndef symb o p p function with a variable number of arguments

1 n

send symb o o p p function with a variable number of arguments

1 n

abbrev feature

putabbrev sym sym function with two arguments

defabbrev sym sym macro

getabbrev symb function with one argument

abbrevp symb function with one argument

hasanabbrev symb function with one argument

remabbrev symb function with one argument

fsymbg macro character

FUNCTION INDEX

systemprintwithabbrevflag variable

microceyx feature

deftclass symbol field field macro

1 n

defrecord symbol field field macro

1 n

tclassnamep symbol function with one argument

recordnamep symbol function with one argument

fieldlist symbol function with one argument

defmake type fn field field macro

1 n

omakeq type field val field val macro

1 1 n n

ogetq tclassorrecord field obj macro

oputq tclassorrecord field obj val macro

omatchq tclass obj macro

demethod ftclassgname obj p p f f body macro

1 n 1 n

send message objet par par function with a variable number of arguments

1 n

sendq message object par par macro

1 n

sendf message par par macro

1 n

sendfq message par par macro

1 n

Chapter

Ob jectoriented programming

This chapter rst describ es functions that provide ways to create structured ob jects in LISP These

ob jects are analogous to Pascal records In addition LISP allows you to create a hierarchy of

structure typ es

The second section is a description of the basic LISP typ e hierarchy and the means provided for

extending it typ ed vectors typ ed strings and tagged pairs Since they are implemented as typ ed

vectors structures provide the most immediate way to extend the LELISP typ e scheme

The third section explains how to use the primitive oblist search functions and the typing functions

to implement an ob jectoriented language of the SmallTalk variety

The fourth section presents an abbreviation facility for describing typ ed ob jects

The nal section describ es a minimal kernel on which ob jectoriented extensions can b e built This

kernel called MicroCeyx b enets from exp erience acquired in the creation at INRIA of earlier

ob jectoriented pro ducts called Ceyx and Alcyone

Structures

The defstruct primitive provides the means to dene new typ es of structured ob jects structures

analogous to Pascal records The new function facilitates the creation of instances of these typ es of

ob jects

Structured ob jects are made up of a numb er of named elds Each eld can contain any kind of

LISP ob ject These elds are not typ ed You can examine and mo dify the contents of the elds of

a structured ob ject by means of eldaccess functions which are dened along with structures

You can dene a structure as a substructure of a previously dened structure In this case in

addition to the elds explicitly declared within its denition the substructure will inherit all the

elds of the original parent structure

defstruct feature

This feature indicates that functions on structures are loaded into the system

CHAPTER OBJECTORIENTED PROGRAMMING

Structure denition

defstruc t struct field field macro

1 n

Denes a structure named struct which is a symb ol containing the elds field field

1 n

struct b ecomes a new typ e of LISP ob ject See the typeof function

field field are the names of the structures elds They are either symb ols or two

1 n

element lists In the second case the rst element in the list is the eld name and the second

element is a LISP form that is evaluated to assign an initial value to the eld when instances

are created This evaluation takes place each time an instance of the structure is created

When a structure is dened readaccess and writeaccess functions as well as a sp ecic

instance creation function are dened simultaneously These functions are describ ed further

on in this do cument

If struct is of the form superstructurestructure where superstructure is the

name of a structure previously dened in the system struct will have in addition to

the elds field field all the elds of superstructure In this case the typ e

1 n

superstructurestructure is a subtyp e of the superstructure typ e

system def st ruc t all ac ce ss fl ag variable

The defstruct macro examines this ag to determine whether access functions dened for

inherited elds should b e made available for use with the structure currently b eing dened

By default this ag is true In other words it has the value t If it is false then the only

access functions dened and available for use with this structure will b e those for elds that

are supplied explicitly as arguments to the relevant defstruct macro

Instance creation

new struct function with one argument

struct ma ke function with no arguments

These two functions create a new instance of the struct structure and return it as their value

The structmake function is the creation functionconstructor for the struct structure It

is automatically dened by the defstruct macro Ob jects created with this constructor will have

typ e struct See the typeof function

The elds of the ob ject so created are optionally initialized with the initialization forms included

in the structure denition These forms are evaluated when the ob ject is created The order of

evaluation of the initialization forms is not fully determined Fields for which no initialization

forms are provided are initialize d with the value

If the argument to the new function is not the name of a structure already dened in the system

the errstc error is raised and this screen is displayed

STRUCTURES

fn not a structure s

where fn is the name of the function that raised the error in this case new and s is the

bad argument

In LELISP new could b e dened in the following manner

defun new type

if structurep type

apply symbol type make

error new errstc type

Access to elds

struct fi el d o e function with one or two arguments

struct is the name of a structure and field is the name of one of the structures elds The

structfield functions are the access functions to the elds of instances of the structure struct

and they are automatically dened by the defstruct function

If the ob ject o is not an instance of the struct structure see the typep function the errstc

error is raised Given a single argument an access function returns the value of the eld field of

the ob ject o If a second argument is given its value is stored in the eld field of the ob ject o

and is also returned as the value of the access function

Supp ose that the LELISP compiler is active when the structure is dened Consequently the form

featurep compiler is true In this case eldaccess functions are dened to b e compiler

macros See the defmacroopen function Compilation of calls to these functions pro duces

extremely ecient co de After b eing compiled access functions will not do typ e checks on their

rst arguments

Typ e tests

structur ep o function with one argument

This predicate is true if the ob ject o is an instance of a dened structure See also the typep

function

Here for example is the denition of a structure person with two elds age and weight The

second eld is initialized with the value

defstruct person

age

weight

person

CHAPTER OBJECTORIENTED PROGRAMMING

Creation of an instance

setq person personmake

person

Assign the value to the age eld of the person ob ject

personage person

Extract the weight eld

personweight person

Use the structurep function

structurep person

t

Next we lo ok at an example of a substructure Extend the person structure into a

researcher structure

defstruct personresearcher

project

articles

personresearcher

Creation of a researcher and automatic initialization of a eld

setq r personresearchermake

personresearcher personresearcherarticles r

confproc thesis

confproc thesis

The researcher inherits the elds of the person structure

personweight r

personage r

personresearcherweight r

personresearcherage r

Implementation of structures

Instances of a structure are implemented as typ ed vectors whose typ e is the name of the structure

The values of the ob jects elds are stored in vector cells

LeLisp typ ology

LELISP ob ject typ es are represented by symb ols The LISP package hierarchy provides a way to

organize these typ es The symb ol personresearcher represents the researcher subtyp e of

the person typ e

LELISP TYPOLOGY

It is not strictly necessary to explicitly create new typ es Simply invoking the symb ol foobar

results in a successful mention of the typ e foo and its subtyp e bar Any LISP symb ol can therefore

b e interpreted as b eing a typ e

In practice the interesting typ es are those capable of b eing returned as values of the typeof

function either a predened system typ e or a user type that is the typ e of a typ ed vector a

typ ed string or a tagged pair

The basic LISP typ es are predened In other words they are already present at system startup

They all have the empty typ e the typ e which is the universal typ e

The basic LISP typ es are

fix small integers

float oatingp oint numb ers

symbol symb ols

null the endoflist marker

string character strings

vector vectors of p ointers

cons list cells

typeof s function with one argument

This function determines the typ e of any LISP ob ject If the argument is a string or a vector typeof

returns the typ e of the ob ject in question In these cases typeof is equivalent to typestring or

typevector resp ectively If the argument is a tagged pair typeof returns its car provided that

this is an atom or a list whose car is an atom In all other casesexcept the error condition

asso ciated with tagged pairs see b elowtypeof returns the LISP typ e of the ob ject fix float

cons etc

If the car of a tagged pair argument is neither a symb ol nor the symb ol of a list the result of

typeof is undened

In LELISP typeof could b e dened in the following manner

defun typeof s

cond fixp s fix

floatp s float

null s null

symbolp s symbol

consp s

if tconsp s

when or atom car s symbolp caar s

car s

cons

vectorp s typevector s

CHAPTER OBJECTORIENTED PROGRAMMING

stringp s typestring s

t

typeof

fix typeof

float typeof

null typeof asd

symbol typeof assasa

string typeof

vector typeof foobarhello mamma

foobar typeof person

person typeof

cons typeof foo a

foo

subtypep type type function with two arguments

type and type are two symb ols representing LISP typ es The predicate subtypep is true if type

is a subtyp e of type and false otherwise

In LELISP subtypep could b e dened in the following manner

defun subtypep type type

or eq type type

ifn packagecell type

null type

subtypep packagecell type type

subtypep personresearcher person

t subtypep symbol symbol

t subtypep personresearcher persondiscoverer

subtypep fix

t

typep s type function with two arguments

This predicate is true if the typ e of the ob ject s is a subtyp e of type

In LELISP typep could b e dened in the following manner

defun typep s type

subtypep typeof s type

typep personresearchermake person

t typep foo symbol

t typep personresearchermake persondiscoverer

typep

t

OBJECTORIENTED PROGRAMMING

Ob jectoriented programming

The LELISP package hierarchy is used to enco de the hierarchy of data typ es In an ob jectoriented

language of the SmallTalk varietysuch as Ceyx or Alcyone for exampleone wants to b e able

to attach methods to ob ject typ es

In LELISP these metho ds are LISP functions dened in the packages to whose typ es they are

attached So the function persondescribe is considered to b e the describe metho d attached

to the person typ e

The goal is for the subtyp es of a given typ e to inherit the metho ds attached to this typ e For

example the ob jects of typ e personresearcher should inherit the describe metho d of the

person ob ject The predened getfn function provides a way to do this metho d search accounting

for inheritance

Sometimes it is desirable to have an ob ject typ e inherit metho ds from several LISP typ es This is

multiple inheritance The getfn function searches for a function in a list of packages by rst doing

a depthrst search in the parent sup erior packages of those in the list

Finally you sometimes need metho ds asso ciated with a mixture of several typ es of ob jects For

instance to implement a generic arithmetic package metho ds would have to b e dened that allow

you to add together dierent typ es of numb ers such as float fix bignum and rational In LE

LISP the metho ds of the product of typ es t and t are lo cated in the product package designated

as t t An addition metho d of the desired kind would b e written as t tadd The

predened getfn function provides a means of searching for pro duct metho ds

Searching for metho ds

The following functions are predened search functions that op erate on metho ds

getfn pkgc fn function with two arguments

Searches for a function named fn in the pkgc package If this function exists it is returned as the

value of getfn If not the function returns

In LELISP getfn could b e dened in the following manner

defun getfn pkgc fn

let nom symbol pkgc fn

if typefn nom

nom

getfn car car

defun foobar foobar

getfn foo bar foobar

getfn gee bar

CHAPTER OBJECTORIENTED PROGRAMMING

getfn pkgc fn pkgc function with two or three arguments

Searches for a function named fn in the pkgc package or in one of the packages that is sup erior

to pkgc in the package hierarchy If the optional pkgc argument is given it is excluded from

the search On the search up the package tree if pkgc is encountered the search is terminated

immediately pkgc is not searched If the function is found it is returned as the value of getfn If

not getfn returns

If pkgc is a list of packages the search b egins in the rst package in the list and in all its parent

packages then in the second package in the list and in all its parent packages and so on until

either the function is found or the list of packages names is exhausted This depthsearch also takes

place if one of the parents of pkgc is a list This mechanism can b e used to implement multiple

inheritance of metho ds In this case the third argument if present provides a way to stop the

search for each package in the list

In LELISP getfn could b e dened in the following manner

defun getfn pkgc symb lastpkgc

let nom symbol pkgc symb

cond typefn nom nom

null pkgc

and consp lastpkgc

eq packagecell pkgc

car lastpkgc

t getfn packagecell pkgc

symb lastpkgc

Let us dene some functions

defun foo foo

defun barfoo barfoo

defun bargeebuzfoo bargeebuzfoo

getfn bargeebuz foo bargeebuzfoo

getfn bargee foo barfoo

getfn bar foo barfoo

getfn foo foo

getfn potopteraz foo foo

getfn bargee foo barfoo

getfn bar foo barfoo

getfn gee foo

getfn bargeebuz foo bar bargeebuzfoo

getfn bargee foo bar

getfn pkgc pkgc fn function with three arguments

Allows you to search for the function fn in the pro duct package pkgc pkgc or in one of

the pro duct packages that is sup erior to this one The pro duct package hierarchy is built from the

OBJECTORIENTED PROGRAMMING

package hierarchy by imp osing a lexicographic ordering on the combinations of p ossible pairs The

climb up the pro duct package hierarchy is always stopp ed b efore reaching the ro ot package for one

of the two memb ers of the pro duct

The packages sup erior to the package ab cd are in order

ab cd ab c a cd a c

Invoking metho ds

The combination of typ edeterminating functions and metho d search functions provides a way to

implement message transmission functions

send symb o p p function with a variable number of arguments

1 n

senderr or symb rest function with two arguments

The send function searches for and invokes the metho d symb assso ciated with the typ e of the ob ject

o This metho d must b e a LISP function that takes n arguments It is called with the list of

arguments formed by the ob ject o and the n arguments p p

1 n

The intended metho d is the LISP function named symb in the package that is the typ e of the ob ject

o or in one of its parent packages up to and excluding the ro ot package If no such metho d is

found send calls the senderror function By default this function raises the errudm error and

displays the following error screen

fn undefined method l

where l is the list of arguments supplied to send and fn is the name of the function that

raises the error here send

In LELISP send could b e dened in the following manner

defun send m o larg

let fn getfn typeof o m

if fn

apply fn o larg

funcall senderror m cons o larg

In LELISP senderror could b e dened in the following manner

defun senderror m rest

error send errudm cons m rest

Here is a denition of the hello metho d for ob jects of typ e fix

defun fixhello n

repeat n print hello

fixhello

CHAPTER OBJECTORIENTED PROGRAMMING

Search for this metho d and invoke it

send hello

hello

hello

hello

t

And here is a denition of the hello metho d for ob jects of the typ e person

defun personhello pers

print I am a person

print I weigh personweight pers pounds

personhello send hello personmake

I am a person

I weigh pounds

pounds send hello personresearchermake

I am a person

I weigh pounds

pounds

sendsup er type symb o p p function with a variable number of arguments

1 n

The function b ehaves very much like the send function except that the metho d is sought

b eginning with but excluding the package type and not b eginning with the typ e of the

ob ject o type must however b e the name of one of the parent typ esthat is parent

packagesof the typ e or package of ob ject o If not an error will b e raised

sendsuper is used primarily inside metho ds to invoke a metho d of the same name but

dened at a higher level in the typ e hierarchy

In the following example the describe metho d is dened for ob jects of typ e person It is

redened for ob jects of the subtyp e personresearcher so that it invokes the describe

metho d at the level immediately ab ove personresearcher in the typ e hierarchy and then

do es some pro cessing sp ecic to ob jects of the personresearcher typ e

defun persondescribe p

print A person personage p years old who weighs

personweight p pounds

persondescribe

defun personresearcherdescribe r

sendsuper personresearcher describe r

print who has written

length personresearcherarticles r

articles

personresearcherdescribe

send describe personresearchermake

A person years old who weighs pounds

who has written articles

OBJECTORIENTED PROGRAMMING

articles

csend fndef symb o p p function with a variable number of arguments

1 n

This function is similar to the send function If the search for the metho d fails instead of

rising an error csend calls the fndef function with all the arguments of csend except the

rst

This function is particularly useful for redening the search for metho ds One can dene

metho ds by default in a sp ecial package for instance or implement another multiple

inheritance

In LELISP csend could b e dened in the following manner

defun csend default s o largs

let fun getfn typeof o s

if fun

apply fun o largs

apply default s o largs

Use the package as a default

defun default m para

apply getfn m jj para

default

defun describe o

print An unknown object

describe

csend default describe

An unknown object

An unknown object csend default describe personmake

A person years old who weighs pounds

pounds

send symb o o p p function with a variable number of arguments

1 n

This function searches for and invokes the metho d symb asso ciated with the pro duct typ e of

the ob jects o and o Searching is done by the getfn function see its description The

function if it is found is invoked with o o and p p as arguments

1 n

Here are some denitions of metho ds for pro duct typ es

defun a afoo o o

aa

a afoo

defun a abfoo o o

ab

a abfoo

defun ab afoo o o

CHAPTER OBJECTORIENTED PROGRAMMING

ba

ab afoo

defun a acfoo o o

ac

a acfoo

We can invoke these metho ds The ob jects here are tagged pairs

send foo a a

aa send foo a ab

ab send foo ab a

ba send foo ab ab

ba send foo ac ab

ab send foo ab ac

ba send foo ac ac

ac

Predened metho ds

LELISP uses the send function internally to print and evaluate LISP ob jects

Commands to print LISP ob jects that are implemented as typ ed vectors typ ed character strings

and tagged pairs cause a prin message to b e sent to these ob jects This message should cause the

ob ject to b e printed onto the output channel without any endofline character If no print metho d

exists for the ob ject the default print format is used

Print metho ds are used by all the printing functions such as print prin prinflush and explode

They will b e used for instance when the parameters of a traced function entire functions or error

messages are printed

The following warning applies in the last of these cases If the print metho d raises an error it is

very probable the error pro cedure reuses the same print metho d and raises the same error You

therefore run the risk of getting the famous lo oping error in the error handler error It is therefore

suggested that the print metho ds for an ob ject b e implemented under a name other than prin

Name them prin only when they seem to have b een completely debugged

The evaluation metho ds are used for typ ed vectors The evaluation of a typ ed vector causes the

eval message to b e sent to the vector If no eval metho d exists for the vector the evaluation of

the vector returns the vector itself as its value Otherwise if an eval metho d exists it is the result

of the vectors eval metho d that is returned as a value

In the following example the ob jects of person typ e will b e printed as Page weight The

macro provides a means of rereading this form of output

defun personprin p

prin m personage p personweight p

personprin

new person

m

defsharp m

ABBREVIATION FUNCTIONS

let ageweight read

person new person

personage person car ageweight

personweight person cadr ageweight

list person

h

m

m

Abbreviation functions

This section describ es a set of functions that allow the programmer to use abbreviations while

addressing the LELISP reader Once instantiated these abbreviations are used by the LELISP

reader if the systemprintwithabbrevflag ag is set

In the worst of cases this feature can raise the following errors

errsxtacc which has the following default screen display

fn bad abbreviation e

errsxtclosingacc which has the following default screen display

fn not within e

errnotanabbrev which has the following default screen display

fn not an abbreviation e

abbrev feature

This ag indicates that the abbreviation package has b een loaded into the system

putabbr ev sym sym function with two arguments

defabbre v sym sym macro

These two functions dene the symb ol sym to b e an abbreviation of the symb ol sym After calling

one of these functions the o ccurrence of the symb ol sym b etween bracesthe characters and

is exactly equivalent for the LISP reader to the o ccurrence of the symb ol sym If a previous

abbreviation existed it is changed

defabbrev is identical to putabbrev except that it do es not evaluate its arguments

Consider for instance the following denition

defabbrev foo bargee

foo

CHAPTER OBJECTORIENTED PROGRAMMING

foo is read as bargee

foomuu is read as bargeemuu

foo is read as bargee

getabbr ev symb function with one argument

Returns the symb ol that has symb as its abbreviation If symb is not an abbreviation it raises the

errnotanabbrev error

getabbrev foo bargee

getabbrev bar getabbrev not an abbreviation bar

abbrevp symb function with one argument

Returns t if symb is an abbreviation If not it returns

abbrevp foo t

abbrevp bar

hasana bbr ev symb function with one argument

Returns the abbreviation of the symb ol symb

hasanabbrev bargee foo

remabbr ev symb function with one argument

Removes the abbreviation asso ciated with the symb ol symb and returns symb as its value

remabbrev foo foo

fsymbg macro character

The macro characters and facilitate the reading of abbreviations A symb ol b etween braces is

read as though it were the symb ol it abbreviates If symb is not an abbreviation then symb is read

as or If symb is not a symb ol or if there are several LISP ob jects b etween a single pair of

braces the errsxtacc error is raised

system pri nt wi th ab bre v fla g variable

If this ag is setthat is if it is truethe standard printer unabbreviates abbreviated symb ols on

output By default this ag has the value true

Here is a denition of the print metho d for symb ols with abbreviations

defun symbolprin symb

if and systemprintwithabbrevflag

MICROCEYX

hasanabbrev packagecell symb

progn let systemprintforread

pratom

pratom hasanabbrev packagecell symb

let systemprintforread

pratom

let systemprintpackageflag

pratom symb

pratom symb

MicroCeyx

This section describ es the MicroCeyx ob ject layer which is a smaller version of the original Ceyx

All the MicroCeyx structures are subtyp es of a ro ot class called tclass which will b e mentioned

frequently in the rest of this chapter

microceyx feature

This feature indicates whether or not MicroCeyx is loaded into the system

Sp ecic errors

All the MicroCeyx functions check the typ e and form of their arguments They can raise one of the

errors listed b elow

defvar errnotafield

argument not a field of a microceyx tclass

defvar errnotatclass

argument not a name of a microceyx tclass

defvar errtclassabbrev

abbrev of microceyx tclass already defined

defvar errrecordabbrev

abbrev of microceyx record already defined

defvar errbadfield

syntax error in field

defvar errrecordtoolong

fields maximum per record

defvar errnotarecordoratclass

CHAPTER OBJECTORIENTED PROGRAMMING

argument not a name of microceyx tclass or record

Denition of structures

deftclas s symbol field field macro

1 n

This function is identical to the defstruct function the only dierence b eing that the typ e it

denes is a subtyp e of tclass if this was not already the case Moreover the symb ol symbol

of the ro ot package is dened as b eing the abbreviation for symbol in its entirety

The form

deftclass foo a b c

tclassfoo

corresp onds to

progn let systemdefstructallaccessflag

defstruct tclassfoo a b c

defabbrev foo tclassfoo

Likewise the form

deftclass ffoogbar d

ffoogbar

corresp onds to

progn let systemdefstructallaccessflag

defstruct tclassfoobar d

defabbrev bar tclassfoobar

defrecor d symbol field field macro

1 n

This function is similar to the defstruct function except that the instances it creates are

implemented in the form of balanced binary trees of lists cells Moreover the instances contain

no typ e information They only satisfy the consp and listp predicates

symbol must b e in the ro ot package There is no inheritance for the records For consistency

with the deftclass function the abbreviation symbolstanding for symbol itselfis

dened

A record cannot have more than elds otherwise the errrecordtoolong error is raised

defrecord recfoo a b

recfoo

tclassn ame p symbol function with one argument

This predicate is true if its argument is the name of a class dened by the deftclass function

MICROCEYX

tclassnamep tclassfoo t

tclassnamep fbarg t

tclassnamep foothebarre

tclassnamep foo bar

recordn ame p symbol function with one argument

This predicate is true if its argument is the name of a record dened by defrecord

recordnamep recfoo t

recordnamep bar

recordnamep

fieldli st symbol function with one argument

Returns the list of the eld names of instances of the tclass referred to as symbol which

must b e a valid tclass name and not an abbreviation

fieldlist ffoog a b c

fieldlist tclassfoobar a b c d

Tclass and record instances

defmake type fn field field macro

1 n

Denes the function fn to b e an instance constructor function for the tclass or record referred to

as type The function fn takes n arguments which are the values of the elds named field of

i

the instance that is created

defmake ffoog makefoo c a

makefoo setq x makefoo

tclassfoo ffooga x

ffoogc x

omakeq type field val field val macro

1 1 n n

Returns an instance of the tclass referred to as type Within this instance each field has

i

the value val Neither type nor the field are evaluated

i i

omakeq fbarg tclassfoobar

omakeq fbarg a tclassfoobar

ogetq tclassorrecord field obj macro

CHAPTER OBJECTORIENTED PROGRAMMING

oputq tclassorrecord field obj val macro

omatchq tclass obj macro

These functions are identical to the corresp onding Ceyx functions

ogetq ffoog b omakeq ffoog

ogetq frecfoog b omakeq frecfoog b

omatchq ffoog omakeq fbarg t

Metho ds and message sending

demethod ftclassgname obj p p f f body macro

1 n 1 n

f f are elds of tclass

1 n

demethod foogee obj x y z a b

body

is equivalent to

defun foogee obj x y z

let a fooa obj

b foob obj

body

send message objet par par function with a variable number of arguments

1 n

sendq message object par par macro

1 n

This function is similar to the standard send function except that in MicroCeyx it searches for

metho ds up to but excluding the ro ot package In the case of no match it searches in the package

and then in the package

sendq is like send except that it do es not evaluate its rst argument

In LELISP sendq could b e dened in the following manner

defmacro sendq message rest

send message rest

The search for metho ds carried out by the send function is implemented by redening the

senderror function in the following manner

defun senderror sem argslist

let fun getfn sem

if fun

MICROCEYX

apply fun argslist

error send errudm cons sem argslist

sendf message par par macro

1 n

sendfq message par par macro

1 n

Generates a oneargument function that transmits to its argument the message message with the

parameters par This function is esp ecially useful for mapping the send function

i

sendfq is like sendf except that it do es not evaluate its rst argument

defun ffooggoo o a

print ffooggoo ffoogb o a

ffooggoo mapc sendf goo

list omakeq ffoog b omakeq ffoog b

ffooggoo

ffooggoo

CHAPTER OBJECTORIENTED PROGRAMMING

Table of contents

Ob jectoriented programming

Structures

Structure denition

Instance creation

Access to elds

Typ e tests

Implementation of structures

LeLisp typ ology

Ob jectoriented programming

Searching for metho ds

Invoking metho ds

Predened metho ds

Abbreviation functions

MicroCeyx

Sp ecic errors

Denition of structures

Tclass and record instances

Metho ds and message sending

Table of Contents

Function Index

defstruct feature

defstruct struct field field macro

1 n

systemdefstructallaccessflag variable

new struct function with one argument

structmake function with no arguments

structfield o e function with one or two arguments

structurep o function with one argument

typeof s function with one argument

subtypep type type function with two arguments

typep s type function with two arguments

getfn pkgc fn function with two arguments

getfn pkgc fn pkgc function with two or three arguments

getfn pkgc pkgc fn function with three arguments

send symb o p p function with a variable number of arguments

1 n

senderror symb rest function with two arguments

sendsuper type symb o p p function with a variable number of arguments

1 n

csend fndef symb o p p function with a variable number of arguments

1 n

send symb o o p p function with a variable number of arguments

1 n

abbrev feature

putabbrev sym sym function with two arguments

defabbrev sym sym macro

getabbrev symb function with one argument

abbrevp symb function with one argument

hasanabbrev symb function with one argument

remabbrev symb function with one argument

fsymbg macro character

FUNCTION INDEX

systemprintwithabbrevflag variable

microceyx feature

deftclass symbol field field macro

1 n

defrecord symbol field field macro

1 n

tclassnamep symbol function with one argument

recordnamep symbol function with one argument

fieldlist symbol function with one argument

defmake type fn field field macro

1 n

omakeq type field val field val macro

1 1 n n

ogetq tclassorrecord field obj macro

oputq tclassorrecord field obj val macro

omatchq tclass obj macro

demethod ftclassgname obj p p f f body macro

1 n 1 n

send message objet par par function with a variable number of arguments

1 n

sendq message object par par macro

1 n

sendf message par par macro

1 n

sendfq message par par macro

1 n

Chapter

Input and output

In LELISP basic inputoutputreferred to throughout this chapter as ioop erates on sequential

streams at either a character level a line level or an Sexpression level

Intro duction

This intro duction presents the principal ideas used in the description of io functions

Characters

Characters can b e represented in two ways

 In the form of an integer numb er which represents the internal character co de of the character

often written cn

 In the form of an atom symb ol string or integer ch If the atom is a symb ol or a string

its rst character is used If the atom is a numb er the rst digit of the representation of the

value of the numb er in the current output base see the function obase is used

LELISP uses either of these two representations Functions that use the rst form generally have

the sux cn and those which use the second form have the sux ch The internal character co de

used dep ends on the host system In general the ASCI I co de is used Internal character co des range

b etween inclusive

It is always more ecient and more spaceconserving to use the internal character co de

representation Morever the use of the macros and makes this representation almost

as readable as the other singlecharacter atom representation

Character strings

Character strings can b e represented in three dierent forms

 Strings of characters represented in the descriptions as string

CHAPTER INPUT AND OUTPUT

 Lists of internal character co des represented in the descriptions as lcn

 Lists of singlecharacter atoms represented in the descriptions as lch

Functions that use the rst of these representations have the sux string They are generally

more ecient in p erformance and in memory use than the others

Lines

Usually read and write functions are used to manipulate Sexpressions In these cases the format

is free and the physical endofline character can o ccur anywhere It is nevertheless sometimes

necessary to read or write character by character or line by line Then the p osition of the end

ofline characters is imp ortant When reading a character at a time using the readcnreadch or

peekcnpeekch functions LELISP delimits the end of a line with the two consecutive characters

cr and lf This is true for terminals as well as for les

When reading a line at a time using the readstring or readline functions the physical endof

line is not included in the result

When printing endofline marks are explicitly inserted by the user by calling the print terpri

and tynewline functions and automatically by the system when the right margin of the output

buer is reached Just which marks are inserted dep ends on the system and the typ e of terminal

b eing used They do not necessarily result in additional output characters in the case of output

to a bitmapped display or output to record les etc

The right margin can b e p ositioned b eyond the end of the buer In this case the system do es not

automatically add the endofline mark see the rmargin function

Channels

All io takes place in a context of sequential streams that are connected to terminals or les

LELISPs basic architecture includes the current input and output streams which are set by the

two functions named inchan and outchan All reading is done on the current input stream and

all writing is done on the current output stream

Programmable IO interrupts

The most oftenused io functionssuch as read and printread and write characters to and

from io buers They do not physically access the terminal or the disk

The lowestlevel functions provide means to manage the io buers These are the programmable

interrupts bol eol and flush They are easily redenable by the user through the programmable

interrupt management mechanism One can thereby extend the io system to read from a list of

character strings write to several les simultaneously etc While these functions are very p owerful

they are seldom used explicitly

BASIC INPUT FUNCTIONS

Basic input functions

read function with no arguments

Reads the next Sexpression of any typ e atom or list from the current input stream and returns

it as its value read is the main read function and provides the means to read any LISP ob ject of

any size whatso ever Its b ehavior is given in detail in the next section

If a syntax error is detected the LISP error errsxt is raised This gives you the name of the function

that caused the error fn and a message indicating the typ e of error

fn syntax error msg

Here is the list of p ossible messages

list too short

string too long

symbol too long

bad beginning of expression

special symbol too long

bad package

bad dotted pair construction

reread list contains noncharacters

bad argument list

bad splicemacro

EOF during READ

bad use of BACKQUOTE

More often than not this error is due to a bad use of dotted pairs to a sp ecial pname that

is to o long more than characters as a result of the omission of the character or to a

character string that is to o long as a result of the omission of a doublequote character

stratom n strg i function with three arguments

Performs a partial read of n characters from the character string strg stratom returns a

symb ol or a numb er if the i ag is equal to and always returns a symb ol if this ag is

not equal to This function gives access to the internal part of the LELISP reader that

do es numerical conversions and searches for symb ols in the oblist and so cannot b e easily

describ ed in LELISP It is used primarily to write new readers in LELISP

stratom abcdef ) abc

stratom )

stratom t )

stratom )

stratom )

stratom )

stratom )

CHAPTER INPUT AND OUTPUT

readstri ng function with no arguments

Reads the next line from the input stream and returns it in the form of a character string

This string contains no endofline delimiters that might have b een present in the input

readstring provides a way to do p ortable reads at the input line level It is used to build

ecient and easilyimplemented interfaces b etween programs and users

Warning This function do es not convert upp ercase letters into their lowercase equivalents

In LELISP readstring could b e dened in the following manner

defun readstring

let l c

while neq setq c readcn cr read up to cr

newl l c

readcn skip lf

string nreverse l

readline function with no arguments

Like the previous function readline reads the next line from the input stream but it returns this

line in the form of a list of internal character co des This list contains no endofline delimiters

that might have b een present in the input This function is more exp ensive in terms of memory

resources than the previous one but sometimes provides a more practical interface

In LELISP readline could b e dened in the following manner

defun readline

explode readstring

progn readline terminate the current line

mapcar ascii readline then read another line

the gay nightingale

t h e g a y n i g h t i n g a l e

To build a sequence of words from a line that contains no sp ecial characters or use

the following

progn readline

implode append readline

the singing mockingbird

the singing mockingbird

BASIC INPUT FUNCTIONS

readcn function with no arguments

Reads and returns the value of the next character of the input stream The value returned

is the characters internal character co dethat is a numb er This function do es not do

automatic conversion from upp ercase to lowercase character co des It cannot b e easily

describ ed in LISP

readch function with no arguments

readch is like the preceding function except that it returns a singlecharacter atom and not a

character co de

In LELISP readch could b e dened in the following manner

defun readch

ascii readcn

peekcn function with no arguments

This function returns the next character in the input stream in the same way that the readcn

function do es except that the character is not really read It is merely examined As a result

consecutive calls to peekcn always return the same result peekcn is used for lo okahead op erations

on the input stream

In LELISP peekcn could b e dened in the following manner

defun peekcn

let cn readcn

reread list cn

peekch function with no arguments

peekch is like the preceding function except that it returns a singlecharacter atom and not a

character co de

In LELISP peekch could b e dened in the following manner

defun peekch

ascii peekcn

reread lcn function with one argument

Pushes the list of characters lcn onto the front of the input stream These characters will b e read

by the next call to one of the preceding read functions read readstring readcn b efore it

continues with the actual input stream This function is particularly p owerful if it is used inside a

read or a macro character reread returns the list of characters that were added onto the head of

the input stream as its value

CHAPTER INPUT AND OUTPUT

progn reread list a sp read

a

To print the list of characters to reread typ e print reread

readdel imi te dl is t cn function with one argument

Reads a list of Sexpressions up to the o ccurrence of a character whose internal character

co de is cn The typ e of the character cn must b e cmacro csplice or cmsymb see the section

on character typ es This function is particularly useful inside a macro to read a group of

Sexpressions

In LELISP readdelimitedlist could b e dened in the following manner

defun readdelimitedlist cn

let res

until eq validcn cn

newl res read

readcn read the character cn

nreverse res

defun validcn

selectq typecn peekcn

csep cecom

readcn

validcn

cbcom

readcn

until eq typecn readcn cecom

validcn

t peekcn

Let us dene two macro characters

dmc

cons list readdelimitedlist

dmc

error errsxt must appear after a

From this p oint on expressions containing braces will b e read in the following manner

is read as list

print a b c foo is read as list print list a b c foo

Comments ignored

is read as list

BASIC INPUT FUNCTIONS

teread function with no arguments

Flushes all the characters waiting in the input buer of the current input channel The rst read

immediately following a call to this function will trigger the programmable interrupt bol This

function is particularly useful for ushing the separation characters delimiters present in the

readers internal buers just after the action of the read function Since the readers internal

buers cannot b e easily describ ed in LISP this function has no LISP description

defun foo

print read read

print readstring readstring

t

foo foo

hello

readhello

readstring

t defun bar

print read read

teread

print readstring readstring

t

bar bar

hello

readhello

hello world

readstringhello world

t

Inside read

The variable and the function describ ed next are only meaningful inside a read They will only b e

used in a macro character or in the pro cessing of the programmable interrupts bol or eof

system in re ad fl ag variable

This internal variable which is maintained by the read function indicates whether the LISP reader

is in the middle of a read that is if a LISP ob ject of any typ e is in the pro cess of b eing read

This variable is used for example in the eof function to test whether an endofle app ears while

a LISP ob ject is b eing read see the eof function

curread function with no arguments

Returns either the list currently b eing read or if the reader is not in the pro cess of reading a

list The returned list contains an additional element at its head the curread symb ol

CHAPTER INPUT AND OUTPUT

Let us dene a macro character as follows

dms

print curread

Reading a b c d e will pro duce the following results

curread a b

curread

curread d

curread a b c d

curread a b c d e

Now let us redene the p ercentage sign as an inx binary op erator

dms

if consp cdr curread

rplacd curread cons cdr curread

error errsxt

Reading a b c will pro duce a b c

Use of the terminal for input

Before each request for input from the terminal the system prints a prompt string by default

This can b e mo died by way of the prompt function It then reads a line of terminal input

The user terminates the line by typing either the cr or lf character The currently active

programming interrupt bol manages the dialog with the user see the section on programmable

io interrupts

LELISP echos each character as it is read ASCI I control characters characters entered by holding

down the CONTROL key and pressing a printable character key at the same time are printed with

a character followed by the printable character

A minimal line editor is also activated It understands the following character keys with the meaning

indicated

 rubout delete or backspace Erase the last character entered

 U or X Completely erase the current line

A full line editor called edlin is provided with the system It has a commandhistory facility and

commandname completion edlin is activated by evaluating the edlin function see chapter

The ESCAPE command gives online help for edlin

The global system variables systemrealterminalflag and systemlinemodeflag can

b e used to supress the character echoing and the minimal line editor functions

STANDARD READER

system rea l ter mi nal fl ag variable

If this ag is set the default dep ends up on the system the line editor and character echo functions

are activated If it is cleared b oth these functions are deactivated and the system assumes that

another pro cess p erforms these tasks

system lin e mod e fla g variable

If this ag is set the default option dep ends up on the system the line editor assumes that reading

can b e carried out one line at a time In this case the b ehavior of the tyi and tys functions is

unpredictable and the system uses the tyinstring function to read a line from the terminal

prompt strg function with an optional argument

The prompt variable holds the prompt string printed by the system when it is ready to receive

input from the terminal This function can b e used with the with control structure to change the

prompt dynamically

By default this string has the value

the default prompt character string

prompt

it has been changed

with prompt hello with the prompt string hello

toplevel call the toplevel interpreter

hellocons

value of the cons

value of the call to toplevel

return to the string

Standard reader

The read function reads LISP Sexpressions in free format that is each syntactic element can b e

surrounded by one or more delimiters spaces endofline characters or comments

The LISP reader is parameterized by a read table which indicates which are the sp ecial characters

list delimiters comments string delimiters macro characters etc All other characters are

characters of typ e pname or normal characters

Reading symb ols

A symb ol is a sequence of characters of typ e pname which do es not represent a numb er integer or

oatingp oint

CHAPTER INPUT AND OUTPUT

To include sp ecial characters in a symb ol enclose the entire symb ol within a pair of symb ol delimiter

characters the vertical or absolute value bar by default

The reader will not accept symb ols longer than characters Very long symb ols can nevertheless

b e made by using the concat function

Symb ol packages are sp ecied in three ways which are describ ed further on

 the macro written as

 the macro character writen as a sign

 a character of typ e packagedelimiter

system rea d cas e fla g variable

This variable provides a way to regulate the automatic conversion of upp ercase characters into their

lowercase equivalents If the value of this variable is which is its default value the conversion

is p erformed automatically If not no conversion is done

Here are several examples of equivalences when this variable has its default value of

car corresponds to the symbol car

LONGVERYLONGATOM longverylongatom

Foo Bar Foo Bar

FooBar foobar

fooBargee fooBargee

Supp ose that we read the symb ols in the following manner

let systemreadcaseflag t

read

In that case the following results are obtained

CdR corresponds to the symbol CdR

AcH AcH

Reading character strings

Character strings are written b etween pairs of string delimiter characters the double quote

character by default If this character is to b e included in a string it should b e intro duced into

the string twice in succession Any character can b e included in a string If there is an endofline in

the middle of a string this latter will contain the two characters cr and lf in the p osition of

the endofline Currently a string cannot exceed characters on input the makestring function

allows for the creation of longer strings Upp ercase to lowercase conversion is never done during

the reading of a string

A typ e can b e assigned to a string by means of the macro written as the signs

STANDARD READER

hello contains the characters hello

with dblquotes with dblquotes

schizparano is a typed string of type schiz

containing the characters parano

Reading integer and rational numb ers

Integer numb ers are represented by a string of digits of any length optionally preceded by a or

sign Rational numb ers are represented by an integer immediately followed by the character

which is itself immediately followed by a second integer

The construction of numb ers from their textual representation is done with generic arithmetic

This means that if a numeral given to the system is not the representation of a small bit

integer its value will dep end on the generic arithmetic b eing used The standard generic arithmetic

converts representations of integers whose values are outside the range of bit storage and those

of rationals which are not reducible to integers to oatingp oint numb ers

Here are some examples of integers

corresponds to the integer

Here are some examples of standard generic arithmetic

corresponds to the integer

corresponds to oatingpoint

And here are some examples of rational arithmetic as describ ed in chapter

corresponds to the integer

corresponds to the rational

ibase n function with an optional argument

CHAPTER INPUT AND OUTPUT

ibase for input base called without an argument returns the input conversion base of the system

If the argument n is provided ibase changes the input conversion base to this value The input base

aects only the input of integer and rational numb ers since the input of oatingp oint numb ers

always takes place in base Values for the input base must b e b etween and inclusive This

function is the counterpart to the obase function

ibase

ibase

fff this is no longer a symbol

ibase a to go back to base

ibase gag

ibase this is a number so are all other symbols containing

only letters and numerals so how to get the input base back to

ibase a simple

There are other ways to read numb ers The macros written as and baser provide

the means for describing numb ers in any base

Reading oatingp oint numb ers

Floatingp oint numb ers are represented by a sequence of decimal numerals the integer or whole

part optionally followed by a decimal p oint p erio d character and another sequence of decimal

numerals the fractional part optionally followed by the character E or e followed by a signed

integer numb er the exp onent part The integer part or the fractional part can b e missing but

b oth cannot b e missing simultaneously The exp onent part can optionally b e omitted altogether

corresponds to the number

e

e

e

e

e

e is a symbol

Reading lists

The representation of lists in LELISP is quite conventional A list is represented by an op ening

parenthesis sign followed by the elements of the list These are separated by spaces and followed

by a closing parenthesis sign It is also p ossible to use the generalized dot notation

sexpr sexpr

STANDARD READER

eg a b c d corresponds to a b c d

a b a b

At the end of an expression read by the read function there can b e any numb er of closing

parentheses which are ignored This gives a sure way to close o Sexpressions without having

to count the exact numb er of closing parentheses required

defun foo n n is read without error

Reading vectors

Vectors are represented by the two characters followed by the elements of the vector which are

separated by blanks followed by the character Vectors are read using the macro written as

You can give vectors a typ e by using the macro designated by the signs

a b c is a vector with three elements a b c

is an empty vector

type is a typed vector

Reading comments

It is p ossible to insert comments into the input stream which are treated as delimiters A comment

is any sequence of characters preceded by a character of typ e begincomment and terminated by

a character of typ e endcomment

By default there is only one character of typ e b egincomment the semicolon and a single

character of typ e endcomment the RETURN character By default then all comments are

terminated at the endofline

defun foo n the number

l the list

if n nothing more to do

It is also p ossible to write multiline comments by using the macros and These multiline

comments can b e emb edded

defun foo the name n

this comment

goes on for several

lines and contains

other comments

which are very neatly embedded

n n

CHAPTER INPUT AND OUTPUT

Typ es of characters

The LELISP lexical analyzer in other words the read function uses a read table in order to

facilitate its analysis This table asso ciates with each character a symb olic typ e

The read table is totally accessible to the user who can therefore change it to b e able to easily

read new LISP dialects with diering syntaxes

The available character typ es are

cnull character type

All characters of this typ e are completely ignored by the reader Examples the character Advance

tape or the character null

cbcom character type

A character of this typ e serves to indicate the b eginning of a comment which will b e terminated

at the o ccurrence of a character of the typ e describ ed next By default there is only one character

of this typ e the semicolon

cecom character type

A character of this typ e serves to indicate the end of a comment By default there is only one

character of this typ e the cr CarriageReturn character

cquote character type

A character of this typ e is used to quote any other character This amounts to giving this instance

of the character concerned the cpname typ e the typ e of normal characters By default there are

no characters of this typ e but it is the custom to use either the slash or the backslash whenever

you happ en to need such a character

clpar character type

A character of this typ ethe op ening parenthesis by defaultserves to demarcate the b eginning

of a list

crpar character type

A character of this typ ethe closing parenthesis by defaultserves to demarcate the end of a

list

cdot character type

A character of this typ ethe p erio d by defaultis used to enter p ointed pairs when they o ccur

surrounded by characters of the typ e csep

STANDARD READER

csep character type

Characters of typ e csep are normal separators examples space tab

cpkgc character type

Characters of this typ e play the role of package delimiter characters By default there are no

characters assigned to this typ e It is however common practice to use the colon character The

use of as a package delimiter character results in the following readings which are more readable

than the corresp onding uses of the macro

typecn cpkgc

cpkgc foobar

foobar geemuuwizz

geemuuwizz setq syspackagecolon myprivatepackage

myprivatepackage bizarre

myprivatepackagebizarre

csplice character type

A character with this typ e is a splicemacro A function is asso ciated with the symb ol whose

pname is this character This function is invoked automatically when this character is read

in the input stream See the following section The classic example of such a character is

the macro character p ound sign or hash sign

cmacro character type

A character with this typ e is a macro character A function is asso ciated with the symb ol

whose pname is this character This function is invoked automatically when this character is

read in the input stream See the following section

cstring character type

Characters of this typ e play the role of character string delimiter characters By default there

is a single character of this typ e namely the double quote character

cpname character type

Characters of this typ e are normal characters and are thus capable of b eing used to build a

pname

csymb character type

This typ e indicates that a character is a delimiter of sp ecial symb ols By default there is only

one character of this typ e the vertical bar sign written as also referred to as the absolute

value sign

CHAPTER INPUT AND OUTPUT

cmsymb character type

Characters of this typ e must b e read as monocharacter symb ols and need not b e delimited

typecn cn symb function with one or two arguments

Provides a means to know if symb is not supplied or to mo dify if symb is supplied the

typ e of the character cn This function returns the current typ e of the character cn after

mo dication in the case the symb is present

After the < and > characters have b een redened as follows

typecn clpar ) clpar

typecn crpar ) crpar

the input cons a b will b e read as cons a b

typech ch symb function with one or two arguments

typech is like the preceding function except that the character is sp ecied in the form of a mono

character symb ol

Here is a program that prints the table of character typ es

defun printablech

print the table of characters types

let i j

al mapcoblist lambda x

when getprop x sharpvalue

list cons getprop x sharpvalue

x

repeat

printablech incr i al

printablech incr j al

terpri

defun printablech val pos al

print the type of a character

outpos pos

with obase prin val outpos pos

with obase prin val outpos pos

cond assoc val al prin cassoc val al

val prin princn val

t prin princn val

if outpos pos

prin

outpos pos

prin typecn val

Here is the printed character typ e table

t

null cnull cpname

A cmacro A cpname

STANDARD READER

B cpname B cpname

C cpname C cpname

D cpname D cpname

E cmacro E cpname

F cmacro F cpname

bell cpname G cpname

bs csep H cpname

tab csep I cpname

A lf cecom A J cpname

B K csep B K cpname

C L cmacro C L cpname

D cr cecom D M cpname

E N cpname E N cpname

F O cpname F O cpname

P cmacro P cpname

Q cpname Q cpname

R cpname R cpname

S cpname S cpname

T cpname T cpname

U cpname U cpname

V cpname V cpname

W cpname W cpname

X cpname X cpname

Y cpname Y cpname

A Z cpname A Z cpname

B esc cpname B cmacro

C cpname C cpname

D cpname D cmacro

E cpname E cmacro

F cpname F cpname

sp csep cmacro

cmacro a cpname

cstring b cpname

csplice c cpname

cpname d cpname

cpname e cpname

cpname f cpname

cmacro g cpname

clpar h cpname

crpar i cpname

A cpname A j cpname

B cpname B k cpname

C cmacro C l cpname

D cpname D m cpname

E cdot E n cpname

CHAPTER INPUT AND OUTPUT

F cpname F o cpname

cpname p cpname

cpname q cpname

cpname r cpname

cpname s cpname

cpname t cpname

cpname u cpname

cpname v cpname

cpname w cpname

cpname x cpname

cpname y cpname

A cmacro A z cpname

B cbcom B cmacro

C cpname C csymb

D cpname D cmacro

E cpname E cpname

F cpname F del cnull

to cpname

Macro characters

A macro character is any character to which a function is asso ciated by the following macro

denition functions The asso ciated function is automatically executed when this character is

encountered in the input stream There are two typ es of macro characters cmacro and csplice

In the case of cmacros the value returned by the function asso ciated with the macro character

replaces the macro character read In the case of csplices the value returned by the function

asso ciated with this macro character must b e a list which can b e empty This list will b e added

to the expression b eing read by means of the nconc function If the value returned by this function

is not a list syntax error numb er will b e raised All characters can b e used as macro characters

dmc ch s ::: s special form

n

Used to dene a macro character of the rst cmacro typ e The argument ch must b e a mono

character symb ol dmc asso ciates with this character a function with an empty parameter list this

empty list is required to o ccupy this p osition in the call and a function b o dy s ::: s dmc has

n

the same syntax as the other denition functions defun df and dm and returns ch as its value

In LELISP dmc could b e dened in the following manner

df dmc l

construct the associated function

apply defun l

set the new type of this character

typech car l cmacro

and return the character as value

car l

STANDARD READER

dms ch s ::: s special form

n

Used to dene a macro character of the second csplice typ e The argument ch must b e a mono

character symb ol dms asso ciates with this character a function with an empty parameter list this

empty list is required to o ccupy this p osition in the call and a function b o dy s ::: s dms has

n

the same syntax as the other denition functions defun df and defmacro and returns ch as its

value

In LELISP dms could b e dened in the following manner

df dms l

build the associated function

apply defun l

set the characters new type

typech car l csplice

and return the character as value

car l

In order to destroy a macro character denition the typ e of the character must b e changed

and the asso ciated function must b e destroyed with for example the following function

defun remach ch

for remove macro character

the character returns to normal

typech ch cpname

destruction of the function

remfn ch

ch

Warning Since the function asso ciated with a macro character is of the same typ e as functions

created by the user of typ e defun it is not p ossible for a monocharacter atom to have a

defuntyp e denition and a dmc or dmstyp e denition at the same time

There are predened macro characters

 ap ostrophe macro character

 grave accent macro character

 comma macro character

 colon macro character

 circumex macro character

 op en bracket macro character

 p ound sign macro character

 bang macro character

 loadle macro character L CONTROLL

CHAPTER INPUT AND OUTPUT

 loadmo dule macro character A CONTROLA

 editle macro character E CONTROLE

 editfunction macro character F CONTROLF

 paragraph macro character P CONTROLP

Basic macro characters colon circumex and op en bracket

macro character

The ap ostrophe or single quote is the b est known and most used of the macro characters Placed

b efore any ordinary Sexpression it returns the list quote Sexpression

In LELISP could b e dened in the following manner

dmc

list quote read

eg a b is read as quote a b

a quote quote a

macro character

This macro character lets monocharacter symb ols whose pnames are control characters b e read

In LELISP could b e dened in the following manner

dmc

ascii logand readcn

to read a monocharacter symbol with ascii code

eg d

macro character

This macro character is only dened within the arbitraryprecision arithmetic libraries and

describ es numb ers longer than a line long or using sp ecialized notation

Warning this macro character should not b e confused with the representation of vectors of

Sexpressions

Backquote macro character

macro character

STANDARD READER

macro character

macro character

macro character

This macro character is used to build programs which construct Lisp Sexpressions in general

lists The Sexpressions built by this macro character will use the quote cons mcons list

append and nconc functions Everything that follows the backquote character is considered to b e

the mo del of the list to construct The variable elements of this mo del will b e indicated by a comma

placed b efore the expression to calculate All the other elements of the mo del are considered as

constants There are three kinds of variable elements

 simple elements prexed by a comma

 list segments which will b e added to the list by means of the append function prexed

by a comma followed by the amp ersand or atsign character

 list segments which will b e added to the list by means of the nconc function prexed by

a comma followed by the p erio d character

In LELISP backquote could b e dened in the following manner

dmc

to circumvent a large number of errors

error errsxt outside a

dmc

flet

cond

eq peekcn

readcn

cons read

eq peekcn

readcn

cons read

t cons read

backquotify read

defun backconstant x

test if the object x is a constant

or null x

and consp x

eq car x quote

null cddr x

CHAPTER INPUT AND OUTPUT

defun backquotify x

construction of the backquoted expression

cond null x

atom x list quote x

eq car x cdr x

and consp car x eq caar x

simplification of the append

let a cdar x

d backquotify cdr x

cond

append x x

null d a

app x app l app x l

and consp d eq car d append

mcons append a cdr d

nothing to do

t list append a d

and consp x

consp car x

eq caar x

if cdr x

list nconc

cdar x

backquotify cdr x

cdar x

t let a backquotify car x

d backquotify cdr x

simplification of the conses

cond

null d

cons x list x or x

if backconstant a

list quote list cadr a

list list a

and backconstant a

backconstant d

cons x y x y

list quote

cons cadr a cadr d

and consp d eq car d cons

cons x cons y z

mcons x y z

list mcons a cadr d caddr d

and consp d eq car d list

STANDARD READER

cons x list y yn

list x y yn

cons list cons a cdr d

and consp d eq car d mcons

cons x mcons y yn

mcons x y yn

mcons mcons a cdr d

t the general case

list cons a d

a b c is read as a b c

a b c mcons a b c

x y cons x y

a b c mcons a b c

a b c d e mcons a b append c d e

x y z v cons x append y z v

x y z cons x nconc y list z

Sharp macro character

macro character

This macro character provides a means for converting numb ers or for calling the interpreter in the

course of a normal read Its action is very general and can b e explained in the following way When

a character o ccurs in the input stream the LISP reader reads the next character using the readch

function This character called the macro selector must have a function denition in the package

whose name is found in the syspackagesharp variable The value returned by a call to this

function must b e a list which can b e empty which will b e inserted into the ob ject b eing read by

means of the nconc function

Certain macro character selectors accept numeric parameters In these cases the function asso ciated

with the selector receives this parameter as its argument The parameters are supplied b etween the

character and the selector They are always interpreted in base

The following read invokes the selector r with the parameter

rfoo

syspac kag e sha rp variable

This variable contains the name of the package in which the functions asso ciated with the

various macro selectors must reside in order to b e found by LELISP By default its value

is sharp

Here is the LISP description of this macro character

defvar syspackagesharp sharp

CHAPTER INPUT AND OUTPUT

dms

let c readcn

argnum

when memq c

setq argnum sub c

while memq setq c readcn

setq argnum add sub c

mul argnum

let f getfn syspackagesharp ascii c

if f

apply f when argnum list argnum

error errudf c

It is p ossible to dene new macros with the following function

defsharp ch larg s ::: sN special form

defsharp denes a new macro ch is the new selector character The list larg is the parameter

list of the function asso ciated with the selector This list is empty if the selector do es not accept

a numerical parameter If so it is a list of the usual parameter the selector and the function

receives the numerical parameter as its argument defsharp thus has the same syntax as the

ordinary denition functions de dmd etc

In LELISP defsharp could b e dened in the following manner

df defsharp ch f

setfn symbol syspackagesharp ch expr f

ch

There are a numb er of predened selectors

macro

This macro returns the internal character co de of the next character in the input stream It is

the b est way known to enter character co des as data in a program A is a convenient replacement

for as the internal character co de of the character A

eg A is read as

a

n macro

sharpv alu e property

STANDARD READER

This macro returns the value asso ciated with the next symb ol in the input stream This value is

found on the Plist of the symb ol under the sharpvalue prop erty This macro is often used to

dene or retrieve the internal character co des of nonprintable characters If no value is found on

the Plist sharpvalue raises the errudv error

cr is read as

esc

sp

to get the list of current values

maploblist lambda x getprop x sharpvalue

macro

This macro returns the internal character co de of the next character in the input stream

considered as an ascii control character that is with bits and set to

c is read as

Z

macro

This macro reads the next numb er in the input stream in base sixteen that is in hexadecimal

ffff is read as

macro

This macro reads the next numb er in the input stream in base two that is in binary

is read as

baser macro

This macro reads the next numb er in the input stream in base base which is a numerical

parameter accepted by the macro

r is read as

r

CHAPTER INPUT AND OUTPUT

inside macro

This macro character allows for the construction of bit numeric values from two bit values

with the vertical bar separating the bytes

This character can only app ear after one of the selectors or

xa is read as

aa

crlf

macro

Placed b efore an Sexpression this macro returns the list function sexpression

foo is read as function foo

It is therefore an abbreviation for calls to the function function

macro

This macro returns the list of internal character co des of the characters enclosed within

quotes To include the quote character double it enter it twice in a row in the input stream

Foo Bar is read as the list

FB

macro

This macro provides a way to refer to the name of a symb ol and its packages With this

selector one can dene or retrieve any kind of package symb ol symb ols or lists It also allows one

to describ e the typ e of a vector or a typ ed character string This same idiom is used by the printer

when it uses the systemprintpackageflag option

pkgcsymb is read as the symbol symb

in the package pkgc

a bfoo the symbol foo in the package a b

bare e the vector e e of type bar

macro

This macro evaluates the next expression in the input stream It returns the value of the

expression This macro provides a way to call the evaluator in the midst of a read

is read as

STANDARD READER

macro

This macro reads a list whose rst cell is tagged

tconsp a b ) a b

macro

This macro reads a vector of Sexpressions

vectorp makevector )

equal makevector a a a ) t

macro

This macro evaluates the next expression in the input stream If its value is equal to true the

macro returns the following expression in the input stream otherwise it returns but skips

over the following expression This macro character can thus b e used to do conditional reads

gcon defun gcalarm

if the value of variable gcon is not equal to

return the list defun gcalarm otherwise return

macro

This macro is the opp osite of the preceding one If the value of the next expression in the input

stream is false equal to the expression following it is returned otherwise it is skipp ed and the

macro returns

macro

This macro starts a multiline comment that terminates at the o ccurrence of the sequence of

characters There can b e multiline comments in the middle of multiline comments

Here are LISP equivalents for the standard macros

defsharp

list eval read

defsharp

if eval read

list read

read

defsharp

ifn eval read

list read read

CHAPTER INPUT AND OUTPUT

defsharp

list list function read

defsharp

sharplowbyte readcn

defsharp

let l read

let n getprop l sharpvalue

if n

sharplowbyte n

error sharpvalue errudv l

mapc

lambda x y putprop x y sharpvalue

null bell bs tab lf return cr esc sp del rubout

defsharp

sharplowbyte logand readcn

de sharplowbyte n

if neq peekcn the vertical bar or absolute value character

list n

readcn skip the vertical bar

list

let n logshift n n readcn

selectq n

ie slash

logor n readcn

ie carret

logor n logand readcn

ie backslash

let l read

let n getprop l sharpvalue

if n

logor n n

error sharpvalue errudv l

t all the others

error sharplowbyte errsxt n

defsharp

STANDARD READER

let l i

untilexit eoc

if setq i readcn

if peekcn

newl l readcn

exit eoc list nreverse l

newl l i

defsharp

with ibase

let r read

if fixp r

list r

error errsxt r

defsharp

with ibase

let r read

if fixp r

list r

error errsxt r

defsharp r base

with ibase base

let r read

if fixp r

list r

error r errsxt r

defsharp

skipsharpcomment

de skipsharpcomment

untilexit eoc

selectq readcn

when eq peekcn

readcn

skipsharpcomment

when eq peekcn

readcn

exit eoc

t

defsharp

CHAPTER INPUT AND OUTPUT

with typecn cpkgc

typecn cpname

list read

defsharp

reread

let l read list tconsmk l

defsharp

list apply vector readdelimitedlist

Colon macro character

Even though it is always p ossible to describ e a symb ol and its package by using the absolute

notation pkgcsymb it is often useful to b e able to use an abbreviation This is the purp ose of

the colon macro character placed in front a symb ol The symb ol will b e created in the package

whose name is the value stored the syspackagecolon variable

syspac kag e col on variable

This variable contains the name of the package to use when the macro character colon is used

in front of a symb ol By default its value is user This variable also describ es the package to use

when a symb ol b eginning with a character of typ e cpkgc is read

defvar syspackagecolon local syspackagecolon

foo will be read as localfoo

defvar syspackagecolon

pkpk syspackagecolon

foobar will be read as pkpkfoobar

typecn cpkgc is a package delimter char

foo will be read as pkpkfoo

foobar pkpkfoobar

Terminal macro characters L A E F P

These macro characters are used to quickly enter commands interactively on the terminal

L macro character

Placed in front of a symb ol this macro character executes the expression libloadfile symbol

t

It therefore allows you to load a LISP le interactively in an extremely concise manner L returns

the name of the le loaded The sux systemlelispextension is not added at the end of

the lename if it is already present

STANDARD READER

In LELISP L could b e dened in the following manner

dmc L

L to load a file

list libloadfile readstring t

eg Lfoo is read as libloadfile foo t

A macro character

CONTROLA has the same role as L but it loads a compiled mo dule with the mo dular compiler

In LELISP A could b e dened in the following manner

dmc A

to load a module

list loadmodule readstring

E macro character

Provides a way to call the pepe editor to treat the contents of a le or the result of the evaluation

of an expression

Ebar is read as pepe bar

Epretty foo pepe pretty foo

EPfoo bar pepe pretty foo bar

To call p ep e on the sorted list of names of global functions

Esortl maploblist lambda x

and null packagecell x

typefn x

F macro character

CONTROLF lets you call the host systems editor on a le in which a function was dened and

reload the le up on exiting from the editor The name of the host systems editor is stored in the

systemeditor global variable

system edi to r variable

The systemloadedfromfile prop erty set by the functiondenition functions indicates that

les should b e edited

CHAPTER INPUT AND OUTPUT

if the function bar was loaded from the file fooll

eg Fbar

is read as

progn comline catenate systemeditor

fooll

load fooll t

but if it was not loaded from a file a temporary file file

having the name gensym is created and

Fbar

is read as

progn prettyf file bar

comline catenate systemeditor file

load file t

P macro character

CONTROLP calls the prettyprinter on one or several functions whose names are given

In LELISP P could b e dened in the following manner

dmc P

cons pretty

implode pname catenate

readstring

Pfoo is read as pretty foo

Pfoo bar pretty foo bar

macro character

Used in front of a line while in interactive mo de this macro character executes the call comline

rest of the line It thus provides a very concise way to send a command to the lo cal op erating

system

ls ls is read as comline ls ls

BASIC OUTPUT FUNCTIONS

Basic output functions

All the following functions print their arguments into the output buer The expressions are not

actually printed until the buer is emptied

This can happ en at dierent times

when the characters reach the right margin of the buer

when the characters reach the end of the buer

up on calls to functions that empty the buer after placing something into it print

prinflush terpri

In the rst of these cases the progammable interrupt eol is triggered and an endofline is inserted

into the output stream In the second case the flush interrupt is triggered The buer is then

simply emptied This can only happ en if the right margin is b eyond the end of the output buer

see the rmargin function

prin s ::: s function with a variable number of arguments

n

prin prints the Sexpressions s sN in the output buer and returns the value of sN This

function cannot b e simply describ ed in LISP The expressions will not actually b e printed until the

buer is emptied A call to prin without arguments prin has absolutely no eect and returns

print s ::: s function with a variable number of arguments

n

This function is similar to prin but it empties the output buer immediately after printing the S

expression arguments therein and b egins a new line by triggering the eol programmable interrupt

A call to print without arguments print empties the buer starts a new line and returns

In LELISP print could b e dened in the following manner

dmd print l

prog prin l itsoft eol

print cdr a b c form to evaluate

b c

b c value returned progn prin print foo form

to evaluate

foo

foo value returned progn repeat prin a

print form to evaluate

aaaaaaaaaaaa

value returned print

CHAPTER INPUT AND OUTPUT

prinflus h s ::: s function with a variable number of arguments

n

This function is similar to prin but empties the output buer immediately after having

printed the Sexpression contained therein by triggering the flush programmable interrupt

prinflush do es not b egin a new line A call to the function with no arguments prinflush

empties the output buer and returns

In LELISP prinflush could b e dened in the following manner

dmd prinflush l

prog prin l itsoft flush

defun quam msg

prinflush msg print the msg into the buffer empty same

read read a reply

quam quam number of vegas satellites

number of vegas satellites

xxx xxx is the user reply

xxx

to print several items and then empty the buffer

defun prinandflush exp n

repeat n prin exp

prinflush

prinandflush

terpri n function with an optional argument

Skips n lines on the current output channel by calling the print function n times It is p ossible

to call terpri without an argument The default value of n is Such a call is equivalent to

b oth terpri and to print

In LELISP terpri could b e dened in the following manner

defun terpri n

repeat if n car n

print

princn cn n function with one or two arguments

Prints the cn character co de n times into the output stream If n is omitted the co de cn is only

printed once princn returns the internal character co de cn as its value

let cn a

repeat princn incr cn

bcdefghijk

t defun pyr n n

when n

CONTROLLING THE OUTPUT FUNCTIONS

princn sp n

princn n

print

pyr n n

pyr pyr

will produce

princh ch n function with one or two arguments

This function is similar to the preceding one except that the character ch is sp ecied in the

form of a monocharacter symb ol

eg print ten characters in the buffer

princh

Controlling the output functions

Limitations on printing

In order to limit the printing of very long structures and to avoid innite print lo ops on circular

or shared lists three functions are available

printlen gth n function with an optional argument

Provides a means of mo difying the maximum numb er of list elements to b e printed by a print or

prin statement Without an argument the function returns the current maximum length value

By default this value is If a list contains more elements than the current maximum length

value the remaining elements are not printed and three susp ension p oints are printed instead

This function can b e used to terminate output from functions which are iterating or recursively

lo oping on a lists cdr In order to deactivate the print length limitation call printlength with

as its argument The function returns the current maximum print length value as its result

printlength )

)

printlev el n function with an optional argument

Provides a means to mo dify the maximum print depth of a print or prin statement Without

an argument the function returns the current maximum depth value By default the maximum

print depth is This value represents the maximum numb er of unmatched op ening parentheses

allowed in a list to b e printed Up on overload the list causing the condition will not b e printed

CHAPTER INPUT AND OUTPUT

and the amp ersand character is printed in its place This function allows the results of functions

which are iterating or recursively lo oping on a lists car to b e printed In order to deactivate this

kind of limitation call printlevel with zero as its argument The function returns the current

maximum print level value as its result

printlevel

defun foo l

if null cdr l

l

foo cdr l

defun foo l if null

Here are some examples of printing circular lists

printlevel

printlength

setq l x y z

x y z rplacd cddr l l

z x y z x y z x y z x y z x y z x y z x y z x y z x

y z x y z x y z x y z x y z x y z x y z x y z x rplaca l l

y z y z y z y z y z y z y z

y z y z y z y z y z y z y z y z y

printlin e n function with an optional argument

Provides a way to mo dify the maximum numb er of lines which will b e printed by a print or

prin statement By default this value is If an expression requires more than this numb er

of lines the last line will app ear with susp ension p oints at the end In order to deactivate

this limit call printline with as its argument The function returns the current maximum

numb er of print lines allowed as its result

There is a library which lets LELISP functions b e printed in a much more readable manner

see chapter as well as a print library for circular or shared lists see chapter

Standard printing environment

The various LISP ob jects are printed in the output buer according to the constraint that the

external representation of an atomic ob ject cannot b e printed across a line b oundary This is the

case for symb ols character strings and numb ers

Sexpressions of the form quote s are printed as s to improve readability

The unnameable numb er in twos complement is always written in the following manner

unnameable number

)

logshift )

Finally all p ointers that are not LELISP p ointers are written in the following manner

CONTROLLING THE OUTPUT FUNCTIONS

<> nonLisp pointer

vag f

On machines with IEEEcompatible oatingp oint pro cessing this value may b e printed as

the value negative NotaNumb er that is NaN

Three system variables and two functions control various print mo des

system pri nt fo r rea d variable

This variable contains the print indicator of symb ols and character strings

If systemprintforread has value t symb ols containing characters of typ e other than

cpname are surrounded by vertical bar characters when b eing printed Character strings

with this same prop erty are surrounded by quote characters The and characters are

themselves represented by and pairs of or in the middle of these ob jects Finally

the system prints a space b etween each argument of the print prin or prinflush functions

When this indicator is set then the print output can b e reread by the read function

setq a foobar bar foo with quote

foobar bar foo with quote setq systemprintforread t

t a

foobar bar foo with quote

system pri nt ca se fl ag variable

This variable contains the output case indicator If systemprintcaseflag has the value

t symb ols are printed in upp er case If it has the value the initial default value symb ols

are printed in the form in which they were entered Notice that in general the read indicator

systemreadcaseflag has the value and that all symb ols are therefore read in lower

case

Here are some examples of the distinction b etween upp er and lower case in reading

setq systemreadcaseflag t

t setq a foobar FOOBAR FooBar

foobar FOOBAR FooBar setq systemprintcaseflag t

T a

FOOBAR FOOBAR FOOBAR setq systemprintcaseflag

a

foobar FOOBAR FooBar

system pri nt pa ck age fl ag variable

This variable contains the package print indicator which can take three values

 Packages are not printed

 t default Packages are printed in complete path full form pkgsym

CHAPTER INPUT AND OUTPUT

 If the value of the package is equal to the value of the variable syspackagecolon

packages are printed in short form using the macro character

setq systemprintpackageflag t

t setq syspackagecolon user

user foobar

foobar foo

userfoo setq systemprintpackageflag

foobar

bar foo

foo setq systemprintpackageflag

foobar

foobar foo

foo

obase n function with an optional argument

Provides a way to mo dify the numeric output conversion base If it is called without the

argument n it returns the current output base As in the case of the corresp onding ibase

function the value of obase must b e b etween and inclusive

obase obase always returns do you see why

obase why not

ibase conversion of base to base

D ab

A ab

AD

ptype symb n function with one or two arguments

Provides a way to mo dify the value of the ptype of the symb ol symb Called without a

second argument n ptype will simply return the ptype of the symb ol symb The ptype is

principally used by the LISP prettyprinter see chapter to determine the format to use to

print the function value of a symb ol ptype returns the current value of the ptype of symb

as its value

Extending the printer

It is p ossible to redene the way in which ob jects are printed for the standard print functions all

search for metho ds named prin asso ciated with the typ e of the ob ject to b e printed If such a

metho d exists it is called in lieu of the standard print function

Warning This function invo cation takes place in the current printer context In particular all

printer variables and variablefunctions remain in their current state

INPUTOUTPUT FOR LISTS

pratom atom function with one argument

The standard print function for atoms atom can b e of any typ e other than list This function must

b e called from within a sp ecic print metho d and provides a way to return to the current print

mo de

modification of the representation of the symbol to nil

defun nullprin obj

pratom nil

nullpratom

nil

Inputoutput for lists

explode s function with one argument

Returns the list of all the internal character co des of the external representation of the expression

s which can b e of any typ e whatso ever explode returns the list of co des that would b e printed if

one asked for s to b e printed by the prin function In fact there is not really an explode function

prop erly sp eaking in the system the output of the prin function is simply redirected

explode )

explode car a b )

explodec h s function with one argument

This is like the preceding function except that it returns a list of atoms monocharacter symb ols

for letters and sp ecial characters numb ers for numerals

In LELISP explodech could b e dened in the following manner

defun explodech s

mapcar ascii explode s

explodech )

explodech car a b ) c a r a b

implode ln function with one argument

Supp ose that ln is a list of ascii co des implode returns the Lisp ob ject which has this list of

internal character co des as its external representation implode is the inverse of explode and

provides a way to build new LISP ob jects from their external representations analogous to the use

of the read function There is not really a separate implode function in the system the input to

the read function is simply redirected

implode )

implode explode a b ) a b

CHAPTER INPUT AND OUTPUT

implodec h s function with one argument

This is similar to the preceding function except that it uses a list of atoms monocharacter symb ols

for letters and sp ecial characters numb ers for numerals

In LELISP implodech could b e dened in the following manner

defun implodech s

implode mapcar cascii s

implodech )

implodech explodech a b ) a b

Inputoutput on character strings

Inputoutput can b e thought of as a problem of transformations b etween an arbitrary ob ject and

a character string The following functions let you carry out either reading op erations within a

character string that is considered as an input stream or writing op erations within a character

string that is considered as an output stream To obtain these functions load the stringio mo dule

withinp ut fr om st rin g string body macro

Redenes the input stream as string and evaluates sequentially the forms contained in body

After the evaluation of body each read call p erforms a read op eration within string This function

returns the value of the nal evaluation inside body

withinputfromstring list read read )

without put t os tr ing string n body macro

Redenes the output stream as string and evaluates sequentially the forms contained in body

After the evaluation of body each print call p erforms a write op eration within string The rst

printing o ccurs at p osition n in string This function returns the numb er of characters written in

string

withoutputtostring setq s print )

s )

withoutputtostring setq s print aprint b )

s ) ab

readfro ms tr ing string function with one argument

Uses the read function to p erform reading op erations within string as if the latter were an input

buer The returned value is that of read If string is not in fact a string the value returned is

string

In LELISP readfromstring could b e dened in the following manner

INPUTOUTPUT BUFFER MANAGEMENT

defun readfromstring s

if stringp s

withinputfromstring s read

s

readfromstring )

typeof readfromstring ) fix

readfromstring )

readfromstring as ) as

printto st ri ng s function with one argument

Creates a string that represents the s ob ject printed by means of print

printtostring )

printtostring a b ) a b

InputOutput buer management

All the read and print functions describ ed up to this p oint work using buers Read functions read

characters in the input buer and print functions write characters in the output buer

These buers are lled and emptied by the system using the three programmable interrupts bol

b eginningoflin e eol endofline and flush

There is actually a separate buer for each input or output channel so io can b e done on several

channels in parallel The buer character string store is allo cated automatically by the system when

new channels are created

Its length characters cannot b e mo died

Input buer

Intro duction

A character string inbuf contains the contents of the current input buer Two indices into this

string inmax and inpos indicate the end of the buer and the p osition of the current read inpos

is the index of the next character to b e read in the string

If inpos b ecomes equal to inmax during a read op eration this means that all the characters

available in the buer have b een read At this p oint the programmable interrupt bol is triggered

The function invoked by this interrupt must rell the input buer and set inmax to indicate how

many characters were put into the buer

Manipulating the input buer

All these functions manipulate the buer of the current input channel which is selected by the

inchan function

CHAPTER INPUT AND OUTPUT

inbuf n cn function with one or two optional arguments

Returns the character string representing the current contents of the input buer The string

handling functions provide an easy means for manipulating this value Here for instance is a

particularly ecient way to implement the readstring function

defun readstring

when inpos inmax

itsoft bol

prog substring inbuf sub inmax

inpos inmax

inbuf accepts two optional arguments giving access to the current input buer contents The

following equivalences hold

inbuf n sref inbuf n

inbuf n cn sset inbuf n cn

inmax n function with an optional argument

Called with the argument n inmax provides a way to sp ecify the maximum numb er of characters

available in the input buer If n is not supplied inmax returns the current numb er of characters

in the input buer This function is used mainly inside a bol function to sp ecify the numb er of

characters to b e loaded into the buer

inpos n function with an optional argument

Called with the argument n inpos changes the p osition of the read p ointer index into the input

buer Without an argument it returns the current value of this index This function is very rarely

used

Beginningofli ne programmable interrupt

When there are no more characters to read in the input buer that is when imax characters

have b een read from the input buer the system triggers an interrupt called bol The function

asso ciated with this interrupt lls the input buer with characters read from the inchan channel

adds endofline characters cr and lf if necessary and sets the inmax index Of course it is

p ossible to manage this interrupt yourself by setting the syspackageitsoft variable in this

case you must ll the buer and set the inmax variable appropriately The system sets inpos back

to zero after it pro cesses a bol interrupt so it is sup eruous to do this even if you are managing

the pro cess

bol programmable interrupt

This programmable interrupt is triggered by the read readcn peekcn readstring and asso ciated

functions when the input buer is empty that is when inpos inmax

INPUTOUTPUT BUFFER MANAGEMENT

bol function with no arguments

This function reads the next line from the terminal or from a le puts it into the input buer and

sets inmax This is the function that p ermits input pro cessing on lines typ ed by the user character

erasure with bs or del line erasure with X or U and which echo es control characters with

a character followed by the printable character

The bol function uses the virtual terminal functions tyi tycn etc to read characters and unless

otherwise programmed echo them It is thus usually sucient to dene a new terminal typ e in

order to eect reads from new input streams windows serial p orts etc

What follows is a partial description of the bol function in LISP We describ e niether reads on les

nor the line editing asp ects nor the echoing of control characters The interested reader can consult

the source of the edlin line editor in the standard library

defun bol

if fixp inchan

code for reading files cannot be described in Lisp

let max

tystring prompt slen prompt

cond

systemlinemodeflag

setq max tyinstring inbuf

not systemrealterminalflag

until memq sset inbuf max tyi cr lf

incr max

t

let inbuf inbuf

char

until memq setq char tyi cr lf

tycn char

sset inbuf max char

incr max

tynewline

sset inbuf max cr

incr max

sset inbuf max lf

incr max

inmax max

Here is an example bol function that counts the numb er of lines the user typ es into the

terminal It changes the prompt to display this value

defvar numberingline

numberingline

defun numberingbol

when null inchan

CHAPTER INPUT AND OUTPUT

prompt catenate incr numberingline

superitsoft numbering bol

numberingbol

setq syspackageitsoft cons numbering syspackageitsoft

numbering

defun foo x

x x

foo

foo

Output buer

Intro duction

A character string outbuf holds the contents of the current output buer An index into the string

outpos marks the current write p osition the p osition in the buer where the next character should

b e written Two indices lmargin and rmargin mark the left and right margins resp ectively of

the output buer

If output b ecomes equal to rmargin during a write this means that a program is trying to write

a character b eyond the right margin of the output buer The programmable interrupt eol is

triggered at this p oint The function invoked by this interrupt must empty the output buer onto

the current output channel terminal or le add an endofline mark ll the output buer with

the space character and set the outpos index to the left margin lmargin

If outpos reaches the end of the buer during a write this means that a program is trying to write

a line longer than the buer This is p ossible when the right margin rmargin is b eyond the end

of the buer In this case the flush programmable interrupt is triggered The function invoked by

this interrupt must empty the output buer onto the current output channel ll the output buer

with space characters and set the outpos index to zero

Manipulating the output buer

lmargin n function with an optional argument

Sets the left print margin to n By default at system initialization lmargin is If n is omitted

the left margin value is not changed In any case lmargin returns the value of the current left

margin It is used primarily by the LISP prettyprinter to automatically manage the placement of

left braces in the printing of control structures

INPUTOUTPUT BUFFER MANAGEMENT

rmargin n function with an optional argument

Sets the right print margin to n By default at system initialization rmargin is If n is omitted

the right margin is not changed In any case rmargin returns the current value of the right

margin It is used primarily to set the line length for the output terminal b eing used teletyp e

screen printer etc

It is p ossible to set the right margin outside the output buer by executing

rmargin add slen outbuf

In this case the eol programmable interrupt is never called but at the end of the buer the

flush programmable interrupt will always b e called

outpos n function with an optional argument

Sets the current output buer p ointer index to n This index is always treated as the rst

free character p osition in the buer outpos returns its current value

outbuf n cn function with one or two optional arguments

Returns the character string representing the current contents of the output buer This

string can b e manipulated by the usual stringhandling functions

outbuf can optionally take two arguments giving access to the contents of the output buer

The following equivalences hold

outbuf n sref outbuf n

outbuf n cn sset outbuf n cn

Programmable interrupts eol and flush

eol programmable interrupt

The eol programmable interrupt is triggered by the prin print prinflush princn and princh

functions when the current write p osition outpos go es b eyond the right buer margin rmargin

The print and terpri functions invoke this programmable interrupt more explicitly

The function invoked by this interrupt must p erform the following op erations

 empty the output buer from p osition through p osition outpos onto the current

output channel

 put an endofline onto the channel

 ll the output buer with the space character

 set the outpos index to the value of the left margin lmargin

CHAPTER INPUT AND OUTPUT

eol function with no arguments

This function p erforms the standard pro cessing of the eol programmable interrupt What follows is

a partial description of it in LISP We do not describ e printing onto les which cannot b e describ ed

in LISP

Notice that this function uses the tystring and tynewline virtual terminal functions to print to

the terminal This means that it is usually sucient to dene a new typ e of virtual terminal in

order to redirect writes onto new streams music synthesizers windows etc

defun eol

if fixp outchan

code for writing to file cannot be described in lisp

tystring outbuf outpos empty the buffer to the terminal

tynewline print an endofline

fillstring outbuf sp rmargin clean the buffer

outpos lmargin set to left margin

flush programmable interrupt

This programmable interrupt is triggered by the print functions when the current print p osition

outpos reaches the end of the output buer This is p ossible if the right margin rmargin is greater

than the length of the print buer The interrupt is also triggered explicitly by the prinflush

function

The function invoked by this by this interrupt must p erform the following op erations

 empty the output buer from p osition through p osition outpos onto the current

output channel

 ll the output buer with the space character

 set the outpos index to the b eginning of the output buer

flush function with no arguments

This function p erforms the standard pro cessing of the eol programmable interrupt What follows

is a partial description of it in LISP We do not describ e writes to les which cannot b e describ ed

in LISP

defun flush

if fixp outchan

code for printing onto files cannot be described in lisp

tystring outbuf outpos empty the buffer to the terminal

fillstring outbuf sp rmargin clean up the buffer

outpos set to beginning of buffer

FUNCTIONS ON IO STREAMS

The eol and less frequently flush programmable interrupts can b e redened in order to extend

the printing system

The following function returns the list of lines printed by the evaluation of its b o dy in the form of

a list of character strings

df streamoutput systemf

let syspackageitsoft streamoutput

systeml the resulting list

eprogn systemf

nreverse systeml

defun streamoutputeol

newl systeml substring outbuf outpos

fillstring outbuf sp rmargin

outpos lmargin

Functions on io streams

LELISP manages io streams comp osed of

 an io terminal distinct streams

 a numb er in general input or output les

A channel chan is a numb er asso ciated with an op en stream All op en streams have channel

numb ers

They are used to connect op en streams to the current input or output stream By convention the

numb er of the terminals input stream is and the numb ers of the terminals two output

streams normal stream and virtual terminal stream are and t

In LELISP a le specication file is a character string or an argument that can b e converted

into a string by using the string function that has the same syntax as the host op erating systems

lenaming scheme

llibvirttyll

usrlocallelispfooll

lelispdisklelispllibvdtll

uddvlsilelispstartupll

lelispllibpepell

LELISP has a standard virtual le management library which is describ ed in the following section

All arguments of typ e file in the following function descriptions can b e virtual le descriptors

All the functions describ ed in this section will use the le system of the host system which can

return error co des in the case of le io problems In these cases the errios LISP error is triggered

which has the following default screen display

CHAPTER INPUT AND OUTPUT

fn io error n

where fn is the name of the LISP function that was called and n is the error co de returned by the

host le system

Errors detected by LELISP are

 function not implemented

 no more channels available

 incorrect channel numb er

 nonop en channel

Positivevalued error co des are op eratingsystem sp ecic in general the error numb er is

In certain cases it is p ossible to get the system to print the error message itself The following

variable can b e set to cho ose this option

system pri nt ms gs variable

If the value of this variable is dierent than the host op erating system will print if it can the

error messages it encounters in io management

Default directories and extensions

To p ermit functions to b e written in a le systemindep endent manner these variables are always

initialized

system lli b dir ec tor y variable

This variable contains the name of the directory where the standard LELISP library is to b e found

system llu b dir ec tor y variable

This variable contains the name of the directory where the user LELISP library is to b e found

system lel is pe xt ens ion variable

This variable contains the default extension of LELISP source les

Selecting io streams

openi file function with one argument

Op ens the le named file in read mode and returns the asso ciated channel numb er chan

openi fooll )

FUNCTIONS ON IO STREAMS

openib file function with one argument

Op ens the le named file in binary read mode and returns the asso ciated channel numb er chan

This le can only b e read with the readcn and readch functions

openib foodir )

openo file function with one argument

Op ens the le named file in write mode and returns the asso ciated channel numb er chan If this

le already exists it is destroyed and recreated as an empty le

openo srclist )

openob file function with one argument

Op ens the le named file in binary write mode and returns the asso ciated channel numb er chan

If this le already exists it is destroyed and recreated as an empty le Writes to such a le must

b e done with the princn or princh functions

openob fooo )

opena file function with one argument

Op ens the le named file in append mode and returns the asso ciated channel numb er chan If

this le do es not already exist it will b e created If it do es exist its le p ointer is p ositioned at

the end of the le so that all writes to the le will take place at the end of its current contents

opena subsyslog )

openab file function with one argument

Op ens the le named file in binary append mode and returns the asso ciated channel numb er chan

If this le do es not already exist it will b e created If it do es exist its le p ointer is p ositioned at

the end of the le so that all writes to the le will take place at the end of its current contents

Writes to such a le must b e done with the princn or princh functions

openab subsyslib )

inchan chan function with an optional argument

Ties the current input stream to the channel chan This means that all succeeding reads until

the next call to inchan will b e on the channel chan If no argument is given inchan returns the

numb er of the current input channel An error o ccurs when the channel asso ciated with the

current input stream has b een closed with the eof or close function and a read is requested

but no new input channel has b een selected This error also ties the current input stream to the

terminal value

outchan chan function with an optional argument

CHAPTER INPUT AND OUTPUT

Ties the current output stream to the channel chan This means that all succeeding writes until

the next call to outchan will b e on the channel chan If no argument is given outchan returns

the numb er of the current output channel An error o ccurs when the channel asso ciated with

the current output stream has b een closed with the close function and a write is requested

but no new output channel has b een selected This error also ties the current output stream to the

terminal value

channel chan function with an optional argument

Returns a descriptor of channel numb er chan This function gives control of the state of channels If

the argument chan is omitted a list of all the channel descriptors is returned A channel descriptor

is a list of the form state name

state is the value of the channels state

 nonop en channel

 channel op en in read mo de

 channel op en in write mo de

 channel op en in binary read mo de

 channel op en in binary write mo de

name is the lename asso ciated with the channel if one exists

In order to get the numb er of available channels evaluate

length channel

close chan function with an optional argument

Closes channel numb er chan and always returns t If no argument is given close closes all op en

channels and then reop ens the terminal

input file function with one argument

This function closes the current input stream op ens the le file in read mo de and ties the current

input stream to its channel numb er

Warning This function loses track of the numb er of the previously op en channel and can

only b e used in the command lo op at the terminal An endofle will nevertheless raise the

errudt error See the following section

In LELISP input could b e dened in the following manner

defun input f

when fixp inchan

close inchan

FUNCTIONS ON IO STREAMS

if f

inchan openi f

inchan

Here is a rather unortho dox way to load a le from the terminal by printing the values of

the evaluations

input f

output file function with one argument

This function closes the current output stream op ens the le named file and selects this channel

for output

Warning This function loses track of the numb er of the previously op en output channel and

must b e used only from the terminal to store the values of evaluations in a le To restore

output to the terminal simply evaluate

output

In LELISP output could b e dened in the following manner

defun output f

when fixp outchan

close outchan

if f

outchan openo f

outchan

Here is an example of le handling

copyfile function which copies the entire contents of the

input file filin to the output file filout compacting

at the same time the representations of lisp expressions

in the latter

defun copyfile filin filout

with inchan openi filin

outchan openo filout

obase

lmargin

rmargin

let systemprintforread t

systemprintpackage t

untilexit eof print read

close outchan filout

CHAPTER INPUT AND OUTPUT

with outchan openo fooll

print defun foo x x x

defun foo x x x copyfile fooll barll

barll

Endofle programmable interrupt

eof programmable interrupt

The end of a le causes the eof programmable interrupt which receives as a parameter the numb er

of the channel on which the endofle o ccurred

The function invoked by this programmable interrupt must in general close the channel using the

close function and cause an escap e with name eof

eof chan function with one argument

This function closes channel numb er chan and propagates an escap e with name eof If this function

is called while an Sexpression is b eing read for instance in the middle of reading a list it causes

a syntax error End of le during read

In LELISP eof could b e dened in the following manner

defun eof n

close n

inchan

if systeminreadflag

error read errsxt eof during a read

exit eof n

The eof programmable interrupt can b e redened by the user

The following functions for example provide a way to load a sequence of les named file

filen all at once Sexpressions can straddle two les

defvar syspackagecolon loadinsequence

defvar number the current extension

defvar file the filename

de loadinsequence file

let number

file file

syspackageitsoft

cons loadinsequence syspackageitsoft

loadfile catenate file number t

FUNCTIONS ON IO STREAMS

de eof n

if not probefile catenate file number

no more files

standard endoffile processing

superitsoft loadinsequence eof list n

go on to the next file in the sequence

print closing n opening n

close n

inchan openi catenate file incr number

Functions on les

probefil e file function with one argument

Returns t if file exists and if not

In certain op erating systems like UNIX a call to probefile with an empty argumenteither

or will always return t

In LELISP probefile could b e dened in the following manner

defun probefile f

let i catcherror openi f

when consp i

close car i

t

renamefi le ofile nfile function with two arguments

Changes the name of le ofile to nfile and returns t

copyfile ofile nfile function with two arguments

Copies the contents of le ofile in the le nfile and returns t

deletefi le file function with one argument

Deletes the le named file and returns t

created ire ct ory dir function with one argument

Creates the directory dir and returns t

deleted ire ct ory dir function with one argument

Deletes the directory dir and returns t

CHAPTER INPUT AND OUTPUT

load function and autoload mo de

loadfile file i function with two arguments

Loads the le named file and evaluates all the expressions it contains The indicator i is the value

of the variable systemredefflag see the description of the denition functions during the

load loadfile always returns file as its value

In LELISP loadfile could b e dened in the following manner

defun loadfile file redef

ifn probefile file

error loadfile file unknown file

let systemloadedfromfile file

systemredefflag redef

syspackagecolon syspackagecolon

systeminreadflag

inchan inchan

inchan openi file

protect untilexit eof eval read

let in inchan

when in close in

inchan inchan

file

load file i special form

This function is the fsubr form of the preceding function Moreover the i argument is optional

and equals by default

In LELISP load could b e dened in the following manner

df load file redef

loadfile file car redef

autoload file sym ::: sym special form

n

Since it is tiresome to load several les of functions by hand at every execution LELISP allows the

use of autoload functions which load automatically the rst time they are called

file is the name of a le that should b e loaded automatically using the loadfile function

if one of the symb ols sym ::: sym is to b e evaluated as a function File loading follows the

n

callbynecessity convention

In LELISP autoload could b e dened in the following manner

df autoload f l

autoload file at atn

FUNCTIONS ON IO STREAMS

mapc lambda at

eval list dm at l

list remfn kwote at

list load f t

l

l

The call autoload pretty pprint results in the following denition of the pprint function

dm pprint l

remfn pprint

load pretty t

l

This results in the macro b eing called at the rst evaluation of pprint This macro

destroys itself to avoid lo oping in case the function is not dened in the le then evaluates

load pretty t which silently loads the le pretty

Since the value returned by the macro was the original call pretty itself eval reevaluates

this form in which pretty is now dened

File access paths

An ordered set of prexes or libraries can b e dened to avoid always having to explicitly sp ecify

complete lenames This set is found in the variable

system pat h variable

This variable contains the directories that will b e searched when le access is requested At the

initialization of LELISP it contains the names of the system directories

defvar systempath

list

systemllibdirectory

systemllubdirectory

systemllmoddirectory

systemllobjdirectory

systemlltestdirectory

systemvirttydirectory

systemvirbitmapdirectory

systemsystemdirectory

searchi np at h path file function with two arguments

Returns the complete lename of the le file if it is found in one of the directories named in path

If no such le is found the function returns

CHAPTER INPUT AND OUTPUT

In LELISP searchinpath could b e dened in the following manner

defun searchinpath path file

when path

let realfile catenate if consp path

car path

path

file

if probefile realfile

realfile

when consp path

searchinpath cdr path

file

probepat hf file function with one argument

If the le named filesystemlelispextension exists in one of the directories named in

systempath probepathf returns its complete name Otherwise it returns

In LELISP probepathf could b e dened in the following manner

defun probepathf file

searchinpath

systempath

catenate file systemlelispextension

Access to libraries

libloadf ile file i function with two arguments

This function is similar to the loadfile function except that it searches for the le named file

in the various directories named in the systempath variable It returns the actual name of the

le loaded or else raises an error if the le is not found

In LELISP libloadfile could b e dened in the following manner

defun libloadfile file redef

let realfile probepathf file

ifn realfile

error libloadfile errfile file

loadfile realfile redef

libload file i special form

This is the fsubr form of the preceding function Furthermore the i argument is optional and

has the value by default

EVENT LOOP

In LELISP libload could b e dened in the following manner

df libload file redef

libloadfile file car redef

For an example try libload hanoi

libautol oad file sym ::: sym special form

n

This function is similar to the autoload function except that les will b e loaded with the libload

function instead of with load

Event lo op

The LELISP event lo op is a functional interface that enables you to asso ciate pro cessing functions

with various kinds of input events This event lo op has no problems with interrupts While awaiting

various typ es of events the event lo op handles all conventional interrupts

In a LELISP program a single event lo op can take care of several dierent kinds of input

 Graphic input generated by the mouse andor the keyb oard

 Files in the UNIX sense so cket or pip e

 MAILBOX in the VMS sense

The implementation of the event lo op is based up on the socalled Virtual Terminal of LELISP

describ ed in chapter of the present manual In UNIX the select device is brought into play In

VMS the AST device is used

To day the functions describ ed here only work in either UNIX or VMS The event lo op uses a virtual

terminal of the ttyevloop typ e In fact the events lo op cannot b e used with a virtual terminal

that is not of the ttyevloop typ e An exception is the virtual terminal used by AIDA which

includes a standard integration of the event lo op

To use the event lo op of LELISP load the evloop mo dule

eventloo p feature

This feature indicates that the eventlo op functions are loaded In other words the evloop mo dule

is present

Functions

evloopi nit function with no arguments

Initializes the event lo op and sets the virtual terminal ttyevloop as the current terminal This

function should only b e called once

CHAPTER INPUT AND OUTPUT

evloops top function with no arguments

Stops the event lo op and sets the default terminal of the tty system as the virtual terminal

evloopr est ar t function with no arguments

Restarts the event lo op and reassigns the ttyevloop virtual terminal as the current terminal

evloopd isa ll ow tt yi npu t function with no arguments

Inhibits the pro cessing by the event lo op of standard user input This function is only eective if

the event lo op has b een initialized and is active

evloopa llo w tty i npu t function with no arguments

Enables the pro cessing by the event lo op of standard user input This function is only eective if

the event lo op has b een initialized and is active

evloopa dd in put fd managefct argtouse function with three arguments

Adds the UNIX le descriptor fd to the event lo op Imagine that the event lo op is active and that

theres something to read in the case of the fd le descriptor In such a situation the managefct

function is executed with argtouse as its argument This function has no eect if the event lo op

has not b een initialize d

evloopr emo ve in pu t fd function with one argument

Removes the fd le descriptor from the list of le descriptors handled by the event lo op Before

deleting fd evaluate evloopinputmanagedp fd to make sure that fd is pro cessed by the event

lo op

evloopch ang e man age f unc ti on fd newmanagefct newargtouse

function with three arguments

If the le descriptor fd is already b eing pro cessed in the event lo op this function replaces the

function to b e executed for this descriptor by the function newmanagefct with newargtouse

as its argument

evloops ele ct function with no arguments

This function is not required for standard use of the event lo op mo dule It is only needed by users

who wish to implement new typ es of virtual terminals This function represents the engine of the

event lo op It is called regularly by the system This is the function that blo cks the program while

waiting for one or several le descriptors to b e ready for reading at which time their asso ciated functions are executed

EVENT LOOP

evloopr ead p fd function with one argument

Returns t if an input is ready for reading Otherwise it returns This is a generalized version

of the eventp function of the Virtual Bitmap

evloopi npu t man ag edp fd function with one argument

Returns t if the fd input is b eing pro cessed by the event lo op The argument fd is typically an

integer that designates a le descriptor under UNIX

evloopi nit ia liz ed p function with no arguments

Returns t if the event lo op has already b een initialized

evloopw ait function with no arguments

Causes the pro cess to wait for an input After the wait when a descriptor is ready the function

returns an expression of the form fd function arg Here fd is the le descriptor

function is the asso ciated pro cessing function and arg is an argument If more than one descriptor

is ready to b e read the function returns a list of expressions of the form fd function arg

evloops et ti meo ut secs millisecs function with two arguments

This function allows you to limit the waiting time of the pro cess in the evloopselect and

evloopwait functions This waiting time is indicated in secs seconds and millisecs When

the time has run out the function sp ecied by evloopsettimeouthandler describ ed b elow is

executed The arguments secs and millisecs must b e p ositive integers If b oth of them are given

as zero this represents an innite waiting time So evloopsettimeout lets you p erio dically

trigger pro cessing op erations while awaiting an event Unlike the clockalarm function of LELISP

the pro cessing is not triggered during the execution of any other pro cessing apart from the calls to

evloopselect and evloopwait

evloops et ti meo ut ha ndl er handler function with one argument

The handler argument must b e either or a function with no argument that is to b e called when

the time sp ecied by the evloopsettimeout function has run out

Output pro cessing

We now describ e functions that let you add output les le descriptors and other entities into

the events lo op

evloopa dd ou tpu t fd managefct argtouse function with three arguments

CHAPTER INPUT AND OUTPUT

Adds the UNIX le descriptor fd into the events lo op If the events lo op is active as so on as the

le descriptor fd is ready the managefct function is executed with argtouse as its argument

This function has no eect if the events lo op has not b een initialized

evloopr emo ve ou tp ut fd function with one argument

Removes the le descriptor fd from the list of le descriptors b eing pro cessed for output by the

event lo op

evloop cha nge o utp ut ma nag e fun cti on fd newmanagefct

newargtouse function with three arguments

If the le descriptor fd is already b eing pro cessed in the event lo op this function replaces the

function to b e executed by the function newmanagefct with newargtouse as its argument

Pro cessing the Virtual Bitmap

Three functions within this mo dule allow you to manipulate graphic input for the VB virtual

bitmap

evloopa dd di spl ay display managefct function with two arguments

Lets you record input graphic events asso ciated with the display device When there is a graphic

event from the display device the managefct function is executed with display as its argument

evloopr emo ve di sp lay display function with one argument

Removes the display device from the inputs pro cessed by the events lo op

evloopd isp la ym an age dp display function with one argument

Returns t when the display device is b eing pro cessed by the events lo op If not the function returns

Technical notes

Using the events lo op in Unix

Most of the functionalities of the events lo op are implemented in C co de under UNIX This C co de is

stored in the evloopc le which is included in the standard LELISP distribution Before using the

events lo op this co de should b e compiled and present in the LELISP binary This co de is not present

in a standard binary but it exists by default when the Virtual Bitmap has b een implemented by

means of X

EVENT LOOP

Portability of the events lo op under VMS

All the functions that we have just describ ed have b een implemented under the VMS op erating

system The UNIX concept of a le descriptor has b een replaced by the notion of an inputoutput

channel Under VMS there are several input typ es but only the MAILBOX and graphic events are

handled by LELISP The VMS user should create the MAILBOX and record the asso ciated channel in

the lo op It is imp ortant to understand that the implementations of these two systems are based

up on dierent principles

 Under UNIX the implementation is based up on the select functionality

 Under VMS the implementation is based up on the AST functionality

Both mo dules nevertheless b ehave identically

Precautions

An imp ortant remark needs to b e made concerning the use of the event lo op in conjunction with

the LELISP savecore functionality The use of this mo dule means that the event lo op must b e

reinitialized each time you launch LELISP So the following actions must b e carried out

Use evloopremoveinput and evloopremoveoutput to remove all inputoutput recorded

in the lo op

Use evloopstop to stop the lo op

Call the savecore function

Initialize the lo op with the evloopinit function

Once again record all inputoutput

Example

Let us lo ok at an example of the use of the events lo op with the LELISP VB device virtual bitmap

under X We need the following utility function that reads all events that are waiting in the

display device and displays them on the screen

defun displaymanageevents display

currentdisplay display

while eventp print readevent

We launch LELISP

lelispX

LeLisp by INRIA version nov sony

Systeme standard sur Xwindows ven nov

bitfloats abbrev callext compiler date debug defstruct edlin loader

mc messages microceyx pathname pepe pretty setf virbitmap virtty

CHAPTER INPUT AND OUTPUT

Load the mo dule that denes the events lo op

loadmodule evloop

evloop

Initialize the display device

setq display bitprologue

displayx X trocadero

Get the le descriptor so cket asso ciated with display

evloopinit

t setq fd send filedescriptor display

Add it to the standard events lo op

evloopaddfiledescriptor fd displaymanageevents display

t

Create a window

setq w createwindow window lisp window

imagerectanglewindow lisp window

Initialize the display device on a second screen

setq display bitprologue X host

displayx X trocadero

Get the le descriptor so cket asso ciated with the second display

setq fd send filedescriptor display

Add it to the standard events lo op

evloopaddfiledescriptor fd displaymanageevents display

t

Create a second window on the screen of the host machine

setq w createwindow window lisp window

imagerectanglewindow lisp window

All mousekeyb oard events asso ciated with the windows w and w will b e displayed as well as

anything typ ed by the user in the LELISP startup window

evententerwindowevent imagerectanglewindow lisp window

eventdownevent imagerectanglewindow lisp window

eventupevent imagerectanglewindow lisp window

eventleavewindowevent imagerectanglewindow lisp window

evententerwindowevent imagerectanglewindow lisp window

eventasciievent imagerectanglewindow lisp window

VIRTUAL FILE SYSTEM

eventleavewindowevent imagerectanglewindow lisp window

Terminate the session

end

May LeLisp be with you

Virtual le system

This section describ es the virtual le system implemented in LELISP This facility provides a

way to manipulate les without regard to the host op erating system It is easily extensible to new

op erating systems

In order to gain access to functions describ ed in this section the mo dule named path must b e

loaded Since this mo dule redenes some standard io functions it should not b e loaded into the

system more than once

First we describ e the new LELISP ob ject typ e pathname and the meaning of its elds Then

we describ e the eld access and manipulation functions Finally we describ e some higherlevel

functions and the means to redene the access functions

pathname feature

This ag indicates whether the functions treating pathnames are loaded into the system that is

whether the path mo dule is present

Pathnames

The pathname ob ject is a LELISP structure that represents le names without regard to particular

op eration system conventions In some systems these ob jects could represent other structures for

example interpro cess communications channels etc

Programmers wanting to use these primitives to increase the p ortability of their co de will have to

restrain the syntax of pathnames to a subset common to and compatible with all the op erating

system environments in which LELISP is used In the rest of this chapter any functionality which

could b e somehow nonp ortable to any system will b e explicitly describ ed as such

Pathnames do not necessarily represent a complete lename Some elds in the sp ecication of a

name could b e missing and in such cases it is useful to designate directories or default eld values

during evaluation

pathname structure

This structure describ es the LELISP ob ject representing op erating systemindep endent pathnames

In LELISP pathname could b e dened in the following manner

CHAPTER INPUT AND OUTPUT

defstruct pathname host device directory name type version

 The host eld should hold the name of the machine on which the le physically exists

in a networkbased environment This eld can also contain access control information

The exact syntax of this eld dep ends on the OS and is therefore not p ortable For les

on machines not supp orting networkbased le systems the value of this eld is in

the other case this eld contains a character string

 The device eld contains the name of the disk on which the le is stored when the

op erating system explicitly designates the p eripheral device as do vms and msdos for

instance If the OS do es not supp ort the notion of a le tree this eld has the value

otherwise it should contain a character string

 The directory eld contains the list of directories and subdirectories where les can b e

found Each directory name is a character string This list is in the intuitive order ie

the rst element is the ro ot of the hierarchy and can designate either an absolute tree

or a relative access path See the section on access paths

 The name eld contains the name of the le in the traditional sense of the term It is

stored as a character string

 The type eld contains the character string designating the extension of the lename

This extension indicates in a general way the nature of the contents of the le Thus in

most LELISP implementations this eld has the value ll for a LELISP source le

 The version eld contains a version numb er The exact version numb ering convention

dep ends on the op erations system but generally the higher the le version numb er the

more recent the vintage of the version of the le

pathname string function with one argument

Converts the character string string corresp onding to a lename in the syntax of the op erating

system into an ob ject of typ e pathname

Under UNIX with systemprintforread set to t

pathname uddlelispllibpathll

pathname udd lelisp llib path ll

The same thing on a VAXVMS system

pathname lelispdisklelispllibpathll

pathname lelispdisk lelisp llib path ll

pathname p s function with one argument

This predicate returns if its argument is not an ob ject of typ e pathname and t otherwise

Example on VAXVMS

pathnamep pathname lelispllibpathll

t same thing on UNIX

VIRTUAL FILE SYSTEM

pathnamep pathname usrlocallelispllibpathll

t

equalpa thn am e path path function with two arguments

Returns t if the two arguments are equivalent pathnames

Examples under UNIX

equalpathname uab uab

t equalpathname uab ub

This function considers that ab and b are dierent UNIX pathnames b ecause of the

p ossible presence of symb olic links

namestri ng path function with one argument

Returns a character string that is the external representation for the host op erating system

of the argument path This external form is obtained by combining the pathname elements

according to the op erating systemsp ecic syntax rules

Warning No syntax validation is carried out by LELISP Obviously invalid lenames can b e

generated

p macro

This macro character returns the path that follows it parsing it according to the host

op erating system syntax

In LELISP p could b e dened in the following manner

defsharp p

ncons pathname read

u macro

This macro character p erforms a function similar to the one describ ed immediately ab ove but it

parses the pathname according to UNIX syntax on al l op erating systems It oers a p ortable way

to enter pathnames

Example on a VAXVMS system

uusrlelispllibpathll

pusrlelispllibpathll

pathna me pr in path function with one argument

Denes the print metho d for ob jects with typ e pathname Its b ehavior dep ends on the value

of the systemprintforread indicator If this latter has the value pathnames are

CHAPTER INPUT AND OUTPUT

printed in the systemsp ecic form of the host op erating system If it is not equal to the

pathnames are printed as LELISP structures This feature allows pathnames to b e saved in

les in a machineindep ende nt way The standard form is however more convenient to the

user who knows the lo cal op erating system lename syntax

Example on a UNIX system

setq systemprintforread

pusrlocallelispllibtestll

pusrlocallelispllibtestll

setq systemprintforread t

t

pusrlocallelispllibtestll

pathname usr local lelisp llib test ll

Relative access paths

Most op erating systems organize les in a hierarchy of directories and subdirectories and give

the user the means to move around in the tree The denition of a current working directory is

fundamental to many systems and lename syntax is then relative to this current directory

LELISP allows keywords to b e substituted for certain pathname elds so that these relative access

paths can b e formed

Warning Relative access paths are not necessarily p ortable to every op erating system on which

LELISP is used

pathnam eu p indicator

This keyword can b e placed in the directory eld of a pathname structure It signies that the

lename is to b e relative to the next higher level of the lesystem hierarchy In the rst p osition

of the directory eld it indicates that the pathname is relative to the users current working

directory

On a UNIX system with systemprintforread set to t

pfoobarll

pathname pathnameup foo bar ll

pathnam ec ur ren t indicator

This keyword can only b e placed in the rst p osition of the list in a pathnames directory

eld It indicates that this pathname starts in the users current directory instead of b eginning

at the ro ot of the le system

On a VAXVMS system

pfoobarll

pathname pathnamecurrent foo bar ll

VIRTUAL FILE SYSTEM

pathnam ew il d indicator

This keyword can b e placed in any eld in a pathname and will b e replaced by a particular

value by the op erating system Pathnames containing this indicator cannot b e passed as

arguments directly to LELISP le access functions First a wildcard function describ ed

b elow must b e executed to convert the wildcard into a particular value

In the following example we select all les in foo that have toto as their name with any

extension whatso ever On a UNIX system with systemprintforread set to t

pfoototo

pathname pathnameup foo toto pathnamewild

wildcard path function with one argument

expandp ath na me path function with one argument

This function takes a pathname argument containing elds with pathnamewild values

or a character string in the host system lenaming syntax and returns the list of expanded

pathnames of les on the host machines le system that match the pattern If no such le is

found it returns

On a UNIX system

expandpathname pll

plisppathll pdemogamesll

On an OS machine the catalogue cannot b e expanded

expandpathname plelispllibpath

plelispllibpathll

Pathname manipulation functions

Arguments to these functions can b e either pathnames or character strings representing the external

le sp ecications ie lenames for the host op erating system In the second case an intermediate

conversion into pathname representation is done It is thus recommended for reasons of eciency to

avoid making frequent calls to these functions with character string ie host lename arguments

pathname ho st path function with one argument

This function returns the host eld of its argument or This eld has the typ e string

pathname de vi ce path function with one argument

This function returns the device eld of its argument or This eld has the typ e string

pathname di re cto ry path function with one argument

CHAPTER INPUT AND OUTPUT

This function returns the directory eld of its argument or This eld is a list of character

strings or the empty list

pathname na me path function with one argument

This function returns the name eld of its argument or This eld has the typ e string

pathname ty pe path function with one argument

This function returns the type eld of its argument or This eld has the typ e string

pathname ve rs ion path function with one argument

This function returns the version eld of its argument or This eld has the typ e fix

All the elds of ob jects of pathname typ e can b e mo died by means of the following functions

setpath nam e hos t path host function with two arguments

Lets you mo dify the host eld of the argument path of pathname typ e The function returns the

new value of the eld The host argument must b e either of string typ e or equal to

setpath nam e dev ic e path device function with two arguments

Lets you mo dify the device eld of the argument path of pathname typ e The function returns

the new value of the eld The device argument must b e either of string typ e or equal to

setpath nam e dir ec tor y path dir function with two arguments

Lets you mo dify the directory eld of the argument path of pathname typ e The function returns

the new value of the eld The dir argument must b e a list whose elements are character strings

or one of the symb ols pathnameup pathnamecurrent or pathnamewild

setpath nam e nam e path name function with two arguments

Lets you mo dify the name eld of the argument path of pathname typ e The function returns the

new value of the eld The name argument must b e either of string typ e equal to or the

pathnamewild symb ol

setpath nam e typ e path type function with two arguments

Lets you mo dify the type eld of the argument path of pathname typ e The function returns the

new value of the eld The type argument must b e either of string typ e or equal to

setpath nam e ver si on path version function with two arguments

VIRTUAL FILE SYSTEM

Lets you mo dify the version eld of the argument path of pathname typ e The function returns

the new value of the eld

default pat hn ame d efa ult s variable

This variable is initialized to the empty pathname all elds equal to It is used to indicate the

default values of various leds during pathname creation and merging op erations

makepat hna me element ::: element function with a variable number of arguments

n

This function takes a variable numb er of arguments and builds a pathname The arguments

must b e supplied in the following order host device directory name type and version If

an argument is missing or has the value the value for the same eld in the global variable

defaultpathnamedefaults is used

The arguments are as follows

 host is either a character string or

 device is either a character string or

 directory is either a list of character strings or

 name is either a character string or

 type is either a character string or

 version is either an integer or

On a UNIX system with systemprintforread set to

defaultpathnamedefaults

p

makepathname toto ll

ptotoll

setq defaultpathnamedefaults puddlelisp

puddlelisp

makepathname toto ll

puddlelisptotoll

filenam est ri ng path function with one argument

This function returns the character string corresp onding to the external sp ecication of the

lename typ e and version part of its pathname argument for the host le system

On a UNIX system with systemprintforread set to

filenamestring puddlelisptestll

testll

hostnam est ri ng path function with one argument

CHAPTER INPUT AND OUTPUT

This function returns the character string representing the le systems host machine or if

this eld is equal to the empty character string

On a VAXVMS machine

hostnamestring pasterixlelispllibstartupll

asterix

devicen ame st rin g path function with one argument

This function returns the character string representing the disk on which the le system

resides or if this eld is equal to the empty character string

On a VAXVMS machine

devicenamestring lelispdisklelispllibstartupll

lelispdisk

director yn am est ri ng path function with one argument

This function returns the character string representing the directory tree stored in the

directory eld of its argument in the syntax of the host op erating system

On a UNIX system with systemprintforread set to

directorynamestring puddlelisptotoll

uddlelisp Example on a VAXVMS machine

directorynamestring plelispdisklelispllibstartupll

lelispllib

mergepa thn am es path defaultpath function with two arguments

This function merges two pathnames It returns a pathname in which the elds missing from

the rst argument are lled in with values from the corresp onding elds from the second

argument

On a UNIX system with systemprintforread set to

mergepathnames ptestll pusrspooluucptotoll

pusrspooluucptestll

combine pat hn ame s path path function with two arguments

This function has two arguments the pathnames path and path It returns the pathname

that results from their comp osition The comp osition of two pathnames is obtained in the

following manner

 Cho ose the host eld of path If it is empty then cho ose the host eld of path

 Cho ose the device eld of path If it is empty then cho ose the device eld of path

 If the directory eld of path describ es a relative path then concatenate the directory

elds of the two pathnames If the directory eld of path is not relative then take it

VIRTUAL FILE SYSTEM

as it stands The resulting directory eld might b e simplied in b oth cases

 The name type and version elds are taken solely from path Those of path are

disregarded

combinepathnames uhome ufoosh

phomefoosh

combinepathnames uusrlelispllib ullobjprettylo

pusrlelispllobjprettylo

combinepathnames uusrlelispllibpathll ullmodpathlm

pusrlelispllmodpathlm

combinepathnames uusrlelispllibpathll

uusrlelispllobjpathlo

pusrlelispllobjpathlo

This function is dierent from mergepathnames in that the latter is used to ll in the missing

elds of a pathname whereas combinepathnames is a comp osition of two things

 Certain elds indicate the place where the le is lo cated host device and directory

 Other elds taken from the second pathname indicate the nature of what the le

contains name type and version

Note that for any two pathnames p and p whatso ever the evaluation

probefile combinepathnames p p

pro duces exactly the same result as

with currentdirectory p probefile p

enoughn ame st rin g path default function with one or two arguments

Builds the shortest p ossible character string that dierentiates the pathname path from the

default value default which is an optional parameter If the second argument is not supplied

values stored in defaultpathnamedefaults are used instead

On a UNIX system with systemprintforread set to

enoughnamestring puddlelisptotoll puddlelispfoobar

totoll

truepat hna me path function with one argument

Some op erating systems allow users to dene sp ecial symb ols which can app ear thereafter in

lenames Examples are UNIX environment variables or VMS or tops logical names The

truepathname function translates a given pathname which may well contain such a symb ol

into its real hard pathname The translation scheme that is used dep ends on the system

On UNIX systems shell variables can b e used in either the head or tail p ositions in a lename

that is either as the rst or last elements in the lename LELISP will search the shell

CHAPTER INPUT AND OUTPUT

environment for variables in these p ositions that b egin with the character Consequently

the UNIX dereferencing syntax must b e resp ected

On VMS systems the pathname is examined to see whether any of its elds corresp ond

to logical names If so they are translated This translation is not p erformed recursively

If an exact physical or hard lename is required it might b e necessary to apply the

truepathname function to the result

On a UNIX system with systemprintforread set to

truepathname pHOMElelisp

pnfshomerodinelelisp truepathname pdevTERM

pdevxterm

On a VAXVMS system

truepathname syslogintestll

pamondradanatestll

If this functionality is not oered by a given op erating system truepathname returns its

argument unchanged

userhom edi r pat hn ame function with no arguments

This function returns the pathname corresp onding to the notion of Homedirectory for

op erating systems that supp ort this In other cases it returns the name of a directory which

must always b e valid

On a UNIX system with systemprintforread set to

userhomedirpathname

pnfshomerodine

On a VAXVMS system

userhomedirpathname

psyslogin

control fil e pat hn ame name path function with one or two arguments

This function takes a character string as its rst argument and returns the asso ciated

pathname found in the users home directory The aim of this function is to provide a standard

means of creating initialization control les for applications written in LELISP The default

name of this le dep ends on the op erating system

< >

 Under UNIX it is HOME name

< >

 Under VMS it is SYSLOGIN name

< >

 Under OS it is HOME name ini

If the path argument is supplied it must b e the name of the initialization le of string or

VIRTUAL FILE SYSTEM

pathname typ e for the name pro duct

On a UNIX system

controlfilepathname aida

puddchateletdanaaida

On a VAXVMS system

controlfilepathname aida

psysloginaida

On an OS system

controlfilepathname aida

puddchateletdanaaidaini

An imp osed name on a UNIX system

controlfilepathname csh pcshrc

puddchateletdanacshrc controlfilepathname csh

puddchateletdanacshrc

temporar yf il ep at hna me name function with one argument

This function provides a standard way to create a le in a temp orary storage area provided

by the op erating system with the name given as argument It returns a pathname

On a UNIX system with systemprintforread set to

temporaryfilepathname toto

ptmptoto

On a VAXVMS system

temporaryfilepathname toto

psysscratchtoto

current dir ec tor y path function with an optional argument

If used without an argument this function returns the users current working directory If

the path argument is supplied it must b e either a pathname whose directory sp ecication

obtained by the call directorynamestring pathis valid or a character string in the

lename syntax of the host system The function changes the current working directory of

the LELISP pro cess to the given argument

director yp path function with one argument

This function lets you nd out whether or not the path pathname is a catalogue directoryp

has the same relationship with catalogues as probefile with les The path argument can b e

of pathname or string typ e directoryp is a natural complement to currentdirectory

directoryp returns either a pathname or The name eld of the pathname is always empty

so that the pathname is a p erfect description of a catalogue

CHAPTER INPUT AND OUTPUT

Portability

When the path mo dule is loaded the set of standard functions which work on les designated

herein by file is redened cf section to accept b oth character strings and also pathnames

The following variable and function provide a way to test the absolute p ortability of lenames

portable pa th nam e variable

When this global variable is set to a value dierent than all functions using pathnames verify

that their pathname arguments are p ortable over the entire set of machines supp orting LELISP

implementations by using the predicate describ ed next This feature is particularly attractive to

developp ers building p ortable applications in LELISP

portable pa th nam e p path function with one argument

This function takes a pathname as argument It tests the validity of this pathname for the various

op erating systems supp orting LELISP implementations It returns if the given pathname is not

p ortable and sends messages describing the p ossible incompatibilities found

Features

LELISP can manage the names of libraries loaded into memory

Here are the names of features in the standard library

abbrev denition of abbreviations

callext connection mo dule for C

compiler standard or mo dular compiler

complex complexnumb er arithmetic

complice mo dular compiler

date date manipulation library

debug debugging to ols

defstruct structure denitions

edlin default line editor

eventloop interface of the event lo op

format format library

gen library of generic op erators for bignums

genr library of generic op erators

hashtable hash tables

libcir circular ob jects library

loader loader

messages multilanguage messages

microceyx MicroCeyx ob jectoriented language

module mo dule management functions

n natural integers of arbitrary precision

FEATURES

pathname virtual le system

pepe fullpage editor

pretty Sexpression prettyprinter

q rationals of arbitrary precision

ratio rationalnumb er arithmetic

setf generalized assignment

sets mathematical sets

stringio IO on strings

termcap termcaptovirtty translator

terminfo terminfotovirtty translator

virbitmap virtual bitmap

virtty virtual terminal

window virtual windowing

z relative integers of arbitrary precision

listfea tur es function with no arguments

Returns the list of features currently in memory

addfeat ure symb function with one argument

Adds the name symb to the list of loaded features

remfeat ure symb function with one argument

Removes the name symb from the list of loaded features

featurep symb function with one argument

Returns symb if the feature symb is found in the list of loaded features

CHAPTER INPUT AND OUTPUT

Table of contents

Input and output

Intro duction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

Characters ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Character strings ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Lines ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

Channels ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Programmable IO interrupts :::::::::::::::::::::::::::::::::::::::::::::

Basic input functions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

Inside read ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Use of the terminal for input ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Standard reader ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Reading symb ols ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

Reading character strings :::::::::::::::::::::::::::::::::::::::::::::::::

Reading integer and rational numb ers :::::::::::::::::::::::::::::::::::::

Reading oatingp oint numb ers :::::::::::::::::::::::::::::::::::::::::::

Reading lists ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::

Reading vectors ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

Reading comments ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Typ es of characters ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Macro characters ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Basic output functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

Controlling the output functions :::::::::::::::::::::::::::::::::::::::::::::::::

Limitations on printing :::::::::::::::::::::::::::::::::::::::::::::::::::

Standard printing environment :::::::::::::::::::::::::::::::::::::::::::

Extending the printer ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Table of Contents

Inputoutput for lists ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

Inputoutput on character strings ::::::::::::::::::::::::::::::::::::::::::::::::

InputOutput buer management ::::::::::::::::::::::::::::::::::::::::::::::::

Input buer ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::

Output buer ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

Functions on io streams ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Default directories and extensions :::::::::::::::::::::::::::::::::::::::::

Selecting io streams ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Endofle programmable interrupt :::::::::::::::::::::::::::::::::::::::

Functions on les ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

load function and autoload mo de ::::::::::::::::::::::::::::::::::::::::

File access paths ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

Access to libraries ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Event lo op ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::

Functions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Technical notes ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

Precautions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::

Virtual le system ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Pathnames ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Relative access paths ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Pathname manipulation functions :::::::::::::::::::::::::::::::::::::::::

Portability ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Features ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

Function Index

read function with no arguments ::::::::::::::::::::::::::::::::::::::::::::::::::

stratom n strg i function with three arguments ::::::::::::::::::::::::::::::::::

readstring function with no arguments :::::::::::::::::::::::::::::::::::::::::::

readline function with no arguments :::::::::::::::::::::::::::::::::::::::::::::

readcn function with no arguments ::::::::::::::::::::::::::::::::::::::::::::::::

readch function with no arguments ::::::::::::::::::::::::::::::::::::::::::::::::

peekcn function with no arguments ::::::::::::::::::::::::::::::::::::::::::::::::

peekch function with no arguments ::::::::::::::::::::::::::::::::::::::::::::::::

reread lcn function with one argument :::::::::::::::::::::::::::::::::::::::::::

readdelimitedlist cn function with one argument :::::::::::::::::::::::::::::

teread function with no arguments ::::::::::::::::::::::::::::::::::::::::::::::::

systeminreadflag variable :::::::::::::::::::::::::::::::::::::::::::::::::

curread function with no arguments :::::::::::::::::::::::::::::::::::::::::::::::

systemrealterminalflag variable ::::::::::::::::::::::::::::::::::::::::::

systemlinemodeflag variable ::::::::::::::::::::::::::::::::::::::::::::::

prompt strg function with an optional argument :::::::::::::::::::::::::::::::::::

systemreadcaseflag variable ::::::::::::::::::::::::::::::::::::::::::::::

ibase n function with an optional argument ::::::::::::::::::::::::::::::::::::::::

cnull character type ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

cbcom character type ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

cecom character type ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

cquote character type ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

clpar character type ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

crpar character type ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

cdot character type ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

csep character type ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

FUNCTION INDEX

cpkgc character type ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

csplice character type ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::

cmacro character type ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

cstring character type ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::

cpname character type ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

csymb character type ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

cmsymb character type ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

typecn cn symb function with one or two arguments ::::::::::::::::::::::::::::::::

typech ch symb function with one or two arguments ::::::::::::::::::::::::::::::::

dmc ch s ::: s special form :::::::::::::::::::::::::::::::::::::::::::::::

n

dms ch s ::: s special form :::::::::::::::::::::::::::::::::::::::::::::::

n

macro character ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

macro character ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

macro character ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

macro character ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

macro character ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

macro character ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

macro character ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

macro character ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

syspackagesharp variable :::::::::::::::::::::::::::::::::::::::::::::::::::

defsharp ch larg s ::: sN special form :::::::::::::::::::::::::::::::::::::::

macro ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

n macro ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

sharpvalue property ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

macro ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::

macro ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

macro ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

baser macro ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

inside macro ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

macro ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

macro ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

macro ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

macro ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

macro ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

FUNCTION INDEX

macro ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

macro ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

macro ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

macro ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

syspackagecolon variable :::::::::::::::::::::::::::::::::::::::::::::::::::

L macro character ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

A macro character ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

E macro character ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

F macro character ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

systemeditor variable ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

P macro character ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

macro character ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

prin s ::: s function with a variable number of arguments ::::::::::::::::::::::::

n

print s ::: s function with a variable number of arguments :::::::::::::::::::::::

n

prinflush s ::: s function with a variable number of arguments ::::::::::::::::::

n

terpri n function with an optional argument :::::::::::::::::::::::::::::::::::::::

princn cn n function with one or two arguments :::::::::::::::::::::::::::::::::::

princh ch n function with one or two arguments :::::::::::::::::::::::::::::::::::

printlength n function with an optional argument :::::::::::::::::::::::::::::::::

printlevel n function with an optional argument ::::::::::::::::::::::::::::::::::

printline n function with an optional argument :::::::::::::::::::::::::::::::::::

unnameable number ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

<> nonLisp pointer ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

systemprintforread variable ::::::::::::::::::::::::::::::::::::::::::::::

systemprintcaseflag variable :::::::::::::::::::::::::::::::::::::::::::::

systemprintpackageflag variable ::::::::::::::::::::::::::::::::::::::::::

obase n function with an optional argument ::::::::::::::::::::::::::::::::::::::::

ptype symb n function with one or two arguments ::::::::::::::::::::::::::::::::::

pratom atom function with one argument ::::::::::::::::::::::::::::::::::::::::::

explode s function with one argument ::::::::::::::::::::::::::::::::::::::::::::

explodech s function with one argument ::::::::::::::::::::::::::::::::::::::::::

implode ln function with one argument :::::::::::::::::::::::::::::::::::::::::::

implodech s function with one argument ::::::::::::::::::::::::::::::::::::::::::

withinputfromstring string body macro :::::::::::::::::::::::::::::::

FUNCTION INDEX

withoutputtostring string n body macro ::::::::::::::::::::::::::::::

readfromstring string function with one argument ::::::::::::::::::::::::::::

printtostring s function with one argument ::::::::::::::::::::::::::::::::::

inbuf n cn function with one or two optional arguments :::::::::::::::::::::::::::::

inmax n function with an optional argument ::::::::::::::::::::::::::::::::::::::::

inpos n function with an optional argument ::::::::::::::::::::::::::::::::::::::::

bol programmable interrupt ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

bol function with no arguments :::::::::::::::::::::::::::::::::::::::::::::::::::

lmargin n function with an optional argument ::::::::::::::::::::::::::::::::::::::

rmargin n function with an optional argument ::::::::::::::::::::::::::::::::::::::

outpos n function with an optional argument :::::::::::::::::::::::::::::::::::::::

outbuf n cn function with one or two optional arguments :::::::::::::::::::::::::::

eol programmable interrupt ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

eol function with no arguments :::::::::::::::::::::::::::::::::::::::::::::::::::

flush programmable interrupt ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

flush function with no arguments :::::::::::::::::::::::::::::::::::::::::::::::::

systemprintmsgs variable :::::::::::::::::::::::::::::::::::::::::::::::::::

systemllibdirectory variable ::::::::::::::::::::::::::::::::::::::::::::::

systemllubdirectory variable ::::::::::::::::::::::::::::::::::::::::::::::

systemlelispextension variable ::::::::::::::::::::::::::::::::::::::::::::

openi file function with one argument :::::::::::::::::::::::::::::::::::::::::::

openib file function with one argument ::::::::::::::::::::::::::::::::::::::::::

openo file function with one argument :::::::::::::::::::::::::::::::::::::::::::

openob file function with one argument ::::::::::::::::::::::::::::::::::::::::::

opena file function with one argument :::::::::::::::::::::::::::::::::::::::::::

openab file function with one argument ::::::::::::::::::::::::::::::::::::::::::

inchan chan function with an optional argument :::::::::::::::::::::::::::::::::::

outchan chan function with an optional argument ::::::::::::::::::::::::::::::::::

channel chan function with an optional argument ::::::::::::::::::::::::::::::::::

close chan function with an optional argument :::::::::::::::::::::::::::::::::::::

input file function with one argument :::::::::::::::::::::::::::::::::::::::::::

output file function with one argument ::::::::::::::::::::::::::::::::::::::::::

eof programmable interrupt ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

eof chan function with one argument ::::::::::::::::::::::::::::::::::::::::::::::

FUNCTION INDEX

probefile file function with one argument ::::::::::::::::::::::::::::::::::::::

renamefile ofile nfile function with two arguments :::::::::::::::::::::::::::::

copyfile ofile nfile function with two arguments :::::::::::::::::::::::::::::::

deletefile file function with one argument :::::::::::::::::::::::::::::::::::::

createdirectory dir function with one argument :::::::::::::::::::::::::::::::

deletedirectory dir function with one argument :::::::::::::::::::::::::::::::

loadfile file i function with two arguments :::::::::::::::::::::::::::::::::::::

load file i special form ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

autoload file sym ::: sym special form ::::::::::::::::::::::::::::::::::::::

n

systempath variable ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

searchinpath path file function with two arguments ::::::::::::::::::::::::::

probepathf file function with one argument :::::::::::::::::::::::::::::::::::::

libloadfile file i function with two arguments :::::::::::::::::::::::::::::::::

libload file i special form ::::::::::::::::::::::::::::::::::::::::::::::::::: :

libautoload file sym ::: sym special form ::::::::::::::::::::::::::::::::::

n

eventloop feature ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

evloopinit function with no arguments ::::::::::::::::::::::::::::::::::::::::::

evloopstop function with no arguments ::::::::::::::::::::::::::::::::::::::::::

evlooprestart function with no arguments ::::::::::::::::::::::::::::::::::::::

evloopdisallowttyinput function with no arguments :::::::::::::::::::::::::

evloopallowttyinput function with no arguments ::::::::::::::::::::::::::::

evloopaddinput fd managefct argtouse function with three arguments ::::::

evloopremoveinput fd function with one argument :::::::::::::::::::::::::::::

evloopchangemanagefunction fd newmanagefct newargtouse function

with three arguments ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::

evloopselect function with no arguments :::::::::::::::::::::::::::::::::::::::

evloopreadp fd function with one argument :::::::::::::::::::::::::::::::::::::

evloopinputmanagedp fd function with one argument ::::::::::::::::::::::::::

evloopinitializedp function with no arguments :::::::::::::::::::::::::::::::

evloopwait function with no arguments ::::::::::::::::::::::::::::::::::::::::::

evloopsettimeout secs millisecs function with two arguments ::::::::::::::::

evloopsettimeouthandler handler function with one argument ::::::::::::::

evloopaddoutput fd managefct argtouse function with three arguments ::::

evloopremoveoutput fd function with one argument :::::::::::::::::::::::::::

FUNCTION INDEX

evloopchangeoutputmanagefunction fd newmanagefct newargtouse

function with three arguments ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

evloopadddisplay display managefct function with two arguments :::::::::::

evloopremovedisplay display function with one argument ::::::::::::::::::::

evloopdisplaymanagedp display function with one argument :::::::::::::::::

pathname feature ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

pathname structure ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

pathname string function with one argument :::::::::::::::::::::::::::::::::::::

pathnamep s function with one argument ::::::::::::::::::::::::::::::::::::::::::

equalpathname path path function with two arguments ::::::::::::::::::::::::

namestring path function with one argument :::::::::::::::::::::::::::::::::::::

p macro ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

u macro ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

pathnameprin path function with one argument :::::::::::::::::::::::::::::::

pathnameup indicator ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

pathnamecurrent indicator ::::::::::::::::::::::::::::::::::::::::::::::::::: :

pathnamewild indicator ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

wildcard path function with one argument ::::::::::::::::::::::::::::::::::::::::

expandpathname path function with one argument :::::::::::::::::::::::::::::::

pathnamehost path function with one argument ::::::::::::::::::::::::::::::::::

pathnamedevice path function with one argument :::::::::::::::::::::::::::::::

pathnamedirectory path function with one argument :::::::::::::::::::::::::::

pathnamename path function with one argument ::::::::::::::::::::::::::::::::::

pathnametype path function with one argument ::::::::::::::::::::::::::::::::::

pathnameversion path function with one argument ::::::::::::::::::::::::::::::

setpathnamehost path host function with two arguments ::::::::::::::::::::::

setpathnamedevice path device function with two arguments ::::::::::::::::::

setpathnamedirectory path dir function with two arguments :::::::::::::::::

setpathnamename path name function with two arguments ::::::::::::::::::::::

setpathnametype path type function with two arguments ::::::::::::::::::::::

setpathnameversion path version function with two arguments :::::::::::::::

defaultpathnamedefaults variable ::::::::::::::::::::::::::::::::::::::::::

makepathname element ::: element function with a variable number of arguments

n

filenamestring path function with one argument :::::::::::::::::::::::::::::::

FUNCTION INDEX

hostnamestring path function with one argument :::::::::::::::::::::::::::::::

devicenamestring path function with one argument :::::::::::::::::::::::::::::

directorynamestring path function with one argument :::::::::::::::::::::::::

mergepathnames path defaultpath function with two arguments ::::::::::::::::

combinepathnames path path function with two arguments ::::::::::::::::::::

enoughnamestring path default function with one or two arguments :::::::::::::

truepathname path function with one argument ::::::::::::::::::::::::::::::::::

userhomedirpathname function with no arguments ::::::::::::::::::::::::::::::

controlfilepathname name path function with one or two arguments :::::::::::

temporaryfilepathname name function with one argument :::::::::::::::::::::

currentdirectory path function with an optional argument ::::::::::::::::::::::

directoryp path function with one argument :::::::::::::::::::::::::::::::::::::

portablepathname variable :::::::::::::::::::::::::::::::::::::::::::::::::::

portablepathnamep path function with one argument ::::::::::::::::::::::::::

listfeatures function with no arguments :::::::::::::::::::::::::::::::::::::::

addfeature symb function with one argument ::::::::::::::::::::::::::::::::::::

remfeature symb function with one argument ::::::::::::::::::::::::::::::::::::

featurep symb function with one argument ::::::::::::::::::::::::::::::::::::::::

Chapter

System functions

The functions describ ed in this chapter provide the means to create subsystems written in LELISP

By means of programmable interrupts it is p ossible to dene new interaction lo ops and new ways

to handle errors

Programmable interrupts

LELISP handles its internal interrupts by calling a sp ecialized function for each of these interrupts

The names of these functions are not xed but are dynamically sought when an interrupt o ccurs

This search follows the search path stored in the syspackageitsoft variable Thus the internal

interrupts are programmable

syspac kag e its of t variable

This variable contains the list of packages in which functions asso ciated with internal programmable

interrupts must b elong By default its value is so initially only the global package named

is searched for these interrupt functions All the internal programmable interrupts have a function

dened in the global package which is therefore the interrupt function called by default

The value of this variable can b e a list of symb ols or a single symb ol In the former case the

function asso ciated with the programmable interrupt named foo is the rst function named foo

found in one of the packages named in the list In the latter case it is the function named foo

found in the package having the same name as the symb ol or in one of its parent packages

The function search is p erformed in horizontal order in the rst case and in vertical order by

climbing the package hierarchy in the second case It is mo delled by the following function

defun getithandler itpath itname

cond symbolp itpath

getfn itpath itname

consp itpath

or getfn car itpath itname

getithandler cdr itpath itname

LELISP has twelve programmable internal interrupts

CHAPTER SYSTEM FUNCTIONS

bol beginningofline

eol endofline

flush endofbuffer

eof endoffile

toplevel interaction loop

gcbeforealarm beginning of gc

gcalarm end of gc

syserror internal error

stepeval entrance into eval

userinterrupt user interrupt

clock clock machine interrupt

but it is entirely p ossible to dene your own programmable interrupts

itsoft symb larg function with two arguments

Explicitly calls the programmable interrupt named symb with larg as its argument list The

denition of this function has the following approximate form

defun itsoft nom larg

apply getithandler syspackageitsoft nom larg

but it creates a sp ecial scop e blo ck and resets the evaluators trace ag to

superit sof t package symb larg function with three arguments

Explicitly invokes the programmable interrupt named symb with larg as its argument list

It assumes that there is a function packagesymb to b e invoked by the itsoft function

The function invoked by superitsoft is the function which would b e invoked by itsoft if

packagesymb did not exist

superitsoft is particularly useful for putting pre or p ostpro cessors on programmable

interrupts For example to keep a count in a variable of the numb er of lines printed onto the

screen

defvar countnlines

defun counteol

incr countnlines

superitsoft count eol

setq syspackageitsoft cons count syspackageitsoft

The following example implements a utility similar to more on UNIX

defvar syspackagecolon minimore

defvar count tyymax

defvar string more

MACHINE INTERRUPTS

defun more

setq syspackageitsoft

cons minimore syspackageitsoft

defun morend

setq syspackageitsoft

delq minimore syspackageitsoft

defun bol

setq count tyymax

superitsoft syspackagecolon bol

defun eol

when count

tystring string slength string

selectq tyi

m j setq count

d setq count div tyymax

sp setq count tyymax

q setq count tyymax

for i sub slength string

tyback chrnth i string

fillstring outbuf sp outpos

outpos

exit systemtopleveltag

t setq count

for i sub slength string

tyback chrnth i string

decr count

superitsoft syspackagecolon eol

Machine interrupts

LELISP handles three machine interrupts the user interrupt the clo ck interrupt and the event

interrupt

The management of these interrupts can b e activated authorized or inhibited masked During

the execution of the function asso ciated with these programmable machine interrupts they are

masked It is up to the user to authorize reset them if that b ecomes necessary

without int er rup ts e ::: e special form

n

This function masks machine interrupts while it evaluates the expressions e ::: e in the same

n

way as progn The value of e is returned

n

User interrupt

It is p ossible at any moment to cause a user interrupt by sending a sp ecial character from the

keyb oard The sp ecic character dep ends on the system but it is always available

CHAPTER SYSTEM FUNCTIONS

userinte rru pt programmable interrupt

This is the name of the programmable machine interrupt triggered by the users keyb oard action

userint err up t function with no arguments

This is the default function executed by the userinterrupt programmable interrupt

In LELISP userinterrupt could b e dened in the following manner

defun userinterrupt

withinterrupts

itsoft syserror break break

Realtime clo ck

clockala rm n function with one argument

n is a oatingp oint numb er indicating the numb er of seconds the system should wait b efore emitting

a single clock programmable machine interrupt If n equals the realtime clo ck is deactivated

and all previous interrupt requests are lost Note that very small values < seconds should

not b e used for the time it takes to pro cess the clock programmable interrupt itself is considerable

esp ecially if a context switch is thereby generated see the suspend function

clock programmable interrupt

This is the name of the programmable machine interrupt triggerred by the realtime clo ck

clock function with no arguments

This is also the name of the default function executed by the clock programmable interrupt

In LELISP clock could b e dened in the following manner

defun clock

MULTIPLE TASKS

Multiple tasks

LELISP has an integrated multitask system It has only three basic functions

schedule fnt e ::: e special form

n

suspend function with no arguments

resume env function with one argument

The schedule function lets you dene a scheduling function The suspend function provides a way

of stopping a task from running and resume lets you start it running again

In schedule fnt is a oneargument function This function evaluates a la progn the expressions

e ::: e In general the value returned by schedule is e but if in the course of the evaluations an

n n

explicit or implicit by way of the programmable interrupts call to the suspend function o ccurs

the current calculation is stopp ed the dynamic execution environment is saved and the function

fnt asso ciated with the most recently encountered schedule function is called with the saved

environment as its argument Finally resume is a function which takes an environment built by

the suspend function as its argument which resumes an interrupted calculation where it left o

Basic sequencers

Using the three functions just describ ed it is p ossible to dene the following basic sequencers Time

sharing is done using the realtime clo ck These function are found in the le named schedule in

the standard library

parallel e ::: e special form

n

Launches the evaluations of the expressions e ::: e in parallel It always returns

n

parallel val ue s e ::: e special form

n

Launches the evaluations of the expressions e ::: e in parallel and returns the list of the results

n

tryinpar all el e ::: e special form

n

Launches the evaluations of the expressions e ::: e in parallel When one of these evaluations

n

terminates tryinparallel returns its value and stops the rest of the evaluations

Example using the realtime clo ck to do timesharing among tasks

defvar systemclocktick

defun clock

its the clock that causes the suspension of the tasks

CHAPTER SYSTEM FUNCTIONS

when debug princn

suspend

defun clockstart

start the clock

clockalarm systemclocktick

defun clockstop

stop the clock

clockalarm

df parallel ll

withoutinterrupts

let l append ll

while l

schedule lambda v

newr l list resume kwote v

let e nextl l

clockstart

withinterrupts eval e

clockstop

df parallelvalues ll

withoutinterrupts

let ltask

l ll

r makelist length ll

i

while or l ltask

schedule lambda v newr ltask v

clockstart

ifn l

resume nextl ltask

let e nextl l

incr i

rplaca nthcdr i r

withinterrupts eval e

clockstop

r

df tryinparallel ll

withoutinterrupts

let ltask

l ll

tag returnvalue

while or l ltask

schedule lambda v newr ltask v

clockstart

let e nextl l

if e

exit returnvalue

prog

withinterrupts

eval e

clockstop

resume nextl ltask

ERRORS PROVOKED BY THE LELISP SYSTEM

Here are examples of things that use the parallel sequencers

defun fib n

cond n

n

t apply parallelvalues fib n

fib n

fib

defun neg n

if n

negative

neg n

neg

defun pos n

if n

positive

pos n

pos

defun sign n

a very fast way to check the sign of a number

if n

zero

tryinparallel neg n pos n

sign

Errors provoked by the LeLisp system

syserror programmable interrupt

When an error is raised during an evaluation the programmable interrupt named syserror is

triggered It invokes a function whose name is computed according to the explanation given in

x that takes three arguments

the name of the function that raised the error

the error name

the faulty argument

The standard b ehavior is that a message describing the error condition is printed on the

current output stream

This message always contains the name of the function which raised the error an explanatory

message and the faulty argument

LELISP also provides a way to explicitly raise an error with the error function and to test

whether an evaluation would raise an error with the catcherror and errset functions

CHAPTER SYSTEM FUNCTIONS

Standard error pro cessing

syserror symb s s function with three arguments

This is the default function invoked by the syserror programmable interrupt symb is the name of

the function that raised the error s is the error name s is the faulty argument or argument list

syserror will print a complete error message onto the current output stream using the printerror

function then unbinds all variables and returns to the Lisp toplevel In debug mo de it is also

p ossible to enter an insp ection lo op b efore returning to the toplevel in order to examine the state

of various lo cal variables or to run certain evaluations see Chapter

printerr or symb s s function with three arguments

Prints a complete error message of the following form

symb s s

symb is the name of the function that raised the error s is the error name and s is generally

the faulty argument There are ab out thirty predened error typ es available in the system

Explicit call and error test

error s s s function with three arguments

Lets you call an error explicitly s is the name of the function that causes the error s is the error

typ e and s is the faulty argument

In LELISP error could b e dened in the following manner

dmd error l

itsoft syserror l

catcherr or i s ::: s special form

n

i is a ag that is evaluated and then set in the system variable systemerrorflag The

expressions s ::: s are evaluated sequentially If an error is raised during one of these evaluations

n

catcherror immediately returns and dep ending up on the state of the systemerrorflag

variable prints an error message using the printerror function If the evaluation of the expressions

raises no error catcherror returns a oneelement list which contains the value of the last expression

evaluated that is of s to distinguish this value from which is returned up on error

n

catcherror never catchs the errudt undened escap e error It has to b e caught by using the

sp ecial form lock

errset e i macro

ERRORS PROVOKED BY THE LELISP SYSTEM

This is a predecessor of the previous function and is included in LELISP for historical and

compatibility reasons only

In LELISP errset could b e dened in the following manner

dmd errset e i catcherror i e

err s ::: s special form

n

Evaluates the expressions s ::: s The value of s is the value returned by the dynamically

n n

englobing catcherror or by toplevel if no catcherror was dynamically dened

Warning This value must b e an atom if you want to place the catcherror in an error

context that is when err returns a simulated error The value must b e a list if err returns

a value without error In the latter case the resultwhich is also that of catcherrorwill

b e interpreted as a list whose rst element is the exp ected result

Examples of exception handling

Let us lo ok at some examples of error exception handling

Normal b ehavior of the errduv error undened variable

gensym

g eval gensym

eval undefined variable g

Redenition of the errduv errorthe undened variable is set to

defun pierresyserror f m a

if eq m errudv

set a

syserror f m a

pierresyserror

setq syspackageitsoft pierre

pierre

setq x gensym

g eval x

x

g eval g

Redenition of the same errorthe undened variables will b e changed into constants

defun christiansyserror f m a

if eq m errudv

set a a

syserror f m a

christiansyserror

CHAPTER SYSTEM FUNCTIONS

setq syspackageitsoft christian

christian

setq x gensym

g eval x

g eval g

g

Return to the normal error handling

setq syspackageitsoft

eval gensym

eval undefined variable g

Redenition of the errudf error

defun danger f l

f l

danger danger car a b c

eval undefined function f

defun oddsyserror systemf systemm systema

if and eq systemf eval

eq systemm errudf

eval systema

syserror systemf systemm systema

oddsyserror defvar syspackageitsoft odd

odd danger car a b c

a if there is no function f in the system

Access to the evaluator

LELISP has three internal evaluator control functions The are used to implement the interpreter and

some debugging to ols trace incremental execution and dynamic control which will b e describ ed

in Chapter

The evaluator has an internal ag which for reasons of eciency is not a LISP variable When this

ag which is set every call to the evaluator that is to the eval function causes the stepeval

programmable interrupt

stepeval programmable interrupt

This programmable interrupt will call a function with the value to b e evaluated as its argument

COREIMAGE FILES

stepeval e env function with two arguments

This is the default function called by the stepeval programmable interrupt e is the form to b e

evaluated and env is the lexical environment in which evaluation is to b e done

By default stepeval prints onto the current output stream

the form that was to have been evaluated

the result of the evaluation of this form

In LELISP stepeval could b e dened in the following manner

defun stepeval e env

print e

print traceval e env

traceval e env function with one or two arguments

Evaluates the expression e in trace mo de that is with the internal trace ag set If env is supplied

it is used as the lexical environment for the evaluation env is pro duced by the stepval function

traceval returns the value of e evaluated in trace mo de

cstack function with no arguments

Each time it enters a function an escap e a lo ck the evaluator builds an activation blo ck on the

dynamic execution stack cstack returns the activation blo cks on the Lisp stack represented as

a list of lists the elements of which have the co ded typ e of the blo ck in their car and the blo ck

arguments in their cdr Here is the list of blo ck typ es currently built by the system

lambda

flet

tag

itsoft

lock

protect

sysprot

schedule

tagbody

block

Coreimage les

It is p ossible to save the entire system in a coreimage le at any time and restore it at a later

time This feature is particularly useful for saving compiled subsystems and calling them up very

rapidly

CHAPTER SYSTEM FUNCTIONS

Warning When a coreimage le is restored execution starts up exactly where it was interrupted

although the io channels and other host op erating system parameters like timers cannot b e

restored

system cor e dir ec tor y variable

This variable contains the name of the directory that holds the standard system coreimage les

system cor e ext en sio n variable

This variable contains the default extension of coreimage lenames

savecor e file function with one argument

Saves the current memory image in the coreimage le named file and returns the value t This

function is a basic primitive and it is suggested that savestd b e used to create standard core

image les You can save a screen by combining savecore and bitmapsave

restore cor e file function with one argument

Restores an coreimage into memory from the coreimage le named file

restorecore returns the value in order to b e able to distinguish it from returns from

savecore but continues evaluation at the same place at which it was stopp ed by the

corresp onding savecore

See bitmaprestore in chapter

Here are some examples of how to use the preceding functions

savecore image

t restorecore image

progn print

savecore qwer

print

restorecore qwer

Here is a go o d way to save a coreimage so that you get a subsystem

progn

savecore bar

coreinitstd You are in the system bar

LeLisp by INRIA version Jan sun

You are in the system bar Tue Jan

INSTALLATION FUNCTIONS

bitfloats abbrev callext compiler date debug defstruct display edlin

loader messages microceyx pathname pepe pretty setf virbitmap virtty

To restart it typ e this expression

restorecore bar

LeLisp by INRIA version Jan sun

You are in the system bar Tue Jan

bitfloats abbrev callext compiler date debug defstruct display edlin

loader messages microceyx pathname pepe pretty setf virbitmap virtty

Here is another example resulting in the temp orary susp ension of the interpreter

defun foo n

if n

prog n foo n

print n

savecore foo

print atbottom

foo

foo

atbottom

Here is something to avoid in order not to send the system lo oping forever

progn

print I start

savecore qaz

print I continue

restorecore qaz

print I finish

I start

I continue

I continue

I continue

Installation functions

The functions describ ed in this section facilitate the loading and compiling of the standard or the

mo dular LELISP system environments They are used only in the construction of coreimages les

that is when the system is b eing installed at a new site

CHAPTER SYSTEM FUNCTIONS

These functions are dened in the startup le in the standard library which is loaded automatically

at system startup if no coreimage le is b eing restored

loadstd im min ed env ld cmp function with one to six arguments

loadstd loads all or part of the interpreters standard environment and optionally builds a core

image le This function accepts from one to six arguments which are ags Arguments that are

not supplied are set to

If the im ag is not it is passed to the function savestd after the environment is loaded so

that a coreimage le named im is created

The min ag indicates that the minimum required system environment is to b e loaded including

only toplevel virtual terminal and virtual bitmap functions

The ed ag indicates that the fullpage pepe editor is to b e loaded

The env ag indicates that the LELISP development environment includin g structures sorting

tables external pro cedures stepping formatted printing generic arithmetic and debugging

insp ection lo op is to b e loaded

The ld ag indicates that the loader which provides a way to dynamically load compiled lisp

mo dules and lap programs is to b e loaded

The cmp ag indicates that the standard LELISP compiler is to b e loaded Loading the compiler

causes the compiledcode loader to b e loaded if it is not already present in the LISP environment

Here is how to load the whole environment without creating a coreimage le

loadstd t t t t t

llcpstd name function with one argument

Compiles the interpreter environment that was stored by the loadstd function If the

argument name is not equal to it is passed to the savestd function after compilation so

that a coreimage le of the compiled system will b e built

It is absolutely necessary to use this function in order to compile the Lisp environment since

this compilation p oses some dicult problems most notably the compilation of the loader

which the compileallincore function cannot resolve

Here is how to load the environment compile it and save it in a compiled coreimage

loadstd t t t t t

llcpstd compile

loadstm im min ed env ld cmp function with one to six arguments

This function is similar to the loadstd function except that it uses mo dules that were

precompiled by Complice It loads all or part of the environment and optionally builds a

coreimage le This function also accepts from one to six ag arguments arguments not

INSTALLATION FUNCTIONS

explicitly provided are set to

loadcpl im min ed env ld cmp function with one to six arguments

This function is similar to the loadstd function except that it loads compiled mo dules

instead of interpreted ones Moreover the cmp ag indicates in this case that the Complice

compiler and not the standard compiler should b e loaded

Since the environment loaded by this function has already b een compiled the llcpstd

function need not b e used after a call to loadcpl

Here is how to load the compiled development environment and save it in the coreimage le

called mylisp

loadcpl mylisp t t

coreini ts td msg function with one argument

Performs the standard initializations after a coreimage le has b een restored The virtual

terminal and the virtual bitmap are loaded qualied by the two variables describ ed b elow

the banner is printed by the herald function and a startup le whose name is system

dep endent is optionally loaded The system then prints the welcome message msg as well

as the date the coreimage le was built coreinitstd returns featureslist the list of

features loaded into memory

In LELISP coreinitstd could b e dened in the following manner

defun coreinitstd msg

when systeminittyafterrestoreflag

initty

when systeminibitmapafterrestoreflag

inibitmap

herald

when systemunixp

let f catenate getenv home lelisp

when probefile f

loadfile f t

print msg date

sortl listfeatures

system ini tt ya ft er res to re fla g variable

If this ag is true the coreinitstd function will initialize the terminal after each restorecore

using the initty function Its default value is t

system ini bi tma p aft er re sto re fl ag variable

CHAPTER SYSTEM FUNCTIONS

If this ag is true the coreinitstd function will initialize the virtual bitmap after each

restorecore using the initbitmap function Its default value is t

savestd name msg fntsav fntrest function of two three or four arguments

name is a character string or a LISP symb ol This function constructs a coreimage le called name

with the sux systemcoreextension This coreimage le is created in the directory named

systemcoredirectory

Just after the creation of the coreimage le by savestd a function is launched automatically

This function is either fntsav if supplied or coreinitstd

When the coreimage le is restored using the restorecore function the fntrest function is

automatically run If this function is not supplied savestd uses the same function as for saving

fntsave if supplied or else the coreinitstd function Finally the main interaction lo op the

programmable interrupt called toplevel is launched

One of two functions is run immediately after a coreimage le has b een created by the savestd

function If the fnstd function is provided then it will b e run otherwise the same function that

is in coreimage le restoration fntrest is run

The savestd function is used by the loadstd loadcpl and llcpstd functions when their im

parameter is not equal to

Various errors can b e pro duced during the restoration of a coreimage le created by the savestd

function They often o ccur during initializati on of the virtual terminal or the virtual bitmap See

the do cumentation concerning the initty and inibitmap functions

Here is typical use of the savestd function

savestd application Welcome to the Application

end coreinitstd

Wait I am saving Welcome to the Application

This results in a coreimage le named application b eing saved which will execute the

coreinitstd function when it is restored After the creation of the coreimage le the

application will exit from the LELISPsystem

Calling and leaving the system

herald function with no arguments

Prints the system banner on the entry terminal Before rep orting any errors found in your system

please run this function to identify it exactly

system function with no arguments

Returns the name of the LELISP system that runs it This name dep ends on the system you are using

CALLING AND LEAVING THE SYSTEM

system uni xp variable

This variable has the value t if the host op erating system is UNIX and otherwise

version function with no arguments

Returns the version numb er of the LELISP system in the form of a numb er To day this numb er

would b e

version

floatp version

version

subversi on function with no arguments

Returns the subversion numb er of the LELISP system in the form of a numb er To day this numb er

would b e subversion within version

subversion

numberp subversion

atend programmable interrupt

At the call of the end function the programmable interrupt atend is activated It is going to invoke

a function whose name is explained in Section that uses as an argument that argument that

was passed to the end function

atend returncode function with an optional argument

This is the default function that is automatically started by the programmable interrupt atend

By default this function do esnt do anything

Note The use of this function will virtually always require you to quit the application at the time

of the call to the end function

end returncode function with an optional argument

Starts the programmable interrupt atend stops the evaluation currently underway closes all op en

les leaves the LELISP system for go o d and returns control to the host op erating system end is

the only predened function that do es not return a value

If no argument is supplied LELISP automatically prints the exit banner If an argument is furnished

the banner is not printed This argument can b e used by the host op erating system to determine

whether or not the system exited normally or not If the value is other than an error has

o ccurred

A normal return to the host system with banner

end

Que LeLisp soit avec vous

CHAPTER SYSTEM FUNCTIONS

A normal return to the host system without banner

end

An abnormal return to the host system

end

Top level

The principal lo op or toplevel of the LELISP system consists of the innite evaluation of the

form

while t itsoft toplevel

It is thus the programmable interrupt toplevel which determines the op erating mo de of the LE

LISP system This interrupt is quite obviously redenable by any user who wants to build their own

system

toplevel programmable interrupt

This is the name of the programmable interrupt run by the LELISP top level

toplevel function with no arguments

This function will in the standard environment

read an Sexpression from the current input stream

evaluate this Sexpression

print the result of this evaluation onto the current output stream

topleve ls ta tus variable

This variable holds the top level ag If this ag is false the toplevel function do es not print the

results of evaluations and in any other case it prints the values returned by each evaluation

topleve lr ea d variable

This variable contains the last form read by the top level

topleve le va l variable

This variable contains the last value computed by the top level

GARBAGE COLLECTOR

system to pl eve l tag escape

This is the name of the escap e that is used to return directly to the top level

At system initialization the toplevel function is equivalent to

defvar toplevelstatus

defvar toplevelread

defvar toplevelcread

defvar topleveleval

defun toplevel

tag systemtopleveltag

setq toplevelread toplevelcread

toplevelcread read

topleveleval eval toplevelcread

when toplevelstatus

print topleveleval

Warning A redenition of this function that fails to evaluate the forms read renders the

entire LELISP system totally unusable

Example of the kind of denition to avoid

defun toplevel read print swamp

Garbage collector

Memory zones that contain LISP ob jects are allo cated dynamically When one of the zones is

saturated the garbage col lector is automatically called to recover unused ob jects

If this eort at recovery comes to naught a fatal error is raised The names of this kind of fatal

error all b egin with errf and have the form errfxxx

errfcns the list zone is full The screen display is

fatal error no room for lists

errfvec the vector zone is full The screen display is

fatal error no room for vectors

errfstr the character string zone is full The screen display is

fatal error no room for strings

errfsym the symb ol zone is full The screen display is

CHAPTER SYSTEM FUNCTIONS

fatal error no room for symbols

errfflt the oatingp oint zone is full The screen display is

fatal error no room for floats

errffix the integer xedp oint zone is full The screen display is

fatal error no room for fixs

LELISP also manages two other memory spaces which do not contain LISP ob jects

The code space which contains co de generated by the compiler This space is managed by

the loaders If space runs out in it the errfcod fatal error o ccurs with the screen display

fatal error no room for code

The heap space which contains values of character strings values of Sexpression vectors

etc The heap space is dynamically managed and is compacted when space runs out If one

of these garbage collections fails to render space available the errfhep fatal error is raised

with the screen display

fatal error no room for heap

LELISP uses a single dynamic execution stack for b oth control and data Co de resulting in stack

overow or underow raises the errfstk fatal error which has the screen display

fatal error stack overflow

This error is not fatal A stack tolerance scheme lets the execution stack b e insp ected and

manipulated with the standard debugging to ols even after a full stack error has b een raised

gc i function with an optional argument

gc calls the garbagecol lector explicitly If no argument is provided gc returns t If an argument

is given gc returns a list just like that which the gcinfo function returns see the explanation

immediately following this one

gcinfo i function with an optional argument

If called with no argument gcinfo returns a list containing information on the last memory recovery

done If an argument is supplied gcinfo returns a list describing the initial memory state of the

system at startup b efore any allo cation was done

The list in either case is in the following form

GARBAGE COLLECTOR

gc n n n n n n n n

cons ncons

symbol nsymb

string nstrg

vector nvect

float nfloat

fix nfix

heap nheap

code ncode

where

n is the total numb er of gcs done since the session b egan due to a shortage of list cells

n is the total numb er of gcs done since the session b egan due to a shortage of symb ols

n is the total numb er of gcs done since the session b egan due to a shortage of character

strings

n is the total numb er of gcs done since the session b egan due to a shortage of vectors

n is the total numb er of gcs done since the session b egan due to a shortage of oating

p oint store

n is the total numb er of gcs done since the session b egan due to a shortage of integer

store

n is the total numb er of gcs done due to a shortage of heap store

n is the total numb er of gcs done due to explicit calls to the gc function

The other values indicate the remaining size of each memory zone These values are expressed

in the number of objects if this is suciently small or else in a list of which the car is in k

objets and the cdr in number of objects remaining

In this case the numb er is in a list

ncons is the numb er of list cells remaining in the list zone

nsymb is the numb er of symb ols remaining in the symb ol zone

nstrg is the numb er of strings remaining in the string zone

nvect is the numb er of vectors remaining in the vector zone

nfloat is the numb er of oats remaining in the oatingp oint zone

nfix is the numb er of xedp oint numb ers remaining in the xedp oint numb er zone if

this latter exists

nheap is the size of the remaining heap store in the heap zone

ncode is the size of the remaining co de store in the co de zone

CHAPTER SYSTEM FUNCTIONS

gcalarm programmable interrupt

This is a programmable interrupt that is automatically run by the system after each garbage

collection It provides a way to dynamically control memory recovery

gcalarm function with no arguments

The gcalarm function is called by the gcalarm programmable interrupt The standard gcalarm

function supplied by default do es nothing

The following redenition of gcalarm provokes a soft error when to o many list cellsthat is more

than remained free in the list zoneare consumed by the user program

defun gcalarm

let nbcons cadr memq cons gcinfo

when and fixp nbcons nbcons

print stopping the run on the list cell bank

error gcalarm number of list cells remaining nbcons

gcbefore al ar m programmable interrupt

This is a programmable interrupt that is automatically run by the system b efore each memory

recovery

Warning During its op eration this programmable interrupt must not allo cate memory or

it will throw the gc into an innite lo op This interrupt only indicates to user programs that

a gc cycle has b egun It could b e used for instance to change the app earance or p osition of

the cursor to account for gc elapsed time etc

gcbefor ea la rm function with no arguments

This function is called by the gcbeforealarm programmable interrupt The standard

gcalarm function supplied by default do es nothing

The following redenition of the gcrelated programmable interrupts prints the time used by

each gc cycle on the console

defvar gcruntime

defun gcbeforealarm

setq gcruntime runtime

defun gcalarm

let rt runtime gcruntime

with outchan

print gc runtime gcruntime sec

freecons cons function with one argument

Enables you to put the cons onto the cons freelist This function yields p erformance gains in memory

management In certain wellundersto o d cases obsolete ob jects can b e incrementally freed by using

DATE PROCESSING

freecons as so on as they are no longer needed freecons is not interruptible and always returns

Warning This function can p ermanently and denitively confuse the memory management

if it is called on a cons to which active p ointers still exist

freecons cannot b e easily describ ed in LISP

defun numberofcons

return the number of conses on the cons freelist

let x cons n

freecons x

while x incr n nextl x

n

freetree tree function with one argument

Enables you to put the tree tree onto the cons freelist tree cannot b e a circular or shared list

Calling freetree on such an ob ject runs the risk of destroying the whole system Like the preceding

function freetree facilitates in certain wellundersto o d cases memory management gains via

incremental lib eration of obsolete ob jects freetree is not interruptible and always returns

Warning This function can p ermanently and denitively confuse the memory management

if it is called on a cons to which active p ointers still exist

In LELISP freetree could b e dened in the following manner

defun freetree s

when consp s

freecons s

freetree car s

freetree cdr s

Date pro cessing

Other access to the system

LELISP oers access to other system characteristics Considering the signicant dierences among

systems it would b e wise b efore using the following functions to rst test their eects in simple

cases

runtime function with no arguments

Returns the cpu time used since this LELISP session b egan This time is given in either integer or

oatingp oint seconds dep ending up on the system b eing used

time e function with one argument

CHAPTER SYSTEM FUNCTIONS

Returns the time used by the cpu to evaluate the expression e As in the last function the time is

given in either integer or oatingp oint seconds dep ending up on the system b eing used

In LELISP time could b e dened in the following manner

defun time e

let runt runtime

eval e

runtime runt

time fib

sleep n function with one argument

Requests the host system to put LELISP into an inactive state for n seconds This numb er n is

given in integer or oatingp oint units dep ending on the system b eing used

comline strg function with one argument

Sends the command line strg to the host op erating system This function is not available on every

implementation of LELISP

A macro character at the top levelthe exclamation point makes it simple to p erform a comline

comline pwd

nfshomerodineitex

t comline nil

sh nil not found

t ls ls a listing of the current directory is printed

t

getenv strg function with one argument

Sends the string strg which is presumed to b e the name of a system variable to the host

op erating system getenv returns a numb er or system atom which is either a nonnull value

asso ciated with strg or else if this variable name has no value in the host op erating system

context This function is not available on all LELISP systems

getenv TERM xterm

getenv DISPLAY unix

getenv MYPORT

Table of contents

System functions

Programmable interrupts ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Machine interrupts ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

User interrupt ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

Realtime clo ck ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

Multiple tasks ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

Basic sequencers ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

Errors provoked by the LeLisp system :::::::::::::::::::::::::::::::::::::::::::

Standard error pro cessing ::::::::::::::::::::::::::::::::::::::::::::::::

Explicit call and error test ::::::::::::::::::::::::::::::::::::::::::::::::

Examples of exception handling :::::::::::::::::::::::::::::::::::::::::::

Access to the evaluator ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

Coreimage les ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Installation functions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

Calling and leaving the system ::::::::::::::::::::::::::::::::::::::::::::::::::

Top level ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

Garbage collector ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Date pro cessing ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

Other access to the system ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Table of Contents

Function Index

syspackageitsoft variable ::::::::::::::::::::::::::::::::::::::::::::::::::

itsoft symb larg function with two arguments ::::::::::::::::::::::::::::::::::::

superitsoft package symb larg function with three arguments ::::::::::::::::::

withoutinterrupts e ::: e special form ::::::::::::::::::::::::::::::::::::

n

userinterrupt programmable interrupt ::::::::::::::::::::::::::::::::::::::::::::

userinterrupt function with no arguments ::::::::::::::::::::::::::::::::::::::

clockalarm n function with one argument :::::::::::::::::::::::::::::::::::::::::

clock programmable interrupt ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

clock function with no arguments :::::::::::::::::::::::::::::::::::::::::::::::::

schedule fnt e ::: e special form ::::::::::::::::::::::::::::::::::::::::::::

n

suspend function with no arguments :::::::::::::::::::::::::::::::::::::::::::::::

resume env function with one argument :::::::::::::::::::::::::::::::::::::::::::

parallel e ::: e special form ::::::::::::::::::::::::::::::::::::::::::::::::

n

parallelvalues e ::: e special form :::::::::::::::::::::::::::::::::::::::::

n

tryinparallel e ::: e special form ::::::::::::::::::::::::::::::::::::::::::

n

syserror programmable interrupt :::::::::::::::::::::::::::::::::::::::::::::::::::

syserror symb s s function with three arguments :::::::::::::::::::::::::::::::

printerror symb s s function with three arguments :::::::::::::::::::::::::::::

error s s s function with three arguments :::::::::::::::::::::::::::::::::::::

catcherror i s ::: s special form ::::::::::::::::::::::::::::::::::::::::::::

n

errset e i macro ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

err s ::: s special form ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

n

stepeval programmable interrupt :::::::::::::::::::::::::::::::::::::::::::::::::::

stepeval e env function with two arguments ::::::::::::::::::::::::::::::::::::::

traceval e env function with one or two arguments ::::::::::::::::::::::::::::::::

cstack function with no arguments ::::::::::::::::::::::::::::::::::::::::::::::::

FUNCTION INDEX

systemcoredirectory variable ::::::::::::::::::::::::::::::::::::::::::::::

systemcoreextension variable ::::::::::::::::::::::::::::::::::::::::::::::

savecore file function with one argument ::::::::::::::::::::::::::::::::::::::

restorecore file function with one argument :::::::::::::::::::::::::::::::::::

loadstd im min ed env ld cmp function with one to six arguments :::::::::::::::

llcpstd name function with one argument ::::::::::::::::::::::::::::::::::::::::

loadstm im min ed env ld cmp function with one to six arguments :::::::::::::::

loadcpl im min ed env ld cmp function with one to six arguments :::::::::::::::

coreinitstd msg function with one argument :::::::::::::::::::::::::::::::::::

systeminittyafterrestoreflag variable :::::::::::::::::::::::::::::::::

systeminibitmapafterrestoreflag variable ::::::::::::::::::::::::::::::

savestd name msg fntsav fntrest function of two three or four arguments :::::

herald function with no arguments ::::::::::::::::::::::::::::::::::::::::::::::::

system function with no arguments ::::::::::::::::::::::::::::::::::::::::::::::::

systemunixp variable ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

version function with no arguments :::::::::::::::::::::::::::::::::::::::::::::::

subversion function with no arguments :::::::::::::::::::::::::::::::::::::::::::

atend programmable interrupt ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

atend returncode function with an optional argument :::::::::::::::::::::::::::

end returncode function with an optional argument :::::::::::::::::::::::::::::::

toplevel programmable interrupt :::::::::::::::::::::::::::::::::::::::::::::::::::

toplevel function with no arguments :::::::::::::::::::::::::::::::::::::::::::::

toplevelstatus variable ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

toplevelread variable ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

topleveleval variable ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

systemtopleveltag escape ::::::::::::::::::::::::::::::::::::::::::::::::

gc i function with an optional argument ::::::::::::::::::::::::::::::::::::::::::::

gcinfo i function with an optional argument :::::::::::::::::::::::::::::::::::::::

gcalarm programmable interrupt ::::::::::::::::::::::::::::::::::::::::::::::::::: :

gcalarm function with no arguments :::::::::::::::::::::::::::::::::::::::::::::::

gcbeforealarm programmable interrupt :::::::::::::::::::::::::::::::::::::::::::

gcbeforealarm function with no arguments :::::::::::::::::::::::::::::::::::::

freecons cons function with one argument ::::::::::::::::::::::::::::::::::::::::

freetree tree function with one argument ::::::::::::::::::::::::::::::::::::::::

FUNCTION INDEX

runtime function with no arguments :::::::::::::::::::::::::::::::::::::::::::::::

time e function with one argument ::::::::::::::::::::::::::::::::::::::::::::::::

sleep n function with one argument :::::::::::::::::::::::::::::::::::::::::::::::

comline strg function with one argument :::::::::::::::::::::::::::::::::::::::::

getenv strg function with one argument ::::::::::::::::::::::::::::::::::::::::::

Chapter

Sexpression prettyprinter

The predened functions print and prin are normally used to print LELISP Sexpressions The

only things done to render them readable are

 a space is inserted b etween atoms

 atoms symb ols and numb ers are not broken up by endoflines

These measures are clearly insucient for program display The prettyprint functions using

variable indentation and line feeds where necessary bring out the control structure of co de and so

render it much more readable

To further increase readability calls to the quote function are represented by the macro and

the macro forms of lets are printed in full

To demonstrate the utility of the prettyprinter we rst present a function in the manner it is

printed by the normal print functions for a given terminal or window line width

getdef prettycond

defun prettycond with lmargin add lmargin while consp l

terpri if prettyinlinep car l nextl l let l nextl l f t

princn when consp l prettyp next l when l prettyprogn

prettypdot

Here is how the prettyprinter presents it

pretty prettycond

de prettycond

with lmargin add lmargin

while consp l

terpri

if prettyinlinep car l

nextl l

let l nextl l f t

princn

when consp l prettyp nextl l

when l prettyprogn

prettypdot

CHAPTER SEXPRESSION PRETTYPRINTER

Prettyprint functions

The following functions are found in the le named pretty in the standard library and they are

autoloaded automatically loaded the rst time one of them is called

pretty feature

This feature indicates whether the prettyprinter is loaded into memory

pprint s function with one argument

Prettyprints the expresssion s onto the current output stream and go es to the next output line a

la print It returns s as its value

pprin s function with one argument

Prettyprints the expression s onto the current output stream and stays on the same output line

a la prin It returns s as its value

pretty sym ::: sym special form

1 n

The arguments sym ::: sym are symb ols that have function denitions pretty prints these

1 n

functions onto the current ouptut stream and returns as its value This function also knows

ab out redened or traced functions so it will use the true denitions of these functions There is

a macro character that eects this function P

prettyf file sym ::: sym special form

1 n

This function is similar to the previous one except that it prints the functions sym ::: sym into

1 n

the output le named file It returns file as its value

For example to create a le named fooll containing the text of the denitions of the functions

foo and bar evaluate prettyf fooll foo bar

prettyen d function with no arguments

Reclaims the space o ccupied by the prettyprint functions ab out list cells It can b e called

when the prettyprinter is no longer b eing used The functions return to autoload status and the

pretty feature disapp ears

Control of prettyprinter functions

The prettyprinter uses the lmargin and rmargin functions to calculate the size of line it can use

Two variables control the printing of constants in program

pretty quo te lev el variable

This variable contains the value to give to the printlevel function when a constant is to b e

printed By default it is equal to zero

pretty quo te len gt h variable

This variable contains the value to give to the printlength function when a constant is to b e

printed By default it is equal to zero

Standard prettyprinter format

By default the prettyprinter prints Sexpressions on a single line In the case of overow it starts

over at the left margin using the following seven standard formats

Format progns

progn

e

en

Format ifs

if e

e

en

Format defuns

defun e e

e

en

Format conds

cond

e

e eix

en

en enz

Format selectqs

selectqs e

e

e ex

en

en enz

CHAPTER SEXPRESSION PRETTYPRINTER

Format setqs

setq e e

en en

Format tagbodys

tagbody

e

label

en

These formats are stored in the symb ols Ptyp es These Ptyp es are accessed with the predened

ptype function so any function can b e assigned a default prettyprint format typ e

Extending the prettyprinter

It is also p ossible to dene sp ecial print formats for extended LELISP typ es These are functions

named pretty in the extended typ e package

defstruct foo a b c

foo

setq v foomake

foo

foob v

fooc v

v

foo

defun foopretty x

princh

pprin foob x

princh

pprin fooc x

princh

pprin fooa x

princh

foopretty

pprint list v v v

foo foo

foo

Table of contents

Sexpression prettyprinter

Prettyprint functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Control of prettyprinter functions ::::::::::::::::::::::::::::::::::::::::

Standard prettyprinter format :::::::::::::::::::::::::::::::::::::::::::

Extending the prettyprinter ::::::::::::::::::::::::::::::::::::::::::::::

Table of Contents

Function Index

pretty feature ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

pprint s function with one argument :::::::::::::::::::::::::::::::::::::::::::::

pprin s function with one argument :::::::::::::::::::::::::::::::::::::::::::::::

pretty sym ::: sym special form ::::::::::::::::::::::::::::::::::::::::::::::

1 n

prettyf file sym ::: sym special form :::::::::::::::::::::::::::::::::::::::

1 n

prettyend function with no arguments ::::::::::::::::::::::::::::::::::::::::::::

prettyquotelevel variable :::::::::::::::::::::::::::::::::::::::::::::::::::

prettyquotelength variable ::::::::::::::::::::::::::::::::::::::::::::::::::

Chapter

Sp ecialize d output

This chapter presents three sub jects

 The format printing function

 A set of functions that work on circular or shared lists

 The multilanguage message facility

Formatted output

format feature

This feature indicates whether the format function is loaded into memory

Printformatting function

format dest cntrl e ::: e function with two or more arguments

n

Prints the cntrl character string onto the dest output channel This string can contain print

directives made up of tilde characters followed by a formatsp ecication character When cntrl

is printed these directives cause the evaluation of the LISP ob jects e ::: e which can b e of any

n

dened typ e The rst directive in the control string cntrl describ es the print format of the e

argument the second that of e etc

The argument dest sp ecies the output channel used for printing It can take various values

 an inputoutput channel numb er op ened by the either the openo or opena function

 the symb ol t in which case printing is done on the terminal channel value

 the symb ol in which case the output is directed to a character string which is returned

by the format function as its value and no other printing is actually done

CHAPTER SPECIALIZED OUTPUT

prinf cntrl e ::: eN SUBRa or N arguments

is identical to the preceding function except that output takes place in the current output channel

printf cntrl e ::: eN SUBRa or N arguments

is identical to the prinf function except that it prints a line skip using the terpri function at the

end of the printing

The directive most often used is A which eects the same print format as the prin command

Here is an example of printing with the A format

defun loves x y

prinf A loves A x y

terpri

loves loves romeo juliet

romeo loves juliet

t

Some print formats accept mo diers and numerical parameters

A modier is one of the two characters or o ccurring immediately b efore the format

sp ecication character Mo diers are used to change the action of the format directive that

they mo dify Their sp ecic actions dep end of course on what they mo dify

Here is an example of the C directive which handles characters

format the character C a

the character a

The C directive can b e mo died by a colon sign indicating that the name of the character

is required

format the character named C a

the character named controlA

The C directive can b e mo died by a indicating that we want to obtain a character that

is readable by a macro

format setq char C a

setq char A

Numeric parameters app ear b etween the tilde character and the mo diers if there are any

They sp ecify various characteristics of the format to which they are applied the numb er of

columns to b e used the ll character tab p ositions and the numeric base for printing

When several numeric parameters are required the must b e separated by commas Certain

parameters are optional and take on default values if they are not supplied

Numeric parameters can b e entered in various forms

 An integer numb er read in the current input base

 A quoted character whose value b ecomes the internal character co de numb er of the

FORMATTED OUTPUT

character

 The v or V character The value of the parameter is the value of the argument e that

i

is next in order The argument printed will then b e the following one namely e

i

 The character The parameters value is the numb er of e arguments remaining to b e

i

formatted

The D directive is used for base numb ers It accepts two optional parameters the numb er

of columns and the ll character to b e used

First we use the D directive without parameters

format the number D

the number

Here is an example of the D directive with the numb er of columns to b e used namely

format the number D

the number

The following example shows the D directive with b oth the numb er of columns and the

ll character namely

format the number D

the number

The numb er of columns can b e given in the argument list

format the number vD

the number

Both the numb er of columns and the ll character can b e given in the argument list

format the number vvD

the number

Format directives

Throughout this section optional parameters in the syntactic forms of the various format directives

are enclosed in square brackets

A print format

This is the ASCI I print format which prints an argument in the same way that prin would It

has the following syntactic forms

A

mincol pad A

mincol colinc minpad pad A

CHAPTER SPECIALIZED OUTPUT

The sign can b e used as a mo dier

In the case of the syntax involving one or two parameters mincol is the minimum width of

the printed string and the result is padded with either sp by default or the pad character

Normally the string is leftpadded It is rightpadded when the mo dier is used

In the case of the syntax involving three or four parameters the result is padded by the

numb er minpad of pad characters then adjusted to a minimum width of mincol by increments

of colinc characters The resp ective default values of the four parameters are zero one zero

and sp

format A abcd ) abcd

format A abcd ) abcd

format A abcd ) abcd

format A abcd ) abcd

format A abcd ) abcd

format A abcd ) abcd

format vA u abcd ) abcduuuuuuuuuuuu

S print format

This Sexpression directive is similar to the previous one except that it sets the

systemprintforread indicator The printed result can then b e reread by the LISP

reader This directive accepts the same parameters and mo diers as the A directive

format S A abcd efgh ) abcd efgh

R print format

This radix directive has the following syntactic forms

base R

base mincol padchar R

The sign can b e used as a mo dier

If the next argument is an integer or rational numb er it is printed in the output base referred

to as base See the obase function If the argument is not numeric the A format is used

The mincol and pad parameters as well as the mo dier play the same role as for the A

directive

format R )

format R )

D print format

This decimal directive is equivalent to the R directive sp ecifying a base print format

It has the following syntactic forms

FORMATTED OUTPUT

D

mincol padchar D

The sign can b e used as a mo dier

format D )

format D )

format D )

format D abcd ) abcd

B print format

This binary directive is equivalent to the R directive sp ecifying a base print format B

accepts the same parameters and mo dier as the D directive

format vB )

O print format

This o ctal directive is equivalent to the R directive sp ecifying a base print format O

accepts the same parameters and mo dier as the D directive

format O )

X print format

This hexadecimal directive is equivalent to the R directive sp ecifying a base print

format X accepts the same parameters and mo dier as the D directive

format X )

P print format

This Englishplural directive prints the character s if the next argument is not equal to

Otherwise it prints nothing

It can b e used with the signs and as mo diers The mo dier pro duces either the character

y when the next argument is equal to or the characters ies when the next argument is not

equal to If the mo dier is present the argument tested is the one that was just pro cessed

by the format function This allows an argument and its plural sux to b e printed from a

single o ccurrence of the argument in the argument list The mo dier in this case inhibits

argument p ointer incrementation

format P )

format P abcd ) s

format D trPD winP ) tries win

format D trPD winP ) try wins

format D trPD winP ) try wins

CHAPTER SPECIALIZED OUTPUT

C print format

This character directive prints the character whose internal character co de is equal to the

next argument

It can b e used with the signs and as mo diers The mo dier assures that the printed

character will b e rereadable by one of the macros or The mo dier prints the

name of the character

format C )

format C )

format C sp ) sp

format C A ) A

format C )

format C A ) controlA

format C I ) tab

E print format

This exp onential oatingp oint directive has the following syntactic form

width digits exp factor oow pad letter E

The sign can b e used as a mo dier

This format prints the next argument which must b e numeric The width parameter sp ecies

the width of the resulting string If the result is wider than width characters then a string of

oow characters of length width is printed instead of a mangled numeric string

The digits parameter sp ecies the numb er of signicant digits and exp is the numb er of digits

in the exp onent Character ll with pad if any is to the left The factor parameterwhose

default value is oneindicates the numb er of digits to the left of the decimal p oint The

mo dier indicates that a plus sign should b e printed if the argument is not negative The

exp onent is always printed with a sign By default the letter parameter is e the character

that separates the exp onent from the mantissa

If the argument is not a oatingp oint value the width D format is used If width digits and

exp are omitted freeprint format of the prin style is used

format E ) e

format vE ) e

format vE ) e

format vE ) e

format vE ) e

format vE ) e

format vE ) e

format vE ) e

format vE ) e

format E ) e

FORMATTED OUTPUT

format E ) e

format E ) e

format E e )

format E ) e

format E ) e

format E )

format E )

format E )

format E e )

F print format

This xedformat oatingp oint directive has the following syntactic form

width digits factor oow pad F

The sign can b e used as a mo dier

This format prints the next argument which must b e numeric The width parameter sp ecies

the width of the resulting character string with optional padding by the pad character to

the left By default pad is the space character sp The digits parameter indicates the

numb er of digits to the right of the decimal p oint The factor parameter is a scaling factor

The numb er actually printed is ten to the p ower factor times the argument If the result

string is wider than width characters then a string of oow characters of length width is

printed The mo dier indicates that a plus sign should b e printed when the argument is

nonnegative

format F )

format F )

format F )

format F )

format F )

format F )

format F )

format F )

format F )

format F )

format F )

CHAPTER SPECIALIZED OUTPUT

G print format

This general oatingp oint directive has the same syntactic structure as the E directive

width digits exp factor oow pad letter G

The sign can b e used as a mo dier

As in the case of the F and E directives this format prints the next argument which must

b e numeric The actual printing is carried out as if either the F or the E directive were

used

 If the given argument can b e handled successfully by means of the xedformat oating

p oint F directive then that is how the G directive in fact b ehaves If a value for the exp

parameter is supplied then exp is incremented by two to obtain the numb er of blanks on

the right Otherwise four blanks are added

 If however the value to b e printed overows when the F directive is used then the E

directive is applied with all its default arguments

print format

This tilde directive has the following syntactic structure

number

The directive prints a single tilde character When the number parameter is supplied a

string of tilde characters of length number is pro duced

format )

format v )

print format

This newline directive has the following syntactic structure

number

The format directive prints a single lf character When the number parameter is

supplied a string of lf characters of length number is pro duced

This directive is included only to ensure compatibility with COMMON LISP It is preferable to

call the terpri function

pname format a )

pname format a )

FORMATTED OUTPUT

lf print format

This skip directive has the following syntactic structure

lf character

Either a or a character can b e used as mo dier

This directive is made up of the tilde character followed immediately by an endofline

mark

Without mo diers it skips over the endofline character and any whitespace characters that

follow With it prints the endofline but skips any whitespace that follows With it

skips the endofline but prints all characters that follow including whitespace according to

the rest of the format statement This directive is included solely for reasons of COMMON LISP

compatibility

format string lf sp tab b ) b

pname format string lf sp tab b )

pname format string lf sp tab b )

T print format

This tabulation directive has the following syntactic structure

T

colnum colinc T

The character can b e used as a mo dier

The T directive moves the cursor to the next tab stop printing spaces if necessary to pro duce

whitespace Both parameters have default values of one

Without tabulation is absolute Spaces are printed up to the column colnum Column

numb ering starts at zero The cursor is displaced to the column following the one that is

sp ecied If the cursor is in column colnum or b eyond it is rep ositioned at the column whose

numb er is colnum k colinc where k takes on the minimum p ossible nonnegative value

Used with T p erforms relative tabulation The cursor is moved colnum p ositions forward

and to the column whose numb er is k colinc where k takes on the minimum p ossible value

format T )

format T )

format abT ) ab

format T )

format T )

format abT ) ab

print format

This ignore directive has the following syntactic structure

CHAPTER SPECIALIZED OUTPUT

number

Either a or a character can b e used as mo dier

The directive ignores the next argument The default value of number is one except when

the mo dier app ears in which case its default value is zero Without mo diers the next

number arguments are skipp ed With the mo dier the argument p ointer is moved back by

th

number arguments With the mo dier the number argument of the original argument

list counting from zero will b e read next In an indirection or an iteration access is relative

to the sublists involved

format A )

format D D )

format D D )

format D D D )

print format

This indirection directive has the following syntactic structure

The character can b e used as mo dier

The format directive p erforms an indirection The next argument which must b e a

character string is taken to b e the format sp ecication If no mo dier is given the argument

to this format sp ecication is the argument that follows it which should therefore b e a list

With the mo dier present the arguments following the format sp ecication are used directly

format D A D foo ) foo

format D A D foo ) foo

print format

This conditional directive has the following syntactic structures

number strg strg strg

n

number strg strg default

false true

true

Warning In the rst two syntactic structures shown ab ove the square brackets around the

number parameter indicate as usual that it is optional But all other square brackets included

in these four linesand printed in a dierent typ efaceare actual terminal characters that

must app ear as such in your LISP co de

This directive p erforms a conditional print format The strg format is used where i is equal i

FORMATTED OUTPUT

to number if it is supplied or to zero if number is not present If there are not enough strg

parameters then default is used If this last parameter is not given then nothing is printed

The colon mo dier serves as a b o olean argument If the mo dier is used then either

the argument is in which case nothing is printed and the next argument will b e used as

the next format or the argument do es not equal and it is then printed according to the

format true A in a conditional returns to the emb edding or if this exists

format siamesemanxpersian cat ) siamese cat

format siamesemanxpersian cat ) persian cat

format siamesemanxpersian cat ) cat

format siamesemanxpersian cat ) persian cat

format truefalse t ) false

format truefalse ) true

format print level D print length D ) print length

fg print format

This iteration directive has the following syntactic structure

number strg

The mo diers and can b e used p ossibly combined

This format directive p erforms an iteration strg is applied to as many arguments as are given

If number is supplied at most number lo ops through strg will b e p erformed If a is

present at least one lo op is p erformed unless nb is equal to zero If strg is empty the next

argumentwhich should b e a character stringis used Without mo diers the iteration is

executed using the argument that immediately follows which must in this case b e a list With

all the remaining arguments are used If a is present each iteration is p erformed on a

dierent constituent sublist each time around Note that the and format directives can

only b e emb edded if they concern formats of dierent typ e

format The winners are S fred harry ) The winners are fred harry

format Pairs SS a b ) Pairs a b

format Pairs SS a ) Pairs a

format Pairs SS a b ) Pairs a b

format Pairs SS a b c ) Pairs a b c

format D )

print format

This escap e directive has the following syntactic structure

n n n

This format directive p erforms an escap e Formatting is terminated from within indirections

or iteration lo ops or if no format directives remain

CHAPTER SPECIALIZED OUTPUT

If no parameters are given the numb er of remaining arguments is considered to b e the sole

parameter If there is only one parameter its value is examined and if it is zero the exit is

p erformed If there are two parameters and they are equal the exit o ccurs If three parameters

are given then the exit o ccurs if n < n or if n < n or b oth In an indirection with

a the escap e o ccurs at the sublist level except when the mo dier is present

format Done D warningPD errorP ) Done

format Done D warningPD errorP ) Done warnings

format Done D warningP D errorP ) Done warning errors

Handling circular or shared ob jects

Although the print limiting functions describ ed in chapter truncate the display of circular or

shared structures and thus give an abbreviated view of them they still do not show clearly which

list cells or vectors are actually b eing shared

Sp ecial functions for printing and reading circular ob jects lists vectors circular symb ols on

packages are furnished in the standard library They can b e loaded with the following command

libload libcir

libcir feature

This ag indicates whether the library of sp ecial functions for circular ob jects has b een loaded

n macro

Enumerates a shared or circular ob ject that can then b e referenced by the n macro

n macro

th

References the n shared or circular ob ject numb ered by n

For example a has the following structure

a

HANDLING CIRCULAR OR SHARED OBJECTS

cirprin e function with one argument

cirprinf lus h e function with one argument

cirprint e function with one argument

These functions print their arguments using the macros n and n on circular or shared

constructions that are passed to them if they cannot b e printed normally

printlevel )

progn setq e rplaca e e e )

cirprint e )

setq s cirlist )

cirprint s )

cirprint a a ) a a

progn setq v vset v v v )

cirprint v )

progn setq x p q y list x foo x

rplacd last y cdr y y =) p q foo p q foo p q

cirprint y =) p q foo

cirequal e e function with two arguments

cirnequa l e e function with two arguments

These functions compare their two arguments even if they involve circular or shared

constructions In these cases equality is understo o d as structure isomorphism

setq x a y list x x z list a a ) a a

cirprint y ) a

equal y z ) t

cirequal x y )

circopy e function with one argument

Copies its argument repro ducing circular or shared structures

progn setq x circopy y cirprint x ) a

cirequal x y ) t

libcir pac ka ge pa ran o variable

If this variable is equal to t it indicates that packages of symb ols can contain circular

structures Use of such structures is normally strictly forbidden Functions op erating on

CHAPTER SPECIALIZED OUTPUT

circular or shared ob jects are seriously slowed down but in this way some nasty errors can

b e chased away

progn setq x foo packagecell x x x )

cirprint x ) foo

Multilanguage messages

Pro ducts based up on LELISP are b eing marketed in many dierent countries This means that LE

LISP messages have to b e lo calized into various foreign languages The goal of the present section

is to describ e an easy and ecient metho dology for handling this question

The initial LELISP le called startupll oered a rudimentary solution to this problem The

global variable systemforeignlanguage had the value t when messages were to app ear in

English and when they were to app ear in French This variable was used in LELISP libraries in

the following manner

defvar errnht

systemforeignlanguage not a Hash Table

systemforeignlanguage Largument nest pas une table de hachage

defvar errbht

systemforeignlanguage Bad type for a Hash Table

systemforeignlanguage Le type de la table de hachage est inconnu

error gethash errnht foo

This solution is to o limited The choice of a language was made when the le was loaded and ab out

to b e interpreted or when the le was compiled and it could not b e changed afterwards Only two

languages could b e handled and you had to create a separate compiled le for each language

The new solution oers the following advantages

 You can handle several dierent languages

 You can change your choice of a language dynamically during program execution

 If you prefer you can limit your choice to a single language

 For reasons of compatibility the new solution do es not interfere with the old one

The basic idea is that languages and messages are handled within the context of a global multi

language database that can b e shared by all applications

messages feature

This feature indicates whether the multilanguage database is loaded into memory

MULTILANGUAGE MESSAGES

Languages

From the users viewp oint a language is simply a symb ol There are two predened languages

english and french Any mention a language which is not a symb ol raises the error

errorwronglanguage Any use of a language that has not b een recorded in the database raises

another error errornotrecordedlanguage Here are the standard denitions of these errors

defmessage errorwronglanguage

english not a language name

french largument nest pas un nom de langue

defmessage errornotrecordedlanguage

english not a recorded language

french largument nest pas une langue enregistree

recordl ang ua ge language function with one argument

The language argument is the name of a new language which is recorded in the multi

language database If this language existed already the database is not mo died The function

returns language in the rst case and in the second This function can raise the error

errorwronglanguage

recordlanguage polish ) polish

current lan gu age language function with an optional argument

Without an argument this function returns the symb olic name of the current language Its

argument if it has one is a language that was previously recorded by the recordlanguage

function In this case language b ecomes the new current language This function can raise the

errors errorwronglanguage and errornotrecordedlanguage

default lan gu age language function with an optional argument

Without an argument this function returns the symb olic name of the default language Its

argument if it has one is a language that was previously recorded by the recordlanguage

function In this case language b ecomes the new default language The default language is

english

This function can raise the errors errorwronglanguage and errornotrecordedlanguage

removel ang ua ge language function with one argument

Removes language and all messages asso ciated with this language in the database If language

did in fact exist in the database then this symb ol is returned If not the function returns The

two predenied languages english and french cant b e removed This function can raise the two

errors errorwronglanguage and errornotrecordedlanguage

message lan gu age s function with no arguments

CHAPTER SPECIALIZED OUTPUT

Returns the list of all the language known to the database This list do es not represent all or even

part of the actual data structures recorded in the multilanguage database So mo dications to

this list have no eect whatso ever on the database itself

messagelanguages ) polish esperanto english french

Messages

A message name is a symb ol of the variable kind The functions describ ed in this section raise

the error errorwrongmessage if the message argument is not a symb ol of this kind The

string value that is asso ciated with a message name must b e a character string If not the error

errornotstringmessage is raised Here are the standard denitions of these errors

defmessage errorwrongmessage

english not a message name

french largument nest pas un nom de message

defmessage errornotstringmessage

english not a message string

french largument nest pas une chaine de message

getmess age message function with one argument

Returns the character string asso ciated with the message name message in the current language

or if this message is not dened in the default language The current languageif such a language

still exists see the removelanguage functionis the one returned by the currentlanguage

function The default language is the one returned by the defaultlanguage function If no such

message exists the string representing the message name itself is returned This function can raise

the error errorwrongmessage

M sharp macro

m sharp macro

The M macro character enables you to access the value of a message

Mfoo is read as getmessage quote foo

Mgee is read as getmessage quote gee

getmess age p message function with one argument

Identical to getmessage except that getmessagep never raises an error It is generally used as

a predicate

putmess age message language string function with three arguments

MULTILANGUAGE MESSAGES

Within the multilanguage message database this function asso ciates string with message in

the language corresp onding to language The function returns the value message It can raise the

following errors errorwronglanguage errornotrecordedlanguage errorwrongmessage

and errornotstringmessage

removem ess ag e message language function with two arguments

Removes message in the language corresp onding to language from the multilanguage message

database This function returns the value message and can raise the following errors

errorwronglanguage errornotrecordedlanguage and errorwrongmessage

defmessa ge message def ::: def macro

n

This macro provides a convenient way of asso ciating a list of values in dierent languages to a

certain message name In other words it lets you group together in one place all the linguistic

variants of a particular message The function returns the value message and can trigger the

following errors errorwronglanguage errornotrecordedlanguage errorwrongmessage

and errornotstringmessage

In LELISP defmessage could b e dened in the following manner

defmacro defmessage msg ldef

progn mapcar lambda def putmessage msg def

ldef

msg

Here is an example

defmessage smecierrornotaprototype

english Not a prototype

french Largument nest pas un prototype

polish Argumentyws nie jest prototypuxzy

esperanto La argumento ne estas prototipo

getall mes sa ges language function with one argument

Returns the list of all messages recorded in the language language getallmessages might raise

the errors errorwronglanguage or errornotrecordedlanguage

To nd out how many messages have b een prerecorded in LELISP

length getallmessages english )

length getallmessages french )

Advice

Since the names of messages are global it is imp ortant to use dierent message names in each

application You can use LELISP packages or you might prefer to write names in full for example

smecierror or smecierrornotaprototype

CHAPTER SPECIALIZED OUTPUT

Let us lo ok at some examples of the handling of multilanguage messages You can temp orarily

change the language of a message in the following manner

with currentlanguage polish

The following example shows how to obtain the list of all the messages dened in a particular

language

defun getallmessages language

with currentlanguage language

defaultlanguage language

mapcoblist lambda msg

when getmessagep msg

list msg

To destroy all messages in all languages except English act as follows

mapc lambda lang when neq lang english

removelanguage lang

messagelanguages

Finally you might wish to verify that all the messages in English say have French equivalents

The following example do es this and it returns you the list of English messages that do not yet

have French equivalents

defun verifyfrench

with currentlanguage english

defaultlanguage english

mapcoblist lambda msg

when getmessagep msg

with currentlanguage french

defaultlanguage french

if getmessage msg

list msg

Table of contents

Sp ecialized output

Formatted output ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Printformatting function :::::::::::::::::::::::::::::::::::::::::::::::::

Format directives ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Handling circular or shared ob jects ::::::::::::::::::::::::::::::::::::::::::::::

Multilanguage messages ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Languages ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Messages ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Advice ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

Table of Contents

Function Index

format feature ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

format dest cntrl e ::: e function with two or more arguments :::::::::::::::::

n

prinf cntrl e ::: eN SUBRa or N arguments :::::::::::::::::::::::::

printf cntrl e ::: eN SUBRa or N arguments ::::::::::::::::::::::::

A print format ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

S print format ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

R print format ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

D print format ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

B print format ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

O print format ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

X print format ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

P print format ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

C print format ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

E print format ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

F print format ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

G print format ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

print format ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

print format ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

lf print format ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

T print format ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

print format ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

print format ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

print format ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

fg print format ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::

print format ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

libcir feature ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

FUNCTION INDEX

n macro ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::

n macro ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::

cirprin e function with one argument ::::::::::::::::::::::::::::::::::::::::::::

cirprinflush e function with one argument ::::::::::::::::::::::::::::::::::::::

cirprint e function with one argument :::::::::::::::::::::::::::::::::::::::::::

cirequal e e function with two arguments ::::::::::::::::::::::::::::::::::::::

cirnequal e e function with two arguments :::::::::::::::::::::::::::::::::::::

circopy e function with one argument ::::::::::::::::::::::::::::::::::::::::::::

libcirpackageparano variable ::::::::::::::::::::::::::::::::::::::::::::::

messages feature ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

recordlanguage language function with one argument :::::::::::::::::::::::::::

currentlanguage language function with an optional argument :::::::::::::::::::

defaultlanguage language function with an optional argument :::::::::::::::::::

removelanguage language function with one argument :::::::::::::::::::::::::::

messagelanguages function with no arguments ::::::::::::::::::::::::::::::::::

getmessage message function with one argument :::::::::::::::::::::::::::::::::

M sharp macro ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

m sharp macro ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

getmessagep message function with one argument ::::::::::::::::::::::::::::::

putmessage message language string function with three arguments :::::::::::::

removemessage message language function with two arguments ::::::::::::::::::

defmessage message def ::: def macro :::::::::::::::::::::::::::::::::::::

n

getallmessages language function with one argument :::::::::::::::::::::::::

Chapter

Rational and complex arithmetic

LELISP has libraries which extend the basic generic arithmetic to op erations on relative rational

and complex numb ers

Since the version LELISP has a new very fast implementation of relative and rational

numb ers the result of a joint development eort at DEC PRL Serp etteal and INRIA

mvs

In order to load the old rational numb er library named ratio typ e the following

loadmodule ratio or

Aratio

To load the new and preferred rational numb er library typ e

loadmodule bnq or

Abnq

To load the complex numb er library named complex typ e

loadmodule complex or

Acomplex

ratio feature

q feature

complex feature

These features indicate whether the various libraries mentioned ab ove are present

CHAPTER RATIONAL AND COMPLEX ARITHMETIC

Rationals le Q

Rational numb er IO

Rationals are entered in the form z n where the numerator z is a relative numb er and the

denominator n is a p ositive whole numb er or zero

)

)

)

)

)

)

)

)

)

The system prints out the rationals in a compact form Insignicant zeros are suppressed values are

simplied numerator and denominator are each divided by their greatest common denominator

or gcd and values with denominator equal to are transformed into elements of Z the relative

integers

The evaluation of a rational numb er returns the numb er itself so it need not b e quoted

Notice the presence in the rationals of the values for p ositive and negative innity and

resp ectively as well as a value representing undened results Any arithmetic op eration

containing an expression whose value is returns which can b e considered to b e an error

value The undened value actually represents the closed interval which contains

all the rationals including plus innity and minus innity Due to the presence of these elements

the Q of LELISP do es not qualify as a eld

Decimal output approximating values in Q

In addition to the standard LELISP print routines which display rational values in their exact

reduced forms a variableprecisi on approximate decimal form is also available

The function which sets the output precision is

precisio n n function with an optional argument

Called with no argument precision returns the current print precision If an argument is supplied

the print precision is determined according to the following scheme

If the argument is any nonnumeric constant including t the print mo de is set to pro duce exact

reduced representation of rationals

If the argument is a oatingp oint value its integer part indicates the numb er of digits that should

b e printed after the decimal p oint in the current output base obase

When the denominator is small the decimal form which is always p erio dic is exact so LELISP

RATIONALS FILE Q

prints the rep eating part b etween braces and Otherwise the numb er of digits requested is

printed after the decimal p oint followed by an ellipse

If the argument is a p ositive integer of typ e fixp it indicates the numb er of terms to b e printed

in continuous normal fraction notation

Rationals printed in any form other than precision t are not rereadable by the LELISP reader

precision )

) fg exact representation

) fg digits to the right of

) fg

precision )

)

)

)

Tests for typ e

Ob jects can b e tested for memb ership in the set of integers Z or in the rationals

Q by using the predicates

rational p q function with one argument

Returns the value of q if it is rational or if not

precision t ) t

rationalp )

rationalp )

rationalp ) a float is not a rational

integerp z function with one argument

Returns the value of z if it is integral or if not

integerp )

integerp )

integerp )

integerp ) a float is not an integer

These two functions are generic To extend them to typ e foo it is sucient to dene

foointegerp and foorationalp

Generic rational arithmetic

All of the generic arithmetic functions of LELISP see chapter work on Q and try when p ossible

to p erform exact calculations The syntax of these calls is the same as those with LELISP small

integer arguments

CHAPTER RATIONAL AND COMPLEX ARITHMETIC

)

quotient ) modulo is in exmod

modulo ) here it is now

)

)

) q is false in q

)

)

Integer division quotient n d given n and d in Q returns a quotient d in Z and a remainder r

stored in the variable exmod in Q such that

n dq r with r absd

Functions limited to Z

gcd z z function with a variable number of arguments

1 n

Calculates the greatest common divisor of its relative integer arguments z z

1 n

pgcd z z function with two arguments

Similar to the last function but limited to two arguments and without verication of their typ es

even z function with one argument

Returns the value of z if this is an even relative integer and if not

fact n function with one argument

Calculates the factorial n n for p ositive integer arguments NB By convention

is equal to

fib n function with one argument

th

Computes the n Fib onacci numb er where F F Fi Fi Fi Of course

n must b e a p ositive integer value

gcd )

fact )

fib )

Functions limited to rational arguments limited to Q

The numerator and denominator functions give access to the numerator and the denominator

resp ectively of rationals without reducing them by their common factors Computation on Q is

RATIONALS FILE Q

done directly on the representation of rationals as entered reduction is explicitly done only when

prin or integerp functions are called

numerato r f function with one argument

denomina tor f function with one argument

numerator ) no reduction done

denominator )

setq a prin ) reduction done by print

numerator a ) a has been reduced

numerator )

denominator fib )

The p ower function tries in more cases than the power function to do exact arithmetic

n m function with two arguments

Computes the pro duct n n n m times for m a p ositive integer

)

)

)

Two examples

The zeta function zeta n e computes the sum of the terms ie for i from to n

defun zeta n e

let z

for i n setq z z i e

z

For e one obtains the harmonic numb ers a divergent series

For e the series converges slowly toward the square of pi divided by six

For e the series converges toward zeta which Apery showed to b e transcendant

Lets compute qe n the sum of the terms i for i from to n This expression converges rapidly

toward the numb er e

defun qe n

let e

for i n setq e e fact i

e

zeta )

zeta )

CHAPTER RATIONAL AND COMPLEX ARITHMETIC

zeta )

qe )

precision )

zeta )

zeta )

zeta )

qe )

Complex numb ers the eld C

After charging complex the complex numb er manipulation package the symb ols i and pi have

the values i and It would not b e wise to change their values

Complex numb er IO

macro character

Complex numb ers are printed b etween square brackets in the form xiy where x is the

imaginary part and y is the real part Some simplications are used xi when y xiy when

y iy when x and iy when x Thus the pure imaginary numb er is known as i

and its square is equal to

C macro

Complex numb ers can b e also represented in the form Cy x where x is the imaginary part and

y is the real part In order to get this printed representation evaluate precision cl

precision cl ) cl

i ) C

i ) C

i ) C

Tests for typ e

complexp c function with one argument

Returns the value of c if it is complex or if not

realp r function with one argument

Returns the value of r if it is numeric and not complex or if not This is a generic function

which can b e extended to the typ e foo by dening foorealp

realp )

COMPLEX NUMBERS THE FIELD C

realp )

realp )

realp i )

complexp )

complexp i ) i

Complex generic arithmetic

The arithmetic functions known as  and  have b een extended to the complex numb ers

i ) i

i i )

i i i )

i i )

i i )

i ) i

i ) i

i i ) i

float i ) i

Whole division using quotient makes no sense in C and raises an error The same is true of

truncate and floor

The float function converts real and imaginary parts of complex numb ers into oatingp oint

numb ers The comparison function applied to two complex numb ers aib cid

returns the value a ci b c which only makes mathematical sense when the

result is that is when aib cid

The domain of the sqrt and log functions extends to C following the formulas

sqrtrrsqrtr logrpiilogr

The asin and acos functions are dened on C by

acoszpiasinz and asinzilogizsqrtzz

sqrt ) i

log ) i

log ) i

log )

sqrt ) i

asin ) i

acos )

Functions limited to the complex numb ers limited to C

makecomp lex c i function with two arguments

This function returns ii c in which the arguments i and c must b e reals

CHAPTER RATIONAL AND COMPLEX ARITHMETIC

realpart c function with one argument

If c xiy realpart returns y

imagpart c function with one argument

If c xiy imagpart returns x

conjugat e c function with one argument

If c xiy conjugate returns xiy

conjugate i ) i

realpart i )

imagpart i )

Polar co ordinates

We write rctc for the p olar representation of c yix The value of the angle tcarctanyx

mo dulo pi is determined by the lo cation of yix in the complex plane The following relationships

hold

if y and x tcpi if y and x pitcpi

if y and x pitc if y and x pitcpi

if y and x tcpi

if y and x tcpi

The mo dulus rc is given by abs c while the angle tc can b e obtained with

phase c function with one argument

If c xiy rctc phase returns tc

signum c function with one argument

If c xiy rctc signum returns tc c abs c

phase i )

phase i )

phase i )

phase i )

abs i )

signum pi )

The complex logarithm and exp onential functions are dened in relation to the p olar representation

as follows

COMPLEX NUMBERS THE FIELD C

logrt tilogr and exprt exprsintiexprcost

cis r function with one argument

Computes sinricosr

The sqrt function is dened for the complex numb ers by

sqrtz explogz

The trigonometric functions are dened by

sinz expciexpcii

cosz expciexpci

atanz ilogzisqrtzz

tanz sinzcosz

The results of the following calculations dep end on the oatingp oint precision used

log exp i ) i

exp log i ) i

exp i pi ) i

setq a sqrt i ) i

a a ) i

asin sin i ) i

cos acos i ) i

atan i )

atan tan i ) i

Hyp erb olic functions

sinh z function with one argument

Computes expzexpz

cosh z function with one argument

Computes expzexpz

tanh z function with one argument

Computes sinhzcoshz

asinh z function with one argument

Computes logzsqrtzz

CHAPTER RATIONAL AND COMPLEX ARITHMETIC

acosh z function with one argument

Computes logzzsqrtzz

atanh z function with one argument

Computes logzsqrtxx

A complex miniextension of generic arithmetic

This example the construction of a simplied version of the mo dule complex illustrates the idea

of an extension to the generic arithmetic package While it is incomplete do es no error checking

and do es not exactly agree with the preceding description of the complex numb ers C we present

it for its p edagogical utility

First we put ourselves in the C package

setq syspackagecolon C

Representation

A complex C is represented by its real part r c and its complex part i c

defstruct C r i

To test the typ e C

defun complexp c eq C typeof c

To construct aib ab

defun makecomplex a b

if b

a

let c make

i c b

r c a

c

The pure complex numb er ii

defvar i makecomplex

IO for C

By convention aib is written bia

A COMPLEX MINIEXTENSION OF GENERIC ARITHMETIC

defun prin c

prin i c i r c

To b e able to reread these complex numb ers

dmc

let j r

setq j read the imaginary part

with typecn i csep read

readcn read i

readcn read the

setq r read read the real part

readcn read the

makecomplex r j

Complex arithmetic

The comparison is only dened in the case of equality

defun a b

if and complexp b i a i b r a r b

error

complex comparison undefined

list a b

Binary addition

defun c r

if complexp r

makecomplex r c r r i c i r

makecomplex r r c i c

Extension of to xed and oatingp oint values

defun fix r c c r rc cr

defun float r c c r

Binary subtraction

defun c r c r cr cr

Extension of to xedp oint and oatingp oint values

defun fix r c r c

defun float r c r c Unary negation

CHAPTER RATIONAL AND COMPLEX ARITHMETIC

defun c makecomplex r c i c

Binary multiplication

defun c r

if complexp r

makecomplex r c r r i c i r

r c i r i c r r

makecomplex r r c r i c

Extension of to xed and oatingp oint values

defun fix r c c r rc cr

defun float r c c r

Binary division

defun a b a b

Extension of to xed and oatingp oint values

defun fix r c r c

defun float r c r c

Unary multiplicative inverse aib amibm with maabb

defun c

makecomplex r c i c module c

defun fix r float r

Compute the square of the mo dulus of c

defun module c

i c i c r c r c

Compute the mo dulus of c

defun abs c if zerop r c abs i c sqrt module c

exp log and sqrt functions

expaib expbsinaicosa

defun exp c

makecomplex cos i c sin i c exp r c

The numb er pi

A COMPLEX MINIEXTENSION OF GENERIC ARITHMETIC

defvar pi atan

logreitheta logritheta

The definition that follows is mathematically false

to simplify things

defun log c

makecomplex log abs c

if r c

pi

atan i c r c

To extend the log function to negative xedp oint values

defun fixlog r

selectq r

log float r

makecomplex log r pi

Extension to oats

defun floatlog r log r

sqrt c c elogc

defun sqrt c exp log c

To extend the sqrt function to negative xedp oint and oatingp oint values

defun fixsqrt r

selectq r

sqrt float r

makecomplex sqrt r

defun floatsqrt r fixsqrt r

CHAPTER RATIONAL AND COMPLEX ARITHMETIC

Table of contents

Rational and complex arithmetic

Rationals le Q

Rational numb er IO

Tests for typ e

Generic rational arithmetic

Functions limited to Z

Functions limited to rational arguments limited to Q

Two examples

Complex numb ers the eld C

Complex numb er IO

Tests for typ e

Complex generic arithmetic

Functions limited to the complex numb ers limited to C

Polar co ordinates

Hyp erb olic functions

A complex miniextension of generic arithmetic

Representation

IO for C

Complex arithmetic

exp log and sqrt functions

Table of Contents

Function Index

ratio feature

q feature

complex feature

precision n function with an optional argument

rationalp q function with one argument

integerp z function with one argument

gcd z z function with a variable number of arguments

1 n

pgcd z z function with two arguments

even z function with one argument

fact n function with one argument

fib n function with one argument

numerator f function with one argument

denominator f function with one argument

n m function with two arguments

macro character

C macro

complexp c function with one argument

realp r function with one argument

makecomplex c i function with two arguments

realpart c function with one argument

imagpart c function with one argument

conjugate c function with one argument

phase c function with one argument

signum c function with one argument

cis r function with one argument

sinh z function with one argument

FUNCTION INDEX

cosh z function with one argument

tanh z function with one argument

asinh z function with one argument

acosh z function with one argument

atanh z function with one argument

Chapter

Debugging to ols

This chapter describ es several utilities written in LISP that make it easier to debug your LISP

programs They are automatically loaded the rst time they are called They include to ols

supp orting stepbystep execution of co de program tracing and an insp ection lo op which allows

the environment to b e examined on the o ccurrence of errors All these to ols use the virtual multiple

windows if they are available

debug feature

This feature indicates whether the debugging to ols are loaded into memory

debugend function with no arguments

Recovers memory that was b eing used by the debugging to ols It also removes the debug feature

from the environment Each debugging function will b e loaded anew the next time it is called

Tracing

Recall that it is p ossible to trace all the internal calls to the eval function during the execution

of a program by using the traceval function See the description of this function This is useful

for understanding the internal b ehavior of the evaluator but not very handy for debugging larger

programs b ecause it provides to o much information for that purp ose

Therefore it is also p ossible to trace calls to any function A trace prints certain information the

user has selected at the entry and the exit of a function The printing can b e controlled by a LISP

expression which is evaluated when the evaluator enters and exits the function

It is also p ossible to conditionally enter an insp ection lo op at the entry of a function As a nal

p ossibility you can redirect the output of the trace by assigning a channel to the traceoutput

global variable

Stepping functions

CHAPTER DEBUGGING TOOLS

trace trace ::: trace special form

n

Traces the functions describ ed by arguments trace ::: trace These arguments are not evaluated

n

They are either function names or lists which have function names in their cars The former kind of

argument activates a standard trace on the given function The latter form lets the caller give trace

parameters for the function involved forms to b e evaluated on function entry and exit conditional

trace p oints and conditional breakp oints These trace parameters are descib ed in section

trace returns a list of all the functions aected

untrace sym ::: sym special form

n

Disables tracing on functions named by the symb ols sym ::: sym These names are not evaluated

n

If no argument is given that is if the call was untrace all current traces will b e disabled

untrace returns a list of the functions aected

Trace parameters

The standard trace on a function prints the following information

 Up on entering the function its name and the names and values of its parameters

 Just b efore exiting the function its name followed by the value it returns

List arguments to trace must have the following form

fn par ::: par

n

where fn is the name of the function to trace and par ::: par are the parameters

n

The parameters recognized by the trace function are

 when e conditional trace

 break e conditional breakp oint

 step e conditional switch into stepwise execution mo de

 entry e ::: e sets LISP forms to evaluate up on function entry

m

 exit e ::: e sets LISP forms to evaluate up on function exit

m

The when parameter is a LISP form which is evaluated at function entry and exit If the evaluation

of this form results in the other trace conditions break step entry and exit are ignored

The break parameter is a LISP form which is evaluated at function entry If the evaluation do es

not result in an inspection loop is activated at the function entry p oint See the break function

describ ed in section Note that the break parameter is evaluated after the when parameter

The breakp oint is created only when b oth the when and break parameters are true

The step parameter is a LISP form which is evaluated after the break parameter but b efore the

b o dy of the function b eing traced If its value is dierent than the b o dy of the function is

evaluated in stepwise execution mo de See the step function describ ed in section Otherwise

TRACING

the b o dy of the function is evaluated normally The step parameter is only evaluated when the

when parameter is true

All the op erations which are activated upon entry into a function are done after variable bindings

have b een done All the op erations which happ en upon exit from a function are done after the

evaluation of the last form in the function in the environment of the function In addition as the

evaluator exits the function the variable tracevalue will contain the value that the function

will return and it can b e used for examining or printing this value

If some values are not furnished in a call to trace they take on the values they would have in a

standard trace They are dened as follows for a twoargument function called foo

trace foo when t nonconditional trace always active

break no breakpoints created

step execute normally not in step mode

entry print foo x x y y

exit print foo tracevalue

Trace global variables

tracea rg variable

tracea rg variable

tracea rg variable

The values of these variables are only meaningful during the evaluation of when break entry and

exit parameters of a compiled traced function which can b e a predened compiled function or a

function compiled by the user

Their values dep end up on the typ e of the traced function as follows

 For subr functions none of these values are meaningful

 For subr functions tracearg contains the value of the functions rst argument

 For subr functions tracearg and tracearg contain the values of the functions

rst and second arguments resp ectively

 For subr functions tracearg tracearg and tracearg contain the values of

the functions rst second and third arguments resp ectively

 For subrn functions tracearg contains the list of values of all the functions arguments

 For fsubr msubr and dmsubr functions tracearg contains the list of the functions

nonevaluated arguments

The use of these variables in trace parameters can result in a very negrained trace of compiled functions

CHAPTER DEBUGGING TOOLS

Here are some examples of their use

 Breakp oint on car when the arguments value is a numb er

trace car when numberp tracearg break t

 Trace putprop when the value of the third argument is

trace putprop when null tracearg

 Trace calls to list with seven arguments

trace list when length tracearg

 Trace all the setqs on the variable foo

trace setq when eq car tracearg foo

Perverse eects can result from using the trace functions The following call reverses the argument

order of all calls to the cons function

trace cons

entry psetq tracearg tracearg

tracearg tracearg

tracev alu e variable

This variable contains the last value returned by a traced function This value is only meaningful

inside forms asso ciated with trace exit parameters

tracen ot in tr ac ef lag variable

This variable has the value during the evaluation of trace parameters and t at other times It

is used by the tracer as a supplementary condition on function tracing Functions are not actually

traced unless this variable has the value This enables traced functions to b e used in the

evaluation of trace parameters without sending the evaluator into an innite lo op For example

the print function can b e traced even though it is b eing used to print trace messages

Here is an example of a trace of the print function Follow it carefullywe are also tracing

toplevels calls to print print eval read

trace print

print print

print

print print

print

print

print

print

print

TRACING

untrace

print

tracet rac e variable

This variable contains the list of all the functions b eing traced at a given moment

Example of trace use

We repro duce here a LELISP session illustrating the use of the tracer

Switch into debug mode debug t

t

defun rv s res

if null s

res

rv cdr s cons car s res

rv

A normal try without tracing rv

Standard tracing trace rv

rv rv

rv s res

rv s res

rv s res

rv s res

rv

rv

rv

rv

Pick some information to be printed upon function entry and exit trace rv entry

print rv res res

exit print rv returns tracevalue

rv entry print rv res res exit print rv returns tracevalue rv

rv res

rv res

rv res

rv res

rv returns

rv returns

rv returns

rv returns

CHAPTER DEBUGGING TOOLS

Trace conditional ly trace rv when length s

rv when length s rv

rv s res

rv s res

rv

rv

Invoke an inspection loop on a condition trace rv break null s

rv break null s rv

rv s res

rv s res

rv s res

rv s res

rv break tracebreak

defun rv s res

if null s res rv cdr s cons car s res

v

s

res

r

rv

rv

rv

rv

Use stepwise execution mode trace rv step length s

rv step length s rv

rv s res

rv s res

rv s res

if null s res rv cdr s cons res step return

null s step return

s step return

rv cdr s cons car s res step return

cdr s step return

s step return

cons car s res step

BREAK AND DEBUG MODE

rv s res

if null s res rv cdr s cons res step

rv

rv

rv

rv

Suppress tracing untrace rv

rv Redirect the trace output de foo x car

foo trace foo

foo let traceoutput openo see

protect foo

close traceoutput

cat see

foo x

foo

t foo

foo x

foo

Break and debug mo de

When an error is raised a message is printed and the environment is restored which results in

the reinitialization of all the dynamic ob jects Sometimes however it is preferable to stay in the

environment which raised the error to examine the variables or the stack as they were when the

error was raised This is accomplished by switching to debug mo de

debug s special form

If the argument s which is not evaluated is equal to t debug mo de is globally activated If the

argument is debug mo de is globally deactivated If the argument s is an expression the debug

mo de will b e activated only during the evaluation of this expression debug returns the value of

the evaluation of s as its value This incidentally allows any Lisp expression to b e submitted to the

debug statement as an argument for debugging

break function with no arguments

Outside debug mo de this function just causes a return to the LISP toplevel by calling the err

function See the explanation of the err function In debug mo de it activates an inspection loop

in its dynamic call environment The insp ection lo op is recognizable by its prompt One can

CHAPTER DEBUGGING TOOLS

return to the LISP toplevel from the insp ection lo op by evaluating exit break or using the

shorthand t break is systematically called by the standard errorhandling function syserror In

debug mo de therefore all user errors send the evaluator into an insp ection lo op

If a new error is raised in the insp ection lo op break will only b e called recursively if the form debug

t was evaluated from within the rst insp ection lo op In this case the prompt will indicate the

numb er of active emb edded calls to break

Insp ection or debug lo op

An insp ection or debug lo op is a readevalprint lo op which runs in a functions lo cal

environment It is created in debug mo de by a call to the break function that is when an error a

breakp oint see the trace function or an explicit user call to the function o ccurs An insp ection

lo op can b e recognized by its prompt >

An insp ection lo op can b e terminated by returning to the Lisp toplevel or by continuing the

interrupted computation

When a debug lo op starts executing the name of the function b eing called it is printed on the

screen and if p ossible the section of the function currently b eing evaluated is highlighted This

op eration uses the tyattrib function

In a debug lo op any LISP function whatso ever can b e evaluated just like at the system toplevel

The expression evaluation takes place however in the lo cal environment of the function which

called the lo op It is therefore p ossible to examine the values of the functions parameters In

addition a numb er of commands let the environments of calls waiting on the stack b e pushed or

p opp ed so parameters and lo cal variables of all the waiting functions can b e examined

The stack insp ection commands take the form of characters to b e typ ed at the b eginning of a line

If a LISP form which b egins with a command character is to b e evaluated it must b e preceded by

the space character

The debug or insp ection lo op commands are

 v Print the current functions lo cal variables

 e Print the full error message of the error that raised the debug lo op

 dot or p erio d Print the current function

 Pop a function call o the stack

 Push the current function back onto the stack

 history Print the rst few function calls b eginning with the current one The numb er of

levels printed is the value of the systemstackdepth global variable

 H Print all susp ended function calls

 quit Leave the debug lo op

 top Return immmediately to the LISP top level

BREAK AND DEBUG MODE

 r Continue the program which caused the debug lo op to b e activated This function provides

a way to continue evaluation after a breakp oint and to correct the undened variable errudv

and undened function errudf errors

 z Continue a function stopp ed at a breakp oint in stepwise execution mo de

 Print this list of debug lo op commands

Those commands which terminate the debug lo op also restore the stack context by pushing function

contexts which may have b een p opp ed b efore continuing execution

Switch to global debug mode debug t

t Dene an incorrect function defun foo x

if x

lisp

cons x x foo x

foo Try the function foo

cons wrong number of arguments

ds cons subr

defun foo x

if x lisp cons x x foo x

The function was printed with the faulty part cons underlined cons requires two

arguments Return to the top level

t

Correct the function defun foo x

if x

lisp

mcons x x foo x

de function redefined foo

foo foo

eval undefined function lisp

defun foo x

if x lisp mcons x x foo x

The part that caused the error lisp is highlighted

Now examine the local variables

v

x

Evaluate some lisp forms

x

mcons x x

CHAPTER DEBUGGING TOOLS

Print a history trace of the function calls on the stack

h

stack foo

stack foo

stack foo

stack foo

List of the available debug comands

v show variables

h print top of stack

h print complete stack

e show error message

show current stack frame

down stack

up stack

t back to toplevel

q exit inspection loop

r resume

z step traced functions

list commands

Pop a function call

defun foo x

if x lisp mcons x x foo x

x equals in this environment

v

x

Push the call back on the stack

defun foo x

if x lisp mcons x x foo x

Continue the computation by correcting the undefined function

r

function list

The function foo must be corrected defun foo x

if x

list

mcons x x foo x

de function redefined foo

foo foo

Set a conditional break point trace foo break x

foo break x foo

BREAK AND DEBUG MODE

foo x

foo x

foo x

foo x

foo x

foo x

foo break tracebreak

defun foo x

if x list mcons x x foo x

v

x

Lets modify foos parameter

setq x

Continue the computation

r

foo x

foo x

foo x

foo x

foo break tracebreak

defun foo x

if x list mcons x x foo x

We are at the breakpoint again

finish the computation

r

foo

foo

foo

foo

foo

foo

foo

foo

foo

foo

Debug mo de functions

The functions describ ed in this section may b e useful to users who want to extend the debug mo de

functionality

CHAPTER DEBUGGING TOOLS

printsta ck n s function with one or two optional arguments

Prints a visual representation of the last n levels of the Lisp dynamic execution stack or the whole

stack if n is not furnished If the s argument is given it must b e a list returned by the cstack

function Such a list represents a LISP stack state and it is the contents of this list and not the

current state of the stack that would b e printed if s were present in the call

debugco mma nd cn function with one argument

The cn argument is an internal character co de This function executes the debug lo op command

asso ciated with this character

system sta ck de pt h variable

The value of this variable is a numb er that indicates the numb er of stack levels that the h debug

lo op command will print Its initial value is This variable is ignored by the H command which

prints the entire stack contents

system deb ug li ne variable

This variable provides a way to limit the numb er of lines printed by the debug lo op information

messages Its value is the maximum numb er of lines to b e printed and its initial value is This

variable is particularly useful for limiting the printing of functions which have caused errors

Stepwise execution

Singlestep mo de lets the user stop at each internal evaluator call During these halts dynamic

ob jects can b e examined and the dynamic b ehavior of a program can thus b e followed very closely

As in the case of tracing you can redirect the display of stepwise execution by means of the

traceoutput variable It is also p ossible to read the stepwise commands by assigning a channel

op ened as input to the traceinput global variable

Warning The current implementation of this feature do es not allow the evaluator to b e stopp ed

during the evaluation of nobind functions

In order to implement this incremental execution feature the system invokes the stepeval

programmable interrupt with the form to evaluate as its argument at each internal call to the

evaluator

Here are the various actions p ossible at each pause

 return Continue the stepwise evaluation one step at a time

 < Evaluate the current expression without stopping at each step and then continue in single

step mo de after the evaluation is done

 q Quit singlestep mo de and return the value of the expression that launched it

STEPWISE EXECUTION

 Activate a debug insp ection lo op in which all the debug lo op commands are available

Return to singlestep mo de by typing the I command in the debug lo op

 h Print a history of the susp ended evaluations

 Print an abbreviated command list

step s special form

Evaluate the expression s in singlestep mo de step returns the value of the evaluation of s

unstep s ::: s special form

n

Susp end singlestep mo de during the evaluation of the expressions s ::: s and return the value

n

of s

n

Change global ly into debug mode debug t

t defun f n

if n

f n n

f

step f

step

if n f n step return

n step return

n step return

step return

f n n step return

f n step return

n step return

n step return

if n f n step return

n step return

n step return

step return

f n n step

The singlestep mode commands are

CHAPTER DEBUGGING TOOLS

CR go to next expression

see current expression

evaluate without step and come back

q return to toplevel

h view history

this message

f n n step h

if n f n n

f n n

f n

if n f n n

f n n

f n n step

step break f n n

defun f n

if n f n n

v

n

h

stack f

stack f

r

f n n step return

f n step

n step return

n step return

Table of contents

Debugging to ols

Tracing ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::

Stepping functions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Trace parameters ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Trace global variables ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Example of trace use ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Break and debug mo de ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

Insp ection or debug lo op ::::::::::::::::::::::::::::::::::::::::::::::::

Debug mo de functions :::::::::::::::::::::::::::::::::::::::::::::::::::

Stepwise execution ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Table of Contents

Function Index

debug feature ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::

debugend function with no arguments :::::::::::::::::::::::::::::::::::::::::::::

trace trace ::: trace special form :::::::::::::::::::::::::::::::::::::::::::

n

untrace sym ::: sym special form :::::::::::::::::::::::::::::::::::::::::::::

n

tracearg variable ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::

tracearg variable ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::

tracearg variable ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::

tracevalue variable ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

tracenotintraceflag variable ::::::::::::::::::::::::::::::::::::::::::::

tracetrace variable ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

debug s special form ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::

break function with no arguments :::::::::::::::::::::::::::::::::::::::::::::::::

printstack n s function with one or two optional arguments ::::::::::::::::::::::::

debugcommand cn function with one argument ::::::::::::::::::::::::::::::::::::

systemstackdepth variable ::::::::::::::::::::::::::::::::::::::::::::::::::

systemdebugline variable :::::::::::::::::::::::::::::::::::::::::::::::::::

step s special form ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::

unstep s ::: s special form :::::::::::::::::::::::::::::::::::::::::::::::::::

n

Chapter

Loaderassembler LLM

The heart of the LELISP system is written in the LLM virtual machine language Chailloux b

This language is available in LISP It is used by the various LELISP compilers but can also b e used

to write new standard functions or to write compilers for languages other than LISP This chapter

describ es the functions that provide access to internal machine resources and the syntax used by

the LLM loaderassembler often called lap for Lisp Assembly Program

Access to memory and the CPU

Functions provided in this section allow you to directly access memory and the cpu The

LLM loaderassembler uses a sp ecial memory zone called the code zone to load and store

instructions The following functions are obviously machinedep endent and are used to build the

LLM loaderassembler

These functions are designed to op erate on all p ossible memory addresses for all machine

architectures Since LELISP integers are bits long they cannot always represent memory

addresses A memory addressreferred to as addr throughout this chapteris therefore

represented in LISP in one of two p ossible ways

 By a bit numb er with an extended sign to represent a complete bit address

 By a cons of two numb ers of the form high low The car high contains the high

order bits of the address The cdr low contains the loworder bits

The address fc is stored as f c

ffff ffff

ffff ffff

ffff

The functions that follow test the validity of memory addresstyp e arguments They can raise the

errdna error which has the following default screen display

CHAPTER LOADERASSEMBLER LLM

fn bad address s

Here fn is the name of the function called and s is the argument that is not of typ e memory

address

system cc od e addr function with an optional argument

This function readsor writes if the addr argument is giventhe current memory load address

in the co de zone

system ec od e function with no arguments

Reads the last memory address in the co de zone

addadr addr addr function with two arguments

Returns the sum of the two memory addresses addr and addr It allo cates a new cons if its

result must b e represented in the cons form

addadr )

addadr )

addadr )

addadr )

addadr fff )

addadr )

addadr ffff )

addadr ffff )

addadr ffff )

subadr addr addr function with two arguments

Returns the dierence of the two addresses addr and addr It allo cates a new cons if its result

must b e represented in the cons form

subadr )

subadr )

subadr )

subadr )

subadr ffff )

incradr addr n function with two arguments

Adds n to the memory address addr If this address is in the form of a cons incradr physically

mo dies the cons cell

setq addr fffe )

incradr addr )

ACCESS TO MEMORY AND THE CPU

incradr addr )

incradr addr )

incradr addr )

addr )

gtadr addr addr function with two arguments

Returns t if the memory address addr is greater than the address addr and otherwise

setq addr )

gtadr addr )

gtadr addr ) t

gtadr addr )

loc s function with one argument

Provides a way to get the absolute memory address of the LISP ob ject s The memory address of a

LISP ob ject is the p ointer to it This function provides a means of lo cating in memory ob jects that

are created dynamically loc cannot b e describ ed in LISP

loc a b c )

loc a b c )

vag addr function with one argument

This is the inverse of the loc function vag returns the LISP ob ject whose absolute memory address

is supplied as the argument So vag loc s is equivalent to s itself The vag function cannot

b e describ ed in LISP

Warning vag do es not test whether or not addr is the address of a real LISP ob ject and

an erroneous call to this function could raise an error on the host system In particular it is

p ossible to refer to ob jects that have disapp eared

let x loc cons a b

gc

vag x the value of x no longer exists

vag returns a pointer to the

free list of conses

memory addr n function with one or two arguments

memory samples or if the second numeric argument n is provided changes the word of memory

whose address addr is given as its rst argument This function do es no p erform validity checking

and must b e used with the utmost care It returns a numb er representing the value of the memory

word after mo dication if the twoargument form was used This function is limited by the nature

of the host cpu bit or bit words word alignment considerations etc

CHAPTER LOADERASSEMBLER LLM

call addr a a a function with four arguments

The rst argument addr must b e the memory address of a memoryresident subroutine call will

call this subroutine after having loaded the three values a a and a into the LLM accumulators

A A and A resp ectively This call format is used by subrs subrs subrs subrs fsubrs

msubrs and dmsubrs See the section on function calls This function must b e used with care

since it p erforms no tests for the validity of the executed co de

call returns as its value the contents of the A accumulator after the co de b eginning at addr

has b een executed

Warning The co de executed by means of a call statement must end with an LLM return

instruction and load the A register with a LISP value to b e returned by the call function

calln addr l function with two arguments

This function is similar to call but pushes the list of arguments contained in l onto the

stack b efore calling the subroutine stored at memory address addr The numb er of arguments

pushed will b e available in the A accumulator This is the form that nsubrs take See the

section on function calls

Warning The co de invoked by means of calln must remove its arguments from the stack

using the numb er of arguments value stored in A and for example the LLM adjstk

instruction terminate with the LLM return instruction and load the A register with a

LISP value to b e returned by the calln function

LLM memory loader

loader feature

This feature indicates whether the LLM loaderassembler is currently in memory

loader l i function with two arguments

The loader function loads the list of LLM instructions l into memory The format of these

instructions is describ ed in the next section If the indicator i is true the loader will print in

the host machine language the assembly listing of these instructions on the current output stream

loader returns as its value

ldspec ial c ase l oad er variable

The pseudoinstruction fentry changes the functional value of functions during loading In

certain dicult b o otstrapping cases loading the loader itself for example functional values

must b e resolved at the end of the load when the pseudoinstruction end is encountered The

ldspecialcaseloader variable is t in these sp ecial cases but by default

LLM INSTRUCTION FORMAT

ldshar ed st rin gs variable

This variable indicates whether character string constants should b e shared during the loading of

LLM instructions

LLM instruction format

A list of LLM instructions contains atoms representing the lab els and lists representing the

instructions An instruction is itself a list of the form

codop op ::: op

n

where codop is the instruction mnemonic and op ::: op are the op erands Only the codop eld

n

is obligatory

Mo dules and lab els

A mo dule is a set of lists of instructions b eginning with the title pseudoinstruction and ending

with the end pseudoinstruction

There are three typ es of lab els

Lab els lo cal to a list of instructions

Lab els lo cal to a mo dule

Global lab els

Labels local to a list of instructions are represented by integers or by symb ols declared using the

local pseudoinstruction A symb olic lab el which is lo cal to a list of instructions must b e declared

b efore it is used These lab els must b e resolved b efore the end of the list of instructions or when the

endl pseudoinstruction is encountered All references to this kind of lab el generate jumps relative

to the program counter

Labels local to a module are always symb olic They are dened using the entry pseudoinstruction

They can b e undened at incremental calls to the loader but must b e resolved when the end

pseudoinstruction is encountered All references to this kind of lab el generate jumps relative to

the program counter

Global labels are also always symb olic They are dened using the fentry pseudoinstruction All

references to this typ e of lab el generate an access to the functional value of the symb ol All the

standard functions are of this typ e

CHAPTER LOADERASSEMBLER LLM

LLM instruction op erands

LLM has four typ es of op erands

Registers accumulators

LISP ob ject immediate values

LISP ob ject elds

Lab els

a LLM operand

a LLM operand

a LLM operand

a LLM operand

These four op erands represent the registers accumulators of the LLM machine

nil LLM operand

This op erand represents the sp ecial null symb ol which is used as the endoflist marker and as

the b o olean false value

quote exp LLM operand

This op erand represents a LELISP constant of any typ e

car accu LLM operand

cdr accu LLM operand

These op erands represent access to the constituents of a list element

cval accu LLM operand

plist accu LLM operand

fval accu LLM operand

LLM INSTRUCTION OPERANDS

pkgc accu LLM operand

oval accu LLM operand

alink accu LLM operand

pname accu LLM operand

These op erands represent access to the various constituents of a symb ol

cvalq symb LLM operand

This op erand gives direct access to the value of the symb ol named symb considered as a variable

that is its cval

fvalq symb LLM operand

This op erand gives direct access to the value of the symb ol named symb considered as a function

that is its fval

typ accu LLM operand

val accu LLM operand

These op erands represent access to constituents of ob jects of typ e character string or vector of

Sexpressions

n LLM operand

th

This op erand represents the n element on the stack The top element of the stack is represented

by the nexttotop element by and so on

lab LLM operand

This op erand refers to a lab el which is lo cal to a list of instructions or to a mo dule

lab LLM operand

This op erand represents the address of an LLM lab el This lab el is either lo cal to a list of

instructions or to a mo dule

eval expr LLM operand

CHAPTER LOADERASSEMBLER LLM

This op erand dynamically calls the LELISP evaluator on the expression expr The value returned

by the evaluation of an eval op erand must b e a legal LLM op erand

Pseudoinstructions

title symb LLM pseudoinstruction

Declares the name of a mo dule Inside a mo dule title app ears as the rst instruction

local symb LLM pseudoinstruction

local provides a way to declare a lab el lo cal to a list of instructions By default numeric lab els

are always lo cal and symb olic lab els are always global

fentry symb ftype LLM pseudoinstruction

The symb argument is the name of the LISP symb ol that will have a global function of typ e subr

written in LLM as its function value ftype must b e one of the following LELISP functional typ es

subr subr subr subr nsubr fsubr msubr or dmsubr

entry symb ftype LLM pseudoinstruction

The symb argument is the name of the LISP symb ol that will have a lo cal function of typ e subr

written in LLM as its function value ftype is one of the following LELISP functional typ es subr

subr subr subr nsubr fsubr msubr ou dmsubr After loading this function is no longer

accessible

endl LLM pseudoinstruction

Terminates the loading of a lo cal function All lo cal lab els must b e resolved at this p oint and are

then discarded

end LLM pseudoinstruction

Terminates the loading of a mo dule

eval e LLM pseudoinstruction

Evaluates the expression e within the context of the loader It loads nothing into memory unless

explicitly instructed to do so

BASIC INSTRUCTIONS

Basic instructions

Moving p ointers

Along with the mov instruction which provides a means to move any p ointer to a LISP ob ject there

are other sp ecialized instructions for moving p ointers or bytes in the heap storage or on the stack

mov op op LLM instruction

Moves the p ointer contained in the source op erand op to the destination op erand op The

destination op erand cannot b e an immediate value

Pointer comparisons

cabeq op op lab LLM instruction

Performs a p ointer comparison If the op erand op is equal to the op erand op a branch will o ccur

to the lo cal lab el lab

cabne op op lab LLM instruction

Like cabeq cabne do es a p ointer comparison If the op erand op is not equal to the op erand op

a branch will o ccur to the lo cal lab el lab

Control

bra lab LLM instruction

Branches to the lo cal lab el lab which must b e within the LLM mo dule The branch is done relative

to the program counter

jmp symb LLM instruction

Jumps to the address of the functional value asso ciated with the symb ol symb The branch is an

indirection through the fval of the symb ol symb Jumps to the co de of standard functions are jmps

and not bras

bri op LLM instruction

Branches indirectly to the address contained in the op erand op

brx llab op LLM instruction

Performs an indexed branch through the list of lab els llab op is the zerorelative index used The

list of lab els is a list of op erands of lab elreference typ e that is lab

CHAPTER LOADERASSEMBLER LLM

sobgez op lab LLM instruction

Decrements the op erand op If this op erand is greater than or equal to zero a branch is done to

the lab el lab

nop LLM instruction

Takes up a little space wastes a little time and nally do es nothing visible

Stack

LLM has a single stack for b oth control and data It is used as an implicit op erand in some sp ecial

stackoriented instructions These instructionswhich use the stack p ointer register referred to as

SPdo not require the stack to grow in a sp ecic direction Also they do not require the stack to

have implicit b oundaryoverow tests built in The stack normally o ccupies the space of K ob jects

Management of the stack p ointer

Two instructions provide for the explicit manipulation of the stack p ointer SP

stack op LLM instruction

Moves the current contents of the stack p ointer into the op erand op

sstack op LLM instruction

Moves the op erand op into the stack p ointer

As a control stack

Three instructions provide for the manipulation of return addresses stored on the stack

call lab LLM instruction

Pushes the current program counter onto the top of the stack and branches to the lo cal lab el lab

which must b e in the current LLM mo dule The branch is direct and relative

calli op LLM instruction

Pushes the current program counter onto the top of the stack and branches to the address contained

in the op erand op

jcall symb LLM instruction

STACK

This function is similar to calli but the destination of the branch can b e in another LLM mo dule

The branch is an indirection through the fval of the symb ol symb All the standard function calls

must use jcall and not call

CHAPTER LOADERASSEMBLER LLM

return LLM instruction

Pops the top address o the stack and it b ecomes the new value of the program counter

As a data stack

push op LLM instruction

Pushes the op erand op onto the stack The stack p ointer is mo died as required

pop op LLM instruction

Pops the value on the top of the stack into the op erand op The stack p ointer is mo died as

required

adjstk op LLM instruction

Adjusts the stack p ointer so that the op last ob jects on the stack are p opp ed o If op is negative

then op places are created at the top of the stack

For the next two instructions assume that the index for the top of the stack is zero that the index

for the second element is one that the index for the third element is two and so on

movxsp op op LLM instruction

th

Moves the op erand op into the op p osition on the stack

xspmov op op LLM instruction

th

Moves the ob ject contained in the op stack p osition into the op erand op

List cell cons op erations

Test for list cell typ e

btcons op lab LLM instruction

If the op erand op has typ e list cell then btcons branches to the address lab

bfcons op lab LLM instruction

If the op erand op do es not have typ e list cell then bfcons branches to the address lab

NIL

Access to list cell elds

These op erands are only valid for p ointers to list cells Co de written in LLM has to check that

accu always contains a p ointer to a list cell b efore using these op erands

car accu LLM operand

cdr accu LLM operand

Creation of list cells

There is no sp ecial instruction for this task List cell creation is accomplished by explicitly calling

one of the cons family LELISP functions such as cons ncons or xcons

nil

The nil op erand contains the value of the endoflist indicator This is equivalent to the b o olean

false value

btnil op lab LLM instruction

If the op erand op is equal to nil btnil branches to the address lab

bfnil op lab LLM instruction

If the op erand op is not equal to nil bfnil branches to the address lab

Symb ols

Test for symb ol typ e

btsymb op lab LLM instruction

If the op erand op is a symb ol btsymb branches to the address lab

bfsymb op lab LLM instruction

If the op erand op is not a symb ol bfsymb branches to the address lab

CHAPTER LOADERASSEMBLER LLM

Access to the elds of a symb ol

These op erands are only valid for p ointers to symb ols Co de written in LLM has to check that

accu always contains a p ointer to a symb ol b efore using these op erands

cval accu LLM operand

cvalq symb LLM operand

plist accu LLM operand

fval accu LLM operand

fvalq symb LLM operand

oval accu LLM operand

alink accu LLM operand

pkgc accu LLM operand

pname accu LLM operand

Variables

A variable is a symb ol whose value can b e changed See the function variablep

btvar op lab LLM instruction

If the op erand op is a variable btvar branches to the address lab

bfvar op lab LLM instruction

If the op erand op is not a variable bfvar branches to the address lab

Numb ers

llm uses two typ es of numb ers

NUMBERS

 Integer numb ers of bits

 Floatingp oint numb ers of or bits dep ending on the implementation

bit integer numb ers

Tests for integer typ e

btfix op lab LLM instruction

If the op erand op is an integer btfix branches to the address lab

bffix op lab LLM instruction

If the op erand op is not an integer bffix branches to the address lab

Instructions for numeric calculations

incr op LLM instruction

Performs the integer calculation op ! op

decr op LLM instruction

Performs the integer calculation op ! op

plus op op LLM instruction

Performs the integer calculation op op ! op

diff op op LLM instruction

Performs the integer calculation op op ! op

negate op LLM instruction

Performs the integer calculation op ! op

times op op LLM instruction

Performs the integer calculation op  op ! op

quo op op LLM instruction

Performs the integer calculation op  op ! op

CHAPTER LOADERASSEMBLER LLM

rem op op LLM instruction

Performs the integer calculation op rem op ! op

Instructions for integer numeric comparisons

cnbeq op op lab LLM instruction

Performs an integer numeric comparison If the op erand op is equal to the op erand op a branch

to the lab el lab o ccurs

cnbne op op lab LLM instruction

Performs an integer numeric comparison If the op erand op is not equal to the op erand op a

branch to the lab el lab o ccurs

cnble op op lab LLM instruction

Performs an integer numeric comparison If the op erand op is less than or equal to the op erand

op a branch to the lab el lab o ccurs

cnblt op op lab LLM instruction

Performs an integer numeric comparison If the op erand op is less than the op erand op a branch

to the lab el lab o ccurs

cnbge op op lab LLM instruction

Performs an integer numeric comparison If the op erand op is greater than or equal to the op erand

op a branch to the lab el lab o ccurs

cnbgt op op lab LLM instruction

Performs an integer numeric comparison If the op erand op is greater than the op erand op a

branch to the lab el lab o ccurs

Instructions for p erforming logical op erations

Op erands of these instructions must always b e bit integer values The results of these instructions

are always bit values

land op op LLM instruction

Performs the b o olean calculation op and op ! op

NUMBERS

lor op op LLM instruction

Performs the b o olean calculation op or op ! op

lxor op op LLM instruction

Performs the b o olean calculation op xor op ! op

lshift op op LLM instruction

The op erand op is shifted op bit p ositions and the result is stored in op If op is p ositive a

left shift multiplication is p erformed If it is negative a right shift division is p erformed

Floatingp oint numb ers

Tests for oatingp oint typ e

btfloat op lab LLM instruction

If the op erand op is a oatingp oint numb er btfloat branches to the lab el lab

bffloat op lab LLM instruction

If the op erand op is not a oatingp oint numb er bffloat branches to the lab el lab

Floatingp oi nt calculatio ns

fplus op op LLM instruction

Performs the oatingp oint calculation op op ! op

fdiff op op LLM instruction

Performs the oatingp oint calculation op op ! op

ftimes op op LLM instruction

Performs the oatingp oint calculation op  op ! op

fquo op op LLM instruction

Performs the oatingp oint calculation op  op ! op

CHAPTER LOADERASSEMBLER LLM

Floatingp oi nt comparisons

cfbeq op op lab LLM instruction

Performs a oatingp oint numeric comparison If the op erand op is equal to the op erand op a

branch to the lab el lab o ccurs

cfbne op op lab LLM instruction

Performs a oatingp oint numeric comparison If the op erand op is not equal to the op erand op

a branch to the lab el lab o ccurs

VECTORS OF LISP POINTERS

cfblt op op lab LLM instruction

Performs a oatingp oint numeric comparison If the op erand op is less than the op erand op a

branch to the lab el lab o ccurs

cfble op op lab LLM instruction

Performs a oatingp oint numeric comparison If the op erand op is less than or equal to the

op erand op a branch to the lab el lab o ccurs

cfbgt op op lab LLM instruction

Performs a oatingp oint numeric comparison If the op erand op is greater than the op erand op

a branch to the lab el lab o ccurs

cfbge op op lab LLM instruction

Performs a oatingp oint numeric comparison If the op erand op is greater than or equal to the

op erand op a branch to the lab el lab o ccurs

Vectors of Lisp p ointers

Test for vector of p ointers

btvect op lab LLM instruction

If op is a vector of p ointers then btvect branches to the lab el lab

bfvect op lab LLM instruction

If op is not a vector of p ointers then bfvect branches to the lab el lab

Access to internal elds of a vector of p ointers

val accu LLM operand

This op erand gives access to the heap p ointer of a p ointer

Warning This value cannot reside in a register since the gc could b ecome p erturb ed

typ accu LLM operand

This op erand gives access to the typ e of a vector

CHAPTER LOADERASSEMBLER LLM

Access to elements of a vector of p ointers

hpxmov vect n op LLM instruction

th

Moves the n element of the vector of p ointers vect into the op erand op

hpmovx op vect n LLM instruction

th

Moves the op erand op into the n element of the vector of p ointers vect

Creation

There is no sp ecial insruction for the creation of vectors of p ointers Call the LELISP function

makevector

Character strings

Test for character string

btstrg op lab LLM instruction

If op is a character string btstrg branches to the lab el lab

bfstrg op lab LLM instruction

If op is not a character string bfstrg branches to the lab el lab

Access to the internal elds of a character string

val accu LLM operand

This op erand returns a strings heap p ointer Warning This value cannot reside in a register since

the gc might b e p erturb ed

typ accu LLM operand

This op erand returns the typ e of a string

Access to characters

hbxmov strg index op LLM instruction

th

Moves the index character of the LISP string strg into the op erand op

HEAP ZONE

hbmovx op strg index LLM instruction

th

Moves the op erand op into the index character p osition of the LISP string strg

Creation

There is no sp ecial instruction to create strings Call the LELISP function makestring

Heap zone

hgsize op op LLM instruction

Puts the size of the character string or vector p ointer ob ject op in op erand op

Extending the LoaderAssembler

It is p ossible to extend the syntax of the LLM loaderassembler by dening functions in sp ecial

packages These extensions are by denition machinesp ecic

ldcodop constant

This is the name of the package in which functions asso ciated with extended op co des must reside

lddir constant

This is the name of the package in which functions asso ciated with extended direct op erands must

reside

ldind constant

This is the name of the package in which functions asso ciated with extended indirect op erands

must reside

Functions

Typ es of functions

Functions written in LLM have one of four typ es

subrs which evaluate their arguments

fsubrs which do not evaluate their arguments

CHAPTER LOADERASSEMBLER LLM

msubrs which do not evaluate their arguments

dmsubrs which do not evaluate their arguments

Function calling rules

 In the case of a subr with or arguments referred to as a subr a subr a subr

or a subr arguments are passed in the registers A A and A resp ectively

 In the case of a subr with more than three arguments or with a variable numb er of arguments

referred to as an nsubr the arguments are all pushed onto the stack and the numb er of

arguments is placed in A

 In the case of a fsubr the list of arguments not evaluated that is the cdr of the call is

placed in A

 In the case of a msubr the list of arguments not evaluated that is the call form itself is

placed in A

 In the case of a dmsubr the list of arguments not evaluated that is the cdr of the call is

placed in A

All functions return a value in A

Examples

This section gives short examples of functions written in LLM There is a test le in the test

directory named testlap which contains all the loader tests It is also p ossible to examine the

LLM co de generated by the compilers See the next chapter

These examples were produced on a Vax

Manual translation into lap of the celebrated fib function

defun fiblap n

if le n

add fiblap sub n

fiblap sub n

defvar fiblap

fentry fiblap subr

cnbgt a

mov a

return

diff a

push a

call fiblap

mov a a

pop a

EXAMPLES

push a

diff a

call fiblap

pop a

plus a a

return

loader fiblap t

fentry fiblap subr e

cnbgt a e b

mov a e d

return e

e

diff a e b

push a eb dd

call fiblap ed f

mov a a ef d

pop a f d e

push a f dd

diff a f b

call fiblap f e

pop a fb d e

plus a a fe a

return

endl

fiblap

Manual translation into lap of the dlq function

defun dlq a l

cond not consp l

eq a car l dlq a cdr l

t cons car l dlq a cdr l

defvar llap

fentry dlq subr

btcons a

mov nil a

return

cabne a car a

mov cdr a a

bra dlq

push car a

mov cdr a a

call dlq

mov a a

pop a

jmp cons

llap

loader llap t

fentry dlq subr ec

CHAPTER LOADERASSEMBLER LLM

btcons a ec d a

mov nil a e d

return e

e

cabne a car a e d

mov cdr a a ea d a

bra dlq ee ec

e

push car a e dd

mov cdr a a e d a

call dlq e e

mov a a e d

pop a eb d e

jmp cons ee d c a

endl e

dlq a b a c a b

b c b

This example demonstrates Lisp character string manipulation

The function definition is given below in LeLisp

defun screat x y

let s makestring x

sset s x a

sset s y b

s

defvar llap

fentry screat subr

push a

push a

mov a

mov x a

jcall makestring

hbmovx a a

hbmovx b a

adjstk

return

llap

loader llap t

fentry screat subr e

push a e dd

push a e dd

mov a e d

mov a eb d f

jcall makestring ea d

hbmovx a ea d d ae f

eb a

hbmovx a eb d d e f a

ebe

adjstk ebf c e

return ec

endl ec

EXAMPLES

screat

xxaxbx

This last example demonstrates vector manipulation

invector is similar to the vector function but produces

an inverted list This example also shows the manipulation

of nary functions in llm

defvar llap

fentry invector nsubr

push a

mov a a

mov nil a

jcall makevector

pop a

mov a

bra

pop a

hpmovx a a a

plus a

sobgez a

return

llap

loader llap t

fentry invector nsubr ec

push a ec dd

mov a a ec d

mov nil a ec d

jcall makevector ecc d e

pop a ed d e

mov a ed d

bra ed

ed

pop a ed d e

hpmovx a a a edb d d a

plus a ee b

ee

sobgez a ee b ef

return ee

endl eea

invector

CHAPTER LOADERASSEMBLER LLM

Table of contents

Loaderassembler LLM

Access to memory and the CPU :::::::::::::::::::::::::::::::::::::::::::::::::

LLM memory loader ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

LLM instruction format ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Mo dules and lab els ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::

LLM instruction op erands ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Pseudoinstructions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::

Basic instructions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Moving p ointers ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

Pointer comparisons ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Control ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

Stack ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::

Management of the stack p ointer :::::::::::::::::::::::::::::::::::::::::

As a control stack ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

As a data stack ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

List cell cons op erations ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Test for list cell typ e ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Access to list cell elds :::::::::::::::::::::::::::::::::::::::::::::::::::

Creation of list cells ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

nil ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::

Symb ols ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::

Test for symb ol typ e ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Access to the elds of a symb ol :::::::::::::::::::::::::::::::::::::::::::

Variables ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Numb ers ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

Table of Contents

bit integer numb ers :::::::::::::::::::::::::::::::::::::::::::::::::::

Floatingp oint numb ers ::::::::::::::::::::::::::::::::::::::::::::::::::

Vectors of Lisp p ointers ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

Test for vector of p ointers ::::::::::::::::::::::::::::::::::::::::::::::::

Access to internal elds of a vector of p ointers :::::::::::::::::::::::::::::

Access to elements of a vector of p ointers ::::::::::::::::::::::::::::::::::

Creation ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Character strings ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Test for character string ::::::::::::::::::::::::::::::::::::::::::::::::::

Access to the internal elds of a character string :::::::::::::::::::::::::::

Access to characters ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Creation ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Heap zone ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::

Extending the LoaderAssembler ::::::::::::::::::::::::::::::::::::::::::::::::

Functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::

Typ es of functions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Function calling rules ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Examples ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::

Function Index

systemccode addr function with an optional argument ::::::::::::::::::::::::::

systemecode function with no arguments ::::::::::::::::::::::::::::::::::::::

addadr addr addr function with two arguments :::::::::::::::::::::::::::::::::

subadr addr addr function with two arguments :::::::::::::::::::::::::::::::::

incradr addr n function with two arguments ::::::::::::::::::::::::::::::::::::::

gtadr addr addr function with two arguments :::::::::::::::::::::::::::::::::::

loc s function with one argument :::::::::::::::::::::::::::::::::::::::::::::::::

vag addr function with one argument ::::::::::::::::::::::::::::::::::::::::::::::

memory addr n function with one or two arguments :::::::::::::::::::::::::::::::::

call addr a a a function with four arguments :::::::::::::::::::::::::::::::::

calln addr l function with two arguments ::::::::::::::::::::::::::::::::::::::::

loader feature ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

loader l i function with two arguments ::::::::::::::::::::::::::::::::::::::::::

ldspecialcaseloader variable :::::::::::::::::::::::::::::::::::::::::::::

ldsharedstrings variable :::::::::::::::::::::::::::::::::::::::::::::::::::

a LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

a LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

a LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

a LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

nil LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

quote exp LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

car accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

cdr accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

cval accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

plist accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

fval accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

FUNCTION INDEX

pkgc accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

oval accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

alink accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

pname accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

cvalq symb LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

fvalq symb LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

typ accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

val accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

n LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

lab LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

lab LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

eval expr LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

title symb LLM pseudoinstruction ::::::::::::::::::::::::::::::::::::::::::::::::

local symb LLM pseudoinstruction ::::::::::::::::::::::::::::::::::::::::::::::::

fentry symb ftype LLM pseudoinstruction ::::::::::::::::::::::::::::::::::::::::

entry symb ftype LLM pseudoinstruction :::::::::::::::::::::::::::::::::::::::::

endl LLM pseudoinstruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

end LLM pseudoinstruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

eval e LLM pseudoinstruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :

mov op op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

cabeq op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

cabne op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

bra lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

jmp symb LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

bri op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

brx llab op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

sobgez op lab LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::::

nop LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

stack op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

sstack op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

call lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

calli op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

jcall symb LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

return LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

FUNCTION INDEX

push op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

pop op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

adjstk op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

movxsp op op LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::

xspmov op op LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::

btcons op lab LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::::

bfcons op lab LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::::

car accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

cdr accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

btnil op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :

bfnil op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :

btsymb op lab LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::::

bfsymb op lab LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::::

cval accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

cvalq symb LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

plist accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

fval accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

fvalq symb LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

oval accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

alink accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

pkgc accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

pname accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

btvar op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :

bfvar op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :

btfix op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :

bffix op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :

incr op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

decr op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

plus op op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :

diff op op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :

negate op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

times op op LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::::

quo op op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

rem op op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

FUNCTION INDEX

cnbeq op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

cnbne op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

cnble op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

cnblt op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

cnbge op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

cnbgt op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

land op op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :

lor op op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

lxor op op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :

lshift op op LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::

btfloat op lab LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::

bffloat op lab LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::

fplus op op LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::::

fdiff op op LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::::

ftimes op op LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::

fquo op op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :

cfbeq op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

cfbne op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

cfblt op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

cfble op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

cfbgt op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

cfbge op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

btvect op lab LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::::

bfvect op lab LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::::

val accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

typ accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

hpxmov vect n op LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::

hpmovx op vect n LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::

btstrg op lab LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::::

bfstrg op lab LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::::

val accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

typ accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

hbxmov strg index op LLM instruction :::::::::::::::::::::::::::::::::::::::::::

hbmovx op strg index LLM instruction :::::::::::::::::::::::::::::::::::::::::::

FUNCTION INDEX

hgsize op op LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::

ldcodop constant ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

lddir constant ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::

ldind constant ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::

Chapter

Loaderassembler LLM

The heart of the LELISP system is written in the LLM virtual machine language Chailloux b

This language is available in LISP It is used by the various LELISP compilers but can also b e used

to write new standard functions or to write compilers for languages other than LISP This chapter

describ es the functions that provide access to internal machine resources and the syntax used by

the LLM loaderassembler often called lap for Lisp Assembly Program

Access to memory and the CPU

Functions provided in this section allow you to directly access memory and the cpu The

LLM loaderassembler uses a sp ecial memory zone called the code zone to load and store

instructions The following functions are obviously machinedep endent and are used to build the

LLM loaderassembler

These functions are designed to op erate on all p ossible memory addresses for all machine

architectures Since LELISP integers are bits long they cannot always represent memory

addresses A memory addressreferred to as addr throughout this chapteris therefore

represented in LISP in one of two p ossible ways

 By a bit numb er with an extended sign to represent a complete bit address

 By a cons of two numb ers of the form high low The car high contains the high

order bits of the address The cdr low contains the loworder bits

The address fc is stored as f c

ffff ffff

ffff ffff

ffff

The functions that follow test the validity of memory addresstyp e arguments They can raise the

errdna error which has the following default screen display

CHAPTER LOADERASSEMBLER LLM

fn bad address s

Here fn is the name of the function called and s is the argument that is not of typ e memory

address

system cc od e addr function with an optional argument

This function readsor writes if the addr argument is giventhe current memory load address

in the co de zone

system ec od e function with no arguments

Reads the last memory address in the co de zone

addadr addr addr function with two arguments

Returns the sum of the two memory addresses addr and addr It allo cates a new cons if its

result must b e represented in the cons form

addadr )

addadr )

addadr )

addadr )

addadr fff )

addadr )

addadr ffff )

addadr ffff )

addadr ffff )

subadr addr addr function with two arguments

Returns the dierence of the two addresses addr and addr It allo cates a new cons if its result

must b e represented in the cons form

subadr )

subadr )

subadr )

subadr )

subadr ffff )

incradr addr n function with two arguments

Adds n to the memory address addr If this address is in the form of a cons incradr physically

mo dies the cons cell

setq addr fffe )

incradr addr )

ACCESS TO MEMORY AND THE CPU

incradr addr )

incradr addr )

incradr addr )

addr )

gtadr addr addr function with two arguments

Returns t if the memory address addr is greater than the address addr and otherwise

setq addr )

gtadr addr )

gtadr addr ) t

gtadr addr )

loc s function with one argument

Provides a way to get the absolute memory address of the LISP ob ject s The memory address of a

LISP ob ject is the p ointer to it This function provides a means of lo cating in memory ob jects that

are created dynamically loc cannot b e describ ed in LISP

loc a b c )

loc a b c )

vag addr function with one argument

This is the inverse of the loc function vag returns the LISP ob ject whose absolute memory address

is supplied as the argument So vag loc s is equivalent to s itself The vag function cannot

b e describ ed in LISP

Warning vag do es not test whether or not addr is the address of a real LISP ob ject and

an erroneous call to this function could raise an error on the host system In particular it is

p ossible to refer to ob jects that have disapp eared

let x loc cons a b

gc

vag x the value of x no longer exists

vag returns a pointer to the

free list of conses

memory addr n function with one or two arguments

memory samples or if the second numeric argument n is provided changes the word of memory

whose address addr is given as its rst argument This function do es no p erform validity checking

and must b e used with the utmost care It returns a numb er representing the value of the memory

word after mo dication if the twoargument form was used This function is limited by the nature

of the host cpu bit or bit words word alignment considerations etc

CHAPTER LOADERASSEMBLER LLM

call addr a a a function with four arguments

The rst argument addr must b e the memory address of a memoryresident subroutine call will

call this subroutine after having loaded the three values a a and a into the LLM accumulators

A A and A resp ectively This call format is used by subrs subrs subrs subrs fsubrs

msubrs and dmsubrs See the section on function calls This function must b e used with care

since it p erforms no tests for the validity of the executed co de

call returns as its value the contents of the A accumulator after the co de b eginning at addr

has b een executed

Warning The co de executed by means of a call statement must end with an LLM return

instruction and load the A register with a LISP value to b e returned by the call function

calln addr l function with two arguments

This function is similar to call but pushes the list of arguments contained in l onto the

stack b efore calling the subroutine stored at memory address addr The numb er of arguments

pushed will b e available in the A accumulator This is the form that nsubrs take See the

section on function calls

Warning The co de invoked by means of calln must remove its arguments from the stack

using the numb er of arguments value stored in A and for example the LLM adjstk

instruction terminate with the LLM return instruction and load the A register with a

LISP value to b e returned by the calln function

LLM memory loader

loader feature

This feature indicates whether the LLM loaderassembler is currently in memory

loader l i function with two arguments

The loader function loads the list of LLM instructions l into memory The format of these

instructions is describ ed in the next section If the indicator i is true the loader will print in

the host machine language the assembly listing of these instructions on the current output stream

loader returns as its value

ldspec ial c ase l oad er variable

The pseudoinstruction fentry changes the functional value of functions during loading In

certain dicult b o otstrapping cases loading the loader itself for example functional values

must b e resolved at the end of the load when the pseudoinstruction end is encountered The

ldspecialcaseloader variable is t in these sp ecial cases but by default

LLM INSTRUCTION FORMAT

ldshar ed st rin gs variable

This variable indicates whether character string constants should b e shared during the loading of

LLM instructions

LLM instruction format

A list of LLM instructions contains atoms representing the lab els and lists representing the

instructions An instruction is itself a list of the form

codop op ::: op

n

where codop is the instruction mnemonic and op ::: op are the op erands Only the codop eld

n

is obligatory

Mo dules and lab els

A mo dule is a set of lists of instructions b eginning with the title pseudoinstruction and ending

with the end pseudoinstruction

There are three typ es of lab els

Lab els lo cal to a list of instructions

Lab els lo cal to a mo dule

Global lab els

Labels local to a list of instructions are represented by integers or by symb ols declared using the

local pseudoinstruction A symb olic lab el which is lo cal to a list of instructions must b e declared

b efore it is used These lab els must b e resolved b efore the end of the list of instructions or when the

endl pseudoinstruction is encountered All references to this kind of lab el generate jumps relative

to the program counter

Labels local to a module are always symb olic They are dened using the entry pseudoinstruction

They can b e undened at incremental calls to the loader but must b e resolved when the end

pseudoinstruction is encountered All references to this kind of lab el generate jumps relative to

the program counter

Global labels are also always symb olic They are dened using the fentry pseudoinstruction All

references to this typ e of lab el generate an access to the functional value of the symb ol All the

standard functions are of this typ e

CHAPTER LOADERASSEMBLER LLM

LLM instruction op erands

LLM has four typ es of op erands

Registers accumulators

LISP ob ject immediate values

LISP ob ject elds

Lab els

a LLM operand

a LLM operand

a LLM operand

a LLM operand

These four op erands represent the registers accumulators of the LLM machine

nil LLM operand

This op erand represents the sp ecial null symb ol which is used as the endoflist marker and as

the b o olean false value

quote exp LLM operand

This op erand represents a LELISP constant of any typ e

car accu LLM operand

cdr accu LLM operand

These op erands represent access to the constituents of a list element

cval accu LLM operand

plist accu LLM operand

fval accu LLM operand

LLM INSTRUCTION OPERANDS

pkgc accu LLM operand

oval accu LLM operand

alink accu LLM operand

pname accu LLM operand

These op erands represent access to the various constituents of a symb ol

cvalq symb LLM operand

This op erand gives direct access to the value of the symb ol named symb considered as a variable

that is its cval

fvalq symb LLM operand

This op erand gives direct access to the value of the symb ol named symb considered as a function

that is its fval

typ accu LLM operand

val accu LLM operand

These op erands represent access to constituents of ob jects of typ e character string or vector of

Sexpressions

n LLM operand

th

This op erand represents the n element on the stack The top element of the stack is represented

by the nexttotop element by and so on

lab LLM operand

This op erand refers to a lab el which is lo cal to a list of instructions or to a mo dule

lab LLM operand

This op erand represents the address of an LLM lab el This lab el is either lo cal to a list of

instructions or to a mo dule

eval expr LLM operand

CHAPTER LOADERASSEMBLER LLM

This op erand dynamically calls the LELISP evaluator on the expression expr The value returned

by the evaluation of an eval op erand must b e a legal LLM op erand

Pseudoinstructions

title symb LLM pseudoinstruction

Declares the name of a mo dule Inside a mo dule title app ears as the rst instruction

local symb LLM pseudoinstruction

local provides a way to declare a lab el lo cal to a list of instructions By default numeric lab els

are always lo cal and symb olic lab els are always global

fentry symb ftype LLM pseudoinstruction

The symb argument is the name of the LISP symb ol that will have a global function of typ e subr

written in LLM as its function value ftype must b e one of the following LELISP functional typ es

subr subr subr subr nsubr fsubr msubr or dmsubr

entry symb ftype LLM pseudoinstruction

The symb argument is the name of the LISP symb ol that will have a lo cal function of typ e subr

written in LLM as its function value ftype is one of the following LELISP functional typ es subr

subr subr subr nsubr fsubr msubr ou dmsubr After loading this function is no longer

accessible

endl LLM pseudoinstruction

Terminates the loading of a lo cal function All lo cal lab els must b e resolved at this p oint and are

then discarded

end LLM pseudoinstruction

Terminates the loading of a mo dule

eval e LLM pseudoinstruction

Evaluates the expression e within the context of the loader It loads nothing into memory unless

explicitly instructed to do so

BASIC INSTRUCTIONS

Basic instructions

Moving p ointers

Along with the mov instruction which provides a means to move any p ointer to a LISP ob ject there

are other sp ecialized instructions for moving p ointers or bytes in the heap storage or on the stack

mov op op LLM instruction

Moves the p ointer contained in the source op erand op to the destination op erand op The

destination op erand cannot b e an immediate value

Pointer comparisons

cabeq op op lab LLM instruction

Performs a p ointer comparison If the op erand op is equal to the op erand op a branch will o ccur

to the lo cal lab el lab

cabne op op lab LLM instruction

Like cabeq cabne do es a p ointer comparison If the op erand op is not equal to the op erand op

a branch will o ccur to the lo cal lab el lab

Control

bra lab LLM instruction

Branches to the lo cal lab el lab which must b e within the LLM mo dule The branch is done relative

to the program counter

jmp symb LLM instruction

Jumps to the address of the functional value asso ciated with the symb ol symb The branch is an

indirection through the fval of the symb ol symb Jumps to the co de of standard functions are jmps

and not bras

bri op LLM instruction

Branches indirectly to the address contained in the op erand op

brx llab op LLM instruction

Performs an indexed branch through the list of lab els llab op is the zerorelative index used The

list of lab els is a list of op erands of lab elreference typ e that is lab

CHAPTER LOADERASSEMBLER LLM

sobgez op lab LLM instruction

Decrements the op erand op If this op erand is greater than or equal to zero a branch is done to

the lab el lab

nop LLM instruction

Takes up a little space wastes a little time and nally do es nothing visible

Stack

LLM has a single stack for b oth control and data It is used as an implicit op erand in some sp ecial

stackoriented instructions These instructionswhich use the stack p ointer register referred to as

SPdo not require the stack to grow in a sp ecic direction Also they do not require the stack to

have implicit b oundaryoverow tests built in The stack normally o ccupies the space of K ob jects

Management of the stack p ointer

Two instructions provide for the explicit manipulation of the stack p ointer SP

stack op LLM instruction

Moves the current contents of the stack p ointer into the op erand op

sstack op LLM instruction

Moves the op erand op into the stack p ointer

As a control stack

Three instructions provide for the manipulation of return addresses stored on the stack

call lab LLM instruction

Pushes the current program counter onto the top of the stack and branches to the lo cal lab el lab

which must b e in the current LLM mo dule The branch is direct and relative

calli op LLM instruction

Pushes the current program counter onto the top of the stack and branches to the address contained

in the op erand op

jcall symb LLM instruction

LIST CELL CONS OPERATIONS

This function is similar to calli but the destination of the branch can b e in another LLM mo dule

The branch is an indirection through the fval of the symb ol symb All the standard function calls

must use jcall and not call

return LLM instruction

Pops the top address o the stack and it b ecomes the new value of the program counter

As a data stack

push op LLM instruction

Pushes the op erand op onto the stack The stack p ointer is mo died as required

pop op LLM instruction

Pops the value on the top of the stack into the op erand op The stack p ointer is mo died as

required

adjstk op LLM instruction

Adjusts the stack p ointer so that the op last ob jects on the stack are p opp ed o If op is negative

then op places are created at the top of the stack

For the next two instructions assume that the index for the top of the stack is zero that the index

for the second element is one that the index for the third element is two and so on

movxsp op op LLM instruction

th

Moves the op erand op into the op p osition on the stack

xspmov op op LLM instruction

th

Moves the ob ject contained in the op stack p osition into the op erand op

List cell cons op erations

Test for list cell typ e

btcons op lab LLM instruction

If the op erand op has typ e list cell then btcons branches to the address lab

CHAPTER LOADERASSEMBLER LLM

bfcons op lab LLM instruction

If the op erand op do es not have typ e list cell then bfcons branches to the address lab

Access to list cell elds

These op erands are only valid for p ointers to list cells Co de written in LLM has to check that

accu always contains a p ointer to a list cell b efore using these op erands

car accu LLM operand

cdr accu LLM operand

Creation of list cells

There is no sp ecial instruction for this task List cell creation is accomplished by explicitly calling

one of the cons family LELISP functions such as cons ncons or xcons

nil

The nil op erand contains the value of the endoflist indicator This is equivalent to the b o olean

false value

btnil op lab LLM instruction

If the op erand op is equal to nil btnil branches to the address lab

bfnil op lab LLM instruction

If the op erand op is not equal to nil bfnil branches to the address lab

Symb ols

Test for symb ol typ e

btsymb op lab LLM instruction

If the op erand op is a symb ol btsymb branches to the address lab

bfsymb op lab LLM instruction

If the op erand op is not a symb ol bfsymb branches to the address lab

NUMBERS

Access to the elds of a symb ol

These op erands are only valid for p ointers to symb ols Co de written in LLM has to check that

accu always contains a p ointer to a symb ol b efore using these op erands

cval accu LLM operand

cvalq symb LLM operand

plist accu LLM operand

fval accu LLM operand

fvalq symb LLM operand

oval accu LLM operand

alink accu LLM operand

pkgc accu LLM operand

pname accu LLM operand

Variables

A variable is a symb ol whose value can b e changed See the function variablep

btvar op lab LLM instruction

If the op erand op is a variable btvar branches to the address lab

bfvar op lab LLM instruction

If the op erand op is not a variable bfvar branches to the address lab

Numb ers

llm uses two typ es of numb ers

CHAPTER LOADERASSEMBLER LLM

 Integer numb ers of bits

 Floatingp oint numb ers of or bits dep ending on the implementation

bit integer numb ers

Tests for integer typ e

btfix op lab LLM instruction

If the op erand op is an integer btfix branches to the address lab

bffix op lab LLM instruction

If the op erand op is not an integer bffix branches to the address lab

Instructions for numeric calculations

incr op LLM instruction

Performs the integer calculation op ! op

decr op LLM instruction

Performs the integer calculation op ! op

plus op op LLM instruction

Performs the integer calculation op op ! op

diff op op LLM instruction

Performs the integer calculation op op ! op

negate op LLM instruction

Performs the integer calculation op ! op

times op op LLM instruction

Performs the integer calculation op  op ! op

quo op op LLM instruction

Performs the integer calculation op  op ! op

NUMBERS

rem op op LLM instruction

Performs the integer calculation op rem op ! op

Instructions for integer numeric comparisons

cnbeq op op lab LLM instruction

Performs an integer numeric comparison If the op erand op is equal to the op erand op a branch

to the lab el lab o ccurs

cnbne op op lab LLM instruction

Performs an integer numeric comparison If the op erand op is not equal to the op erand op a

branch to the lab el lab o ccurs

cnble op op lab LLM instruction

Performs an integer numeric comparison If the op erand op is less than or equal to the op erand

op a branch to the lab el lab o ccurs

cnblt op op lab LLM instruction

Performs an integer numeric comparison If the op erand op is less than the op erand op a branch

to the lab el lab o ccurs

cnbge op op lab LLM instruction

Performs an integer numeric comparison If the op erand op is greater than or equal to the op erand

op a branch to the lab el lab o ccurs

cnbgt op op lab LLM instruction

Performs an integer numeric comparison If the op erand op is greater than the op erand op a

branch to the lab el lab o ccurs

Instructions for p erforming logical op erations

Op erands of these instructions must always b e bit integer values The results of these instructions

are always bit values

land op op LLM instruction

Performs the b o olean calculation op and op ! op

CHAPTER LOADERASSEMBLER LLM

lor op op LLM instruction

Performs the b o olean calculation op or op ! op

lxor op op LLM instruction

Performs the b o olean calculation op xor op ! op

lshift op op LLM instruction

The op erand op is shifted op bit p ositions and the result is stored in op If op is p ositive a

left shift multiplication is p erformed If it is negative a right shift division is p erformed

Floatingp oint numb ers

Tests for oatingp oint typ e

btfloat op lab LLM instruction

If the op erand op is a oatingp oint numb er btfloat branches to the lab el lab

bffloat op lab LLM instruction

If the op erand op is not a oatingp oint numb er bffloat branches to the lab el lab

Floatingp oi nt calculatio ns

fplus op op LLM instruction

Performs the oatingp oint calculation op op ! op

fdiff op op LLM instruction

Performs the oatingp oint calculation op op ! op

ftimes op op LLM instruction

Performs the oatingp oint calculation op  op ! op

fquo op op LLM instruction

Performs the oatingp oint calculation op  op ! op

VECTORS OF LISP POINTERS

Floatingp oi nt comparisons

cfbeq op op lab LLM instruction

Performs a oatingp oint numeric comparison If the op erand op is equal to the op erand op a

branch to the lab el lab o ccurs

cfbne op op lab LLM instruction

Performs a oatingp oint numeric comparison If the op erand op is not equal to the op erand op

a branch to the lab el lab o ccurs

cfblt op op lab LLM instruction

Performs a oatingp oint numeric comparison If the op erand op is less than the op erand op a

branch to the lab el lab o ccurs

cfble op op lab LLM instruction

Performs a oatingp oint numeric comparison If the op erand op is less than or equal to the

op erand op a branch to the lab el lab o ccurs

cfbgt op op lab LLM instruction

Performs a oatingp oint numeric comparison If the op erand op is greater than the op erand op

a branch to the lab el lab o ccurs

cfbge op op lab LLM instruction

Performs a oatingp oint numeric comparison If the op erand op is greater than or equal to the

op erand op a branch to the lab el lab o ccurs

Vectors of Lisp p ointers

Test for vector of p ointers

btvect op lab LLM instruction

If op is a vector of p ointers then btvect branches to the lab el lab

bfvect op lab LLM instruction

If op is not a vector of p ointers then bfvect branches to the lab el lab

CHAPTER LOADERASSEMBLER LLM

Access to internal elds of a vector of p ointers

val accu LLM operand

This op erand gives access to the heap p ointer of a p ointer

Warning This value cannot reside in a register since the gc could b ecome p erturb ed

typ accu LLM operand

This op erand gives access to the typ e of a vector

Access to elements of a vector of p ointers

hpxmov vect n op LLM instruction

th

element of the vector of p ointers vect into the op erand op Moves the n

hpmovx op vect n LLM instruction

th

Moves the op erand op into the n element of the vector of p ointers vect

Creation

There is no sp ecial insruction for the creation of vectors of p ointers Call the LELISP function

makevector

Character strings

Test for character string

btstrg op lab LLM instruction

If op is a character string btstrg branches to the lab el lab

bfstrg op lab LLM instruction

If op is not a character string bfstrg branches to the lab el lab

Access to the internal elds of a character string

val accu LLM operand

HEAP ZONE

This op erand returns a strings heap p ointer Warning This value cannot reside in a register since

the gc might b e p erturb ed

typ accu LLM operand

This op erand returns the typ e of a string

Access to characters

hbxmov strg index op LLM instruction

th

Moves the index character of the LISP string strg into the op erand op

hbmovx op strg index LLM instruction

th

Moves the op erand op into the index character p osition of the LISP string strg

Creation

There is no sp ecial instruction to create strings Call the LELISP function makestring

Heap zone

hgsize op op LLM instruction

Puts the size of the character string or vector p ointer ob ject op in op erand op

Extending the LoaderAssembler

It is p ossible to extend the syntax of the LLM loaderassembler by dening functions in sp ecial

packages These extensions are by denition machinesp ecic

ldcodop constant

This is the name of the package in which functions asso ciated with extended op co des must reside

lddir constant

This is the name of the package in which functions asso ciated with extended direct op erands must

reside

ldind constant

CHAPTER LOADERASSEMBLER LLM

This is the name of the package in which functions asso ciated with extended indirect op erands

must reside

Functions

Typ es of functions

Functions written in LLM have one of four typ es

subrs which evaluate their arguments

fsubrs which do not evaluate their arguments

msubrs which do not evaluate their arguments

dmsubrs which do not evaluate their arguments

Function calling rules

 In the case of a subr with or arguments referred to as a subr a subr a subr

or a subr arguments are passed in the registers A A and A resp ectively

 In the case of a subr with more than three arguments or with a variable numb er of arguments

referred to as an nsubr the arguments are all pushed onto the stack and the numb er of

arguments is placed in A

 In the case of a fsubr the list of arguments not evaluated that is the cdr of the call is

placed in A

 In the case of a msubr the list of arguments not evaluated that is the call form itself is

placed in A

 In the case of a dmsubr the list of arguments not evaluated that is the cdr of the call is

placed in A

All functions return a value in A

Examples

This section gives short examples of functions written in LLM There is a test le in the test

directory named testlap which contains all the loader tests It is also p ossible to examine the

LLM co de generated by the compilers See the next chapter

These examples were produced on a Vax

Manual translation into lap of the celebrated fib function

defun fiblap n

if le n

EXAMPLES

add fiblap sub n

fiblap sub n

defvar fiblap

fentry fiblap subr

cnbgt a

mov a

return

diff a

push a

call fiblap

mov a a

pop a

push a

diff a

call fiblap

pop a

plus a a

return

loader fiblap t

fentry fiblap subr e

cnbgt a e b

mov a e d

return e

e

diff a e b

push a eb dd

call fiblap ed f

mov a a ef d

pop a f d e

push a f dd

diff a f b

call fiblap f e

pop a fb d e

plus a a fe a

return

endl

fiblap

Manual translation into lap of the dlq function

defun dlq a l

cond not consp l

eq a car l dlq a cdr l

t cons car l dlq a cdr l

defvar llap

fentry dlq subr

btcons a

mov nil a

return

CHAPTER LOADERASSEMBLER LLM

cabne a car a

mov cdr a a

bra dlq

push car a

mov cdr a a

call dlq

mov a a

pop a

jmp cons

llap

loader llap t

fentry dlq subr ec

btcons a ec d a

mov nil a e d

return e

e

cabne a car a e d

mov cdr a a ea d a

bra dlq ee ec

e

push car a e dd

mov cdr a a e d a

call dlq e e

mov a a e d

pop a eb d e

jmp cons ee d c a

endl e

dlq a b a c a b

b c b

This example demonstrates Lisp character string manipulation

The function definition is given below in LeLisp

defun screat x y

let s makestring x

sset s x a

sset s y b

s

defvar llap

fentry screat subr

push a

push a

mov a

mov x a

jcall makestring

hbmovx a a

hbmovx b a

adjstk

return

llap

EXAMPLES

loader llap t

fentry screat subr e

push a e dd

push a e dd

mov a e d

mov a eb d f

jcall makestring ea d

hbmovx a ea d d ae f

eb a

hbmovx a eb d d e f a

ebe

adjstk ebf c e

return ec

endl ec

screat

xxaxbx

This last example demonstrates vector manipulation

invector is similar to the vector function but produces

an inverted list This example also shows the manipulation

of nary functions in llm

defvar llap

fentry invector nsubr

push a

mov a a

mov nil a

jcall makevector

pop a

mov a

bra

pop a

hpmovx a a a

plus a

sobgez a

return

llap

loader llap t

fentry invector nsubr ec

push a ec dd

mov a a ec d

mov nil a ec d

jcall makevector ecc d e

pop a ed d e

mov a ed d

bra ed

ed

pop a ed d e

hpmovx a a a edb d d a

plus a ee b

CHAPTER LOADERASSEMBLER LLM

ee

sobgez a ee b ef

return ee

endl eea

invector

Table of contents

Loaderassembler LLM

Access to memory and the CPU :::::::::::::::::::::::::::::::::::::::::::::::::

LLM memory loader ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

LLM instruction format ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Mo dules and lab els ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::

LLM instruction op erands ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Pseudoinstructions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::

Basic instructions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Moving p ointers ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

Pointer comparisons ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Control ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

Stack ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::

Management of the stack p ointer :::::::::::::::::::::::::::::::::::::::::

As a control stack ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

As a data stack ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

List cell cons op erations ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Test for list cell typ e ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Access to list cell elds :::::::::::::::::::::::::::::::::::::::::::::::::::

Creation of list cells ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

nil ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::

Symb ols ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::

Test for symb ol typ e ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Access to the elds of a symb ol :::::::::::::::::::::::::::::::::::::::::::

Variables ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Numb ers ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

Table of Contents

bit integer numb ers :::::::::::::::::::::::::::::::::::::::::::::::::::

Floatingp oint numb ers ::::::::::::::::::::::::::::::::::::::::::::::::::

Vectors of Lisp p ointers ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

Test for vector of p ointers ::::::::::::::::::::::::::::::::::::::::::::::::

Access to internal elds of a vector of p ointers :::::::::::::::::::::::::::::

Access to elements of a vector of p ointers ::::::::::::::::::::::::::::::::::

Creation ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Character strings ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Test for character string ::::::::::::::::::::::::::::::::::::::::::::::::::

Access to the internal elds of a character string :::::::::::::::::::::::::::

Access to characters ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Creation ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Heap zone ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::

Extending the LoaderAssembler ::::::::::::::::::::::::::::::::::::::::::::::::

Functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::

Typ es of functions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Function calling rules ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Examples ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::

Function Index

systemccode addr function with an optional argument ::::::::::::::::::::::::::

systemecode function with no arguments ::::::::::::::::::::::::::::::::::::::

addadr addr addr function with two arguments :::::::::::::::::::::::::::::::::

subadr addr addr function with two arguments :::::::::::::::::::::::::::::::::

incradr addr n function with two arguments ::::::::::::::::::::::::::::::::::::::

gtadr addr addr function with two arguments :::::::::::::::::::::::::::::::::::

loc s function with one argument :::::::::::::::::::::::::::::::::::::::::::::::::

vag addr function with one argument ::::::::::::::::::::::::::::::::::::::::::::::

memory addr n function with one or two arguments :::::::::::::::::::::::::::::::::

call addr a a a function with four arguments :::::::::::::::::::::::::::::::::

calln addr l function with two arguments ::::::::::::::::::::::::::::::::::::::::

loader feature ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::

loader l i function with two arguments ::::::::::::::::::::::::::::::::::::::::::

ldspecialcaseloader variable :::::::::::::::::::::::::::::::::::::::::::::

ldsharedstrings variable :::::::::::::::::::::::::::::::::::::::::::::::::::

a LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

a LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

a LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

a LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

nil LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

quote exp LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

car accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

cdr accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

cval accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

plist accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

fval accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

FUNCTION INDEX

pkgc accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

oval accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

alink accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

pname accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

cvalq symb LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

fvalq symb LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

typ accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

val accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

n LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

lab LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

lab LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

eval expr LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

title symb LLM pseudoinstruction ::::::::::::::::::::::::::::::::::::::::::::::::

local symb LLM pseudoinstruction ::::::::::::::::::::::::::::::::::::::::::::::::

fentry symb ftype LLM pseudoinstruction ::::::::::::::::::::::::::::::::::::::::

entry symb ftype LLM pseudoinstruction :::::::::::::::::::::::::::::::::::::::::

endl LLM pseudoinstruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

end LLM pseudoinstruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

eval e LLM pseudoinstruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :

mov op op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

cabeq op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

cabne op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

bra lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

jmp symb LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

bri op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

brx llab op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

sobgez op lab LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::::

nop LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

stack op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

sstack op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

call lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

calli op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

jcall symb LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

return LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

FUNCTION INDEX

push op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

pop op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

adjstk op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

movxsp op op LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::

xspmov op op LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::

btcons op lab LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::::

bfcons op lab LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::::

car accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

cdr accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

btnil op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :

bfnil op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :

btsymb op lab LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::::

bfsymb op lab LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::::

cval accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

cvalq symb LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

plist accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

fval accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

fvalq symb LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

oval accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

alink accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

pkgc accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

pname accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

btvar op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :

bfvar op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :

btfix op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :

bffix op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :

incr op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

decr op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

plus op op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :

diff op op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :

negate op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

times op op LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::::

quo op op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

rem op op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

FUNCTION INDEX

cnbeq op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

cnbne op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

cnble op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

cnblt op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

cnbge op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

cnbgt op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

land op op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :

lor op op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

lxor op op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :

lshift op op LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::

btfloat op lab LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::

bffloat op lab LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::

fplus op op LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::::

fdiff op op LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::::

ftimes op op LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::

fquo op op LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::::::: :

cfbeq op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

cfbne op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

cfblt op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

cfble op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

cfbgt op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

cfbge op op lab LLM instruction ::::::::::::::::::::::::::::::::::::::::::::::

btvect op lab LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::::

bfvect op lab LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::::

val accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

typ accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

hpxmov vect n op LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::

hpmovx op vect n LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::

btstrg op lab LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::::

bfstrg op lab LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::::

val accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

typ accu LLM operand ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

hbxmov strg index op LLM instruction :::::::::::::::::::::::::::::::::::::::::::

hbmovx op strg index LLM instruction :::::::::::::::::::::::::::::::::::::::::::

FUNCTION INDEX

hgsize op op LLM instruction :::::::::::::::::::::::::::::::::::::::::::::::::

ldcodop constant ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

lddir constant ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::

ldind constant ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::

Chapter

Compilatio n

This chapter describ es the two compilers available in LELISP version the standard compiler

and the mo dular compiler called COMPLICE They p erform the same function so there is no p oint

in having b oth of them in your LISP system

 The standard compiler is totally compatible with the interpreter In particular it

consistently builds the same dynamic and lexical activation blo cks as the interpreter Its

only limitations are its inability to pro cess selfmo difying programs its failure to raise the

errudv error in the case of undened variables and the fact that it do es not fully implement

the dynamic asp ect of the flet form It is small it has fair p erformance b etween three and

six times faster than the interpreter and it p ermits function denitions to b e moved from

the list zone into the co de zone This can improve the p erformance of garbage collection and

dep ending on the host architecture can also achieve space savings

 The modular compiler COMPLICE pro duces much b etter co de than the standard compiler

It also supp orts separate compilation of mo dules The co de it pro duces is b etween two and

ve times faster than the equivalent standard compiled co de and therefore six to thirty times

faster than interpreted co de but certain precautions have to b e taken These are describ ed

b elow COMPLICE uses a lexical scheme to bind function variables

The two compilers use the same memory loader describ ed in the previous chapter

Calling the compilers

compiler feature

This feature indicates whether one of the compilers is loaded into memory

complice feature

This feature indicates whether the COMPLICE compiler is loaded into memory

compiler source status print loader function with four arguments

CHAPTER COMPILATION

Compiles the function or list of functions referred to as source If status is not a list then all the

functions inside functions in source are compiled In calls to the standard compiler a value of

for status indicates that none of the functions called by functions in source should b e compiled

The print argument is a ag that indicates when set that the list of LLM instructions generated

by the compiler should b e printed on the current output stream loader is a ag that is passed

to the loader status indicates the status of functions used inside source If status is a list it is

taken to b e the list of functions that should not b e compiled during the compilation of the functions

in source

This is not p ossible using the COMPLICE compiler If one the functions in status is a subr the

COMPLICE compiler generates a call to the evaluator when this subr function is called The standard

compiler ignores the o ccurrence of subr functions in status

compile source status print loader special form with one two three or four arguments

This is the fsubr form of the preceding function So none of its arguments is evaluated The

status print and loader arguments are optional with default values of

compile all i nc or e print loader function with zero one or two optional

arguments

Compiles all the functions in the oblist of typ e subr fsurb macro or dmacro The print and

loader ags p erform the same functions here as they do in the compiler function

In LELISP compileallincore could b e dened in the following manner

defun compileallincore flags

let printflag car flags loaderflag cadr flags

First deal with subrsfsubrs if the macros use them

compiler maploblist lambda x

and null getprop x dontcompile

memq or car getprop x resetfn

typefn x

subr fsubr

t

printflag

loaderflag

then all the macros

compiler maploblist lambda x

and null getprop x dontcompile

memq or car getprop x resetfn

typefn x

macro dmacro

t

printflag loaderflag

compilef ile s source object function with two arguments

Compiles all the functions in the le or list of les source and stores the result of the compilation

in the le named object The extension systemlelispextension is automatically added to

the lenames in source that do not already have it The output le ob ject can b e loaded into LISP

by using the classic load loadfile and L functions

The object argument is optiomal in calls to the COMPLICE mo dular compiler By default it is set

to the rst element in the list source In addition COMPLICE adds the systemobjextension

extension to the object lename if it do es not already have it In any case the le should then

b e loaded with the loadobjectfile function

precompi le exp result exp operand special form

When interpreted precompile returns the value of the evaluation of exp and ignores the other

three arguments The compilers assume that result is the result of the compilation of the expression

exp and they load the LLM instructions that it contains After loading result the compiler

executes the expression exp in the compiler environment The operand argument is the LLM

op erand indicating the place where the result can b e found Its default value is A This function

allows precompilers to match the interface that the current compilers present

dontcom pil e exp ::: exp special form

n

Informs the compiler that the functions exp ::: exp should never b e compiled To force one of

n

them to b e compiled use the function compiler explicitly

Compiler macros

Before compilation LISP forms are sub jected to macroexpansion which recognizes not only user

macros functions of macro dmacro msubr or dmsubr typ e but also two new compilersp ecic

kinds of macro functions open macros and closed macros

Some system functions have op en or closed macro denitions Functions that have closed macro

denitions must not b e redened Compiler macro denitions are included in the cpmac le in the

standard library

Closed macros

Closed macros are always expanded during the compilation phase In the case of certain functions

that are implemented in the interpreter in a subr or fsubr form this expansion gives the compiler

an opp ortunity of generating highly ecient co de The mapc function for instance which generatyes

a simple lo op is a subrn in the interpreter and a closed macro in the compiler

Here is a list of the standard closed macros of the compiler

add any atomp catcherror cond

decr defprop desetq err errset

evalwhen every ifn incr letvq

CHAPTER COMPILATION

lognot loop map mapc mapcan

mapcar mapcon mapl maplist mapvector

neq nequal newl newr nextl

null prog psetq return setqq

sub time unless untilexit when

Op en macros

For op en macros to b e expanded during the compilation phase the compileropenp ag must

b e set In the standard implementation the car and cdr primitives are op en compiler macros The

user can use op en denitions for any function at all except those with closed macro denitions

The user who makes such a replacement must verify that the op en macro denition is consistent

with the regular function denition so that compatibility b etween compiled and interpreted co de

is maintained

compile ro pe np variable

This variable indicates whether op en compiler macros should b e expanded When a compiler is

loaded this variable is set by default to t This ag also sp ecies whether access functions to LE

LISP ob ject elds and the lowlevel primitives shoud b e compiled without tests for argument typ es

This a less secure but more ecient executable image

The following functions are aected by this feature

add car cdr comment div

fadd fdiv fmul fsub logand

logor logshift logxor mul objval

packagecell plist rem rplaca rpacd

set slen sref sset sub

symeval vlength vref vset

The generated co de is obviously denser and faster but do es not p erform tests that the interpreter

do es For instance the car function no longer veries that its argument is in fact a list Machine

errors can therefore b e brought ab out by incorrect programs

defun test l

cons car l cdr l

test

defun test l

cons car l cdr l

test

defvar compileropenp t

compileropenp

Here is the direct LLM expansion for car cdr eld access

compile test t t

fentry testsubr

entry test subr

mov cdraa

mov caraa

jmp cons

test

Here are calls to car and cdr functions

defvar compileropenp

compileropenp

compile test t t

fentry testsubr

entry test subr

push a

jcall car

push a

mov a

jcall cdr

mov aa

pop a

adjstk

jmp cons

test

defmacro op en name ::: fval special form

Gives the name function an op en macro denition The arguments to this function follow exactly

the same description as for defmacro

makemac ro op en name fval function with two arguments

This is the subr version fo defmacroopen It is particularly useful for generating op en macro from

programs

macroop enp name function with one argument

Returns a function that has the op en macro denition asso ciated with the name function If name

do es not have an op en macro denition this function returns The op en macro asso ciated with

a function can b e expanded in the following manner

defun expandopen call

let openmacro macroopenp car call

when openmacro

apply openmacro

expandopen

defun second v

vref v

second

defmacroopen second v

CHAPTER COMPILATION

vref v

second

expandopen second

vref

removem acr o ope n name function with one argument

Removes the op en macro denition from the name function

Mo dules

From this p oint on all we have to say concerns COMPLICE exclusively and not the standard compiler

COMPLICE is an optimizing compiler that enables large and complex LISP programs to b e compiled

in a fragmented fashion describ ed as modular

The set of all the les involved in a compilation is referred to as a module The minimum numb er

of les in a mo dule is three They can b e describ ed as follows

 A source file by default with the extension ll contains denitions of LISP functions

and metho ds

 A description file with the extension lm describ es the contents of the mo dule

 An object file with the extension lo is generated by COMPLICE using the two les that

were just mentioned

A typical mo dule contains no more than these three les but there may b e cases in which a mo dule

incorp orates more than a single source le

Description le

Let us create mo dule called mymodule When we say that the name of this future mo dule is

mymodule this means that the description le of this mo dule will b e called mymodulelm In

other words the name of a mo dule can b e dened as the name of its description without the

lm extension

The rst item of information in the mymodulelm le starts with the keyword defmodule followed

by a symb ol that we can cho ose You might think of this defmodule statement as a declaration

of the existence of the mo dule that we are ab out to create This rst line of the mymodulelm le

might read as follows

defmodule mypackage

Here we have chosen the word mypackage b ecause this information relates as we shall see in a

moment to the general theme in LELISP of packages

We now indicate the name of the source le containing the LISP co de that we wish to compile This

is done using the keyword files Supp ose that our le is called mysource In that case the second

line of the le mymodulelm would b e

files mysource

Supp ose that there are functions in mysource that need some of functions contained in an existing

mo dule which we call anothermodule In other words there is another mo dule description le

in the system called anothermodulelm which contains compiled LISP co de that we need within

mymodule We indicate this fact by using the keyword import followed by the name of this outside

mo dule enclosed in parentheses So our mymodulelm description le now reads as follows

defmodule mypackage

files mysource

import anothermodule

In the mo dular context of compilation this use of the import keyword brings us to the allimp ortant

concepts of import and export which can b e thought of as complementary When we state as we

have just done that mymodule needs to imp ort anothermodule we are implying that within this

foreign mo dule called anothermodule there are various functions that we can use in mymodule In

other words mymodule must b e able to refer to these functions that are lo cated within the imp orted

mo dule called anothermodule Now if it is true that there are functions within anothermodule

that can b e referred to in our own mo dule these functions are describ ed from the viewp oint of the

foreign mo dule called anothermo dule as exp orted This means that the creators of anothermodule

said to themselves as it were when they were developing this mo dule Mayb e other p eople might

like to use our function called alpha say So lets exp ort it

Just as the p eople who created anothermodule went to the trouble of making some of their functions

exp ortable we to o should think ab out this question in the case of our construction of mymodule

To indicate the various functions in mymodule that we are prepared to make available to further

mo dules we use the keyword export Supp ose that our functions beta and gamma fall into this

category In that case we would add a fourth line to the mymodulelm description le which would

now read as follows

desmodule mypackage

files mysource

import anothermodule

export beta gamma

We shall explain in a moment why there is a colon b efore the name of the gamma function

Let us step back to the previous line with import keyword We said a moment ago that the creators

of anothermodule exp orted their alpha function which we now intend to use in mymodule This

means then that the le anothermodulelm must contain the following line

export alpha

To summarize then The creators of a mo dule export functions that might b e required in other

mo dules Inversely when you import a foreign mo dule into the one that you are creating you

supp ose that the creators of this outside mo dule have exported the functions that you need for your

own mo dule

CHAPTER COMPILATION

Natually within our le mysource at the base fo mymodule there are no doubt many other

functions b esides the exp orted ones called beta and gamma that we do not wish to make available

to outside mo dules We say that these functions are local to our own mo dule

Keys and values

In the terminology commonly used in the domain of mo dules the various keywords defmodule

files import and export are referred to as keys and the indications that accompany them are

referred to as the corresp onding values of these keys So the general syntactic structure of a mo dule

description le could b e presented in the following manner

key value

::: :::

::: :::

::: :::

key value

n n

The four lines of the mymodulelm description that we have just written might b e thought of

merely as a preface in the sense that COMPLICE during the compilation of mymodule adds further

keyvalue pairs to the le But the user do es not have to b e concerned with theses additonal keys

and values In fact COMPLICE inserts a line just after your preface warning you not to touch

anything b eyond that p oint

As for the preface written by the user it can b e in any layout whatso ever with comments preceded

by a semicolon sign as in LISP The files import and export keys can b e rep eated so long as

the attached value always app ears in the form of a list which could b e empty in certain cases If

keys are rep eated only the last instance is used COMPLICE merely reads this preface but do es not

mo dify it in any way whatso ever

In the rst line that we wrote for the mymodulelm description le we used the word mypackage

defmodule mypackage

What this really means is that is a package called mypackage and that the exp orted function

referred to as gamma with a colon is to b e found in this mypackage package It is as if we had

written the mymodulelm le in the following manner

defmodule anything

files mysource

import anothermodule

export beta mypackagegamma

In other words this title following the keyword defmodule is a convenient means of avoiding to

have to include these explicit package references in the names of exp orted les

In actual fact the solution adopted by most programmers would consist of using one single symb ol

namely mymodule and writing the mymodulelm le in the following manner

defmodule mymodule

files mymodule

import anothermodule

export Beta gamma

Here the symb ol mymodule is used for the name of the mo dule the name of the package and even

the name of the source le

The use of the keys and their values in a mo dule description le can b e summarized as follows

 The rst key is defmodule The asso ciated value must b e a LISP symb ol The sole purp ose of

this name is to b e used as an input package for the remainder of the description le

 The next key files is followed by a list indicating the set of LISP source les containing the

functions of the mo dule Both COMPLICE and the loadmodule function describ ed later on

make use of this files key and its value

 The next key import is followed by a list containing the names of other mo dules that contain

compiled LISP co de required for the execution of the present mo dule The exp orted functions

contained in an imp orted mo dule are used at execution time by the functions contained in

the present mo dule Both COMPLICE and the loadmodule function describ ed later on make

use of this import key and its value

 The next key is export The asso ciated list indicates the exp orted functions in the present

mo dule Ab ove all the names of these exp orted functions will b e known outside the present

mo dule so that other mo dules could imp ort the present mo dule and call up on these exp orted

functions

Structures can b e used to dene several functions serving as lexical sugar enabling you to

avoid having to explicitly indicate the name of each function to b e exp orted To use this

facility use the sp ecial structure structurename notation in the exp orted function

list This form concerns structures dened with defstruct defrecord and deftclass In

the latter case dont forget to make the name of the structure internal inside the tclass

package Only COMPLICE makes use of this export key and its value Heres an example of

source co de in a le named mymodulell

defun myfunct x x

defstruct mystruct a b

defrecord myrecord cd

deftclass mytclass e f

Here is the mo dule description le named mymodulelm

defmodule mymodule

files numodule

export myfunct

structure mystruct

structure myrecord

structure tclassmytclass

CHAPTER COMPILATION

 There is also an include key which exists solely for compatibility with older versions of

COMPLICE It can now b e replaced by the use of the evalwhen function in the source le

This function is describ ed later on in this chapter

 COMPLICE inserts into a mo dule description le for its own needs various internal keys that

do not normally concern the programmer In particular there is a cpenv key that describ es

the exact compilation environnement that would b e transmitted to any other mo dule that

happ ened to imp ort the present one This key and its asso ciated value would play a role if

the creator of the present mo dule were to use the ab ovementioned evalwhen function to

mo dify the compilation environment

As we mentioned earlier on when a mo dule is compiled only these internal keys are mo died

by COMPLICE The socalled preface of the description le concerning the defmodule files

import and export keys emains unchanged by the compilation

Lets lo ok at an example Consider a le fll containing

defun example tmp l

defun tmp l cons car l example l

and a le fll containing

defun example l tmp l

defun tmp l cons car l example l

The mo dule description le for fll is the le mlm containing

defmodule user

files fl

export example

and the mo dule description le for fll si the le mlm containing

defmodule user

files f

export Example

import m

Let us lo ok at an example of the use of mo dules in interpreted form and the compilation of mo dules

We start out by loading the interpreted mo dule m

loadmodule m t

loadmodule load interpreted module m

loadmodule load interpreted module m

m

pretty example

defun example l

tmp l

compilemodule m t

moduleinterpretedlist

m m

Here is an example of the use of a compiled mo dule

loadmodule m t

m

pretty example

ds example subr

pretty tmp

example

Source les

The main comp onents of the mo dule under construction come from one or several les The name

of a source le has by default the extension ll A source le must contain all the data that is

necessary for the successful construction of the desired mo dule Here are several p oints that should

b e kept in mind

 Naturally the source le must contain the denitions of all the functions macros and other

defstruct data structures that are to b e exported These entities will b e made available to

users of the present mo dule and to any other mo dule that imp orts the present mo dule As

we p ointed out earlier on the names of all these entities must app ear in the list that follows

the export keyword in the description le of the present mo dule

 The source le also includes other entities describ ed as local which are used by the exp orted

entities but without b eing made available to the outside world These internal entities can

usually b e compiled more eciently than for exp orted entities since their calling proto cols

are relatively simplied

 Other imp ortant elements in a source le are related to the p ossibiliti es of an interesting

function called evalwhen which we examine in the next section under the general theme

of evaluation This function enables you to control the compilation environment

COMPLICE generates compiled co de for all the functions dened in the les listed under the files

key and only for these les Functions dened in the import or include les never give rise to

co de in the compiled mo dule

The co de pro duced by COMPLICE contains compiled denitions of the exp orted functions of the

mo dule In other words the compiled co de is asso ciated with the LISP symb ol that names each

function The other entities app earing in the source les mentioned after the files keyword give

rise to co de in the compiled mo dule but no symb ols are asso ciated with them

When you load a compiled mo dule by means of the loadmodule function the imp orted mo dules

are loaded rst of all except of course if they have already b een loaded then the compiled

co de of the mo dule is loaded into the zone reserved for compiled co de in the LELISP system The

include les are never loaded by the loadmodule function If you want these les to b e present in

the extension environment of the mo dule which is not generally the case you have to load them

explicitly

CHAPTER COMPILATION

During compilation COMPLICE do es not automatically imp ort mo dules imp orted by imp orted

mo dules The import key is not transitive during the compilation In the same way the compiler

never loads the include les of imp orted mo dules If you want to use the include or import les

of imp orted mo dules you have to list them explicitly under the corresp onding keys of the mo dule

Note that include les are loaded in the order in which they are listed This might b e imp ortant

when these les contain successive the denitions of abbreviations or LISP structures

Ob ject les

The COMPLICE compiler which is used to compile mo dules builds ob ject les which contain LLM

co de in lap form These les always have the value of systemobjextension as their extension

system obj e xte ns ion variable

This variable contains the default extension of LELISP ob ject les

probepat ho file function with one argument

Returns the complete lename of the ob ject le file if it is found in the systempath directory

list If the mo dule is not found there probepatho returns

In LELISP probepatho could b e dened in the following manner

defun probepatho mod

searchinpath

systempath

catenate mod systemobjextension

probepatho pretty

nfscurrentlelispllobjprettylo

loadobje ctf il e file function with one argument

Loads the ob ject le file if it is found in the systempath directory list In LELISP

loadobjectfile could b e dened in the following manner

defun loadobjectfile file

let realfile probepatho file

ifn realfile

error loadobjectfile unknown file file

loadfile realfile t

Controlling evaluation

Using mo dules means that you have to b e able to precisely control the moment at which expressions

within a mo dule are evaluated When a mo dule is compiled the default b ehavior is that all the

forms in the mo dule are evaluated b efore the actual moment of compilation The following sp ecial

form lets you sp ecify for each form in a mo dule whether it should b e evaluted when the mo dule is

loaded in interpreted mo de when the mo dule is loaded in compiled mo de or during the compilation

pro cess

evalwhe n moments expressions function with a variable number of arguments

The moments argument is a nonevaluated list of symb ols from the set of eval load localcompile

or compile The expressions argument is a sequence of arbitrary legal expressions that b e

evaluated according to the presence of one of the symb ols of the moments argument This evaluation

takes place according to the following criteria

 eval The expressions are evaluated when the source les of the mo dule are loaded with the

libloadfile function or from the main interpreter interactive lo op

 load The expressions are evaluated when the mo dule is loaded with the loadobjectfile

function

 localcompile The expressions are evaluated when the mo dule is compiled but they will

not b e exp orted

 compile The expressions are evaluated when the mo dule is compiled or when any other

mo dule that imp orts this mo dule is compiled

By default all the expressions in a mo dule are surrounded by the form

evalwhen eval load localcompile

Having seen this description of the evalwhen function we can now return to the question that

we started to examine earlier on of the p ossible contents of a source le

 A source le might contain certain denitions that are exploited solely during the compilation

of the present mo dule This p ossibility is made available by the evalwhen function with the

localcompile keyword

 Other denitions in the source le might b e used b oth when compiling the present mo dule

and when compiling another mo dule that imp orts the present one This is the case of the

evalwhen function with the compile keyword

 There might b e denitions that are useful b oth at execution time and in the case of a lo cal

compilation This involves using evalwhen with the localcompile and load keywords

together with exp ort

 Finally there might b e denitions that are useful b oth at execution time and in the case of

lo cal and external compilations This involves using evalwhen with the compile and load

keywords together with export The eval keyword would b e added if you wanted to use such

a denition in interpreted mo de In fact any of the combinations of the keywords compile

localcompile load and eval can b e envisaged

CHAPTER COMPILATION

Let us lo ok at examples of the use of evaluation control The source le called when contains the

following forms

evalwhen eval

print eval

evalwhen load

print load

evalwhen localcompile

print localcompile

evalwhen compile

print compile

evalwhen eval load localcompile compile

print eval load localcompile compile

defun first

first

This has the following mo dule denition

defmodule when

files when

export first

It b ehaves in the following manner

Lwhen

eval

eval load localcompile compile

whenll

compilemodule when

localcompile

compile

eval load localcompile compile

eval load localcompile compile

eval load localcompile compile

Awhen

load

eval load localcompile compile

when

The source le named when contains

evalwhen eval

print eval

evalwhen load

print load

USE AND MANIPULATION OF MODULES

evalwhen localcompile

print compile

evalwhen compile

print compile

evalwhen eval load localcompile compile

pirnt eval load localcompile compile

defun second

second

It has the following mo dule denition

defmodule when

files when

export second

import when

It b ehaves in the following manner

Lwhen

eval

eval load localcompile compile

whenll

compilemodule when

compile

eval load localcompile compile

localcompile

compile

eval load localcompile compile

eval load localcompile compile

eval load localcompile compile

Pfirst

Awhen

eval

eval load localcompile compile

eval

eval load localcompile compile

when

Pfirst

ds first subr

Use and manipulation of mo dules

This section presents seven functions and two variables that are used by COMPLICE

CHAPTER COMPILATION

Functions on mo dules

probepat hm module function with one argument

Returns the complete lename of the mo dule description le of module if it is found in the

systempath directory tree If the mo dule is not found there probepathm returns

In LELISP probepathm could b e dened in the following manner

defun probepathm mod

searchinpath

systempath

catenate mod systemmodextension

probepathm pretty

nfscurrentlelispllmodprettylm

readdefm odu le module function with one argument

Returns a LISP structure containing the information in the mo dule description le of module This

struture will b e referred to from now on as a module denition and will b e denoted by the

argument defmod

getdefmo dul e defmod key function with two arguments

Returns the value asso ciated with key in the mo dule denition defmod

setdemod ule defmod key value function with three arguments

Adds the pair valuekey to the mo dule denition defmod If the key already exists in the denition

its existing value is replaced by the value argument

printdef mod ul e defmod module function with two arguments

Up dates the mo dule description le that corresp onds to the mo dule module using the mo dule

denition defmod

Loading and compiling mo dules

loadmodu le module reloadp interpretedp function with one two or three arguments

Loads module and all the mo dules that it imp orts Imp orted mo dules are loaded in the rst instance

using a single loadmodule function Loading is recursive Consequently mo dules imp orted by

imp orted mo dules are likewise imp orted and so on Only mo dules that have not already b een

USE AND MANIPULATION OF MODULES

loaded into the system are loaded Nevertheless the reloadp argument provides a means of

forcing all the imp orted mo dules to b e loaded or reloaded

If the mo dule was compiled loadmodule loads it using the loadobjectfile function If the mo dule

was not compiled loadmodule loads the uncompiled source les dened in the files key using the

libloadfile function The interpretedp ag when set forces all the source les of a mo dule

to b e loaded regardless of whether compiled versions of the mo dule are already loaded

When a mo dule is loaded from source les a warning with the following standard screen display

is printed

load interpreted module module

Here module is the name of the mo dule loaded and interpreted

The following two variables are maintained by the loadmodule function

module int er pre te dl ist variable

This variable contains the set of names of mo dules whose les have b een loaded by the libloadfile

function

module com pi led l ist variable

This variable contains the set of names of mo dules whose les have b een loaded by the

loadobjectfile function

compilem odu le module ind function with one or two arguments

Compiles module with the COMPLICE mo dular compiler The result of the compilation is stored in

the le named module with the extension systemobjextension which is created if it do es

not already exist If the ind ag is set the mo dules imp orted by module are recursively compiled

using the same compilemodule function

Files pro duced by the compilation can b e loaded using the loadobjectfile function The compiled

mo dule and the mo dules it imp orts can b e loaded all at once using the loadmodule function

When the ag is not supplied the denition of compilemodule is almost equivalent to the following

co de

defun compilemodule mod

compilefiles

getdefmodule readefmodule mod files

mod

The mo dule description is up dated though to reect the fact that the mo dule was compiled

Moreover functions not exp orted by the mo dule will no longer exist after the compilation Write

access to the mo dule description le is needed in order to carry out a mo dule compilation

CHAPTER COMPILATION

Complice

To compile a mo dule you use the COMPLICE compiler This section describ es the features sp ecic

to COMPLICE as well as its error and warning messages

Compatibility messages

Whenever p ossible COMPLICE compiles variable bindings as lexical bindings This means that

variables do not exist prop erly sp eaking outside the lexical blo ck in which they are declared

Programs normally executed in intrepreted mo de might therefore b e rendered incompatible or

unworkable after compilation by COMPLICE In order to alleviate these problems COMPLICE has a

ag called compliceparanoflag When this ag is set explicit calls to the evaluator result

in dynamic binding of the variables involved so that compiled and interpreted versions have the

same b ehavior

complic ep ar ano f lag variable

This variable indicates whether complete compatibility with the interpreter is required When

COMPLICE is rst loaded the value of this ag is t meaning that total compatibility is required

Let us lo ok at an example

defun test word funcall test

test

defun test word

test

test local ) local

Now compile test by entering compile test Since the compliceparanoflag is set to

t the test function still works normally

test local ) local

Let us now redene the same test function Before recompiling it we shall set the ag to with

defvar compliceparanoflag Then we recompile the function

defun test word funcall test

test

defvar compliceparanoflag

compliceparanoflag

compile test t t

fentry test subr

entry test subr

push

push test

mov a

jmp funcall

eval

return

test

This time the evaluation pro duces a dierent result

COMPLICE

let word global

test local

global

Here is a list of functions that mo dity the b ehavior of the compiler according to the setting of the

compliceparanoflag variable

apply deset eval evlis flambda

flet funcall lambda lock set

symeval time unexit unwind

Errors and warnings

COMPLICE errors and warning are printed onto the current output stream in one of two formats

 For an error the format is

En entity message

argument

 For a warning the format is

Wn entity message

argument

The items in italics have the following meanings

 n is the numb er of the error or warning

 entity is the entity such as a function or a variable that was b eing compiled

 message is a complete explanatory message

 argument is the faulty argument

When an error is raised entity is not compiled If a warning o ccurs the co de pro duced might b e

incompatible with the interpreter See however the compliceparanoflag ag

complic ew ar nin g fla g ag

This ag allows you to suppress warning messages By default its value is t and warnings are

printed To turn them o set complicewarningflag to

complic en o war ni ng variable

This variable contains the list of warning message numb ers that corresp ond to messages that you

do wish to see printed When COMPLICE is initially loaded complicenowarning contains the

list

CHAPTER COMPILATION

E Complice error message

This error message is displayed as follows

Eentity Internal error

f m b

Cause Sometimes for eciency reasons or in unforeseen cases COMPLICE do es not systematically

verify that the co de it pro duces is valid For example it might pro duce the instruction add

which is not legal In these cases a machine error is usually raised and the m argument will b e

equal to errmac

Arguments f m and b are standard error handling arguments See the explanation of the syserror

function

Remedy Verify that entity works in interpreted mo de and verify that the LISP co de of entity is

coherent and correct

E Complice error message

This error message is displayed as follows

Eentity Function computed

LISPexpression

Cause This error is raised when the rst element of a form is neither a symb ol nor a lamb da

expression as in the case of if x

Argument For the ab ove example the LISP expression is if x

Remedy Replace this expression with funcall if x

E Complice error message

This error message is displayed as follows

Eentity Application of an mlambda

lambdaexpression

Cause COMPLICE cannot compile a form such as mlambda x ncons x x

Argument For the ab ove example the lamb daexpression is mlambda x ncons x

Remedy If the macro generation can b e p erformed during the compilation use an intermediate

macro function

E Complice error message

This error message is displayed as follows

Eentity Error during macro expansion

macrofunction

Cause All macro expansions b oth macro and dmacro are p erformed in the compiler environment

So the macro functions that use the dynamic environment of the users program raise this error

COMPLICE

Here is an example

defun f a

bclos a a a

dmd bclos v pg

let v symeval v

pg

Argument For the ab ove example macrofunction is bclos

Remedy If the macro generation can only b e p erformed a single time in the userprogram

environment do it b efore the compilation in a test case

E Complice error message

This error message is displayed as follows

Eentity Function not defined

function

Cause The function designated as entity called a function that was not dened at the time the

compilation to ok place Here is an example

defun f g

Argument For the ab ove example the function is g

Remedy If the problem was not simply the result of a typing error p erform the call by means of

a funcall such as defun f funcall g

E Complice error message

This error message is displayed as follows

Eentity Cannot compile an flet

LISP expression

Cause When the compliceparanoflag ag is not set COMPLICE refuses to compile a form

b eginning with flet

Remedy If you want to temp orarily mo dify the b ehavior of functions such as syserror bol or

eol you might use the systemitsoft programmableinterrupt approach The other obvious

solution is to set compliceparanoflag to t

E Complice error message

This error message is displayed as follows

Eentity Cannot compile a letv

LISP expression

Cause COMPLICE can only compile dynamicenvironment constructions when the variable tree is

supplied explicitly Here is an example

CHAPTER COMPILATION

defun goodf vals letv a b vals a b

defun badf env vals letv env vals a b

Argument For the ab ove example the LISP expression is env

Remedy None

W Complice warning message

This warning message is displayed as follows

Wentity Undeclared global variable

variable

Cause In the transitive closure of entity variable can b e used without having b een instantiated

Here is an example

defun f xyz

or

defun last ifn xyz let xyz last cdr

Argument In the ab ove example the variable is xyz

Remedy If the problem stems from neither a typing error nor a logical error in the program give

the variable in question a global value using the defvar function The call to defvar must b e in a

le

W Complice warning message

This warning message is displayed as follows

Wmodule Unused function

function

Cause This warning only o ccurs with the compilemodule function It app ears if function is

created in module but is not used by any of the exp orted functions

Remedy If the function is needed it should b e added to the mo dule description of module under

the export key

W Complice warning message

This warning message is displayed as follows

Wentity Wrong function type

function type

Cause If entity is the same symb ol as function and type is not an attempt was made to compile

a noncompilable function for example compile car Otherwise function is undened typ e is

and the evaluator will b e called explicitly

COMPLICE

Remedy In the rst case the funcall function should b e used to compile the arguments of

function In the second case dene function in your source co de At times you have to b e

careful of synonymq

W Complice warning message

This warning message is displayed as follows

Wmodule External function

function

W Complice warning message

This warning message is displayed as follows

Wentity Wrong number of arguments

function

Cause The call sequence of function inside entity do es not macth its denition Here is an example

defun f cons

or

defun f g

defun g x y cons x y

W Complice warning message

This warning message is displayed as follows

Wmodule Function external to module

function

Cause This warning is only pro duced with the compilemodule function It app ears if function is

used in mo dule but is not created by one of the imp orted mo dules

Remedy If it is known which mo dule contains function it should b e added to the mo dule description

of module under the import key Otherwise arrange things in such a way that function is already

compiled when compilemodule is called and that it is also there at execution time

W Complice warning message

This warning message is displayed as follows

Wentity Calculated function

LISPexpression

Cause The entity function uses a function such as funcall or apply The LISP expression is a

functional value Here is an example

defun tw f a funcall f funcall f a

CHAPTER COMPILATION

Argument In the ab ove example the LISP expression is f

Remedy If there is no interaction b etween the called functional value and the calling function

highp erformance co de is generated when the compliceparanoflag ag is set to

W Complice warning message

This warning message is displayed as follows

Wentity Explicit call to evaluator

LISPexpression

Cause The entity function uses a function such as eval or set Here is an example

defun symev v env or cassq v env symeval v

Argument In the ab ove example the LISP expression is v

Remedy If there is no interaction b etween the called functional value and the calling function

highp erformance co de is generated when the compliceparanoflag ag is set to

W Complice warning message

This warning message is displayed as follows

WcompilefilesFunction external to file

function

Cause This warning only o ccurs with the compilefiles function It app ears if function is used in

one of the les app earing in the arguments to a call to compilefiles but was not created by one

of these les

Remedy Arrange things is such a way that function has already b een compiled when

compilefiles is executed and that it is present at execution time as well

W Complice warning message

This warning message is displayed as follows

WmakemoduleModule interdependence

modulelist

Cause This warning only o ccurs with the compilemodule function It app ears if the compiler

detects a circularity in the set of mo dules b eing compiled according to the links dened by the

import key In this case all the les involved in mo dules in modulelist will b e recompiled once

indep endently of all links to other memb ers of modulelist and then a second time to resolve

dynamic variable bindings The modulelist argument do es not describ e the smallest circularity

of intermo dule reference Given the prohibitive cost of the double compilation you are advised

to recompile one of the mo dules involved in the circularity by hand b efore trying to compile the

mo dules together a second time

COMPLICE

W Complice warning message

This warning message is displayed as follows

Wentity Function redefined in the module

module

Cause This warning indicates that entity which app ears in the mo dule b eing compiled is also a

function exp orted by module and that the latter is imp orted by the mo dule b eing compiled In

this case it is the lo cal denition that is used during the compilation of the current mo dule

General remarks and examples

Using defvar

In some particular cases COMPLICE do es not nd variables that should b e dynamically linked even

when the compliceparanoflag is set to t Here is an example

defun linecount

let syspackageitsoft count countn

untilexit eof read

countn

defun countbol

setq countn add countn

bol

In this case the variable countn is used in a dynamic manner but it will b e compiled lexically

To alleviate these problems a global variable declared by defvar can b e used for it and will always

b e compiled by COMPLICE according to dynamic binding rules

The ab ove program would b e rewritten as follows

defar countn

defun linecount

let syspackageitsoft count countn

untilexit eof read

countn

defun countbol

setq countn add countn

bol

It is therefore suggested that defvars b e used for variables such as l n and at

Using macros

A macro function instantiated in a mo dule but not exp orted will no longer exist after compilation

For example the mo dule le test might contain

CHAPTER COMPILATION

defmodule user

files test

export test

and the LISP source le test might contain

defun test n testmacro n

dmd testmacro n add n

Once the mo dule is compiled the testmacro function will no longer exist

Function generators

In pro cessing the compilefiles and compilemodule functions COMPLICE determines which

functions to compile by isolating the o ccurrence of the de df defun setfn dm dmd and

defmacro primitives There are two compiler features that provide the means to dene new function

generators

The rst follows from the fact that forms read from les are macroexpanded It is p ossible to dene

macro functions that dene calls to the standard primitives intro duced ab ove Here is an example

dmd defsys name fval

defun symbol system name fval

defsys ob oblist system

On the other hand the mo dule description les must sp ecify the complete names of functions to

exp ort as shown here

defmodule system

files foo

export systemob

The second phenomenon is due to the fact that forms b eginning with progn are themselves scanned

to determine p ossible function denitions

dmd newtype type make pred

progn

defun make l

let v apply vector l

typevector v type

newl listtype type

defun pred v eq typevector v type

defmacroopen pred v eq typevector v type

defvar listtype

newtype cell makecell cellp

COMPLICE

Using the precompile function

Among other things the precompile function allows data denition to b e delayed until load time

Consider the following example

defun staticstream

let stream cons cirlist

prog cadr stream

rplacd stream cddr stream

This function is correctly compiled by the compile and compileallincore functions but the

corresp onding lap co de will not b e able to b e loaded into a le b ecause of the circularity of the

data In such cases the precompile function can b e used in the following manner

dmd reconstruct data

precompile eval data eval kwote data

defun staticstream

let stream reconstruct cons cirlist

prog cadr stream

rplacd stream cddr stream

Undesirable asp ects of Complice

The compilemodule function can create the ob ject le only in the current working directory

Lexical control functions such as tagbody block go and return systematically call sp ecialized

evaluation routines

In imp orted mo dules b e wary of any macro denitions that are not inside an evalwhen

compileconstruction Such denitions might cause the total loading of the imp orted mo dule during the compilation of the mo dule that imp orts it

CHAPTER COMPILATION

Table of contents

Compilation

Calling the compilers ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Compiler macros ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

Closed macros ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

Op en macros ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::

Mo dules ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

Source les ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Ob ject les ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Controlling evaluation ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Use and manipulation of mo dules ::::::::::::::::::::::::::::::::::::::::::::::::

Functions on mo dules ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Loading and compiling mo dules :::::::::::::::::::::::::::::::::::::::::::

Complice ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

Compatibility messages ::::::::::::::::::::::::::::::::::::::::::::::::::

Errors and warnings ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

General remarks and examples ::::::::::::::::::::::::::::::::::::::::::::

Table of Contents

Function Index

compiler feature ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

complice feature ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

compiler source status print loader function with four arguments ::::::::::::::

compile source status print loader special form with one two three or four

arguments ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::

compileallincore print loader function with zero one or two optional arguments

compilefiles source object function with two arguments ::::::::::::::::::::::::

precompile exp result exp operand special form ::::::::::::::::::::::::::::

dontcompile exp ::: exp special form :::::::::::::::::::::::::::::::::::::::

n

compileropenp variable ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

defmacroopen name ::: fval special form :::::::::::::::::::::::::::::::::::::

makemacroopen name fval function with two arguments :::::::::::::::::::::::::

macroopenp name function with one argument ::::::::::::::::::::::::::::::::::::

removemacroopen name function with one argument :::::::::::::::::::::::::::::

systemobjextension variable ::::::::::::::::::::::::::::::::::::::::::::::::

probepatho file function with one argument :::::::::::::::::::::::::::::::::::::

loadobjectfile file function with one argument ::::::::::::::::::::::::::::::::

evalwhen moments expressions function with a variable number of arguments ::::

probepathm module function with one argument :::::::::::::::::::::::::::::::::::

readdefmodule module function with one argument :::::::::::::::::::::::::::::::

getdefmodule defmod key function with two arguments :::::::::::::::::::::::::::

setdemodule defmod key value function with three arguments :::::::::::::::::::::

printdefmodule defmod module function with two arguments :::::::::::::::::::::

loadmodule module reloadp interpretedp function with one two or three

arguments ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::

moduleinterpretedlist variable ::::::::::::::::::::::::::::::::::::::::::::

modulecompiledlist variable ::::::::::::::::::::::::::::::::::::::::::::::::

FUNCTION INDEX

compilemodule module ind function with one or two arguments ::::::::::::::::::::

compliceparanoflag variable ::::::::::::::::::::::::::::::::::::::::::::::::

complicewarningflag ag ::::::::::::::::::::::::::::::::::::::::::::::::::

complicenowarning variable :::::::::::::::::::::::::::::::::::::::::::::::::

E Complice error message ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

E Complice error message ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

E Complice error message ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

E Complice error message ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

E Complice error message ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

E Complice error message ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

E Complice error message ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::

W Complice warning message ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

W Complice warning message ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

W Complice warning message ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

W Complice warning message ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

W Complice warning message ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

W Complice warning message ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

W Complice warning message ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

W Complice warning message ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

W Complice warning message ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

W Complice warning message ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

W Complice warning message ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Chapter

External interfaces

The rst section of this chapter describ es functions that interface LELISP system with external

pro cedures written in other programming languages The following sections describ e the details of

the pro cess of interfacing LELISP with dierent languages on dierent systems Only the section

covering the UNIX system is included in this manual For the vms interface see Dana

Interface functions

LELISP provides ways to call external pro cedures written in another These

external pro cedures must b e integrated into LELISP with the host systems link editor

The following functions which provide the interface of external pro cedures are not standard on

all LELISP systems Check to see if they exist on your system b efore trying to use them

getgloba l strg function with one argument

Returns the starting address entry p oint of the external pro cedure name strg This name must

exist in the symb ol table generated by the link editor when LELISP is created The result of this

function can b e used as the rst argument to callextern

The notion of a symbol dep ends of course up on the the host system On UNIX systems for example

Clanguage names are usually preceded by the underscore character as in getenv whereas

fortran names are surrounded by this same character as in getenv Dep ending on the machine

on which it is running LELISP takes account of the p ossible presence of such prexes For example

you nd the underscore prex on a Sun whereas it is a dot on the RS

In no case do es the user have to b e aware of the convention in use He or she only needs to use the

name of the symb ol as it is dened in C

Of course for compatibility reasons the user can indicate a prex when p erforming a getglobal

but this technique is slow and it might cause p ortability problems when the co de is taken onto

another machine In any case the presence of a prex in the character string sent to getglobal is

a means of avoiding p ossible name conicts b etween LELISP functions and C pro cedures

On a Sun with no prex

getglobal getenv )

CHAPTER EXTERNAL INTERFACES

time getglobal getenv )

On a Sun with a prex

getglobal getenv )

time getglobal getenv )

With the prex of an RS

getglobal getenv )

callexte rn address type v t ::: v t function with a variable number of

1 1 n n

arguments

Calls an external pro cedure starting at address This call must return a value whose typ e is type

The v designate values transmitted to the external pro cedure and their corresp onding typ es are

i

indicated by the t These t are co ded in the following manner

i i

! p ointer

! integer numb er

! oatingp oint numb er

! character string

! vector of Sexpressions

! integer numb er passed by reference fortran

! oatingp oint numb er passed by reference fortran

! vector of integer numb ers

! vector of oatingp oint numb ers

The typ e of the result returned by the external pro cedure call referred to as type can only

corresp ond to one of the rst four items in this list either p ointer integer numb er oating

p oint numb er or character string

defexter n symb ltype type special form

Dynamically asso ciates a LELISP function to an external pro cedure symb is the name of an

external mo dule that is going to b ecome a new LELISP function ltype is the list of typ es of

input arguments The version intro duces a dynamic verication of the typ es ltype

at the time of the call to the function symb

ex defextern mafonction string fix

mafunction

mafunction

mafonction the argument is not a string

type is the typ e of the return value The p ossible typ es for the ltype argument are memb ers of

the following set of symb ols

INTERFACE FUNCTIONS

 t a LELISP p ointer

 external an external p ointer

 fix an integer numb er

 float a oatingp oint numb er

 string a character string

 vector a vector of Sexpressions

 rfix an integer passed by reference

 rfloat a oat passed by reference

 fixvector a vector of integers

 floatvector a vector of oats

The returned type is one of the following symb ols

 t a LELISP p ointer

 external an external p ointer

 fix an integer numb er

 float a oatingp oint numb er

 string a character string

Let us examine these symb ols more closely

 The t typ e corresp onds to any LELISP p ointer that is passed without b eing altered

 The external typ e corresp onds to a p ointer external to the LISP memory space It is

represented by a LELISP address A detailed description of this kind of address is provided

in section Generally such a p ointer is the result of a previous call to an external

pro cedure and it is sucient to store and pass it to other external pro cedures when it is

called for

 The fix typ e corresp onds to an integer numeric value

 The float typ e corresp onds to a oatingp oint numeric value When the p ort allows it

this typ e works equally well in b oth the bit and bit LELISP oatingp oint mo des

 The string typ e corresp onds to the address of the rst character of a character string

It is imp ossible to pass a character string by value

 The rfix typ e corresp onds to a reference to an integer numeric value This is the typ e

of argument passing that is used in fortran

 The rfloat typ e corresp onds to a reference to a oatingp oint numeric value This is the

typ e of argument passing that is used in fortran When the p ort allows it this typ e

works equally well in b oth bit and bit LELISP oatingp oint mo de

CHAPTER EXTERNAL INTERFACES

 The fixvector typ e corresp onds to the address of the rst element of a vector of integer

numeric values Vectors of integers are therefore always passed by reference Because of

the way integers are represented in LELISP this typ e is dierent to the typ e of a vector

of Sexpressions containing only integer numeric values

 The floatvector typ e corresp onds to the address of the rst element of a vector of

oatingp oint numeric values Vectors of oats are therefore always passed by reference

Because of the way that oats are represented in LELISP this typ e is dierent to the typ e

of a vector of Sexpression containing only oatingp oint numeric values Note that this

floatvector typ e works only in bit oatingp oint mo de You cannot use it in bit

oatingp oint mo de

Example the following external pro cedure is dened in C

double ctest strgnfnivect

char strg double nf int ni int vect

int i

printfthe string is snr strg

printfthe float is enr nf

printfthe integer is dnr ni

printfthe vector contains vectx vectxnr vect vect

i vect vect vect vect i

returnnfni

Here is the corresp onding LELISP interface

defextern c test string float fix vector float

test defvar vec a b c

test fou barr vec vec c

the string is fou barr

the float is e

the integer is

the vector contains vect ed vect ae

vec

a b

The following external pro cedure is dened in fortran

subroutine tabflt lg tfloat

integer lgi

real tfloatlg

do ilg

tfloatitfloati

continue

return

end

Here is the corresp onding LELISP interface

LINKS WITH EXTERNAL PROCEDURES UNDER UNIX

defextern tabflt rfix floatvector

tabflt setq v

tabflt vlength v v

v

defexter nc ac he flag special form

If flag is true the following defexterns will b e cached When the ag will b e set to false

all the cached defexterns will b e resolved

Links with external pro cedures under Unix

We explain here how to interface LISP with external pro cedures written in C using defextern and

how to call LISP from external pro cedures using lispcall

These featuresthe least p ortable in the systemare describ ed here only for UNIX systems

Principles

The LELISP language is not p erfectly adapted to every p ossible computing task It is notably

ineective for long numeric calculations such resolutions of dierential equations and nite element

metho ds or bitbased op erations on highresolution screens such as general rasterop pro cedures

For these tasks programmers generally prefer languages that p erform these sp ecial tasks well such

as fortran C or an assembly language

LELISP provides the means to interface pro cedures written in other languages These pro cedures

b ecome regular LISP functions

It is p ossible to pass arguments of all typ essuch as integer and oatingp oint numeric values

character strings vectors of LELISP ob jects and any LISP ob jectto these pro cedures and to

receive their typ ed results

LELISP can therefore b e used to drive very fast pro cedures written in other languages and can b e

considered as a to ol for interfacing and carrying on dialogues with these pro cedures

Calling functions written in C

We describ e here the way to interface LISP with C programs Everything describ ed here is also

valid for fortran which rep ects the C calling conventions under UNIX and for those assembly

languages that do likewise

There could b e problems with a pascal interface due to le handling pro cedures In pascal les

must b e declared in the program declaration It is therefore dicult to link pascal pro cedures

outside a pascal context The solution in this case is to write a pascal program that calls the

LELISP system as an external pro cedure

CHAPTER EXTERNAL INTERFACES

To call a C function from the LISP system you have to link the compiled function ob ject and the

system kernel into the same executable program and then asso ciate the C entry p oint to a LISP

function The LISP function call then lets the C program b e run

Linking external pro cedures

The link op eration consists of binding the co de of several external pro cedures into a single

executable program In this case the LISP system and the C mo dules containing the C pro cedures

that will b e called are linked together

This link can b e created statically when the system is created or dynamically at any time under

the control of the system

The static link op eration consists of creating a new executable binary containing the kernel of

the LELISP system and the C mo dules The new binary can then b e used to generate a new LISP

system It can b e installed on any and all UNIX machines This is a ma jor undertaking though

since it requires the recreation of the system every time that one of the C mo dules is changed

The dynamic link op eration can only b e carried out on machines that have linkersalso known

as link editorsthat make it p ossible to carry out incremental linking In the UNIX system the

linker is called using the ld command with the A option The dynamic linking op eration happily

replaces the static link describ ed ab ove and eliminates the need for recreation after each change in

the C mo dules Moreover the dynamically linked mo dules are maintained in memory images les

So the dynamic link actually ends up b eing more durable than the static link

Dynamic links

cload string function with one argument

The argument to this function is the name of a compiled mo dule that is to b e linked to the system

cload calls the UNIX linker ld to link the C mo dule with the system b eing used The compiled

co de of the C mo dule is loaded into the LISP code memory zone and can thereby b e saved into a

LISP memory image Here is an example

lelisp

LeLisp by INRIA version Jan sun

Standard modular system Sat Dec

bitfloats date microceyx pathname debug setf pepe virbitmap

defstruct virtty compiler pretty abbrev loader messages callext

We compile a C mo dule named fooc thereby creating the binary ob ject named fooo

cc c fooc

t

We then link the fooo mo dule to the system

cload fooo

LINKS WITH EXTERNAL PROCEDURES UNDER UNIX

The character string argument is passed to the ld link editor This means that options to load

libraries to get a trace of the link edit or to link several mo dules at once can b e exercised with

the cload function For more details see the UNIX do cumentation for ld on your machine

Let us lo ok at other examples of the use of the cload function The next call loads the asho

mo dule and the rastera library

cload asho lraster

The next example loads the hyp erb olic sine entry p oint from the mathematical function

library

cload u sinh lm

The next call loads three mo dules named fooo geeo and baro

cload fooo geeo baro

The character string argument is the means by which the call to the ld link editor is

constructed For more precision see the UNIX do cumentation concerning ld

Consider the call cload string

On a Sun this generates the call

ld A lelispbin Bstatic N x T end o temporary string lc

On an SPS this generates the call

ld C A lelispbin N x T end o temporary string lc

Here lelispbin is a path that contains the directory where the currentlyrunning LELISP

binary is lo cated end is the rst available address in the LISP zone reserved for compiled

co de and temporary is a unique temp orary le in the directory tmp

After the mo dule is linked the temporary le contains the co de of the C mo dule It is loaded

into the LISP code zone It is this temporary le that will b e used in place of lelispbin for

subsequent calls to cload So numerous calls to cload can b e made to sequentially build and

mo dify an executable image

Static links

The static link is describ ed in the system installation do cumentaton in the b eginning of the

reference manual It consists of a p ermanent link b etween the LELISP system lelispbin and

the relevant C mo dules to make a new binary After this the system must b e congured This

involves loading an environment and creating a memory image as describ ed in the installation

do cumentation Generally an entry p oint is made in the makefile so that the new LISP system

can b e linked and congured

Let us lo ok at an example Here are the makefile declarations that allow the asho mo dule and

the rastera library to the lelispbin system and to congure a system named ashlelisp See

the do cumentation on the installation of LELISP on UNIX for more details

ashlelisp ashlelispbin ashll

config ashlelisp ashlelispbin ashll

CHAPTER EXTERNAL INTERFACES

ashlelispbin asho

cc x n cflags lelispbino commonlelispc

asho lraster lm lc o ashlelispbin

An inconvenience of the static link is the need to recreate the complete system each time that the

C les are mo died This op eration can often b e quite timeconsuming

C function declarations

Once the mo dules are linked to the system the C functions must b e linked to LISP functions The

LISP function defextern see ab ove p erforms this asso ciation

LISP typ e C typ e Argument Result

fix long Sign extended to bits Converted to bits

float double Value passed Lisp oat created

string char Pointer to char string passed Lisp string allo cated C string copied

into it

vector any Vector of Lisp p ointers passed No change Lisp receives C p ointer as

is

rfix long Integer passed by reference Used Not implemented

ab ove all to exchange integers

with Fortran

rfloat double Float passed by reference Single Not implemented

or double precision oat changed

to double in external language

Used ab ove all to exchange oats

with Fortran

fixvector long Array of integers passed Sign of Not implemented but changes made to

each integer extended to bits C array are recovered by Lisp

floatvector float Array of oats passed Single Not implemented but changes made to

precision Lisp oats changed to C array are recovered by Lisp

C oats

t any No change C receives the Lisp No change Lisp receives C p ointers as

p ointers as is is Warning LeLisp might do strange

things if random p ointer values are

passed to it

external any Lisp ob ject must b e a cons of Lisp cons is allo cated and initialized

two integers co ding an address with mostleast signicant parts of the

See vag function in Lisp address of the C ob ject See loc

Passed to C function in Lisp The function returns

the cons as its result

The ab ove table describ es the conversions that take place when arguments are passed to C and

when results are returned In this table the socalled LISP typ e is the typ e dened at the time

of the defextern whereas the socalled C typ e is the typ e of the arguments received by the C

function connected to LISP

LINKS WITH EXTERNAL PROCEDURES UNDER UNIX

LISP p ointers are either p ointers into the LISP data zone or bit short integers The lelisph le

contains the declarations of the typ e of C structure to which LISP p ointers p oint More details are

revealed b elow The external typ e provides a way of manipulating C structures in LISP It is not

true that any C p ointer at all can b e manipulated within the system It must rst b e converted

into a cons of two integers that represent the highorder and loworder parts of the address The

external typ e p ermits values to b e converted b etween C p ointer and LISPdoublet representations

at each call to or return from a C function

Examples

Lets lo ok at examples of the use of the defextern function For each example we rst show a C

program to b e called Next there is the defextern declaration that allows the corresp onding LISP

function to b e built Finally there are samples showing the function b eing used

The rst function takes three argumentsan integer a string and a oatand returns a oat

double foo x s f

int x char s double f

printfinteger d string s float gn x s f

returnx strlens f

defextern foo fix string float float

foo

setq str hello

hello foo str e

integer string hello float e

e

The next function accepts a string and returns a string

char getenv

char envar s

char s

returngetenv s

defextern envar string string

envar

envar HOME

uddhallesrodine Now it is a Lisp string

We next lo ok at a function that takes a vector Its argument v is declared as having the typ e

CHAPTER EXTERNAL INTERFACES

int v It will b e able to b e used on vectors of bit LISP integers which will app ear to it

like C vectors of bit integers that happ en to have values b etween zero and inclusive

It is generally handy to o to pass the length of the vector as an argument

whatyousay v l

int v l l is the length of the vector

int i

for i i l i

printfd vi

printfrn

defextern whatyousay vector fix

whatyousay

whatyousay

The next example involves the use of the external typ e It shows how to manipulate a

p ointer of any typ e received from C In this example it is meant to b e a p ointer to a window

allo cated in the C context

window

createawindow x y l h

int x y l h

create a structured window object and

return a pointer to it

selectawindow w

window w

receive a pointer to a structured window object

defextern createawindow fix fix fix fix external

createawindow

defextern selectawindow external

selectawindow

setq a createawindow

the pointer that is manipulable in Lisp

selectawindow a which can be sent back to C when necessary

Arguments whose typ e is t are passed straight through to C functions as is without mo dication

These functions therefore receive LISP ob jects generally p ointers to structures The integer and

LINKS WITH EXTERNAL PROCEDURES UNDER UNIX

oatingp oint cases are slightly dierent See the remainder of this chapter The lelisph le

included in the standard distribution contains C structures corresp onding to LISP ob jects

For example here is the C structure declaration for cons with two elds llcar and llcdr each

of which contains a LISP ob ject

struct LLCONS

LLOBJECT llcar

LLOBJECT llcdr

The LLOBJECT typ e is a p olymorphic typ e that covers all LISP ob ject typ es such as LLSYMBOL

and LLCONS Since C has no notion of p olymorphic typ e LLOBJECT is declared as follows

typedef char LLOBJECT

Let us lo ok at an example The following function extracts the car of a LISP pair received as its

argument

include lelisph

LLOBJECT carinc o

struct LLCONS o

return ollcar

defextern car in c t t

in c car

car in c a b c

a warning it can be dangerous to take the car of just anything

car in c

I quit on signal

Symb ols are treated in the same way as cons The llalink and llpname elds are used

by LELISP to link symb ols in the ob ject and their contents should never b e touched

struct LLSYMBOL

LLOBJECT llcval

LLOBJECT llplist

LLOBJECT llfval

LLOBJECT llalink

LLOBJECT llpkgc

LLOBJECT lloval

char llftype

char llptype

short llpad

CHAPTER EXTERNAL INTERFACES

LLOBJECT llpname

Character strings and vectors are p ointers to p ointers to variablesized structures This double

indirection is needed for memory deallo cation Since variablesized structures do not exist in C the

following declarations corresp ond to onebyte ob jects such as a singlecharacter constant or a vector

with one element The llxxxsiz eld indicates the real size of the ob ject that is the numb er of

characters in a string or the numb er of elements in a vector The rst element in the ob ject is the

llxxxfil eld and the other elements follow it contiguously in memory The llxxxtyp elds

contain the typ es of strings and vectors

struct LLSTRING

struct

struct LLSTRING llstrarr

int llstrsiz

char llstrfil

llstrobj

LLOBJECT llstrtyp

struct LLVECTOR

struct

struct LLVECTOR llvecarr

int llvecsiz

LLOBJECT llvecfil

llvecobj

LLOBJECT llvectyp

Here is an example function that prints the characters in a LISP string one by one

onebyone string

struct LLSTRING string

int i

int size

char s

size stringllstrobjllstrsiz the size of the string

s stringllstrobjllstrfil the address of the first

character

for i i size i

printfcharacter d crn i si

LISP ob jects of the fix typ e are not p ointers but rather immediate values Integers are bit

numb ers A LISP ob ject of typ e integer is therefore a bit p ointer whose rst bits are always

zero

Floats can b e implemented in various dierent ways according to host system architecture The

LINKS WITH EXTERNAL PROCEDURES UNDER UNIX

next example shows how to send to C a vector of LISP oats C raises each oat to the second

p ower and LISP recovers the vector with these side eects

CLLFIX Fonction C

The function C CLLFIX allows you to transform a C integer into a Lisp ob ject of the typ e fix

This function do es not carry out overow control on the domain of Lisp ob jects of typ e fix

The example b elow presents how to carry out the addition of two Lisp fixs in C with conversion

of the results into Lisp format in C

In C

LLOBJECT tcclfixij

long ij

returnCLLFIXij

In Lisp

defextern tcclfix fix fix t

tcclfix

tcclfix

LLCFIX Fonction C

The function C LLCFIX allows you to transform a Lisp ob ject of typ e fix into a C integer

Because of the existence of the domain of C integer representations always at least sup erior to

the domain of Lisp ob ject representations of typ e fix overow is not p ossible at the time of this

conversion

Example of the use of the function LLCFIX

In C

long tllcfixij

LLOBJECT ij

returnLLCFIXi LLCFIXj

In Lisp

defextern tllcfix t t fix

tllcfix

tllcfix

Floating p oint numb ers can b e implemented in various dierent ways according to host system

architecture

CHAPTER EXTERNAL INTERFACES

CLLFLOA T Fonction C

The function C CLLFLOAT allows you to transform a C double oating p oint numb er into a Lisp

ob ject of typ e float

Example of the use of the function CLLFLOAT

In C

LLOBJECT tcllfloatf

double f

returnLLOBJECTCLLFLOATf

In Lisp

defextern tcllfloat float t

tcllfloat

tcllfloat

LLCFLOA T Fonction C

The function C LLCFLOAT allows you to transform a Lisp ob ject of typ e float into a C double

oating p oint numb er

Example of the use of the function LLCFLOAT

In C

double tllcfloatf

LLOBJECT f

returnLLCFLOATf

defextern tllcfloat t float

tllcfloat

tllcfloat

The LLCFLOAT C macro transforms LISP oatingp oint numb ers into C oatingp oint numb ers

The next function copies a vector of LISP oats into an array of C oats

LINKS WITH EXTERNAL PROCEDURES UNDER UNIX

In C

int ttabflt size tabf

int size

float tabf

int i

for i isize i

tabfi tabfi tabfi

return size

In Lisp

defextern ttabflt fix floatvector

ttabflt

setq v

ttabflt v

v

WARNING

The manipulation of LISP ob jects in C is a risky activity Be careful when mo difying the contents

of LISP ob jects received as arguments In particular never touch the following elds llpname

llalink llstrobj llvecobj llstrarr llvecarr llstrtyp or llvectyp If you were

to interfere with any of these elds this could raise system errors

Communication with fortran takes place in a similar fashion the only dierence b eing the

argument declarations on the fortran side

 An integer is declared rfix on the defextern side and integer on the fortran side

 A oat is declared rfloat on the defextern side and real on the fortran side

 An array of integers is declared fixvector on the defextern side and integer lg on the

fortran side

 An array of oats is declared floatvector on the defextern side and real lg on the

fortran side

As b efore in the case of arrays every mo dication carried out in fortran is recovered in LISP

when control returns to the defextern

CHAPTER EXTERNAL INTERFACES

Calling Lisp from C

On certain machinessuch as the Sm VAX Sps and Sunit is p ossible to call the LISP system

from a C function that was itself called from LISP Here is a sketch of this interaction

The LISP system is called

The C function is called from LISP by defextern

The system is called from one of the the C functions

These backandforth calls b etween LISP and C can b e emb edded until system resources are depleted

Implementation

This dialog is carried out on the LISP side by using the defextern primitive describ ed ab ove and

on the C side by using three functions getsym pusharg and lispcall These functions use the

LISP ob ject denitions from the lelisph le and are dened as follows

struct LLSYMBOL

getsyms

char s

Return the Lisp symbol that has the string s as its pname

pushargtype val

int type any val

Stack up the argument ival which has type itype

LLOBJECT lispcalltyperes narg function

int typeres the type of the Lisp functions result

int narg the number of args pushed by pusharg

struct LLSYMBOL function the Lisp function to run

Call the Lisp function with the narg arguments on the stack

Return the result of this function

The argument typ es for the pusharg as for the return from lispcall can b e chosen from the

following symb olic typ es LLTFIX LLTFLOAT LLTSTRING LLTVECTOR and LLTT which is a

p ointer to anything As in the LISP to C call automatic conversion of argument format is also

carried out in the other direction from C to LISP as describ ed in the table ab ove

Examples

Several examples of denitions of C functions that call the LISP system follow along with sample uses of them

LINKS WITH EXTERNAL PROCEDURES UNDER UNIX

Calling the cons function

This C function takes two LISP ob jects of any typ e as arguments and returns a cons of these two

ob jects

struct LLCONS consinc a b

LLOBJECT a b

struct LLSYMBOL lispcons

lispcons getsymcons

pushargLLTT a

pushargLLTT b

return struct LLCONS lispcallLLTT lispcons

defextern cons in c t t t

in c cons

cons in c

trace cons

cons

consinc

cons the Lisp cons function is called sure enough

cons

Nary functions

Nary LISP functions can also b e called from C This example function transforms a vector into a

list by calling the LISP list function

Note that in general the getsym function is not called each time that the C function is called but

only once during an initialization pass

define null struct LLSYMBOL

struct LLSYMBOL lisplist null

struct LLCONS vecttolist v l

int v l

int i

iflisplist null

lisplist getsymlist

for i i l i

pushargLLTT vi

CHAPTER EXTERNAL INTERFACES

return struct LLCONS lispcallLLTT l lisplist

defextern vect to list vector fix t

to list vect

vect to list

Recursion

Rememb er that the LISP and C interlanguage calls can b e recursively emb edded For example you

could write the Fib onnacci function in the form of mutuallyrecursive LISP and C functions

cat fibc

include lelisph

struct LLSYMBOL lispfib

initcfib

lispfib getsymfib

int

cfib n

int n

int x

if n return

else

if n return

else

pushargLLTFIX n

x int lispcallLLTFIX lispfib

pusharglltfix n

returnx int lispcalllltfix lispfib

t

Dynamic link of the fibo module with the intepreter

cc c fibc

t cload fibo

defextern c fib fix fix

fib defextern init c fib c

init c fib init c fib

LINKS WITH EXTERNAL PROCEDURES UNDER UNIX

Here is the Lisp function that calls the C function in the midst of the recursion

defun fib n

cond eq n

eq n

t c fib n the first recursive C call

c fib n the second

fib

fib

trace fib c fib

fib fib c

fib

fib n

c fib arg

fib n

fib

fib n

fib

c fib

fib arg c

fib c

fib

Launching Lisp from C

On certain machines you can hand over the control of a LISP application to C In such a situation

it is no longer LISP that calls C but rather C that calls LISP Some UNIX p orts have a llmainc

le that has no other role than to act as the main program that launches LELISP The user can

execute all the co de he wants to b efore launching LISP After that he can either recall C using the

defextern pro cess describ ed earlier on or return to his C environment of the main program This

mechanism is implemented by means of the UNIX system calls setjmp and longjmp UNIX p orts

that oer this p ossibility contain demonstration les named fromcc and fromcll in the LELISP

directory called lltest

CHAPTER EXTERNAL INTERFACES

Table of contents

External interfaces

Interface functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Links with external pro cedures under Unix :::::::::::::::::::::::::::::::::::::::

Principles ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Calling functions written in C ::::::::::::::::::::::::::::::::::::::::::::

Calling Lisp from C ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Table of Contents

Function Index

getglobal strg function with one argument ::::::::::::::::::::::::::::::::::::::

callextern address type v t ::: v t function with a variable number of

1 1 n n

arguments ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::

defextern symb ltype type special form :::::::::::::::::::::::::::::::::::::::

defexterncache flag special form :::::::::::::::::::::::::::::::::::::::::::::

cload string function with one argument :::::::::::::::::::::::::::::::::::::::::

CLLFIX Fonction C ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

LLCFIX Fonction C ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

CLLFLOAT Fonction C ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

LLCFLOAT Fonction C ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

Chapter

Virtual terminal

To free the user from the explicit management of all the dierent kinds of alphanumeric ttys

that exist LELISP has included the notion of a virtual terminal which is comp osed of a set of

variables and functions that describ e the functionalities of a certain ideal terminal typ e A large

numb er of physical terminals have LELISP virtualterminal descriptions The virtual terminal is

initialized by the initty function which loads a le from the library of LELISP virtual terminals

If a terminal has no LELISP virtualterminal description initty compiles the description using

other terminaldescription databases such as termcap and terminfo

initty symb function with an optional argument

Initializes the virtual terminal for a terminal of typ e symb If no argument is given the physical

terminal typ e is determined rst by a call to getenv TERM and next by using the name of the

system returned by system If virtual terminal initialization fails the errvirtty error is raised

and its default screen display is printed as follows

fnt unknown terminal symb

Here fnt is the name of the function that caused the errortermcap or terminfoand symb

is the name of the unknown terminal The following messages are displayed when a terminal

typ e cannot b e found

initty alogon

attempt to make the virtty file using the termcap entry for alogon

termcap unknown terminal type alogon

attempt to make the virtty file using the terminfo entry for alogon

terminfo unknown terminal type alogon

alogon

system vir tt yd ir ect ory variable

This variable contains the name of the directory where the LELISP virtualterminal description

les are lo cated The default extension attached to these les names is the value of the

systemlelispextension variable

CHAPTER VIRTUAL TERMINAL

system ter mc ap fi le variable

This variable contains the name of the le with the termcapformat terminal descriptions If the

TERMCAP environment variable has a value obtained from getenv TERMCAP then this is used

instead of the value in systemtermcapfile

system ter mi nfo d ire cto ry variable

This variable contains the name of the directory where the terminfoformat terminal description

les are stored If the TERMINFO environment variable has a value obtained from getenv

TERMINFO then this is used instead of the value in systemtermcapfile

termcap feature

This feature indicates that the LELISP virtual terminal descriptiontotermcap format translator

has b een loaded into memory This translator is found in the standard library under the name

termcap

terminfo feature

This feature indicates that the LELISP virtual terminal descriptiontoterminfo format translator

has b een loaded into memory This translator is found in the standard library under the name

terminfo

Virtual terminal functions

The virtual terminal functions can b e divided into three groups the standard functions the required

functions and the optional functions

 The standard functions provide the minimal level of interaction with the LELISP

system by implementing basic writecharactertoscreen and readcharacterfromkeyb oard

functionalities These functions are also used by the bol eol and flush LISP functions to

handle dialogue with the terminal

 The required functions are used by fullscreen to ols such as the pepe fullscreen editor the

multiwindow interface and games

 The optional functions p erform more sophisticated video functions but are not used by

functions in the standard library

The action of the functions describ ed here varies according to the kind of terminal actually

connected to the system When a terminal cannot bring ab out the desired eect the tyerror

function is raised This function returns by default and can b e redened to generate an error

or to try to p erform the desired action in another way

VIRTUAL TERMINAL FUNCTIONS

tyerror list function with one argument

This function is automatically called by the virtual terminal functions when it is not p ossible to

obtain a particular eect on a connected terminal The argument list is the name of the function

call that failed The default b ehavior of tyerror is to return which is compatible with version

Standard functions

tyi function with no arguments

Reads a character from the keyb oard and returns its internal character co de

tys function with no arguments

Reads the keyb oard If a character is waiting to b e read it is returned in the same manner as with

the tyi function If there are no outstanding characters tys will return immediately

For example we might decide to increment a counter until a character is typ ed

let counter

until tys

incr counter

counter

The tyi can b e dened in terms of tys

defun tyi

let c

until setq c tys

tyinstri ng string function with one argument

Reads a line from the keyb oard and stores the input characters in string a character string It

returns the numb er of characters read as its value A line longer than the length of string will b e

truncated to its length This function should b e used when the systemlinemodeflag ag is

set See the denition of the bol function for example

tycn cn function with one argument

Displays the character whose internal character co de is cn The character is sent immediately to

the screen

tystring string length function with two arguments

Sends the length rst characters of string to the screen

In LELISP tystring could b e dened in the following manner

CHAPTER VIRTUAL TERMINAL

defun tystring s l

for i sub min slen s l

tycn sref s i

tynewlin e function with no arguments

Sends an endofline marker to the screen

tyback cn function with one argument

Erases the character whose internal co de is cn which is assumed to b e immediately b efore the

cursor on the screen and moves the cursor back one space If the character just b efore the cursor

do es not have internal co de cn the eect on the screen is undened This function is used by the

bol function to erase a character when the user typ es an erase character like delete or backspace

The character co de argument allows the line editor to work with prop ortionallyspaced characters

For example the following sequence leaves the screen unchanged

tycn a

tyback a

Generally the following denition pro duces the desired eect

defun tyback cn

tycn bs

tycn sp

tycn bs

Required functions

The printing functions describ ed in this section print characters to the virtual terminals output

channel This channel is distinct from the ordinary terminal channel and has the numb er t as

its index When the current channel is t prints resulting from the action of the prin print and

princn functions and character emissions by the tyo and tyod functions o ccur in the same buer

The t channel is an output channel with the same status as the channel Its right margin is set

just after the end of the buer Recall the familiar formula slen outbuf Therefore

there is never an eol programmable interrupt on the t channel but only the flush interrupt when

the write p osition reaches the end of the buer

The tyflush function triggers a flush interrupt on the channel of the virtual terminal

Furthermore the buer is emptied by the system after each read p erformed by a tyi tys or

tyinstring function

tyo o ::: o function with a variable number of arguments

1 n

Prints the characters corresp onding to the ob jects o ::: o into the virtual terminals buer Each

1 n

ob ject o can b e one of the following i

VIRTUAL TERMINAL FUNCTIONS

 An internal character co de

 A character string

 A list of internal character co des

In LELISP tyo could b e dened in the following manner

defun tyo objs

with outchan t

while objs tyo nextl objs

defun tyo o

cond consp o mapc princn o

stringp o prin o

fixp o princn o

tyflush function with no arguments

Empties the virtual terminals buer by causing a flush programmable interrupt on the channel

t The flush function is invoked by this programmable interrupt and prints the contents of the

buer to the screen

In LELISP tyflush could b e dened in the following manner

defun tyflush

with outchan t

itsoft flush

tyod n nc function with two arguments

Prints the base nccharacter representation of the numb er n into the virtual terminal buer

The functions describ ed next give fullscreen editing control over the screen They are required for

the use of various to ols furnished with the system for example the pepe fullscreen editor If these

functions send escap e sequences or other control characters or sequences to the screen they must

use the virtual terminal output channel via the tyo function to ensure the prop er synchronization

of fullpage functions

typrolog ue function with no arguments

Activates the terminal in fullpage mo de This function must b e called b efore any calls to the

following functions

tyepilog ue function with no arguments Returns the screen to normal scrolling mo de

CHAPTER VIRTUAL TERMINAL

tyxmax function with no arguments

Returns the zerobased numb er of columns currently printable on the terminal Generally tyxmax

return for column terminals

This function in fact returns the value of the xmax global variable of the syspackagetty

package

In LELISP tyxmax could b e dened in the following manner

defun tyxmax

symeval getsymb syspackagetty xmax

tyymax function with no arguments

Returns the zerobased numb er of lines currently printable on the terminal Generally tyymax

return for column terminals

tycursor x y function with two arguments

Places the cursor in column p osition x on line y The upp erlefthandmost character p osition in

the corner of the screen has the index

tybs cn function with one argument

Moves the cursor p osition back one place without erasing anything on the screen The argument

sp ecies the character immediately preceding the cursor on the screen This lets programs back up

over prop ortionallyspaced characters

In general the following denition pro duces the desired eect

defun tybs cn

tyo bs

tycr function with no arguments

Places the cursor at the b eginning of the current line

In general the following denition pro duces the desired eect

defun tycr

tyo cr

tycls function with no arguments

Erases the entire screen

tybeep function with no arguments

VIRTUAL TERMINAL FUNCTIONS

Triggers the alarm or b ell of the terminal

tyleftke y function with no arguments

Returns the key co de asso ciated with the left arrow key By default this co de is B

tyrightk ey function with no arguments

Returns key co de asso ciated with the right arrow ! key By default this co de is F

tyupkey function with no arguments

Returns the key co de asso ciated with the up arrow " key By default this co de is P

tydownke y function with no arguments

Returns the key co de asso ciated with the down arrow # key By default this co de is N

Optional functions

tycleol function with no arguments

Erases the screen and places the cursor at the endofline p osition

tycleos function with no arguments

Erases the screen and places the cursor at the endofscreen p osition

tyinscn cn function with one argument

tyinsch ch function with one argument

These two functions which are identical in their b ehavior insert the character whose internal

character co de is cn at the current cursor p osition

tydelcn cn function with one argument

tydelch function with no arguments

These two functions erase the character at the current cursor p osition The tydelcn function takes

in addition a character co de cn which sp ecies the character to b e erased to facilitate the treatment

of prop ortionallyspaced characters If the character at the current cursor p osition do es not have

internal co de cn the eect on the screen is undened

In LELISP tydelcn could b e dened in the following manner

CHAPTER VIRTUAL TERMINAL

defun tydelcn cn

tydelch

tyinsln function with no arguments

Inserts a new line at the current cursor p osition Lines b elow the current line are scrolled down

and the last line if it was not empty disapp ears

tydelln function with no arguments

Erases the line at the current cursor p osition Lines b elow the current line are scrolled up and the

last line on the screen b ecomes blank

tyattrib i function with an optional argument

If the i ag is truethat is if it is dierent to tyattrib activates attribute mo de Otherwise

when it is equal to the attribute mo de will b e turned o Called with no arguments tyattrib

returns the current value of attribute mo de Attribute mo de highlights text on the screen and its

exact nature dep ends on the terminal It can b e implemented as underlining blinking or reverse

video

This function can b e used with the with control structure to mo dify the attribute in a lo cal context

with tyattrib t

tyo hello

defun tyattrib x

ifn x

symeval getsymb syspackagetty tyattrib

funcall getfn syspackagetty tyattrib car x

set getsymb syspackagetty tyattrib car x

tyshowcu rso r i function with an optional argument

If the i ag is truethat is dierent to tyshowcursor activates cursor display on the terminal

If i is falseif it is equal to then tyshowcursor deactivates cursor display Called with no

arguments the function returns the current value of the cursor display ag

This function can b e used with the with control structure to mo dify the cursor display in a lo cal

context

with tyshowcursor

vdt

tyco x y cn ::: cn function with a variable number of arguments

1 n

The form tyco x y cn ::: cn is equivalent to

1 n

progn tycursor x y tyo cn cnN

SCREEN FUNCTIONS

It places the cursor at p osition x y then prints the characters with co des cn ::: cn into

1 n

the terminal buer using the tyo function

tycot x y cn ::: cn function with a variable number of arguments

1 n

The form tycot x y cn ::: cn is equivalent to

1 n

with tyattrib t

tyco x y cn cnN

It places the cursor at p osition x y shifts into attribute mo de prints the characters with

co des cn ::: cn into the terminal buer using the tyo function and shifts back into the

1 n

previous mo de

Screen functions

A screen is a matrix of characters with a width w and a height h that is stored in the form of

a character string The following functions determine the dierences b etween two screen images

so that asynchronous screen up dates can b e p erformed They also let you place and manage sub

screens within a screen

redispla ysc re en sn so w h function with four or twelve arguments

Supp ose that sn and so are character strings that hold screen representations that are w wide by h

high redisplayscreen will up date the terminal using the tycursor and tyo functions describ ed

ab ove by sending sequences representing the dierences b etween the old screen so and the new

one sn At the end of the up date so will have b een physically mo died to contain all the characters

of sn so that calls to redisplayscreen can b e iterated

It is p ossible to add eight more arguments which have the same meaning here as they do in the

context of the next funtion

bltscree n sd ss w h function with four or twelve arguments

Moves characters from screen ss onto screen sd The screens are w characters wide and h characters

high If this function is called with only four arguments then the sizes of the screens are considered

to b e identical If twelve arguments are used a subscreen can b e placed anywhere on the main

screen The following is a description of these twelve arguments

 sd destination screen

 ss source screen

 wd width of the destination screen

 hd height of the destination screen

 ws width of the source screen

CHAPTER VIRTUAL TERMINAL

 hs height of the source screen

 xd xco ordinate of the destination subscreen

 yd yco ordinate of the destination subscreen

 xs xco ordinate of the source subscreen

 ys yco ordinate of the source subscreen

 wt width of the subscreen moved

 ht height of the subscreen moved

Here is a demonstration of the combined use of the two screenmanipulation functions that have

just b een describ ed

defun bltdemo

let nscreen makestring sp

oscreen makestring sp

for i

bltstring nscreen i

bltstring nscreen i

bltstring nscreen i

tycls

while t

redisplayscreen nscreen oscreen

for i

bltscreen nscreen nscreen

random random

i

Using the virtual terminal

There are three demonstration programs for the virtual terminal

 hanoi simulates the wellknown Tower of Hanoi puzzle

 whanoi do es the same but with asynchronous screen refresh

 vdt simulates the dicult life of an earthworm

They are found in the les hanoi whanoi and vdt in the standard library They are easy to read

and serve as guides to using the terminal directly the virtual terminal and the asynchronous refresh

functions

hanoi n function with one argument

Animates the Towers of Hanoi puzzle using n disks This n must lie b etween three and nine

inclusive This function is loaded automatically the rst time it is called

DEFINING A VIRTUAL TERMINAL

hanoiend function with no arguments

Reclaims space used by the functions comprising the game describ ed immediately ab ove

whanoi n function with one argument

This function is similar to the hanoi function except that it uses the asynchronous redisplay

provided by the redisplayscreen function

whanoien d function with no arguments

Reclaims space used by the functions comprising the game describ ed immediately ab ove

vdt function with no arguments

Runs an animated game that simulates the growth of an earthworm Use the arrow keys on the

terminal to direct the growth of the worm This function is loaded the rst time that it is called

vdtend function with no arguments

Reclaims space used by the functions comprising the game describ ed immediately ab ove

Dening a virtual terminal

syspac kag e tty variable

All the virtualterminal functions call functions whose names are computed according to the

following scheme

getfn syspackagetty name of the function

The tycn function for example is dened as follows

defun tycn cn

funcall getfn syspackagetty tycn cn

At system initializati on the syspackagetty variable has the value tty The functions

that implement the standard interface are therefore searched for in the tty package The

functions in this packagesuch as ttytycn ttytyi and ttytyoare the functions

that implement the physical interface to the user terminals

There are two things that you have to do when dening a virtual terminal

 Assign the appropriate value to the syspackagetty global variable

 Dene the required functions in the package whose value is that of syspackagetty

CHAPTER VIRTUAL TERMINAL

The syspackagetty variable must always p oint to a subpackage of the tty package to

p ermit the use of the virtual terminal default b ehaviors

These default b ehaviors are implemented by the following functions

 tyi tys and tyinstring empty the terminal buer after reads

 tyo tyod tyco and tycot govern the use of the virtual terminal buer

 tyinsch tydelch and other optional functions call the tyerror function

 tyerror returns

 redisplayscreen determines the dierence b etween two screens and sends sequences

to the screen using the tyo and tycursor functions

Usually for a sp ecic terminal it suces to redene the functions that handle insertion

and deletion of lines and characters See however the example of a virtual terminal of typ e

ttywindow in the virbitmap le of the standard library It redenes the tyi tys tycn

tynewline and redisplayscreen functions

As an example here is the denition of a virtual terminal for the H terminal

LeLisp version compilation of the virtual terminal H

setq syspackagetty ttyh

defvar ttyhxmax

defvar ttyhymax

defun ttyhtycursor col line

ttytyo line col

defun ttyhtycls

ttytyo

defun ttyhtycleol

ttytyo

defun ttyhtycleos

ttytyo

defun ttyhtydelch

ttytyo

defun ttyhtyinsln

ttytyo

defun ttyhtydelln

ttytyo

defun ttyhtyattrib x

if x ttytyo ttytyo

defvar ttyhtyattrib

DEFINING A VIRTUAL TERMINAL

defun ttyhtyinsch arg

ttytyo arg

defun ttyhtyprologue

ttyhtycls

defun ttyhtyepilogue

tycursor sub ttyhymax

defvar ttyhtyshowcursor t

CHAPTER VIRTUAL TERMINAL

Table of contents

Virtual terminal

Virtual terminal functions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Standard functions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Required functions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Optional functions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Screen functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

Using the virtual terminal ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Dening a virtual terminal ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Table of Contents

Function Index

initty symb function with an optional argument :::::::::::::::::::::::::::::::::::

systemvirttydirectory variable ::::::::::::::::::::::::::::::::::::::::::::

systemtermcapfile variable :::::::::::::::::::::::::::::::::::::::::::::::::

systemterminfodirectory variable ::::::::::::::::::::::::::::::::::::::::::

termcap feature ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::

terminfo feature ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

tyerror list function with one argument :::::::::::::::::::::::::::::::::::::::::

tyi function with no arguments :::::::::::::::::::::::::::::::::::::::::::::::::::

tys function with no arguments :::::::::::::::::::::::::::::::::::::::::::::::::::

tyinstring string function with one argument :::::::::::::::::::::::::::::::::::

tycn cn function with one argument :::::::::::::::::::::::::::::::::::::::::::::::

tystring string length function with two arguments :::::::::::::::::::::::::::::

tynewline function with no arguments ::::::::::::::::::::::::::::::::::::::::::::

tyback cn function with one argument ::::::::::::::::::::::::::::::::::::::::::::

tyo o ::: o function with a variable number of arguments :::::::::::::::::::::::::

1 n

tyflush function with no arguments :::::::::::::::::::::::::::::::::::::::::::::::

tyod n nc function with two arguments ::::::::::::::::::::::::::::::::::::::::::::

typrologue function with no arguments :::::::::::::::::::::::::::::::::::::::::::

tyepilogue function with no arguments :::::::::::::::::::::::::::::::::::::::::::

tyxmax function with no arguments ::::::::::::::::::::::::::::::::::::::::::::::::

tyymax function with no arguments ::::::::::::::::::::::::::::::::::::::::::::::::

tycursor x y function with two arguments ::::::::::::::::::::::::::::::::::::::::

tybs cn function with one argument :::::::::::::::::::::::::::::::::::::::::::::::

tycr function with no arguments ::::::::::::::::::::::::::::::::::::::::::::::::::

tycls function with no arguments :::::::::::::::::::::::::::::::::::::::::::::::::

tybeep function with no arguments ::::::::::::::::::::::::::::::::::::::::::::::::

FUNCTION INDEX

tyleftkey function with no arguments ::::::::::::::::::::::::::::::::::::::::::::

tyrightkey function with no arguments :::::::::::::::::::::::::::::::::::::::::::

tyupkey function with no arguments :::::::::::::::::::::::::::::::::::::::::::::::

tydownkey function with no arguments ::::::::::::::::::::::::::::::::::::::::::::

tycleol function with no arguments :::::::::::::::::::::::::::::::::::::::::::::::

tycleos function with no arguments :::::::::::::::::::::::::::::::::::::::::::::::

tyinscn cn function with one argument :::::::::::::::::::::::::::::::::::::::::::

tyinsch ch function with one argument :::::::::::::::::::::::::::::::::::::::::::

tydelcn cn function with one argument :::::::::::::::::::::::::::::::::::::::::::

tydelch function with no arguments :::::::::::::::::::::::::::::::::::::::::::::::

tyinsln function with no arguments :::::::::::::::::::::::::::::::::::::::::::::::

tydelln function with no arguments :::::::::::::::::::::::::::::::::::::::::::::::

tyattrib i function with an optional argument ::::::::::::::::::::::::::::::::::::

tyshowcursor i function with an optional argument :::::::::::::::::::::::::::::::

tyco x y cn ::: cn function with a variable number of arguments ::::::::::::::::::

1 n

tycot x y cn ::: cn function with a variable number of arguments ::::::::::::::::

1 n

redisplayscreen sn so w h function with four or twelve arguments ::::::::::::::::

bltscreen sd ss w h function with four or twelve arguments :::::::::::::::::::::::

hanoi n function with one argument :::::::::::::::::::::::::::::::::::::::::::::::

hanoiend function with no arguments :::::::::::::::::::::::::::::::::::::::::::::

whanoi n function with one argument :::::::::::::::::::::::::::::::::::::::::::::

whanoiend function with no arguments ::::::::::::::::::::::::::::::::::::::::::::

vdt function with no arguments :::::::::::::::::::::::::::::::::::::::::::::::::::

vdtend function with no arguments ::::::::::::::::::::::::::::::::::::::::::::::::

syspackagetty variable ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Chapter

Fullpage editor

A virtual terminalas describ ed in the previous chaptercan b e used to construct a fullpage

editor In the context of LELISP the le pepe in the standard library presents us with an editor

of this kind The use of LELISP as the implementation language for such an editor facilitates

development and debugging and gives rise to an extensible editor

Functions to call the fullpage editor

pepe feature

This ag indicates whether the fullpage editor called pepe has b een loaded into memory

pepe f special form

This function calls the pepe editor on the ob ject f which is not evaluated There is an easier way

to do the same thing using the macro character CONTROLE which we often write as E Typing

E and then thingwith no blank b etween E and thingcorresp onds to the call pepe thing

 If the thing ob ject is the current buer is edited

 If the ob ject is t editing b egins on a new buer named tmp

 If the ob ject is an atom the le of the same name is edited

 If the ob ject is a list it is evaluated and editing b egins on a buer named tmp that

contains everything that was printed as a result of this evaluation

Let us lo ok at a few examples To edit a disk le named fooll typ e

Efooll

To edit the prettyprinted versions of the foo and bar functions typ e

Epretty foo bar

To edit the sorted list of system functions typ e

CHAPTER FULLPAGE EDITOR

Emapc print sortl maploblist typefn

pepefile f function with one argument

This function is similar to the previous one except that it evaluates its argument

pepend function with no arguments

Allows you to regain space taken up by the editor functions The pepe ag disapp ears and any

succeeding call to pepe will reload these functions The editor buer is also deallo cated

Fullpage editor commands

CONTROLA Go to the b eginning of the line

CONTROLB Go back one character

CONTROLC Quit the pepe editor reenter with E

CONTROLD Erase the current character

CONTROLE Go to the end of the line

CONTROLF ! Go forward one character

CONTROLG Kill the current command

CONTROLK Erase the line containing the cursor

CONTROLL Redisplay the entire screen

CONTROLM - Break the line at the cursor p osition

CONTROLN # Go to the next line

CONTROLO Break the line at the cursor level

CONTROLP " Go to the preceding line

CONTROLS Search for a string

CONTROLV Go to the next screen

CONTROLY Insert at the current cursor p osition the last line erased with K

DELETE Erase the character to the left of the cursor

ESCAPEE Execute the contents of the current buer

ESCAPEF Change the name of the current le

ESCAPEI Insert the contents of another le

ESCAPER Read a new le into the buer

ESCAPES Save the current buer into the current le

ESCAPEV Go to the previous screen

ESCAPEW Write the current buer into a le

ESCAPEX Call a pepe function directly

ESCAPEZ Save the current buer onto disk and load it into memory

ESCAPE Place the cursor on the next character in a LISP style

ESCAPE Place the cursor on the next character in a LISP style

ESCAPE Go to the b eginning of the buer

ESCAPE Go to the end of the buer

ESCAPE Display the present pepe help list

FULLPAGE EDITOR COMMANDS

Extensions to the fullpage editor

An interesting feature of pepe is its extensibility Extensions can b e made simply by assigning new

op erations to keystrokes The following two functions asso ciate LELISP expressions with keystrokes

defkey key e ::: e special form

1 n

Asso ciates the expressions e ::: e with the value of key

1 n

defescke y key e ::: e special form

1 n

Asso ciates the expressions e ::: e with the sequence of keystrokes ESCAPEkey

1 n

CHAPTER FULLPAGE EDITOR

Table of contents

Fullpage editor

Functions to call the fullpage editor :::::::::::::::::::::::::::::::::::::::::::::

Fullpage editor commands ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Extensions to the fullpage editor :::::::::::::::::::::::::::::::::::::::::

Table of Contents

Function Index

pepe feature ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::

pepe f special form ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::

pepefile f function with one argument :::::::::::::::::::::::::::::::::::::::::::

pepend function with no arguments ::::::::::::::::::::::::::::::::::::::::::::::::

defkey key e ::: e special form ::::::::::::::::::::::::::::::::::::::::::::::

1 n

defesckey key e ::: e special form ::::::::::::::::::::::::::::::::::::::::::

1 n

Chapter

Terminalbased line editor

The terminalbased commandline editor called edlin is available in interactive mo de from

the keyb oard Using this editor you do not need to retyp e long or complicated commands The

editor facilitates all the usual editing op erations on input lines and it can carry out automatic

searches for symb ols

The edlin to ol is not a fullpage editor since it works on one line at a time It do es not use

cursoraddressing functions and it scrolls the screen when necessary The following virtualterminal

primitives are used to insert and erase characters erase endoflines and move the cursor around

within a line

tyinscn

tydelcn

tycleol

tycr

tybs

tynewline

The edlin to ol is written so that it can b e used with prop ortionallyspaced fonts The functions

asso ciated with this editor are found in the standard library named edlin

Loading the terminalbased line editor

edlin feature

This ag indicates whether the edlin line editor has b een loaded into memory

edlin function with no arguments

If the edlin line editor has not already b een loaded and activated this function p erforms these

tasks

The editoravailable as so on as this function has b een calledmanages the LELISP reader This

means that the editing capability of edlin can b e available throughout an entire session regardless

of the application that carries out reading

CHAPTER TERMINALBASED LINE EDITOR

The edlin editor provides online help which can b e obtained by hitting the ESCAPE key followed

by a question mark

Terminalbased lineeditor commands

Cursor movement of an EMACS kind

CONTROLF Move forward one character

CONTROLB Move back one character

ESCAPEF Move forward one word

ESCAPEB Move back one word

CONTROLA Move to the b eginning of the line

CONTROLE Move to the end of the line

Deletions the DELETE key can b e used in place of BACKSPACE

CONTROLD Erase the next character

BACKSPACE Erase the previous character

ESCAPED Erase the next word

ESCAPEBACKSPACE Erase the previous word

CONTROLU Erase to the b eginning of the line see Y

CONTROLK Erase to the end of the line see Y

CONTROLY Reinsert characters erased by U or K

Command history

CONTROLI Recall the previous command

CONTROLN Recall the next command

ESCAPE Beginning of history

ESCAPE End of history

ESCAPEH Show history

ESCAPEESCAPE Retrieve a previous command that b egins like the current one

End of line

RETURN or LINEFEED Send the line to LISP and save it in the history

CONTROLO Send the line to LISP and skip to the next line in the history

Shortcuts

ESCAPESPACEBAR Complete the symb ol preceding the cursor or show all completion p ossibilities

ESCAPE Quote the current symb ol

TERMINALBASED LINEEDITOR COMMANDS

Miscellaneous

ESCAPEnumber command Rep eat command number times

CONTROLL Redisplay the line

Quote character forces literal interpretation of the following character

ESCAPECONTROLG Illegal sequence useful when ESCAPE has b een hit by mistake

ESCAPE edlin help

CONTROLT Translate that is interchange the two previous characters

edlin Run edlin

edlinend Kill edlin

Commands that are also LELISP macro characterssuch as L for exampleare not interpreted

as macros at the b eginning of a command line Consequently the quote character do es not need

to b e used in these cases

CHAPTER TERMINALBASED LINE EDITOR

Table of contents

Terminalbased line editor

Loading the terminalbased line editor :::::::::::::::::::::::::::::::::::::::::::

Terminalbased lineeditor commands ::::::::::::::::::::::::::::::::::::::::::::

Table of Contents

Function Index

edlin feature ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::

edlin function with no arguments :::::::::::::::::::::::::::::::::::::::::::::::::

Chapter

Virtual bitmap display

The LELISP system provides a p ortable graphics facility called the Virtual Bitmap Display often

referred to as vbd It is capable of managingindep endently of the underlying hardwarea high

resolution bitmapp ed screen and a p ointing device This graphics facility provides LISP functions

that construct windows draw into these windows and react to p ointingdevice movements These

three asp ects are relatively indep endent They are describ ed in chapters and of the

present Reference Manual

The Virtual Bitmap Display facility has b een p orted to a variety of hardware devices using dierent

window systems servers and managers

A version running on classic alphanumeric terminals based on the virtual terminal facility is

available in the standard LELISP system congured with the bvtty feature This version is quite

limited due to the low resolution of alphanumeric terminals

Loading the description le

The vbd functions are parameterized by conguration les describing the various screen managers

to which the system has b een p orted These les are stored in the virbitmap directory of the

standard LELISP distribution

Before the vbd functions can b e used the description le corresp onding to the relevant screen

manager must b e loaded This is done by the inibitmap LISP function This op eration should b e

carried out only once p er LISP session It is p ossible of course to save a core image le after this

op eration has b een p erformed When the image is restored the description le do es not need to b e

reloaded

On some systems and in particular on most UNIX systems loading a screen manager requires the

use of a LISP executable that includes lowlevel primitives that read from and write to the screen

and the p ointing device For more details see the manual describing the LELISP implementation

on your particular system

inibitma p symbol function with an optional argument

Loads the screen manager description le symbol is the name of the kind of screen manager to b e

loaded

CHAPTER VIRTUAL BITMAP DISPLAY

Here are the names that are currently recognized

 X to load the XWINDOW System versions Xr Xr or Xr

 mac to load the Macintosh To olBox

 uis to load a VaxStation with uis

 bvtty to load the minimal vbd for alphanumeric terminals

If symbol is not given the value of the BITMAP environment variable is used See the getenv

function

Here for example is the loading of an XWINDOW System rx description le

inibitmap X

X

Note that several dierent description les can b e loaded in succession This might b e

necessary if dierent screen typ es are to b e managed during a single session

inibitmap bvtty

bvtty

At this stage X and bvtty are b oth available in the LELISP environment

Screen preparation

A socalled screen is a LISP structure that allows you to manipulate a physical screen device A

physical screen device normally includes a bitmapp ed video display tub e a keyb oard and a mouse

The vbd functions can build screens on dierent physical screen devices simultaneously since

these functions work on the logically current screen which can b e read from and written to by the

currentdisplay function

Managing a single screen

If only a single screen is to b e used in a LISP session the rst call to one of the vbd functions will

automatically allo cate a screen of the typ e loaded by inibitmap and will set the current screen

variable to p oint to it In this case it is not necessary to call the bitprologue and currentdisplay

functions since the work they do will have already b een done

Here for example is the creation of a window

createwindow window fenestre

window fenestre

SCREEN PREPARATION

Managing several screens

If several dierent screens are to b e managed simultaneously bitprologue has to b e called to

create them explicitly The currentdisplay function lets you move from one screen to another

bitprolo gue name device function with one or two optional arguments

Creates initializes and returns as its result a screen for the screen manager of typ e name name is

one of the symb ols recognized by the inibitmap function If name is not supplied the name of the

last window manager loaded by inibitmap is used

The screen returned by this function can b e used as an argument in the screen p osition in the

functions describ ed b elow

device is a supplementary argument that dep ends on the screen manager b eing used For

the XWINDOW System environments X this argument is a character string describing the

connection in the standard X format If the device argument is not supplied the value of

the DISPLAY environment variable is used

current dis pl ay screen function with an optional argument

Returns the current screen If an argument is supplied the current display is changed to b e

the argument value This current screen is involved in the following op erations

 Windows are created on the current screen by means of createwindow and makewindow

 Icons are created on the current screen by means of createbitmap

 Fonts are created on the current screen by means of loadfont

 Colors are created on the current screen by means of makecolor makenamedcolor

and makemutablecolor

 Cursors are created on the current screen by means of makecursor

 Patterns are created on the current screen by means of makepattern

 Events are read on the current screen by means of readevent peekevent and eventp

 Windows are found on the current screen by means of findwindow

The current window is an implicit argument for the vbd drawing functions

In the following examples we are dealing with machines named london and paris We rst

op en the screen of the machine called london

setq london bitprologue X london

displayX X london

We then op en the screen on the machine called paris

setq paris bitprologue X paris

displayX X paris

CHAPTER VIRTUAL BITMAP DISPLAY

We now op en a window on london

currentdisplay london

displayX X paris

setq londonwindow createwindow window london

window london

Next we op en a window on paris

with currentdisplay paris

setq pariswindow createwindow window paris

window paris

We draw something on london

with currentwindow londonwindow

drawline

Finally we draw something on paris

with currentdisplay paris

currentwindow pariswindow

drawline

bitepilo gue screen function with an optional argument

Closes screen by killing all its op en windows and all the icons fonts colors cursors and patterns

that might have b een created within it It also empties the queue of events waiting on this screen

You cannot use screen as an argument to the currentdisplay function after this call If the

screen argument is not supplied the current screen is closed

bitmaps ave screen function with an optional argument

Closes screen in the same way as the previous function but stores in screen the set of ob jects

that were created within it It also returns the saved screen as its value The saved screen can

b e passed later to the bitmaprestore function in order to automatically reconstruct all the

ob jects it contained b efore the save Warning The contents of windows are not saved but each

window receives a repaintwindowevent event as the restore comes to completion If the screen

argument is not supplied the current screen is saved

Used in conjunction with the savecore function bitmapsave makes it p ossible to save LISP core

image les containing windows

let savedscreen bitmapsave

savecore imagecore

bitmaprestore savedscreen

FUNCTIONS ON SCREENS

bitmapr est or e screen function with one argument

The screen argument is a screen saved by the previous function The function initialize s screen

and reconstructs all the ob jectswindows icons fonts cursors colors and patternsthat were

within it when it was saved The contents of windows are not saved but each window receives a

repaintwindowevent event as the restore comes to completion

Functions on screens

The functions in this section rep ort data concerning the current screen its size fonts colors cursors

and patterns and its predened windows if any

These functions can take an optional screen argument If this argument is not supplied they

op erate on the current screen

bitxmax screen function with an optional argument

bitymax screen function with an optional argument

These functions return the dimensions of the screen The value of bitxmax is the width of the

screen minus one and the value of bitymax is its height minus one The units are those of the

elementary display p oints pixels of the device

For an Ap ollo screen these functions return the following values

bitxmax )

bitymax )

rootwin dow screen function with an optional argument

Returns the window asso ciated with the screen background Drawing carried out in this window

writes over all the other windows p osted to the screen

The ro ot window can b e used to follow the mouse on the whole screen for example when a

nonro ot window is b eing moved or resized

Op erations in the ro ot window should b e as nondestructive as p ossibleusing xor for drawing and

then erasing images for exampleso that the contents of other windows will not b e p erturb ed

The following visuallystriking function for example blinks the whole screen once

defun flashscreen

with currentwindow rootwindow

with currentmode

fillrectangle bitxmax bitymax

bitmapflush

fillrectangle bitxmax bitymax

bitmapflush

CHAPTER VIRTUAL BITMAP DISPLAY

allcolo rs screen function with an optional argument

Returns the list of colors that have b een allo cated by the makecolor makenamedcolor and

makemutablecolor functions See the descriptions of these functions

bitmapr efr es h screen function with an optional argument

Requests that screen b e refreshed This function can b e used to clear the screen of stray bits that

might b e left after the execution of an incorrect graphics program

If the host system do es not preserve window contents the XWINDOW system do es not for example

the windows will all b e simply erased and sent repaintwindowevent events

bitmapf lus h screen function with an optional argument

In some systems for example in the XWINDOW system the stream of graphic op erations is

buered These op erations will b e visible on the screen only when the buer has b een emptied This

buer is automatically emptied by a call to one of the event manipulation functions readevent

peekevent or eventp

Sometimes it is necessary to explicitly empty the buer This happ ens for instance when frequent

up dates are required for animating a simulation or when event reads are not b eing constantly

done At such times bitmapflush can b e used to explicitly empty the buer of surplus events

In the following function which displaces a character in the screen background the use of

bitmapflush makes sure that the movement is regular

defun movechar cn

let x y dx dy

with currentwindow rootwindow

currentmode modexor

currentfont largeromanfont

while t

drawcn x y cn

setq x x dx

y y dy

when or x bitxmax x

setq x x dx

dx dx

when or y bitymax y

setq y y dy

dy dy

drawcn x y cn

bitmapflush

bitmaps ync display function with an optional argument

This function makes sure that all requests sent to the server have b een executed and that all

events generated by these requests are in the events le If the display argument is not supplied

the current display is used

FUNCTIONS ON SCREENS

display syn ch ron iz e display flag function with one or two arguments

Certain systems such as X can op erate in two mo des

 Asynchronous A graphic action might not b e terminated when the function that triggered

it returns control the default option under X

 Synchronous A graphic action is terminated when the function that triggered it returns

control

On systems op erating in the two mo des synchronous and asynchronous this function lets you

know the current mo de or go from one to the other The synchronous mo de corresp onds to a true

value of the flag argument The asynchronous mo de corresp onds to a false value This function

should only b e used for debug and must not b e employed in normal use

display dep th display function with one argument

This function returns the numb er of plans bits by pixel in the screen used by the display device

If the display device is mono chrome it therefore returns

default win do wt yp e screen type function with one or two arguments

If the type argument is not supplied this function gives you the typ e used by default by the

windows in screen Supply type if you want to mo dify it

standard ro ma nf on t screen function with an optional argument

standard bo ld fo nt screen function with an optional argument

largero man f ont screen function with an optional argument

smallro man f ont screen function with an optional argument

These functions return the numeric indices of the preloaded fonts of screen or the current screen

See the currentfont function Four xedwidth fonts are always available

 standardromanfont is a regular font that can b e used for text

 standardboldfont is a b older font that can b e used to highlight text

 largeromanfont is a larger font that can b e used for titles

 smallromanfont is a smaller font that can b e used for notes and captions

standard fo re gro un d screen function with an optional argument

CHAPTER VIRTUAL BITMAP DISPLAY

standard ba ck gro un d screen function with an optional argument

These two functions return the initial foreground and background colors

See the currentforeground and currentbackground functions

standard fo re gro un dp att er n screen function with an optional argument

standard ba ck gro un dp att er n screen function with an optional argument

standard li gh tg ra yp att er n screen function with an optional argument

standard me di um gr ay pat te rn screen function with an optional argument

standard da rk gr ay pa tte rn screen function with an optional argument

These functions return the numeric indices of the predened textures ll patterns of screen or

the current screen See the currentpattern function

The standardforegroundpattern and standardbackgroundpattern are solids that use

the current value returned by currentforeground and the current value returned by

currentbackground Their eect therefore dep ends on the current colors

The other predened patterns are grays that are indep endent of the current foreground and

background colors They provide a regular gradation b etween the initial foreground color given

by the value of standardforeground and the initial background color given by the value of

standardbackground Here are the details

 standardmediumgraypattern

A medium grayed value b etween these two colors

 standardlightgraypattern

Between standardbackground and standardmediumgraypattern

 standarddarkgraypattern

Between standardforeground and standardmediumgraypattern

standard le li sp cu rso r screen function with an optional argument

standard gc c urs or screen function with an optional argument

standard bu sy cu rs or screen function with an optional argument

These functions return the numeric indices of the predened cursors of screen or the current screen

See the currentcursor function

FUNCTIONS ON WINDOWS

These cursors can b e used in one of the following capacities

 standardlelispcursor is displayed during normal LELISP op eration

 standardgccursor is displayed during garbagecollection cycles See the gcalarm and

gcbeforealarm functions

 standardbusycursor is displayed when LELISP is carrying out a long computation

standard fo re gro un d screen function with an optional argument

standard ba ck gro un d screen function with an optional argument

These function return initial foreground and background colors These are the foreground and

background colors which are set for each newlycreated window

In some systems these colors are selectable by the user at LELISP startup time In the XWINDOW

System for example this can b e done in the Xdefaults le

Functions on windows

Global co ordinates

A global bitmap coordinate is a pair of integers x y that represents an address on a highresolution

screen

The origins of this co ordinate system are dened as follows

 Upp er left corner x y

 Lower left corner x ybitymax

 Upp er right corner xbitxmax y

 Lower right corner xbitxmax ybitymax

Lo cal co ordinates

The graphics environment attached to a window denes a lo cal co ordinate system in the window

dened as follows

 Upp er left corner of the window x y

 Lower right corner of the window xwindow height ywindow width

The title and b order regions are outside this co ordinate system but can b e represented in it by

using negative co ordinates The p oint for example is in the b order region of the window

CHAPTER VIRTUAL BITMAP DISPLAY

Windows

Windows are typ ed structured ob jects that have graphical representations on the screen See the

explanation of structures These are rectangular frames that can have an optional title A graphics

environment is attached to each window This environment supp orts various text line and zone

drawing op erations within the window See the section on virtual graphics

Window events are caused by mouse p ointer movements and button clicks or selections that o ccur

when the p ointer is within a window See the readevent function Likewise the displacement

or resizing of windows by a nonLISP to ol such as the window manager running in an XWINDOW

System environment can cause events informing LELISP that the windows were mo died or need

to b e redrawn

The Virtual Bitmap Display facility do es not assume that the contents of hidden parts of windows

are saved by the system When they are not saved a repaintwindowevent indicates the

concealed areas that need to b e redrawn

Each window can contain any numb er of subwindows which have neither b orders nor titles They

can cover each other in any manner but they are all transparent so that a subwindow do es not

obscure the contents of a daughter or sister subwindow that it covers Moreover subwindows have

no contents The displacement or resizing of a subwindow never visually aects the screen

Subwindows are manipulated in the same way as windows All the graphics and window

manipulation functions can b e p erformed on subwindows It is even p ossible to divide subwindows

into subsubwindows Graphics op erations in subwindows are carried out in the co ordinate

system of the subwindow but the image is clipp ed limited to that part of the subwindow

contained within the mother window Subwindows obtain mouse events with the priority due

the sup erwindow that contains them However they never receive repaintwindowevent or

modifywindowevent events

The total numb er of windows that can b e displayed at a given moment might b e limited in some

systems If this limit is surpassed window creation functions raise the errnmw error which has the

following screen display

fn no more windows available

Some systemssuch as virtual windows on the virtual terminaldo not have virtual graphics Even

so these systems have a minimal graphics environment that allows only the display of text This

minimal graphics environment is describ ed in the remainder of this chapter and the full graphics

environment is describ ed in chapter

The system recognizes a current window on which displayoriented functions o ccur There is one

current window p er screen

At systemwindow initializationthat is after the call to the bitprologue functionthe current

window is the sp ecial window which indicates that the only available window is the virtual

terminal and that graphics functions will have no eect

WINDOWS

Creating windows

The creation of a window or a subwindow usually happ ens with a call to the makewindow function

which receives an instance of the imagerectanglewindow structure as its argument This

structure must b e allo cated and its elds must b e lled in with appropriate values b efore the

call to makewindow The createwindow and createsubwindow functions provide the means to

allo cate an instance of this structure and to call the makewindow function in a single call

imager ect an gle w ind ow structure

This LISP structure represents a window It is dened as follows

defstruct imagerectangle

x y w h

defstruct imagerectanglewindow

title

hilited

visible

graphenv

extend

father

properties

cursor

display

subwindows

eventslist

windowtype

graphicproperties

state

Some elds must b e set by the user b efore a call to the makewindow function is made Other elds

will b e set automatically by the system

The elds that must b e lled are describ ed next They should never b e mo died directly after the

call to makewindow has b een made Instead window manipulation functions should b e used to

mo dify them although they can b e directly examined ie read at any time

 x y short integers the upp er left corner of the window expressed in the global co ordinate

system for windows and in the lo cal co ordinate system of the mother window for subwindows

The window can contain various b orders and titles according to the host system See the

hilited and visible elds These will always b e outside the window prop er The co ordinate

p oint in the window will always b e a p oint x y in the global co ordinate system for

a window or in the lo cal co ordinate system of the mother window for a subwindow

 w h short integers the width and height of the useful zone of the window that is not

counting the b order or title zones Each value is indicated as a numb er of basic display p oints pixels for the device

CHAPTER VIRTUAL BITMAP DISPLAY

 title character string the optional title to b e p osted in the window b order

 hilited short integer indicates the highlight mo de of the window If this eld has the value

zero the window is not highlighted If it is not equal to zero its value indicates the highlight

mo de title highlighted window colored etc The various highlight mo des available dep end

on the system By default only one mo de exists co ded by the value

 visible short integer indicates the windows visibility degree on the screen If this ag

has the value zero the window is invisible If it is not equal to zero its value indicates the

visibility degree entirely visible semivisible transparent etc The available visibili ty degrees

dep end on the system By default a single degree of visibility is available co ded by the value

This represents opacity meaning that the window obscures windows that it covers

 father window or contains the windows parent window If it has the sp ecial value

then there is no parent window Otherwise this eld represents a previouslyconstructed

window of which the current window is a subwindow

 display screen contains the screen on which the window is displayed If this eld is

not lled the makewindow function displays the window on the current screen See the

bitprologue function

 windowtype the typ e of the window transparent or opaque In XWINDOW these typ es

corresp ond to InputOnly and InputOutput Opaque windows can receive events of redisplay

typ e whereas transparent windows cannot

 state symb ol the current state of the window iconify map or unmap

The other elds are maintained by the system They can b e read by the user at any time but must

not b e mo died

 graphenv structure graphenv contains the graphics environment attached to the window

 extend the contents and typ e of this eld are systemdep endent and not of much interest to

the user

 properties a list contains the prop erty Alist attached to the window See the

definewindowpropertyaccessor function

 cursor short integer contains the cursor currently attached to the window See the

currentcursor function

 subwindows list of windows contains the list of the windows subwindows

 eventslist contains the list of authorized events of the window

 graphicproperties contains a list of internal graphic prop erties

Windows can b e instances of any substructure of the imagerectanglewindow structure This

together with the fact that windowmanipulation functions work by sending messages to windows

means that the Virtual Bitmap Display facility can b e easily extended See the virbitmap le of

the standard distribution for more information on this sub ject

WINDOWS

makewin dow win function with one argument

This function takes an instance of a window structure of a certain typ e as argument and do es

everything necessary to create a window of this typ e describ ed by the structure It returns win as

its value with the systemmaintained elds lled in as describ ed ab ove All the other elds of the

win structurex y w h title hilited visible father and displayshould b e initialized

b efore the call to makewindow To make a subwindow set the father eld of win to contain

the structure of a previouslycreated window In all other cases father must contain If the

display eld contains then makewindow lls it with the value of the current screen See the

currentdisplay function

The following function creates a window whose p osition and size are passed as arguments

defun buildwindow x y w h

let window new imagerectanglewindow

imagerectanglex window x

imagerectangley window y

imagerectanglew window w

imagerectangleh window h

imagerectanglewindowtitle window fenestre

imagerectanglewindowhilited window

imagerectanglewindowvisible window

imagerectanglewindowdisplay window currentdisplay

makewindow window

window

createw ind ow type x y w h ti hi vi function with eight arguments

Allo cates a window of typ e type This must b e a subtyp e of the imagerectanglewindow typ e

The function initializes the elds of the window with the values passed as arguments and calls the

makewindow function createwindow provides a convenient means for building a window without

explictly allo cating its structure instance

createwindow has the same b ehavior as the following function

defun createwindow type x y w h ti hi vi

let window new type

imagerectanglex window x

imagerectangley window y

imagerectanglew window w

imagerectangleh window h

imagerectanglewindowtitle window ti

imagerectanglewindowhilited window hi

imagerectanglewindowvisible window vi

imagerectanglewindowdisplay window currentdisplay

makewindow window

window

creates ubw in dow type x y w h ti hi vi fa function with nine arguments

This function is similar to the last one except that it creates a subwindow of the fa parent window

The x and y co ordinates should b e in the lo cal co ordinate system of fa

CHAPTER VIRTUAL BITMAP DISPLAY

Drawing in windows

The makewindow call adds a repaintwindowevent event to the event queue as so on as the

window has actually b een created This event must b e received and handled b efore any drawing is

done in the window Requests to draw in the window that o ccur b efore this event might in fact b e

lost

Wellstructured programs using the vbd should therefore create windows and then enter an event

handling lo op which primarily waits on repaintwindowevent events and paints the windows

b oth initially and then after changes are made to windows during the execution of the program

The following example shows how such an eventhandling lo op might b e written The nicepicture

function draws something in the window The openwindow function creates a window then enters

an eventhandling lo op the processevents function This lo op reacts to repaintwindowevent

events by calling nicepicture to draw or redraw the window contents The lo op terminates and

kills the window as so on as a mouse click o ccurs The processevents lo op is a typical event

handling pro cedure that is presented here as a mo del for writing other lo ops of a similar nature

Chapter describ es in detail the kind of b ehavior that should b e asso ciated with the various typ es

of vbd facility events

defun openwindow

let window createwindow imagerectanglewindow target

protect

processevents

killwindow window

bitmapflush

defun processevents

untilexit done

let event readevent

selectq eventcode event

repaintwindowevent

with currentwindow eventwindow event

currentclip eventx event

eventy event

eventw event

eventh event

nicepicture

downevent

exit done

modifywindowevent

updatewindow eventwindow event

eventx event

eventy event

eventw event

eventh event

defun nicepicture

unless nicecolors niceinit

let colors apply cirlist nicecolors

for i div imagerectanglew currentwindow

with currentforeground nextl colors

fillcircle

WINDOWS

div imagerectanglew currentwindow

div imagerectangleh currentwindow

i

defvar nicecolors

defun niceinit

setq nicecolors

list

makecolor

makecolor

makecolor

makecolor

makecolor

Attaching prop erties to windows

It is p ossible to attach named prop erties to each instance of the imagerectanglewindow typ e

These prop erties are manipulated like elds but they are stored in an Alist in the windows

properties eld

definew ind ow pr op ert ya cc ess or prop macro

This macro denes the imagerectanglewindowprop function to b e an access function to the

window prop erty named prop which must b e a symb ol

image rec ta ngl e win dow p rop w v function with one or two arguments

Examines or sets if the second argument is supplied the value asso ciated with the prop erty named

prop b elonging to the window w If the window do es not have the prop prop erty is returned

The prop erty is stored in the Alist in the prop erties eld of window w To distinguish b etween the

absence of the prop erty and its presence with the value examine this Alist directly

Prop erties only take up memory space in a window structure if the window actually has the

prop erties in question

Here for example is the denition of a window prop erty named contents

definewindowpropertyaccessor contents

imagerectanglewindowcontents

For the win window this prop erty has the value in win

imagerectanglewindowcontents win in win

in win

Let us lo ok at this value

imagerectanglewindowcontents win

in win

CHAPTER VIRTUAL BITMAP DISPLAY

Finally let us lo ok at the prop erty lists of win and of another window called win

imagerectanglewindowproperties win

contents in win

imagerectanglewindowproperties win

Functions on windows

The following functions let programs act on windows created by the makewindow createwindow

or createsubwindow functions Their role is to simply transmit messages to the window sp ecied

in their arguments It is the primitive window functions describ ed in the next section which act

directly on windows Generally only the functions describ ed in this section are used

current win do w win function with an optional argument

The window passed as the argument will b ecome the current window on the screen to which it is

attached All ensuing graphics functions will take place in this window If no argument is furnished

currentwindow returns the current window The current window has no role other than to b e the

implicit argument for drawing functions

If the argument is the screens current window b ecomes and the graphics printing functions

will not b e eective on this screen

If the argument is a window which has b een killed the system raises the errnotawindow error

with the following display

fn not a window e

Whenever an argument is supplied the uncurrentwindow message is sent to the current

window b efore the current window is changed

A window can b e temp orarily selected by using currentwindow within a with control

structure Here for example is a way to draw a line in a window

with currentwindow window

drawline

current key bo ard f ocu sw in dow win function with an optional argument

Examines or mo dies if the second argument is given the current owner of the keyb oard The

owner of the keyb oard is the window that receives asciievent events See the readevent

function After a call to this function keyb oard strokes will result in asciievent events b eing

sent to the win window

The host windowing system or a window manager can sometimes change the keyb oard owner

indep endently of LELISP In this case keyboardfocusevent events will b e generated and placed

in the event queue LELISP structures can b e kept up to date by treating them appropriately

WINDOWS

modifyw ind ow win x y w h ti hi vi function with eight arguments

The win agument is a window previously created by the makewindow function The x y w h

ti hi and vi arguments are similar to the arguments of the same name of the createwindow

function This function provides a means of mo difying the parameters of a window Its p osition

title or size can b e changed it can b e highlighted or unhighlighted and it can b e made visible or

invisible The function returns the mo died window structure as its value By convention if one

of the arguments x y w h ti hi or vi has the value the corresp onding parameter remains

unchanged

Window size mo dications do not aect the size of subwindows

As an example let us create a window entitled Lisp and a window entitled Foo

defvar wlisp createwindow window Lisp

wfoo createwindow window Foo

Move the window named Lisp

modifywindow wlisp

Reduce the size of the window named Foo

modifywindow wfoo

Mo dify the title of the window named Lisp

modifywindow wlisp New Title

Highlight the title of the wfoo window

modifywindow wfoo

Erase the wlisp window from the screen making it invisible

modifywindow wlisp

Cause this same window to reapp ear

modifywindow wlisp

killwin dow win function with one argument

Kills the window given as its argument as well as all its subwindows if it has any If the

window is visible it will b e erased from the screen Any further use of this window will raise the

errnotawindow error The windowp predicate applied to win will subsequently return Note that

win can b e rebuilt using the makewindow function but this would not rebuild any subwindows

it might have had

If the current window is killed by this function the window b ecomes the current window The

window that was current b efore killwindow was called receives an uncurrentwindow message b efore b eing killed

CHAPTER VIRTUAL BITMAP DISPLAY

movewin dow win x y function with three arguments

Move the win window at the co ordinate p oint x y

resizew ind ow win w h function with three arguments

Resize the win window with a width of w and a height of h

moveres ize w ind ow win x y w h function with ve arguments

Perform a movewindow win x y followed by a resizewindow win w h

windowe ven ts li st win events function with one or two arguments

Consult or set if the events argument is present the event list attached to the win window

events when present is a list of events among downevent upevent asciievent :::

windowt itl e win title function with one or two arguments

Consult or set if the title argument is present the title of the win window title when present

must b e a character string Only main windows can have a title

windows tat e win state function with one or two arguments

Consult or set if the state argument is present the state of the win window state when present

must b e a symb ol among map unmap lower raise and iconify This function can iconify a

window and later raise it

windowb ack gr oun d win color function with one or two arguments

Consult or set if the color argument is present the background color of the win window color

when present must b e a valid instance of the color typ e

windowb ord er win border function with one or two arguments

Consult or set if the border argument is present the size in pixels of the b order of the win

window

windowc lea r reg io n win x y w h function with ve arguments

Clear the rectangle x y w h of the win window

windowp win function with one argument

This predicate is true if win is an instance of the imagerectanglewindow typ e or of one of

WINDOWS

its subtyp es and if win has b een created by createwindow createsubwindow or makewindow

and has not yet b een killed by killwindow

The next two functions provide means to manage the display order of windows displayed on the

screen They mo dify the stacking order of the windows but not their x y co ordinates

popwind ow win function with one argument

Puts the win window in the foreground

movebeh ind w ind ow win win function with two arguments

Puts the win window b ehind the win window on the screen This do es not necessarily mean that

win is directly b ehind win The stacking p osition of win is not changed

The next two functions provide means to use absolute co ordinates when dealing with windows

findwin dow x y function with two arguments

Returns the lowest LISP window in the stacking hierarchy that contains the screen p oint x y

considered as a p oint in the global co ordinate system If this p oint do es not app ear in any window

findwindow returns

Points in b order and title areas count for findwindow as b eing included in their windows

mapwind ow win x y symbx symby function with ve arguments

The win argument is a window x and y are numb ers designating a p oint in the global co ordinate

system of the screen symbx and symby are symb ols When mapwindow returns these symb ols

contain as their values the co ordinates in the lo cal co ordinate system of win of the global p oint

x y

Return values from mapwindow are only meaningful for x y p oints that are in the window win

or in its b order or title regions Given p oints in the b order or title regions mapwindow will just

return lo cal co ordinates that are not contained in the window area prop er

defvar w createwindow window w

x

y

eq w findwindow

t

mapwindow w x y

x

y

CHAPTER VIRTUAL BITMAP DISPLAY

Primitive functions on windows

These functions are the primitive functions of the virtual multiwindowing system They

are the metho ds for the currentwindow uncurrentwindow modifywindow killwindow

movebehindwindow and mapwindow messages for ob jects of typ e imagerectanglewindow

Normally you will never need to use them directly They are included here merely for reasons of

completeness at a do cumentary level

image rec ta ngl e win dow c urr en tw ind ow win function with one

argument

imager ec tan gl ew ind ow cu rre nt ke yb oar df oc us wi ndo w w

function with one argument

image rec ta ngl e win dow u ncu rr ent wi nd ow win function with one

argument

image re cta ng le win do wm odi fy wi nd ow win left top w h ti hi vi

function with eight arguments

image rec ta ngl e win dow k ill w ind ow win function with one argument

image rec ta ngl e win dow p op wi ndo w win function with one argument

image rec ta ngl e win dow m ove b ehi nd wi ndo w win win function

with two arguments

image rec ta ngl e win dow m ap wi ndo w win x y symbx symby function

with ve arguments

WINDOWS

Minimal graphics primitives

The Virtual Bitmap Display facility denes a set of minimal graphics primitives that work on

every implementation even on alphanumeric terminals Extended graphics primitives available on

with highresolution screens are describ ed in Chapter

All the drawing functions op erate in the current window on the current screen See the

currentwindow function

cleargr aph e nv function with no arguments

Erases the screen In other words the screen is uniformly lled with the standardbackground

color See the description of this attribute

drawcur sor x y i function with three arguments

This function provides a way to display and erase a cursor at the p oint x y in the current

window i is a binary ag If it has the value the cursor is erased If it has the value t the

cursor is displayed The actual form of the cursor that is displayed dep ends of course on the

system

This cursor is generally used to tell the user that they should typ e a character Here is the standard

technique for reading a character from the keyb oard and echoing it at the p osition x y which

it takes as its argument

defun wtyiecho x y

drawcursor x y t

let c tyi

drawcursor x y

drawcn x y c

drawcn x y cn function with three arguments

Writes the character whose internal co de is cn at the x y p osition of the current window The

character is in fact a twocolored rectangular tile

the letter b eing drawn in the currentforeground color and the background in the

currentbackground color

In LELISP drawcn could b e dened in the following manner

defun drawcn x y cn

drawsubstring x y string ascii cn

drawstr ing x y s function with three arguments

drawsub str in g x y s start length function with ve arguments

CHAPTER VIRTUAL BITMAP DISPLAY

The drawsubstring function writes length characters of the string s taken from the p osition

start at the x y p osition in the current graphics environment

The drawstring macro writes the complete string s at the p oint x y

Here for example we write the string foothebar at lo cal co ordinate p oint in the

current window

drawsubstring foothebar

In LELISP drawstring could b e dened in the following manner

dmd drawstring x y s

let s s

drawsubstring x y s slength s

Character strings

A character string on the screen has a display rectangle a base point and an increment point

 The display rectangle is the screen zone o ccupied by the string

 The base p oint is the p oint within the display rectangle at the lowerleft corner of the rst

character of the string It is passed to the drawstring function which displays the string

at the p oint x y See the description of drawstring

 The increment p oint is a p oint of the display rectangle that can b e used as the base p oint of

the next character string to b e displayed after the current string

The following diagrams illustrate these various quantities

The display rectangle width and height

width

height

v

WINDOWS

The base point in the lo cal co ordinates of the display rectangle

xbase

ybase

v

The increment point relative to the base p oint

xinc

yinc b i

In the ab ove example the increment p oint and the base p oint have the same yco ordinate The

value of yinc is therefore zero

These six quantities representing the visual asp ects of a character string obviously dep end on

the display attributes such as b o dy b oldface and font They can b e computed by the following

functions

widthsu bst ri ng string start length function with three arguments

heights ubs tr ing string start length function with three arguments

CHAPTER VIRTUAL BITMAP DISPLAY

xbases ubs tr ing string start length function with three arguments

ybases ubs tr ing string start length function with three arguments

xincsu bst ri ng string start length function with three arguments

yincsu bst ri ng string start length function with three arguments

These functions return the values describ ed ab ove for the length characters of the string string

b eginning in p osition start The values returned take account of the current windows font See

the currentfont function

The following function can b e used for example to determine if the p oint px py is in the

graphics representation of the string foo at p osition x y

defun instringp px py s x y

let lx x xbasesubstring s slength s

ty y ybasesubstring s slength s

and px lx

py ty

px lx widthsubstring s slength s

py ty heightsubstring s slength s

The next function displays n strings on the screen one after the other

defun drawnstrings x y string strings

drawstring x y string

while strings

drawstring

incr x xincsubstring string slength string

incr y yincsubstring string slength string

nextl strings string

widthsp ace function with no arguments

heights pac e function with no arguments

xbases pac e function with no arguments

ybases pac e function with no arguments

These four functions calculate the width height and basep oint co ordinates of the space character

They are particularly useful for manipulating xedwidth text

In LELISP widthspace could b e dened in the following manner

WINDOWS

defun widthspace

widthsubstring

fonthei ght function with no arguments

Returns the dierence b etween the ordinates yaxis of two successive lines of text in the current

typ e font

fontasc ent function with no arguments

Returns the ascent of the current typ e font This is the greatest height of a character ab ove the

base line

display get f ont n ame s display max pattern function with two or three

arguments

Takes a pattern character string that can contain the characters any series of characters even

empty and any character whatso ever and returns the names of the loadable typ e fonts that

corresp ond to this expression The pattern argument is optional and is equal to by default

The max argument lets you limit the numb er of replies b ecause there could b e a very large numb er

of typ e fonts in the system

In the following example we lo ok for all the typ e fonts whose names start with adobe

displaygetfontnames currentdisplay adobe

display get f ont i nfo display fontname fontinfo function with two or three

arguments

Returns an instance of the fontinfo class whose elds provide metric data concerning the

typ e font called fontname If the fontinfo argument is supplied this function do es not

allo cate a new instance of fontinfo but uses the fontinfo argument which must b e of

fontinfo typ e This function do es not require the typ e font called fontname to b e already

loaded The function is useful for example to nd out whether a typ e font is of xed or

prop ortional spacing This function provides the following metric data

 General data on the font

ascent and descent elds

 Data concerning the smallest character

minlbearing minrbearing minascent mindescent and minwidth elds

 Data concerning the largest character

maxlbearing maxrbearing maxascent maxdescent and maxwidth elds

 An angle for the slop e of italic fonts

 A width Iweight for b oldface fonts

CHAPTER VIRTUAL BITMAP DISPLAY

The result dep ends up on the screen system and certain elds can remain empty If the typ e

font called fontname do es not exist the function returns

Table of contents

Virtual bitmap display

Loading the description le ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

Screen preparation ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

Managing a single screen :::::::::::::::::::::::::::::::::::::::::::::::::

Managing several screens :::::::::::::::::::::::::::::::::::::::::::::::::

Functions on screens ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::

Functions on windows ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::

Global co ordinates ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

Lo cal co ordinates ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Windows ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

Creating windows ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Drawing in windows ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Attaching prop erties to windows ::::::::::::::::::::::::::::::::::::::::::

Functions on windows ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Primitive functions on windows :::::::::::::::::::::::::::::::::::::::::::

Minimal graphics primitives ::::::::::::::::::::::::::::::::::::::::::::::

Character strings ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Table of Contents

Function Index

inibitmap symbol function with an optional argument :::::::::::::::::::::::::::::

bitprologue name device function with one or two optional arguments ::::::::::::::

currentdisplay screen function with an optional argument ::::::::::::::::::::::

bitepilogue screen function with an optional argument :::::::::::::::::::::::::::

bitmapsave screen function with an optional argument :::::::::::::::::::::::::::

bitmaprestore screen function with one argument ::::::::::::::::::::::::::::::

bitxmax screen function with an optional argument ::::::::::::::::::::::::::::::::

bitymax screen function with an optional argument ::::::::::::::::::::::::::::::::

rootwindow screen function with an optional argument :::::::::::::::::::::::::::

allcolors screen function with an optional argument ::::::::::::::::::::::::::::

bitmaprefresh screen function with an optional argument :::::::::::::::::::::::

bitmapflush screen function with an optional argument ::::::::::::::::::::::::::

bitmapsync display function with an optional argument ::::::::::::::::::::::::::

displaysynchronize display flag function with one or two arguments ::::::::::

displaydepth display function with one argument ::::::::::::::::::::::::::::::

defaultwindowtype screen type function with one or two arguments :::::::::::

standardromanfont screen function with an optional argument :::::::::::::::::

standardboldfont screen function with an optional argument :::::::::::::::::::

largeromanfont screen function with an optional argument :::::::::::::::::::::

smallromanfont screen function with an optional argument :::::::::::::::::::::

standardforeground screen function with an optional argument :::::::::::::::::

standardbackground screen function with an optional argument :::::::::::::::::

standardforegroundpattern screen function with an optional argument ::::::::

standardbackgroundpattern screen function with an optional argument ::::::::

standardlightgraypattern screen function with an optional argument ::::::::

standardmediumgraypattern screen function with an optional argument :::::::

FUNCTION INDEX

standarddarkgraypattern screen function with an optional argument :::::::::

standardlelispcursor screen function with an optional argument ::::::::::::::

standardgccursor screen function with an optional argument :::::::::::::::::::

standardbusycursor screen function with an optional argument ::::::::::::::::

standardforeground screen function with an optional argument :::::::::::::::::

standardbackground screen function with an optional argument :::::::::::::::::

imagerectanglewindow structure ::::::::::::::::::::::::::::::::::::::::::::

makewindow win function with one argument :::::::::::::::::::::::::::::::::::::

createwindow type x y w h ti hi vi function with eight arguments :::::::::::::

createsubwindow type x y w h ti hi vi fa function with nine arguments ::::::

definewindowpropertyaccessor prop macro ::::::::::::::::::::::::::::::

imagerectanglewindowprop w v function with one or two arguments ::::::::

currentwindow win function with an optional argument :::::::::::::::::::::::::::

currentkeyboardfocuswindow win function with an optional argument :::::::::

modifywindow win x y w h ti hi vi function with eight arguments ::::::::::::::

killwindow win function with one argument :::::::::::::::::::::::::::::::::::::

movewindow win x y function with three arguments :::::::::::::::::::::::::::::::

resizewindow win w h function with three arguments ::::::::::::::::::::::::::::

moveresizewindow win x y w h function with ve arguments :::::::::::::::::::

windoweventslist win events function with one or two arguments ::::::::::::::

windowtitle win title function with one or two arguments ::::::::::::::::::::::

windowstate win state function with one or two arguments ::::::::::::::::::::::

windowbackground win color function with one or two arguments ::::::::::::::::

windowborder win border function with one or two arguments ::::::::::::::::::::

windowclearregion win x y w h function with ve arguments ::::::::::::::::::

windowp win function with one argument ::::::::::::::::::::::::::::::::::::::::::

popwindow win function with one argument ::::::::::::::::::::::::::::::::::::::

movebehindwindow win win function with two arguments :::::::::::::::::::::

findwindow x y function with two arguments ::::::::::::::::::::::::::::::::::::

mapwindow win x y symbx symby function with ve arguments ::::::::::::::::::::

imagerectanglewindowcurrentwindow win function with one argument :::

imagerectanglewindowcurrentkeyboardfocuswindow w function

with one argument ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

imagerectanglewindowuncurrentwindow win function with one argument :

FUNCTION INDEX

imagerectanglewindowmodifywindow win left top w h ti hi vi function

with eight arguments ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::

imagerectanglewindowkillwindow win function with one argument :::::::

imagerectanglewindowpopwindow win function with one argument ::::::::

imagerectanglewindowmovebehindwindow win win function

with two arguments ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

imagerectanglewindowmapwindow win x y symbx symby function

with ve arguments ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

cleargraphenv function with no arguments :::::::::::::::::::::::::::::::::::::

drawcursor x y i function with three arguments :::::::::::::::::::::::::::::::::

drawcn x y cn function with three arguments :::::::::::::::::::::::::::::::::::::

drawstring x y s function with three arguments :::::::::::::::::::::::::::::::::

drawsubstring x y s start length function with ve arguments ::::::::::::::::

widthsubstring string start length function with three arguments ::::::::::::

heightsubstring string start length function with three arguments :::::::::::

xbasesubstring string start length function with three arguments :::::::::::

ybasesubstring string start length function with three arguments :::::::::::

xincsubstring string start length function with three arguments ::::::::::::

yincsubstring string start length function with three arguments ::::::::::::

widthspace function with no arguments ::::::::::::::::::::::::::::::::::::::::::

heightspace function with no arguments ::::::::::::::::::::::::::::::::::::::::

xbasespace function with no arguments ::::::::::::::::::::::::::::::::::::::::

ybasespace function with no arguments ::::::::::::::::::::::::::::::::::::::::

fontheight function with no arguments ::::::::::::::::::::::::::::::::::::::::::

fontascent function with no arguments ::::::::::::::::::::::::::::::::::::::::::

displaygetfontnames display max pattern function with two or three

arguments ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::

displaygetfontinfo display fontname fontinfo function with two

or three arguments ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Chapter

Virtual mouse

The LELISP system provides the means to manage a device that selects discrete p oints on a high

resolution screen This device called the virtual mouse can b e an actual physical mouse with one

or several buttons an optical p en a graphics tablet a touch screen or any other p ointing device

The binding of the cursor asso ciated with the virtual mouse is always p erformed by the underlying

graphics system

The p ointing device is always multiplexed with the user keyb oard This chapter describ es all the

p ointingdevice and keyb oard manipulation functions

The Virtual Bitmap Display device includes events that are enqueued to reect changes in the state

of the underlying graphics system Pointingdevice actions keyb oard actions actions on windows

brought ab out by agents outside the LELISP system and refresh requests for particular zones of

the screen all result in events b eing queued In addition the use of structures to represent events

makes the event system easy to extend

Events

An event is an information unit emanating from the Virtual Bitmap Display facility This

information might b e generated b ecause of one of the following happ enings

 a physical mouse action selecting p oints in a window or subwindow in various ways

 a keystroke

 an action on windows carried out via the underlying window manager

 a window refresh request

The set of events actually generated dep ends up on the system b eing used The list of event typ es

provided later on in this chapter is complete enough to deal with most of the wellknown graphics

systems It could easily b e enriched and extended to deal with other systems

Events are stored in a queue that a program can consult at any time There is one single event

queue and all events are multiplexed on a single channel

A convenient way of managing events consists of the using the event loop describ ed in chapter

of this manual This approach generalizes the inputoutput notion by harmonizing input from the

CHAPTER VIRTUAL MOUSE

keyb oard and the mouse with all other kinds of input such as the reading of a pro cess or a UNIX

pip e

Structure and typ es of events

event structure

This structure describ es LISP ob jects that represent events in the queue It has the following

denition

defstruct event

code window detail gx gy x y w h

The code eld contains a symb ol describing the event typ e The window eld indicates the

window aected by the event which is usually the lowest window in the hierarchy that

contained the mouse when the event was triggered See however the grabevent function

The meaning of the other elds dep ends on the typ e that the code eld contains The

list of event typ es is not exhaustive and on some systems supplementary co des could b e

implemented Also some systems do not generate certain event co des Only the asciievent

and downevent events are implemented in all cases In general the dragevent upevent

and moveevent events with several values of the detail eld are also fully implemented

Note From this p oint on an event name such as dragevent will often b e used to refer b oth

to the event typ e and to an instance of that event This enables us to avoid awkward phrases

such as dragevent event

The various event typ es are describ ed b elow

moveeven t event

The moveevent describ es a p ointingdevice movement when no buttons are pushed The gx

and gy elds in the asso ciated event structure represent the global co ordinates of the mouse

at the moment of the event while x and y are the mouse co ordinates relative to the lo cal

window co ordinate system

downeven t event

drageven t event

upevent event

downevent indicates that a mouse button has b een pushed It can b e followed by any numb er of

dragevents indicating that the mouse was moved while a button was held down

STRUCTURE AND TYPES OF EVENTS

The numb ers gx gy x and y play the same role as in the case of the moveevent event

detail is a numeric co de describing the action of pushing a button It enco des information

ab out which button was pushed whether the button singleclicked doubleclicked or triple

clicked whether a key was b eing held down at the same time that the button was pushed

etc The values of detail lie b etween zero and some p ositive integer dep ending up on the

system The zero value corresp onds to the simplest manner in which a button can b e pushed

in the underlying graphics system

The system guarantees that after a downevent o ccurs in a window it receives a matching

upevent

asciieve nt event

This event indicates that a character has b een typ ed on the keyb oard detail represents

the ASCI I co de of the typ ed character The window aected by this event is the one that

was designated as the recipient of keyb oard events either by the system or by a call to the

currentkeyboardfocuswindow function See the description of this function

modifywi ndo w eve nt event

This event indicates that an agent outside the LELISP system has mo died the size or the

p osition of window gx gy w and h represent the new p osition and size of the window After

an event of this typ e o ccurs the updatewindow function must b e called so that the LISP

data structures representing the window are kept up to date

killwind ow ev ent event

This event indicates that an agent external to the LELISP system is requesting the destruction

of window After this typ e of event o ccurs and when the program agrees to kill the window

the killwindow function must b e called to actually carry out this task

enterwind ow ev ent event

leavewind ow ev ent event

These events indicate that the mouse entered or left a window window is the window

concerned

repaintw ind ow ev en t event

This event indicates that the system needs to refresh a part of window and is asking LELISP

to do the work x y w and h represent the rectangular zone of the window to b e repainted x

and y are given in the windows lo cal co ordinates When this event o ccurs it is p ossible that

the zone has b een erased that is lled with the standardbackground color

The standard reaction to this event is to call a function to redraw the windows contents by

CHAPTER VIRTUAL MOUSE

drawing the clipping region in the sp ecied refresh zone This can b e done in the following

manner

defun repaintwindow event

let window eventwindow event

clipx clipy clipw cliph

with currentwindow window

currentclip get the current clip

clip to the zone

currentclip eventx event eventy event

eventw event eventh event

repaint the window here

reposition the old clip

currentclip clipx clipy clipw cliph

This event also makes it p ossible to synchronize LELISP and the underlying window system In some

systemsthe XWINDOW system for examplean arbitrary time can pass b etween the return

of the createwindow function and the actual creation of the window on the screen The rst

repaintwindowevent indicates that the window has actually b een created

All op erations carried out on a window b etween the o ccurrence of the createwindow event and

the repaintwindowevent event are in general lost It is therefore imp ortant to wait for the

refresh event b efore doing anything in the window For a b etter understanding of event handling

see the processevents function in the Drawing in windows section of Chapter as well as the

processevents function in the examples of grabevent in this chapter

keyboard foc us ev en t event

This event indicates that the host system has changed the owner of the keyb oard window contains

either the new owner or if the owner is no longer a window managed by LELISP After an event

of this typ e the currentkeyboardfocuswindow function must b e called so that the LISP data

structures representing the window are kept up to date

mapwindo w event

This event o ccurs when a window comes to the top of all the other windows

unmapwin dow event

This event o ccurs when a window disapp ears from the screen or is iconied

visibilit yc ha nge event

This event o ccurs when the level of visibility of a window changes The detail eld of the event is

a p ositive integer with the following p ossible values

 totally visible

MOUSE MODES

 partly visible

 totally invisible

clientme ssa ge event

This is a communicationtyp e event whose detail eld contains the message sent if it is a character

string

Mouse mo des

The mouse can function in several mo des which are determined by the settings of two indep endent

ags the abbreviated mouse mo de ag and the mouse interrupt mo de ag

If the abbreviated mouse mode ag is set the insertion of a new moveevent in the event queue

pro ceeds according to the following rules

 If the last event in the queue is also a moveevent or a dragevent the new event replaces

the previous one

 Otherwise it is added to the queue as in the normal case

This mechanism allows the size of the event queue to b e kept small

If the mouse interrupt mode ag is set a programmable interrupt named event is raised just b efore

any event is added to the queue

eventmo de mode function with an optional argument

mode b ecomes the new mouse mo de Without an eventmode argument this function returns the

current mouse mo de Used with the with control structure this function can temp orarily mo dify

the mouse mo de

The co des are dened as follows

Mo de Mouse interrupt mo de Abbreviated mouse mo de





 

This is the case on some systems only

At the initialization of the system the mouse mo de is zero The event interrupts are not raised and the queue do es not use abbreviated mouse mo de

CHAPTER VIRTUAL MOUSE

Events queue

Events are instances of the event structure and are placed onto the event queue

The length of the event queue dep ends on the particular system If the queue overows the oldest

events are lost or in the worst of casesas with some XWINDOW implementationsLELISP is

abruptly killed

eventp function with no arguments

This predicate is true if there is at least one event waiting for service in the queue This function

never mo dies the contents of the queue

readeve nt event function with an optional argument

peekeve nt event function with an optional argument

These functions provide ways to read and examine the next event in the queue The readevent

function removes the rst event from the queue while peekevent just examines it without

removing it

These functions return an instance of the event structure whose elds have b een lled with the

descriptors of the event b eing read or examined

If an argument is provided it must b e an instance of the event structure and it is this structure

duly up dated that is returned Otherwise a common global structure instance is always returned

since successive calls to these functions up date its contents

Both readevent and peekevent call the bitmapflush function b efore reading the event queue

This guarantees that display op erations are actually carried out b efore user actions are handled

The following function prints a trace of mouse events

defun traceevents

let e

loop

setq e readevent

print place eventx e eventy e

event eventcode e

In general every program should contain an eventhandling routine The processevents

function of Chapter is an example of such a routine

flushev ent function with no arguments

Empties all waiting events from the events queue

addeven t event function with one argument

EVENTS QUEUE

addeven t gx gy code function with three arguments

If there is a single argument addevent copies event onto the head of the event queue This

function is particularly useful for extending the available typ es of events

When there are three arguments addevent b ehaves like the following function

defun addevent x y code

let event eventmake

eventgx event x

eventgy event y

eventcode event code

addevent event

grabeve nt window function with an optional argument

Given a window argument grabevent makes it the owner of all the events in the queue This

means that all mouse events downevent dragevent upevent and moveevent and keyb oard

events asciievent will then have window as their destination On some systems where the

mouse is shared by several programs this function also makes LELISP the owner of the mouse

Consequently programs other than LELISP no longer receive mouse events

If the argument has the value the mouse is treated normally

Without an argument grabevent returns the LISP window that owns the queue or if no LISP

window has called the grabevent function

This function is particularly useful for forcing the user to conrm that he really wants a certain

op eration to b e p erformed A typical example might involve a question from the machine such as

Do you real ly want to erase al l your les

Making LISP the owner of the mouse might render the system unusable in the case of a LISP error

If this were to happ en it would no longer b e p ossible to select another window with the mouse in

order to kill LELISP This function should therefore b e used with care

Let us lo ok at an example The following function creates a window and blo cks all op erations

even those meant for or coming from other programs that share the screen with LISPuntil the

user clicks the mouse in the window Notice that the grabevent function is not called until the

o ccurrence of the rst repaintwindowevent for the conrmation window This message indicates

that the window has actually b een created and it makes it p ossible to synchronize the grabbing

of the mouse with the creation of the window

defun confirm string

let window createwindow window

protect

processevents window string

grabevent

killwindow window

bitmapflush

defun processevents window string

CHAPTER VIRTUAL MOUSE

untilexit done

let event readevent

selectq eventcode event

downevent exit done

repaintwindowevent

when eq eventwindow event window

grabevent window

with currentwindow window

drawstring string

allowev ent display event function with two arguments

This function lets you add event to the list of events handled by the display device called display

All windows created after this function is called will ask the system to receive this new typ e of

event except if they have sp ecied their own event lists The function returns the event

Example

allowevent currentdisplay functionkeyevent

disallow ev en t display event function with two arguments

This function lets you remove event of the list of the events handled by the display device called

display All windows created after this function is called will ask the system to receive this new

typ e of event except if they have sp ecied their own event lists The function returns the event

Example

disallowevent currentdisplay functionkeyevent

allowed eve nt p display event function with two arguments

This predicate indicates whether event b elongs to the events handled by the display device called

display If this is the case it returns the event Otherwise it returns

Programmable interrupts

It must b e p ointed out that the event programmable interrupt is not available in some systems

event programmable interrupt

When the mouse interrupt ag is set the event programmable interrupt is triggered just b efore

the p osting of an event onto the event queue See the eventmode function In such a case the

event is not added to the event queue Instead the interrupt receives as an argument the event

that triggered the interrupt

SYNCHRONOUS MOUSE TRACKING

This interrupt has the same status as the break and clock interrupts It is inhibited by the function

withnointerrupts and during the handling of event interrupts all other interrupts are blo cked

by an implicit call to this same function The events that o ccur during the handling of an event

interrupt are added normally to the queue The function called by this interrupt to actually handle

events must empty the queue b efore termination

The default handling of this interrupt consists of adding the event to the queue by using the

addevent function as describ ed in the function b elow

event event function with one argument

This is the standard eventhandling function asso ciated with the event programmable interrupt

In LELISP event could b e dened in the following manner

defun event event

addevent event

Synchronous mouse tracking

The next function informs you at all times of the p osition and state of the mouse

readmou se event function with an optional argument

Returns an instance of the event structure whose elds describ e the current p osition and state

of the mouse If an argument is supplied it is this structure duly up dated that is returned

Otherwise the same structure instance is always returned since successive calls to readmouse

up date its contents

The elds of the structure have the following meanings

 gx gy global co ordinates of the mouse

 window lowest window in stacking order app earing under the current mouse p osition

 x y windowlo cal mouse co ordinates

 detail state of the mouse buttons A zero value indicates that all buttons are up

Virtual menus

Virtual menus allow the user to make a choice from among a set of character strings

A menu prop oses a choice in one or several lists of character strings called selection lists The

op erations actually carried out on the screen in order to p ost choices and then validate the

particular choice dep end on the system b eing used Selection lists can b e implemented in one

of several ways

CHAPTER VIRTUAL MOUSE

 Pulldown menus hung o a menu bar in an Apple Macintosh style

 Wandering menus as in the Sun Microsystems SunViews pro duct

 A deck of cards as in the XMenu package

createm enu ti n v ::: n v function with a variable number of arguments

1 1 n n

Creates and initializes a menu containing the items n with values v in a selection list named ti

i i

The n and v arguments have the same meanings as those of the string and value arguments in

i i

the menuinsertitem function The selection list and the menu items placed in the menu are all

active Here is an example of the creation of a menu

setq menu createmenu tty menu

aidapaint

calculator

function

file

help

icon

lhoblist

object

structure

end

menu tty menu

killmen u menu function with one argument

Destroys menu

activate me nu menu x y function with three arguments

Displays and activates menu at the global co ordinate p oint x y This function returns either the

value asso ciated with the chosen item or if the user did not make a choice

menuins ert i tem l ist menu choice string active function with four

arguments

Inserts a new selection list named string in the choice p osition of the selection list of menu If

choice has the value the list b ecomes the rst selection list If choice is greater than or equal

to the numb er of selection lists in the menu it is added in the last p osition

The short integer active indicates whether the selection list to b e added is selectable value or

not value

The menuinsertitemlist function returns the index of the inserted selection list as its value

menuins ert i tem menu choice item string active value function with six

arguments

CUT AND PASTE

Adds an item to a menu in the item p osition of the choice list item indicates the items row in the

menu counting from zero value is the value asso ciated with the item and must b e a LISP ob ject

not equal to The activatemenu function returns this value when the item has b een chosen

active is a short integer acting as a ag indicating whether the item is selectable active or

not active

The menuinsertitem function returns the index of the inserted item as its value

menudel ete i tem l ist menu choice function with two arguments

Removes the selection list in the choice row counting from zero in menu

menudel ete i tem menu choice item function with three arguments

Removes item from the choice selection list of menu

menumod ify i tem l ist menu choice string active function with four

arguments

Mo dies the selection list whose index is choice in menu If either string or active has the value

it is not mo died

menumod ify i tem menu choice item string active value function with six

arguments

Mo dies a menu item If either string value or active has the value it is not mo died

Cut and Paste

The virtual bitmap prop oses two cutpaste functions that can work in conjunction with other

applications when the screen system allows it

display sto re se le cti on display buffer function with two arguments

Takes the buffer character string and copies it into a buer asso ciated with the display device

called display If the display device allows it buffer is shared with all nonLELISP applications

that use this display device

display get s ele ct ion display function with one argument

This function retrieves a character string representing the current selection in the display device

called display If the display device oers this characteristic this is true for X this function

lets you retrieve a character string coming from another application using the same display device

CHAPTER VIRTUAL MOUSE

Table of contents

Virtual mouse

Events ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::

Structure and typ es of events ::::::::::::::::::::::::::::::::::::::::::::::::::: :

Mouse mo des ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::

Events queue ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::

Programmable interrupts ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

Synchronous mouse tracking ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Virtual menus ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

Cut and Paste ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

Table of Contents

Function Index

event structure ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::

moveevent event ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

downevent event ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

dragevent event ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

upevent event ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::

asciievent event ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

modifywindowevent event ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

killwindowevent event ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

enterwindowevent event ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

leavewindowevent event ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

repaintwindowevent event ::::::::::::::::::::::::::::::::::::::::::::::::::: :

keyboardfocusevent event ::::::::::::::::::::::::::::::::::::::::::::::::::: :

mapwindow event ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

unmapwindow event ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

visibilitychange event ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::

clientmessage event ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::

eventmode mode function with an optional argument :::::::::::::::::::::::::::::::

eventp function with no arguments ::::::::::::::::::::::::::::::::::::::::::::::::

readevent event function with an optional argument :::::::::::::::::::::::::::::

peekevent event function with an optional argument :::::::::::::::::::::::::::::

flushevent function with no arguments ::::::::::::::::::::::::::::::::::::::::::

addevent event function with one argument :::::::::::::::::::::::::::::::::::::

addevent gx gy code function with three arguments ::::::::::::::::::::::::::::::

grabevent window function with an optional argument ::::::::::::::::::::::::::::

allowevent display event function with two arguments :::::::::::::::::::::::::

disallowevent display event function with two arguments :::::::::::::::::::::

FUNCTION INDEX

allowedeventp display event function with two arguments ::::::::::::::::::::

event programmable interrupt ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::

event event function with one argument ::::::::::::::::::::::::::::::::::::::::::

readmouse event function with an optional argument :::::::::::::::::::::::::::::

createmenu ti n v ::: n v function with a variable number of arguments ::::::

1 1 n n

killmenu menu function with one argument ::::::::::::::::::::::::::::::::::::::

activatemenu menu x y function with three arguments :::::::::::::::::::::::::::

menuinsertitemlist menu choice string active function with four arguments

menuinsertitem menu choice item string active value function with

six arguments ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::

menudeleteitemlist menu choice function with two arguments :::::::::::::::

menudeleteitem menu choice item function with three arguments :::::::::::::::

menumodifyitemlist menu choice string active function with four arguments

menumodifyitem menu choice item string active value function with

six arguments ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::

displaystoreselection display buffer function with two arguments :::::::::

displaygetselection display function with one argument ::::::::::::::::::::

Chapter

Graphics primiti ves

This chapter describ es the p ortable graphics asp ects of the Virtual Bitmap Display vbd

facility These primitives constitute a virtual graphics interface that provides you with the means

to draw and ll gures and to display text on color bitmap screens

Graphics environments

The graphics environment is the set of graphics attributes employed by a drawing function The

following attributes are retained by the vbd facility

 cursor currentcursor

 foreground color currentforeground

 background color currentbackground

 character font currentfont

 ll pattern or texture currentpattern

 line style currentlinestyle

 drawing combination mo de currentmode

 clipping zone currentclip

A separate graphics environment is attached to each window All the graphics op erations use the

graphics attributes dened in the graphics environment of the current window

A set of functions describ ed b elow allows the graphics environment of the current window to b e

mo died

Current font

A font is a collection of gures used by the drawcn drawstring and drawsubstring functions

to represent characters on the screen In the Virtual Bitmap Display a font is represented by a

small integer called the font identier

CHAPTER GRAPHICS PRIMITIVES

A numb er of fonts is initally available in the system Some of these fonts have standard uses See

the standardromanfont function A new font can b e added to the system at any timethe

system simply allo cates a new font identier for it The name of the fonts available for loading

dep ends of course on the system b eing used

current fon t font function with an optional argument

font b ecomes the font for the current graphics environment Called without an argument

currentfont returns the font for the current graphics environment font is a font identier

that is an integer b etween zero and fontmax The numb er of utilizable fonts their image on

the screen and their sizes all dep end on the system b eing used

fontmax function with no arguments

Returns the biggest legal argument usable in a call to the currentfont function that is also equal

to the numb er of fonts available minus one This numb er is always greater than or equal to one

loadfon t string function with one argument

Loads the font describ ed in the system by the character string string It returns a small integer

which can b e used as a parameter to the currentfont function Subsequent calls to the fontmax

function will reect the fact that this new font was loaded into the system If the character font

named string was already loaded loadfont will return its font identier

The value of the string called string dep ends on the system and is absolutely not p ortable

If the font do es not exist in the system b eing used the erroob error is raised with the following

screen display

loadfont out of bounds string

fontnam e font function with one argument

Returns the character string that describ es the font whose identier is font an integer b etween

and fontmax

Foreground and background colors

The foreground color is the color used for drawing lines and characters and for lling zones when the

current ll pattern is standardforegroundpattern The background is used as the background of

character designs and to ll zones when the current ll pattern is standardbackgroundpattern

Two colors are initally available standardforeground and standardbackground See the

function of the same names New colors can b e constructed by either using the rgb system of

color denition or by using a Virtual Bitmap Display facility database which allows colors to b e

named symb olically Since colors are exp ensive resources and since only a few are usually needed

it is suggested that they b e freed as so on as they are no longer b eing used

GRAPHICS ENVIRONMENTS

One can also allo cate dynamically mo diable colors In general these are even more exp ensive

resources than the regular colors just describ ed

current for eg rou nd color function with an optional argument

current bac kg rou nd color function with an optional argument

These function examine or if an argument is provided set the foreground and background colors

of the current window

nameto rgb name function with one argument

Takes the name of a color name and returns the corresp onding RGB values red green and blue

in the form of a vector of three integers If this color do es not exist is returned

getrgb val ue s pixel function with one argument

Takes a color pixel value pixel of the kind that would b e returned by the byteref function

and returns the corresp onding RGB values red green and blue in the form of a vector of three

integers If this pixel value do es not corresp ond to a color is returned

makecol or red green blue function with three arguments

red green and blue are integers in the range of zero to makecolor returns a new color

with rgb comp onents equal to the argument values A value of indicates saturation Black

and white are represented therefore by the following colors

setq black makecolor

setq white makecolor

makenam ed co lor name function with one argument

Returns a new color whose rgb comp onents are those sp ecied in the system color database A

certain systemdep endent numb er of colors are predened in this database

setq red makenamedcolor red

setq gr makenamedcolor goldenrod

makemut abl e col or red green blue function with three arguments

This function is similar to the last one but returns a mo diable color whose rgb comp onents

can b e changed in the course of a session In certain cases this enables you to carry out ecient

animations See the example b elow

CHAPTER GRAPHICS PRIMITIVES

killcol or color function with one argument

Frees the color color A color can no longer b e used after this function has b een called on it

redcomp one nt color value function with one or two arguments

greenco mpo ne nt color value function with one or two arguments

bluecom pon en t color value function with one or two arguments

Given a single argument these functions return the value of the corresp onding red green or blue

comp onent of color If two arguments are supplied color must b e a mo diable color See the

makemutablecolor function These functions then mo dify the value of the corresp onding red

green or blue comp onent of the color value has the same meaning here as in the argument lists

of the makecolor and makemutablecolor functions

Here is an example of the use of mo diable colors in an animation

defun modifiablecolors n

return a list of n modifiable colors

let res

repeat n

newl res makemutablecolor

res

defun drawbar colors

draw the form to animate

fill it with the foreground color

currentpattern standardforegroundpattern

let circolors apply cirlist colors

for i

currentforeground nextl circolors

fillcircle i

defun animatebar colors

animate the colors in the color list

let circolors apply cirlist colors

while t

redcomponent nextl circolors

redcomponent car circolors

bitmapflush

flushevent

defun animation n

with currentwindow createwindow imagerectanglewindow

tube

let colors modifiablecolors n

protect

progn drawbar colors

animatebar colors

mapc killcolor colors

GRAPHICS ENVIRONMENTS

killwindow currentwindow

bitmapflush

Test the example with animation or even animation Quit by typing CONTROLC

Cursor

The cursor is the mouses image on the screen Three predened cursorsstandardlelispcursor

standardgccursor and standardbusycursorare available

current cur so r cursor function with an optional argument

cursor b ecomes the cursor for the current screen Called without an argument currentcursor

returns the current cursor cursor is a small p ositive integer which designates a cursor The numb er

of dierent cursors available and their image on the screen dep end on the system b eing used

cursorm ax function with no arguments

Returns the largest legal argument usable in a call to the function currentcursor

makecur sor b b x y function with four arguments

Returns a new cursor identier b and b are bitmaps that hold the foreground drawing and the

background pattern of the cursor x and y are the co ordinates of the hot p oint of the cursor

makenam ed cu rso r name function with one argument

This function loads a new cursor whose name name must b e a character string from the following

list

 circle transparent circle

 cross crossroads

 crosshair thin cross

 diamondcross diamond comp osed of four triangles

 dot full circle

 exchange icon representing an exchange of two entities

 compass northsoutheastwest icon

 lefthand handing p ointing left

 heart heart

CHAPTER GRAPHICS PRIMITIVES

 xcross xshap ed cross

 leftptr arrow p ointing left

 mouse computer mouse

 pencil p encil

 pirate skull and crossb ones

 plus addition symb ol

 question question mark

 sizing icon representing a size change

 spray spray can

 watch watch indicating wait time

 ibeam vertical insertion bar

The new cursor is only inserted into the list of available cursors if it was not there already The

named cursors are p ortable since they are similar on all Virtual Bitmap implementations

cursorn ame num function with one argument

Takes a cursor numb er such as the currentcursor function would supply and returns either

the character string corresp onding to the name of this cursor if it is a named cursor or if this

is not the case If this numb er do es not corresp ond to a loaded cursor an error is raised

movecur sor x y function with two arguments

Displaces the current cursor to the global co ordinaterelative p oint x y on the screen

Line style

The line style describ es the way that lines are drawn The drawpolyline drawrectangle

drawcircle and drawellipse functions all use lines that are aected by the line style A numb er

of dierent stylessuch as dotted and doubledashedare initally available dep ending on the

system b eing used

current lin e sty le linestyle function with an optional argument

linestyle b ecomes the line style for the current window Called without an argument

currentlinestyle returns the current line style linestyle is a small p ositive integer which

designates a line style The numb er of dierent available styles and their images on the screen

dep end on the system b eing used

GRAPHICS ENVIRONMENTS

linesty le ma x function with no arguments

Returns the biggest legal argument usable in a call to the currentlinestyle function

makelin es ty le width style function with two arguments

Creates a new linedrawing style and returns its numb er The new style is dened by width

expressed in pixels and style which is a p ositive integer that will interpreted by the particular

kind of display device For example in X there are three p ossible styles and

Fill patterns or textures

The ll functions fillarea fillrectangle fillcircle and fillellipse can use single

color or twocolor patterns A pattern or texture is lo cated by use of a pattern identier a numb er

b etween zero and the value of patternmax

Singlecolor patterns called standardforegroundpattern and standardbackgroundpattern

can b e used to ll forms with the current foreground or background color

The other patterns have two color values which are indep endent of the foreground and background

colors A numb er of twocolor patterns are initally available which provide a set of graytones or

mixtures of colors See the standardgraypattern function

New twocolor patterns can b e created using icons as the starting p oint The pattern will do a ll

by regularly rep eating the icon image on the screen

current pat te rn pattern function with an optional argument

pattern b ecomes the pattern for the current graphics environment Called without an argument

currentpattern returns the current pattern pattern is a small p ositive integer which designates

a pattern The numb er of dierent patterns available and their image on the screen dep ends on the

system b eing used

pattern max function with no arguments

Returns the biggest legal value which can b e used in a call to the currentpattern function

makepat ter n bitmap function with one argument

Returns a new pattern identier The use of this pattern in a ll command will result in the

duplication of the icon bitmap to ll the zone in question Patterns made in this way will use the

icons colors and so are indep endent of the foreground and background colors

Drawing combination mo de

In drawing op erations the p oints drawn onto the screen the source points or source image can b e

combined in various ways with the p oints already displayed on the screen the destination points

CHAPTER GRAPHICS PRIMITIVES

or destination image The combination or drawing mo de do es not have much signicance when

more than two colors are b eing used This mo de only works then with drawing op erations using

the predened standardforeground and standardbackground colors

current mod e mode function with an optional argument

mode b ecomes the drawing mo de for the current graphics environment Called without an argument

currentmode returns the current drawing mo de mode is a small integer which designates a

drawing or combination mo de Sixteen mo des are available numb ered from zero to Each

mo de indicates the manner in which the drawing primitives will combine a pixel from the graphics

environment stored images textures etc and a pixel displayed on the screen

The mo des are dened as a function of the source pixel S and the destination pixel D in the

following manner

S D Resulting pixel

Mode

modese t variable

modeor variable

modexo r variable

modeno t variable

These variables contain the most oftenused drawing mo des They have the following values

modeset

modeor

modexor

modenot

Clipping zone

All graphics op erations will draw only that part of the requested image which based on the p osition

at which the image is to b e attached to the current window will b e included therein One can

GRAPHICS PRIMITIVES

furthermore sp ecify a rectangular zone within the window to which images will b e limited This is

particularly useful for treating repaintwindowevents when it is only necessary to redraw the

part of the image eected by the event See the readevent function

current cli p x y w h function with zero or four arguments

The rectangle with upp er lefthand corner at the p oint x y with width w and height h b ecomes

the current clipping rectangle Called without an argument currentmode returns the current

clipping rectangle in the global variables clipx clipy clipw and cliph All display

op erations are limited by this clipping rectangle So only those op erations requested to b e carried

out within this region will b e p erformed

clipx variable

clipy variable

clipw variable

cliph variable

These variables contain the co ordinates of the current clipping rectangle after a call to the

currentclip function without arguments

Graphics primitives

The absolutely lowestlevel primitives are the four functions dened in the gks graphics standard

these b eing drawpolyline drawpolymarker fillarea and drawsubstring For eciency

reasons extensions to these primitives are furnished in LELISP These extensions for the most part

are dedicated to the display and lling of rectangular zones op erations which are often very rapid

on bitmap screens These functions could of course b e dened using gks primitives

drawpol yli ne n vx vy function with three arguments

vx and vy are two vectors of length greater than or equal to n This function draws the n vectors

dened by the sequence of p oints vx vy vxn vyn The line style used

to draw the vectors is determined by the value of the current linestyle parameter The current

drawing mo de determines how the vectors will b e combined with ob jects already drawn on the

screen

For example the following call draws a triangle

drawpolyline

CHAPTER GRAPHICS PRIMITIVES

drawpol yma rk er n vx vy function with three arguments

This function is similar to the previous one but draws only the extremitiesthe endp ointsof the

vectors The current drawing mo de determines how the vector endp oints will b e combined with

ob jects already present on the screen

For example the following call draws the vertices of a triangle

drawpolymarker

fillare a n vx vy function with three arguments

vx and vy are two vectors of length greater than or equal to n This function lls the p olygon

dened by the n p oints whose x y co ordinates are given by the vectors vx and vy The p olygon

is lled by the pattern dened by the current value of the pattern parameter The current drawing

mo de determines how the p olygon will b e combined with ob jects already drawn on the screen

For example the following call lls a triangular zone

fillarea

drawsub str in g x y s start length function with ve arguments

See Chapter and the description there of the minimal graphics environment

drawell ips e x y rx ry function with four arguments

Draws an ellipse whose axes are parallel to the two co ordinate axes The co ordinate p oint x y

is the center of the ellipse and rx and ry are integers representing the two halfaxes of the ellipse

fillell ips e x y rx ry function with four arguments

This function is similar to the last one except that it lls the ellipses outline with the current

pattern instead of drawing it

These two ellipse functions are not strictly sp eaking gks primitives but most gks systems provide

similar functionality by means of escap e functions

cleargr aph e nv function with no arguments

See Chapter for a description of the minimal graphics environment

Extended graphics functions

Linedrawing functions

These functions draw lines using the line current style given by linestyle We give their

denitions in terms of gks or gkscompatible primitives

EXTENDED GRAPHICS FUNCTIONS

drawpoi nt x y function with two arguments

In LELISP drawpoint could b e dened in the following manner

defun drawpoint x y

drawpolymarker vector x vector y

drawlin e x y x y function with four arguments

In LELISP drawline could b e dened in the following manner

defun drawline x y x y

drawpolyline vector x x vector y y

drawrec tan gl e x y w h function with four arguments

In LELISP drawrectangle could b e dened in the following manner

defun drawline x y w h

drawpolyline vector x x w x w x y

vector y y y h y h y

drawcir cle x y r function with four arguments

In LELISP drawcircle could b e dened in the following manner

defun drawcircle x y r

drawellipse x y r r

drawarc x y w h angle angle function with six arguments

This function draws an arc of a circle or an ellipse in the current window This arc is dened by

the rectangle centered at x and y of height h and width w It draws only the p ortion of the ellipse

b etween the two angles angle and angle expressed in degrees in a trigonometrical sense with

the origin at oclo ck Here is an example that draws the halfcircle at with a radius of

drawarc

drawseg men ts n vx vy vx vy function with ve arguments

As the outcome of a single call this function draws n segments in the current window Segment

numb er i is dened by its two extremities vxi vyi and vxi vyi The vx

vy vx and vy arguments are therefore ob jects of vector typ e including at least n elements

CHAPTER GRAPHICS PRIMITIVES

drawrec tan gl es n vx vy vw vh function with ve arguments

As the outcome of a single call this function draws n rectangles Rectangle numb er i is dened

by vxi vyi vwi vhi The vx vy vw and vh arguments are vectors of integers If

one or several values are identical for all the rectangles it is p ossible to pass a single integer rather

than a vector whose values all identical

Fill functions

These functions ll zones using the current ll pattern given by pattern We give their denitions

in terms of gks primitives

fillrec tan gl e x y w h function with four arguments

In LELISP fillrectangle could b e dened in the following manner

defun fillrectangle x y w h

fillarea vector x x w x w x

vector y y y h y h

fillcir cle x y r function with three arguments

In LELISP fillcircle could b e dened in the following manner

defun fillcircle x y r

fillellipse x y r r

fillarc x y w h angle angle function with six arguments

This function lls in a p ortion of a pie chart circle graph in the current window The arc that

is lled in is dened by the rectangle centered at x and y of height h and width w It only lls

in the p ortion of the ellipse b etween the two angles angle and angle expressed in degrees in a

trigonometrical sense with the origin at oclo ck Here is an example that draws the halfcircle

with its center at and a radius of

fillarc

fillrec tan gl es n vx vy vw vh function with ve arguments

Fills n rectangles in a single call Rectangle numb er i is dened by vxi vyi vwi

vhi The vx vy vw and vh arguments are vectors of integers If one or several values are

identical for all the rectangles it is p ossible to pass a single integer rather than a vector whose

values all identical

EXTENDED GRAPHICS FUNCTIONS

highligh tr ec tan gl e x y w h function with four arguments

This function inverses a rectangle dened as x y w h by interchanging the background color

currentbackground with the drawing color currentforeground and vice versa It therefore

causes inversion in a colorscreen system In a mono chrome system it has the same eect as

fillrectangle in modexor mo de Points that start out with neither the background nor the

foreground color end up with an indeterminate color

Displaying text

These functions are dened in Chapter They are mentioned here to remind the reader of their

existence and form

drawstr ing x y s function with three arguments

drawcn x y cn function with three arguments

widthsu bst ri ng string start length function with three arguments

heights ubs tr ing string start length function with three arguments

xbases ubs tr ing string start length function with three arguments

ybases ubs tr ing string start length function with three arguments

xincsu bst ri ng string start length function with three arguments

yincsu bst ri ng string start length function with three arguments

Bitmaps

bitmap structure

A bitmap is a twodimensional bit array implemented in the form of a LISP structure as dened

b elow

The current version of the Virtual Bitmap Display facility manipulates only towcolor bitmaps with

set bits value painted with the foreground color and the cleared bits value painted with the

background color The values of these two colors are determined for any particular bitmap at the

moment the bitmap is created

CHAPTER GRAPHICS PRIMITIVES

defstruct bitmap

w

h

extend

display

The w and h elds contain the width and height of the bitmap These are short integers The

contents of the extend eld are systemdep endent although it often contains a p ointer to an

external memory zone containing the bitmap bits This eld cannot b e manipulated by the

user The w and h elds can only b e examined via the bitmapw and bitmaph functions

The bitmaps set of image p oints can b e examined and aected by the bitmapbits

function describ ed b elow

createb itm ap w h bits function with two or three arguments

Creates and returns a new bitmap The optional third argument is analogous to the second

argument of the bitmapbits function It allows the bitmaps set of image p oints to b e

initalized from the p oint store

windowb itm ap window function with one argument

Returns the bitmap store of the graphics environment of window This bitmap store is shared

with the graphics environment of window All op erations on one of these are therefore reected

in the other

bitmap w bitmap function with one argument

bitmap h bitmap function with one argument

These two functions rep ort the values of the w and h elds of the bitmap passed as their

argument

bitmap bi ts bitmap bits function with one or two arguments

Given a single argument bitmapbits returns a LISP ob ject representing the set of image

p oints of bitmap With two arguments it copies the set of p oints describ ed by the LISP ob ject

bits into bitmap This function is particularly useful for reading and writing bitmaps and for

loading a set of predened bitmaps for example a set of icons used by another programming

language pro cessor

A set of p oints is represented by a vector of character strings these b eing of typ e bitvector

Each string represents a line of the bitmap The rst character of the rst string describ es the

rst eight bits of the rst line of the bitmap The most signicant bit in this string corresp onds

to the rst leftmost bit in the bitmap

If a string do es not contain enough characters to ll a line of the bitmap the remaining

bits are set to a systemdep endent garbage value If a string contains more characters than

needed to ll a line the surplus characters are ignored and do no harm

EXTENDED GRAPHICS FUNCTIONS

macro

This macro allows character strings of typ e bitvector to b e lled with hexadecimal values

For example aa is read as a character string of typ e bitvector containing the eight bits

And a is read as a character string of typ e bitvector containing the

bits

bitvec tor p rin bitvector function with one argument

bitmap pr in bitmap function with one argument

These functions are used by the system to print a bitmap If the systemprintforread

ag is set the bits of the bitmap are also b e printed This makes it p ossible for bitmaps to

b e easily saved into les

The format used to write a bitmap is determined by the ag that we now present

system com pr ess ed ic on variable

If this variable is not equal to bitmaps will b e printed using a compressed mo de which

gains a space factor of around ve This is reected in prop ortionally faster read times to o

If this ag is not set then bitmaps are simply printed as they app ear

It is not necessary to set this ag when reading in bitmaps for the read format is automatically

determined from the read source It is strongly suggested that the ag b e set when doing IO

on very large bitmaps

b w h bits macro

This macro reads in a bitmap The required parameters w and h indicate the width and

height of the bitmap The optional bits parameter is the LISP representation of the image

p oints of the bits bitmap It must b e a vector of character strings each of which is a string

of typ e bitvector

B is read as createbitmap

B is read as createbitmap

The latter example refers to the following little  bitmap

defsharp B

ncons apply createbitmap read

CHAPTER GRAPHICS PRIMITIVES

killbit map bitmap function with one argument

killbitmap lib erates the memory space used by the bitmap passed to it as an argument This

function is necessary for bitmaps that contain p ointers to a memory zone external to the LELISP

system A bitmap should never b e used again after this function has b een applied to it

defun killbitmap bitmap

tobitmap killbitmap bitmap

bmref bitmap x y function with three arguments

bmset bitmap x y bit function with four arguments

These functions are used to examine and mo dify the bit at co ordinate x y in bitmap

bitblit b b x y x y w h function with eight arguments

Copies the rectangle whose upp er lefthand corner is x y with width w and height h from

the bitmap b into the bitmap b at co ordinate p oint x y

The p oints of the source zone in b combine with the destination bits in b in one or other of the

following mo des

 Current combination mo de see the currentmode function if the bitmap b is a window

 Otherwise in global top window mo de

The value returned by bitblit has no particular meaning

b and b can represent the same bitmap and this makes it p ossible to p erform animation

scrolling and other essential graphics op erations

In the following example the joke function scrolls the screenthe bitmap of the ro ot

windowfrom left to right

defun joke

let b windowbitmap rootwindow

for i bitxmax

bitblit b b i bitxmax bitymax

bitmapflush

bitmap byt em ap structure

The bytemap typ e is a subtyp e of bitmap typ e with no additional elds It lets you manipulate

bitmaps in colors

You can create a color bitmap by calling the createbytemap function

EXTENDED GRAPHICS FUNCTIONS

createb yte ma p w h bytes table function with two to four arguments

Allo cates a bytemap structure whose dimensions are w and h The third argument if it is supplied

is the vector of byte strings indicating the index of the color of each p oint from to The

fourth argument lets you sp ecify the color table to b e used to initialize the bitmap For example

we can write the following co de

createbytemap

BC

createbytemap

t

BC

Each vector of the color table is comp osed of the following values in this order

 Color numb er

 Red comp onent

 Green comp onent

 Blue comp onent

 Indicator of a mutable color

Each o ccurrence of a color numb er will b e replaced if need b e by the the closest color in the

current color table obtained through the allcolors function Mutable colors are replaced

if p ossible by the closest mutable colors in the color table The closeness b etween two colors

is evaluated by obtaining the sum of dierences comp onent by comp onent

BC macro

The B macrocharacter lets you dene color bitmaps Consider the following examples of co de

BC

and

createbytemap

They are equivalent

CHAPTER GRAPHICS PRIMITIVES

bitmap by te s bytemap bytes function with one or two arguments

This function lets you set or consult the totality of bytemap

byteref bytemap i j function with three arguments

For the p oint whose co ordinates are i and j this function returns the index of its color in

the color table

byteset bytemap i j col function with four arguments

This function sets the p oint whose co ordinates are i and j to the color whose index is col

in the color table

substitu te co lor bytemap oldcol newcol function with three arguments

This function lets you change the oldcol color to newcol throughout the entire bytemap

substco lor s bytetmap l function with two arguments

The l argument is a list of the form old new oldn newn Here oldi and

newi are instances of the color class This function lets you replace in bytemap all the

p oints whose color is oldi by the color newi This function has no eect on a mono chrome

bitmap The substcolors function returns the obsolete substitutecolor function

send bitmapb yte ma pp rin bitmap method with one argument

This function is used by the system to print a color bitmap If the systemprintforread

indicator is set the bits of the bitmap are also printed as well as the current color table

Compatibility b etween typ es of bitmaps

The functions describ ed ab ove as well as the similar functions that op erate on black and white

bitmaps bmset bmref ::: can b e applied b oth to ob jects of bitmap typ e and to those of bytemap

typ e

You can dene and use color bitmaps in a mono chrome environment The createbytemap function

then creates bitmap ob jects and all the functions that op erate on bytemap ob jects b ehave in the

same way as those that op erate on bitmap ob jects

Table of contents

Graphics primitives

Graphics environments ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

Current font ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::

Foreground and background colors ::::::::::::::::::::::::::::::::::::::::

Cursor ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

Line style ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

Fill patterns or textures ::::::::::::::::::::::::::::::::::::::::::::::::

Drawing combination mo de :::::::::::::::::::::::::::::::::::::::::::::

Clipping zone ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::

Graphics primitives ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::

Extended graphics functions ::::::::::::::::::::::::::::::::::::::::::::::::::: ::

Linedrawing functions :::::::::::::::::::::::::::::::::::::::::::::::::::

Fill functions ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::

Displaying text ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::

Bitmaps ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

Compatibility b etween typ es of bitmaps :::::::::::::::::::::::::::::::::::

Table of Contents

Function Index

currentfont font function with an optional argument ::::::::::::::::::::::::::::

fontmax function with no arguments :::::::::::::::::::::::::::::::::::::::::::::

loadfont string function with one argument ::::::::::::::::::::::::::::::::::::

fontname font function with one argument ::::::::::::::::::::::::::::::::::::::

currentforeground color function with an optional argument ::::::::::::::::::::

currentbackground color function with an optional argument ::::::::::::::::::::

nametorgb name function with one argument ::::::::::::::::::::::::::::::::::::

getrgbvalues pixel function with one argument :::::::::::::::::::::::::::::::

makecolor red green blue function with three arguments ::::::::::::::::::::::::

makenamedcolor name function with one argument ::::::::::::::::::::::::::::::

makemutablecolor red green blue function with three arguments ::::::::::::::

killcolor color function with one argument ::::::::::::::::::::::::::::::::::::

redcomponent color value function with one or two arguments :::::::::::::::::::

greencomponent color value function with one or two arguments ::::::::::::::::

bluecomponent color value function with one or two arguments ::::::::::::::::::

currentcursor cursor function with an optional argument :::::::::::::::::::::::

cursormax function with no arguments :::::::::::::::::::::::::::::::::::::::::::

makecursor b b x y function with four arguments :::::::::::::::::::::::::::::

makenamedcursor name function with one argument :::::::::::::::::::::::::::::

cursorname num function with one argument :::::::::::::::::::::::::::::::::::::

movecursor x y function with two arguments ::::::::::::::::::::::::::::::::::::

currentlinestyle linestyle function with an optional argument ::::::::::::::

linestylemax function with no arguments ::::::::::::::::::::::::::::::::::::::

makelinestyle width style function with two arguments :::::::::::::::::::::::

currentpattern pattern function with an optional argument :::::::::::::::::::::

patternmax function with no arguments ::::::::::::::::::::::::::::::::::::::::::

FUNCTION INDEX

makepattern bitmap function with one argument ::::::::::::::::::::::::::::::::

currentmode mode function with an optional argument ::::::::::::::::::::::::::::

modeset variable ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

modeor variable ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::

modexor variable ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

modenot variable ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::

currentclip x y w h function with zero or four arguments :::::::::::::::::::::::

clipx variable ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

clipy variable ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

clipw variable ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

cliph variable ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::

drawpolyline n vx vy function with three arguments ::::::::::::::::::::::::::::

drawpolymarker n vx vy function with three arguments ::::::::::::::::::::::::::

fillarea n vx vy function with three arguments :::::::::::::::::::::::::::::::::

drawsubstring x y s start length function with ve arguments ::::::::::::::::

drawellipse x y rx ry function with four arguments ::::::::::::::::::::::::::::

fillellipse x y rx ry function with four arguments ::::::::::::::::::::::::::::

cleargraphenv function with no arguments :::::::::::::::::::::::::::::::::::::

drawpoint x y function with two arguments ::::::::::::::::::::::::::::::::::::::

drawline x y x y function with four arguments :::::::::::::::::::::::::::::

drawrectangle x y w h function with four arguments ::::::::::::::::::::::::::::

drawcircle x y r function with four arguments ::::::::::::::::::::::::::::::::::

drawarc x y w h angle angle function with six arguments ::::::::::::::::::::

drawsegments n vx vy vx vy function with ve arguments ::::::::::::::::::

drawrectangles n vx vy vw vh function with ve arguments ::::::::::::::::::::

fillrectangle x y w h function with four arguments ::::::::::::::::::::::::::::

fillcircle x y r function with three arguments :::::::::::::::::::::::::::::::::

fillarc x y w h angle angle function with six arguments ::::::::::::::::::::

fillrectangles n vx vy vw vh function with ve arguments ::::::::::::::::::::

highlightrectangle x y w h function with four arguments ::::::::::::::::::::::

drawstring x y s function with three arguments :::::::::::::::::::::::::::::::::

drawcn x y cn function with three arguments :::::::::::::::::::::::::::::::::::::

widthsubstring string start length function with three arguments ::::::::::::

heightsubstring string start length function with three arguments :::::::::::

FUNCTION INDEX

xbasesubstring string start length function with three arguments :::::::::::

ybasesubstring string start length function with three arguments :::::::::::

xincsubstring string start length function with three arguments ::::::::::::

yincsubstring string start length function with three arguments ::::::::::::

bitmap structure ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::

createbitmap w h bits function with two or three arguments :::::::::::::::::::::

windowbitmap window function with one argument :::::::::::::::::::::::::::::::

bitmapw bitmap function with one argument :::::::::::::::::::::::::::::::::::

bitmaph bitmap function with one argument :::::::::::::::::::::::::::::::::::

bitmapbits bitmap bits function with one or two arguments :::::::::::::::::::

macro ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::

bitvectorprin bitvector function with one argument ::::::::::::::::::::::::

bitmapprin bitmap function with one argument :::::::::::::::::::::::::::::::

systemcompressedicon variable :::::::::::::::::::::::::::::::::::::::::::::

b w h bits macro ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::

killbitmap bitmap function with one argument ::::::::::::::::::::::::::::::::::

bmref bitmap x y function with three arguments :::::::::::::::::::::::::::::::::::

bmset bitmap x y bit function with four arguments :::::::::::::::::::::::::::::::

bitblit b b x y x y w h function with eight arguments ::::::::::::::::::::

bitmapbytemap structure ::::::::::::::::::::::::::::::::::::::::::::::::::: :::

createbytemap w h bytes table function with two to four arguments :::::::::::::

BC macro ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::

bitmapbytes bytemap bytes function with one or two arguments :::::::::::::::

byteref bytemap i j function with three arguments :::::::::::::::::::::::::::::::

byteset bytemap i j col function with four arguments :::::::::::::::::::::::::::

substitutecolor bytemap oldcol newcol function with three arguments :::::::::

substcolors bytetmap l function with two arguments :::::::::::::::::::::::::::

send bitmapbytemapprin bitmap method with one argument ::::::::::::::::

Index of concepts

Fatal error no room for code

Fatal error no room for fixs

Fatal error no room for floats

Fatal error no room for heap

Fatal error no room for lists

Fatal error no room for strings

Fatal error no room for symbols

Fatal error no room for vectors

Fatal error stack overflow

Fatal error stack underflow

fn bad address s

fn bad arguments list a

fn bad definition symb

fn bad parameter e

fn bad parameter s

fn bad fg abbreviation e

fn bad type for an hash table s

fn cant compute larg

fn illegal bind p v

fn inactive lexical scope e

fn methode indefinie l

fn no lexical scope e

fn not a fix s

fn not a float s

fn not a list e

fn not a number s

fn not a string e

fn not a structure s

fn not a symbol e

fn not a variable e

fn not a vector s

fn not an abbreviation e

fn not an atom e

fn not an Hash Table s

fn out of bounds s

fn g not within fg e

fn redefined function symb

fn io error n

fn string expected s

fn string too long s 1

0-2 INDEX

fn syntax error msg

fn undefined function symb

fn undefined method l

fn undefined tag symb

fn undefined variable symb

fn wrong number of arguments n

fn wrong number of arguments s

fn no more windows available

fn not a window e

fnt unknown terminal symb

function division by zero

loadfont argument hors limite string

loadfont out of bounds string

toplevel undefined tag symb

A

a

abbreviated mode mouse

ackermann function

addr

Aida

al

alink

Alist

allcdr

l Function

anonymous function

arrays

association list

autoload

autoload function

autoload mode

B

backspace character

begincomment

bitmapbytemapprin

bitmap Method

boolean value

boolean value

C

INDEX 0-3

car

cdr

ch

chan

channel

character in LeLisp

character strings

circular list

circular or shared list

classes of objects

clipping zone

C LL FIX

LL FLOAT C

closed compiler macros

cn

code zone

Color bitmaps

colors

comment delimiter

comments

compiler macros

compilers

complex numbers

complex standard library file

Complice compiler

Complice errors

Complice warnings

conditional read

control character

coreimage file

cpmac standard library file

cursor

cval

D

debug loop

debug mode

debugging

debugging tools

dec prl

delete character

dmacro functions

dmsubr

down arrow keyboard key

0-4 INDEX

dynamic execution environment

E

edlin standard library file

embedded comments

endcomment

endofline

errdv

errbal

errbdf

errbht

errbpa

errfcns

errfcod

errffix

errfflt

errfhep

errfstk

errfstr

errfsud

errfsym

errfvec

errgen

errilb

errios

errnaa

errnab

errnda

errnfa

errnht

errnia

errnla

errnmw

errnna

errnotanabbrev

errnotawindow

errnsa

errnva

erroob

errstc

errstl

errsxt

errsxtacc

errsxtclosingacc

INDEX 0-5

errsym

errudf

errudm

errudt

errudv

errvec

errvirtty

errwna

errxia

escape

evaluation of atomic objects

event loop

events

events loop

evloop

evloop file in the standard library

expr

F

feature

fexpr

file

file specification

fill patterns or textures

flambda expression

fn

font of characters

form capable of evaluation

format standard library file

formatted output

Franz Lisp

fsubr

ftype

function call

function definition

functions

fval

G

garbage collector

global variable

Graphics environment

graphics primitives

0-6 INDEX

H

hanoi demonstration file

hash tables

hashcoding

high

HOMElelisp

I

incremental execution

inheritance of methods

input buffer

input file

input stream

Inria

inspection loop

installation directory

internal character codes

interrupt character

interrupt mode mouse

intrinsic property

invisible bit

L

l

labelled cons

lambda expression

lap

lch

lcn

left arrow keyboard key

left print margin

LeLisp

lexical analysis

lexical environment for execution

libcir standard library file

libraries

library

line editor

line style

lines

Lisp Assembly Program

Lisp Machine Lisp

list cell

INDEX 0-7

LL C FIX

C FLOAT LL

llm

llm instruction

llm label

llm operands

local variable

lock function

low

M

machine interrupts

Maclisp

macro character

macro functions

managing interrupts

memory access

memory address

memory allocator

methods

mlambda expression

msubr

multitasks

N

n

NIL New Implementation of Lisp

nil special symbol

nonlocal branch

nsubr

numbers

O

objectoriented programming

open compiler macros

output channel of the virtual terminal

output file

output stream

oval

own variable

P

0-8 INDEX

packages

path

pathname

pckgcell

plist

pname

programmable interrupts

prompt string

ptype

Q

Q standard library file

quote

quote character

R

r argument to LeLisp command

ratio standard library file

rational numbers

rationals numbers

read errors

read table

reading a character

reading a line

reading Sexpressions

realtime clock interrupt

records a la Pascal

right arrow keyboard key

right print margin

rubout character

S

s

io streams

scheduler standard library file

sequencer

Sexpressions

singlestep mode

IO inputoutput

snobol

special form

special symbol

INDEX 0-9

standard functions

standard reader

startup standard library file

stepwise execution

strg

string delimiter

string is the default character string type

stringio

stringio file in the standard library

structures

subr

switch

symb

symbol delimiter

symbols

T

t symbolic constant

tables association

tcons

termcap virtual terminal description database

terminal input

terminal output channel

Terminal Virtuel

terminfo virtual terminal description database

toplevel

trace

tracing

true

type of a character string

type of a vector of Sexpressions

typed vector of Sexpressions

types of characters

U

U character

up arrow keyboard key

user interrupt

V

variablefunctions

vdt demonstration file

0-10 INDEX

vect

vector of Sexpressions

vectors of Sexpressions

virtual bitmap

virtual files

virtual mouse

virtual pointing device

virtual terminal

Vlisp

VMS

W

whanoi demonstration file

X

X character

Index of the LLM Machine

a [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::: 12-6

a [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::: 12-6

a [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::: 12-6

a [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::: 12-6

addadr addr addr [function with two arguments ] ::::::::::::::::::::::::::::::::::::: 12-2

adjstk op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::: 12-11

alink accu [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: 12-13

alink accu [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: 12-7

bfcons op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::: 12-12

bffix op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 12-14

bffloat op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 12-16

bfnil op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 12-12

bfstrg op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::: 12-18

bfsymb op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::: 12-12

bfvar op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 12-13

bfvect op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::: 12-17

bra lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::: 12-9

bri op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::: 12-9

brx llab op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::: 12-9

btcons op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::: 12-11

btfix op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 12-14

btfloat op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 12-16

btnil op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 12-12

btstrg op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::: 12-18

btsymb op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::: 12-12

btvar op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 12-13

btvect op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::: 12-17

cabeq op op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::: 12-9

cabne op op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::: 12-9

calli op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: 12-10

calln addr l [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::: 12-4

call addr a a a [function with four arguments ] :::::::::::::::::::::::::::::::::::: 12-4

0-2

call lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: 12-10

car accu [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::: 12-12

car accu [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::: 12-6

cdr accu [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::: 12-12

cdr accu [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::: 12-6

cfbeq op op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::: 12-17

cfbge op op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::: 12-17

cfbgt op op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::: 12-17

cfble op op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::: 12-17

cfblt op op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::: 12-17

cfbne op op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::: 12-17

cnbeq op op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::: 12-15

cnbge op op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::: 12-15

cnbgt op op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::: 12-15

cnble op op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::: 12-15

cnblt op op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::: 12-15

cnbne op op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::: 12-15

cvalq symb [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: 12-13

cvalq symb [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: 12-7

cval accu [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::: 12-13

cval accu [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::: 12-6

decr op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::: 12-14

diff op op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 12-14

endl [LLM pseudoinstruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::: 12-8

end [LLM pseudoinstruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::: 12-8

entry symb ftype [LLM pseudoinstruction ] :::::::::::::::::::::::::::::::::::::::::::: 12-8

eval expr [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::: 12-8

eval e [LLM pseudoinstruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 12-8

fdiff op op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::: 12-16

fentry symb ftype [LLM pseudoinstruction ] ::::::::::::::::::::::::::::::::::::::::::: 12-8

fplus op op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::: 12-16

fquo op op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 12-16

ftimes op op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 12-16

fvalq symb [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: 12-13

0-3

fvalq symb [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: 12-7

fval accu [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::: 12-13

fval accu [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::: 12-6

gtadr addr addr [function with two arguments ] :::::::::::::::::::::::::::::::::::::: 12-3

hbmovx op strg index [LLM instruction ] :::::::::::::::::::::::::::::::::::::::::::::: 12-19

hbxmov strg index op [LLM instruction ] :::::::::::::::::::::::::::::::::::::::::::::: 12-19

hgsize op op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 12-19

hpmovx op vect n [LLM instruction ] :::::::::::::::::::::::::::::::::::::::::::::::::: 12-18

hpxmov vect n op [LLM instruction ] :::::::::::::::::::::::::::::::::::::::::::::::::: 12-18

incradr addr n [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::: 12-2

incr op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::: 12-14

jcall symb [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::: 12-11

jmp symb [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: 12-9

lab [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::: 12-7

land op op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 12-15

ldcodop [constant ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::: 12-19

lddir [constant ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::: 12-19

ldind [constant ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::: 12-20

ldsharedstrings [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 12-5

ldspecialcaseloader [variable ] :::::::::::::::::::::::::::::::::::::::::::::::: 12-4

loader l i [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 12-4

loader [feature ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 12-4

local symb [LLM pseudoinstruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 12-8

loc s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 12-3

lor op op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::: 12-16

lshift op op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 12-16

lxor op op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 12-16

memory addr n [function with one or two arguments ] :::::::::::::::::::::::::::::::::::: 12-3

movxsp op op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 12-11

mov op op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::: 12-9

negate op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::: 12-14

nil [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::: 12-6

nop [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::: 12-10

lab [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::: 12-7

0-4

n [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::: 12-7

oval accu [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::: 12-13

oval accu [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::: 12-7

pkgc accu [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::: 12-13

pkgc accu [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::: 12-7

plist accu [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: 12-13

plist accu [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: 12-6

plus op op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 12-14

pname accu [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: 12-13

pname accu [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: 12-7

pop op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::: 12-11

push op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::: 12-11

quote exp [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::: 12-6

quo op op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::: 12-14

rem op op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::: 12-15

return [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::: 12-11

sobgez op lab [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::: 12-10

sstack op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::: 12-10

stack op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: 12-10

subadr addr addr [function with two arguments ] ::::::::::::::::::::::::::::::::::::: 12-2

systemccode addr [function with an optional argument ] ::::::::::::::::::::::::::::: 12-2

systemecode [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::: 12-2

times op op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::: 12-14

title symb [LLM pseudoinstruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 12-8

typ accu [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::: 12-18

typ accu [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::: 12-19

typ accu [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::: 12-7

vag addr [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::: 12-3

val accu [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::: 12-18

val accu [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::: 12-19

val accu [LLM operand ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::: 12-7

xspmov op op [LLM instruction ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 12-11

Index of LELISP entities

abbrevp symb [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::: 5-14

abbrev [feature ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 5-13

abs x [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 4-5

[macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::: 6-25

[print format ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 9-9

[print format ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 9-10

A [print format ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 9-3

B [print format ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 9-5

C [print format ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 9-6

D [print format ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 9-4

E [print format ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 9-6

F [print format ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 9-7

G [print format ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 9-8

O [print format ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 9-5

P [print format ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 9-5

R [print format ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 9-4

S [print format ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 9-4

T [print format ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 9-9

X [print format ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 9-5

[print format ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::: 9-10

lf [print format ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::: 9-9

[print format ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 9-8

fg [print format ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::: 9-11

[print format ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 9-8

[print format ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 9-11

[macro character ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::: 6-20

A [macro character ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::: 6-31

E [macro character ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::: 6-31

F [macro character ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::: 6-31

L [macro character ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::: 6-30

P [macro character ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::: 6-32

0-2

acons s s al [function with three arguments ] :::::::::::::::::::::::::::::::::::::::: 3-65

acosh z [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 10-10

acos x [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 4-10

activatemenu menu x y [function with three arguments ] :::::::::::::::::::::::::::::: 19-10

addevent event [function with one argument ] :::::::::::::::::::::::::::::::::::::::: 19-6

addevent gx gy code [function with three arguments ] ::::::::::::::::::::::::::::::::: 19-7

addfeature symb [function with one argument ] ::::::::::::::::::::::::::::::::::::::: 6-75

add x [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 4-13

addprop pl pval ind [function with three arguments ] :::::::::::::::::::::::::::::::::: 3-76

add x y [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::: 4-13

adjoin item list eqfunc [function with two or three arguments ] ::::::::::::::::::::::: 3-107

allcolors screen [function with an optional argument ] ::::::::::::::::::::::::::::::: 18-6

allcar l [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::: 3-8

allowevent display event [function with two arguments ] :::::::::::::::::::::::::::: 19-8

allowedeventp display event [function with two arguments ] ::::::::::::::::::::::: 19-8

alphalessp str str [function with two arguments ] :::::::::::::::::::::::::::::::::: 3-91

and s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::: 3-28

n

any fn l ::: l [function with a variable number of arguments ] ::::::::::::::::::::::::: 3-11

n

append l s [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::: 3-55

append l ::: l [function with a variable number of arguments ] ::::::::::::::::::::::::: 3-54

n

apply fn s ::: s l [function with a variable number of arguments ] ::::::::::::::::::::: 3-7

n

aref array i ::: i [function with a variable number of arguments ] ::::::::::::::::::::: 3-103

n

arg n [function with an optional argument ] :::::::::::::::::::::::::::::::::::::::::::::: 3-5

array [feature ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::: 3-103

asciievent [event ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::: 19-3

asciip cn [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::: 3-98

ascii cn [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::: 3-97

aset array i ::: i e [function with a variable number of arguments ] :::::::::::::::::: 3-104

n

asinh z [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 10-9

asin x [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 4-10

assoc s al [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 3-66

assq symb al [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::: 3-65

atend returncode [function with an optional argument ] ::::::::::::::::::::::::::::::: 7-17

atend [programmable interrupt ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::: 7-17

0-3

atanh z [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 10-10

atan x [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 4-10

atomp s [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 3-43

atom s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 3-43

autoload file sym ::: sym [special form ] ::::::::::::::::::::::::::::::::::::::::: 6-54

n

backtrack symb l e ::: e [special form ] :::::::::::::::::::::::::::::::::::::::::: 3-41

n

baser [macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::: 6-25

BC [macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::: 20-17

bitblit b b x y x y w h [function with eight arguments ] ::::::::::::::::::::::: 20-16

bitepilogue screen [function with an optional argument ] :::::::::::::::::::::::::::::: 18-4

bitmapflush screen [function with an optional argument ] ::::::::::::::::::::::::::::: 18-6

bitmaprefresh screen [function with an optional argument ] ::::::::::::::::::::::::::: 18-6

bitmaprestore screen [function with one argument ] ::::::::::::::::::::::::::::::::: 18-5

bitmapsave screen [function with an optional argument ] :::::::::::::::::::::::::::::: 18-4

bitmapsync display [function with an optional argument ] ::::::::::::::::::::::::::::: 18-6

bitmapbits bitmap bits [function with one or two arguments ] :::::::::::::::::::::: 20-14

send bitmapbytemapprin bitmap [method with one argument ] ::::::::::::::::::: 20-18

bitmapbytemap [structure ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::: 20-16

bitmapbytes bytemap bytes [function with one or two arguments ] :::::::::::::::::: 20-18

bitmaph bitmap [function with one argument ] :::::::::::::::::::::::::::::::::::::: 20-14

bitmapprin bitmap [function with one argument ] ::::::::::::::::::::::::::::::::::: 20-15

bitmapw bitmap [function with one argument ] :::::::::::::::::::::::::::::::::::::: 20-14

bitmap [structure ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::: 20-13

bitprologue name device [function with one or two optional arguments ] ::::::::::::::::: 18-3

bitvectorprin bitvector [function with one argument ] :::::::::::::::::::::::::::: 20-15

bitxmax screen [function with an optional argument ] ::::::::::::::::::::::::::::::::::: 18-5

bitymax screen [function with an optional argument ] ::::::::::::::::::::::::::::::::::: 18-5

block symb e ::: e [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::: 3-33

n

bltscreen sd ss w h [function with four or twelve arguments ] :::::::::::::::::::::::::: 15-9

bltstring str n str n n [function with four or ve arguments ] :::::::::::::::::: 3-94

bltvector vect n vect n n [function with ve arguments ] ::::::::::::::::::::::: 3-102

bluecomponent color value [function with one or two arguments ] ::::::::::::::::::::: 20-4

bmref bitmap x y [function with three arguments ] :::::::::::::::::::::::::::::::::::::: 20-16

bmset bitmap x y bit [function with four arguments ] :::::::::::::::::::::::::::::::::: 20-16

0-4

boblist n [function with an optional argument ] ::::::::::::::::::::::::::::::::::::::::: 3-85

bol [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 6-43

bol [programmable interrupt ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: 6-42

boundp symb [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::: 3-69

break [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 11-7

byteref bytemap i j [function with three arguments ] :::::::::::::::::::::::::::::::::: 20-18

byteset bytemap i j col [function with four arguments ] :::::::::::::::::::::::::::::: 20-18

b w h bits [macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::: 20-15

cr l [functions of one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 3-49

callextern address type v t ::: v t [function with a variable number of arguments ] 14-2

n n

cartesianproduct set set [function with two arguments ] :::::::::::::::::::::::::: 3-109

car l [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 3-49

cascii ch [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::: 3-97

cassoc s al [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::: 3-67

cassq symb al [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::: 3-66

catchallbut l s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::: 3-41

n

catcherror i s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::: 7-8

n

catenate str ::: str [function with a variable number of arguments ] :::::::::::::::::: 3-91

n

cbcom [character type ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::: 6-14

cdot [character type ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::: 6-14

cdr l [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 3-49

cecom [character type ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::: 6-14

ceiling n [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::: 4-4

channel chan [function with an optional argument ] ::::::::::::::::::::::::::::::::::::: 6-50

chrnth n strg [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::: 3-93

chrpos cn strg pos [function with two or three arguments ] ::::::::::::::::::::::::::::: 3-93

chrset n strg cn [function with three arguments ] :::::::::::::::::::::::::::::::::::::: 3-94

circopy e [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::: 9-13

cirequal e e [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::: 9-13

cirlist e ::: e [function with a variable number of arguments ] :::::::::::::::::::::::: 3-62

n

cirnequal e e [function with two arguments ] :::::::::::::::::::::::::::::::::::::::: 9-13

cirprinflush e [function with one argument ] ::::::::::::::::::::::::::::::::::::::::: 9-13

cirprint e [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 9-13

cirprin e [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::: 9-13

0-5

cis r [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 10-9

cleargraphenv [function with no arguments ] :::::::::::::::::::::::::::::::::::::::: 18-21

cleargraphenv [function with no arguments ] :::::::::::::::::::::::::::::::::::::::: 20-10

clientmessage [event ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::: 19-5

cliph [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::: 20-9

clipw [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::: 20-9

clipx [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::: 20-9

clipy [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::: 20-9

cload string [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::: 14-6

clockalarm n [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::: 7-4

clock [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 7-4

clock [programmable interrupt ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::: 7-4

close chan [function with an optional argument ] :::::::::::::::::::::::::::::::::::::::: 6-50

closure lvar fn [function with two arguments ] :::::::::::::::::::::::::::::::::::::::: 3-22

clpar [character type ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::: 6-14

clrhash ht [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 3-106

cmacro [character type ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::: 6-15

cmsymb [character type ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::: 6-16

cnull [character type ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::: 6-14

combinepathnames path path [function with two arguments ] ::::::::::::::::::::::: 6-70

comline strg [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::: 7-24

comment e ::: e [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 3-6

n

compileallincore print loader [function with zero one or two optional arguments ] : 13-2

compilefiles source object [function with two arguments ] ::::::::::::::::::::::::::: 13-3

compilemodule module ind [function with one or two arguments ] ::::::::::::::::::::::: 13-17

compileropenp [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::: 13-4

compiler source status print loader [function with four arguments ] ::::::::::::::::: 13-2

compiler [feature ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::: 13-1

compile source status print loader [special form with one two three or four arguments ]13-2

complexp c [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 10-6

complex [feature ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::: 10-1

complicenowarning [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 13-19

compliceparanoflag [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 13-18

complicewarningflag [ag ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 13-19

0-6

complice [feature ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::: 13-1

concat str ::: str [function with a variable number of arguments ] ::::::::::::::::::::: 3-83

n

cond l ::: l [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::: 3-29

n

conjugate c [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::: 10-8

consp s [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 3-45

constantp s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::: 3-43

cons s s [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 3-52

controlfilepathname name path [function with one or two arguments ] ::::::::::::::: 6-72

copyfile ofile nfile [function with two arguments ] :::::::::::::::::::::::::::::::::: 6-53

copylist l [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 3-55

copy s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 3-56

coreinitstd msg [function with one argument ] :::::::::::::::::::::::::::::::::::::: 7-15

cosh z [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 10-9

cos x [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 4-10

cpkgc [character type ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::: 6-15

cpname [character type ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::: 6-15

cquote [character type ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::: 6-14

createbitmap w h bits [function with two or three arguments ] :::::::::::::::::::::::: 20-14

createbytemap w h bytes table [function with two to four arguments ] :::::::::::::::: 20-17

createdirectory dir [function with one argument ] :::::::::::::::::::::::::::::::::: 6-53

createmenu ti n v ::: n v [function with a variable number of arguments ] ::::::::: 19-10

n n

createsubwindow type x y w h ti hi vi fa [function with nine arguments ] ::::::::: 18-13

createwindow type x y w h ti hi vi [function with eight arguments ] :::::::::::::::: 18-13

crpar [character type ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::: 6-14

csend fndef symb o p ::: p [function with a variable number of arguments ] :::::::::::: 5-11

n

csep [character type ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::: 6-15

csplice [character type ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::: 6-15

cstack [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 7-11

cstring [character type ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::: 6-15

csymb [character type ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::: 6-15

curread [function with no arguments ] :::::::::::::::::::::::::::::::::::::::::::::::::: 6-7

currentbackground color [function with an optional argument ] ::::::::::::::::::::::: 20-3

currentclip x y w h [function with zero or four arguments ] ::::::::::::::::::::::::::: 20-9

currentcursor cursor [function with an optional argument ] ::::::::::::::::::::::::::: 20-5

0-7

currentdirectory path [function with an optional argument ] ::::::::::::::::::::::::: 6-73

currentdisplay screen [function with an optional argument ] ::::::::::::::::::::::::: 18-3

currentfont font [function with an optional argument ] ::::::::::::::::::::::::::::::: 20-2

currentforeground color [function with an optional argument ] ::::::::::::::::::::::: 20-3

currentkeyboardfocuswindow win [function with an optional argument ] :::::::::::: 18-16

currentlanguage language [function with an optional argument ] :::::::::::::::::::::: 9-15

currentlinestyle linestyle [function with an optional argument ] ::::::::::::::::: 20-6

currentmode mode [function with an optional argument ] ::::::::::::::::::::::::::::::: 20-8

currentpattern pattern [function with an optional argument ] :::::::::::::::::::::::: 20-7

currentwindow win [function with an optional argument ] :::::::::::::::::::::::::::::: 18-16

cursormax [function with no arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 20-5

cursorname num [function with one argument ] :::::::::::::::::::::::::::::::::::::::: 20-6

CLLFIX [Fonction C ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::: 14-13

CLLFLOAT [Fonction C ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::: 14-14

C [macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::: 10-6

debugcommand cn [function with one argument ] ::::::::::::::::::::::::::::::::::::::: 11-12

debugend [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::: 11-1

debug s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::: 11-7

debug [feature ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::: 11-1

decr symb n [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::: 3-74

defabbrev sym sym [macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::: 5-13

defaultlanguage language [function with an optional argument ] :::::::::::::::::::::: 9-15

defaultpathnamedefaults [variable ] ::::::::::::::::::::::::::::::::::::::::::::: 6-69

defaultwindowtype screen type [function with one or two arguments ] ::::::::::::::: 18-7

defesckey key e ::: e [special form ] :::::::::::::::::::::::::::::::::::::::::::::: 16-3

n

defexterncache flag [special form ] :::::::::::::::::::::::::::::::::::::::::::::::: 14-5

defextern symb ltype type [special form ] ::::::::::::::::::::::::::::::::::::::::::: 14-2

definewindowpropertyaccessor prop [macro ] ::::::::::::::::::::::::::::::::: 18-15

defkey key e ::: e [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::: 16-3

n

defmacroopen name ::: fval [special form ] ::::::::::::::::::::::::::::::::::::::::: 13-5

defmacro symb lvar s ::: s [special form ] :::::::::::::::::::::::::::::::::::::::: 3-19

n

defmake type fn field ::: field [macro ] ::::::::::::::::::::::::::::::::::::: 5-17

n

defmessage message def ::: def [macro ] ::::::::::::::::::::::::::::::::::::::::: 9-17

n

defprop pl pval ind [special form ] :::::::::::::::::::::::::::::::::::::::::::::::::: 3-77

0-8

defrecord symbol field ::: field [macro ] :::::::::::::::::::::::::::::::::::::: 5-16

n

defsetf access lparams store body [macro ] ::::::::::::::::::::::::::::::::::::: 3-24

defsharp ch larg s ::: sN [special form ] :::::::::::::::::::::::::::::::::::::::::: 6-24

defstruct struct field ::: field [macro ] :::::::::::::::::::::::::::::::::::::: 5-2

n

defstruct [feature ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::: 5-1

deftclass symbol field ::: field [macro ] :::::::::::::::::::::::::::::::::::::: 5-16

n

defun symb lvar s ::: s [special form ] :::::::::::::::::::::::::::::::::::::::::::: 3-18

n

defvar symb e [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::: 3-70

deletedirectory dir [function with one argument ] :::::::::::::::::::::::::::::::::: 6-53

deletefile file [function with one argument ] :::::::::::::::::::::::::::::::::::::::: 6-53

delete s l [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 3-64

n [macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::: 6-24

delq symb l [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::: 3-64

demethod ftclassgname obj p ::: p f ::: f body [macro ] :::::::::::::: 5-18

n n

denominator f [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::: 10-5

depositbyte n np nl m [function with four arguments ] ::::::::::::::::::::::::::::::: 4-18

depositfield n np nl m [function with four arguments ] :::::::::::::::::::::::::::::: 4-18

desetq l l [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::: 3-72

deset l l [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::: 3-72

devicenamestring path [function with one argument ] :::::::::::::::::::::::::::::::: 6-70

de symb lvar s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::: 3-18

n

df symb lvar s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::: 3-18

n

difference x ::: x [function with a variable number of arguments ] :::::::::::::::::::: 4-25

n

differ x ::: x [function with a variable number of arguments ] ::::::::::::::::::::::::: 4-25

n

digitp cn [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::: 3-98

directorynamestring path [function with one argument ] :::::::::::::::::::::::::::: 6-70

directoryp path [function with one argument ] :::::::::::::::::::::::::::::::::::::::: 6-73

disallowevent display event [function with two arguments ] ::::::::::::::::::::::::: 19-8

displace l ln [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::: 3-60

displaydepth display [function with one argument ] ::::::::::::::::::::::::::::::::: 18-7

displaygetfontinfo display fontname fontinfo [function with two or

three arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::: 18-25

displaygetfontnames display max pattern [function with two or three arguments ] : 18-25

displaygetselection display [function with one argument ] :::::::::::::::::::::::: 19-11

0-9

displaystoreselection display buffer [function with two arguments ] ::::::::::::: 19-11

displaysynchronize display flag [function with one or two arguments ] :::::::::::::: 18-7

divide x y [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 4-26

div x y [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::: 4-13

dmc ch s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 6-18

n

dmd symb lvar s ::: s [special form ] :::::::::::::::::::::::::::::::::::::::::::::: 3-19

n

dms ch s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 6-19

n

dm symb lvar s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::: 3-19

n

do lv lr ec ::: ec [macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 3-37

n

dontcompile exp ::: exp [special form ] :::::::::::::::::::::::::::::::::::::::::: 13-3

n

downevent [event ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::: 19-2

do lv lr ec ::: ec [macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 3-35

n

dragevent [event ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::: 19-2

drawarc x y w h angle angle [function with six arguments ] :::::::::::::::::::::::: 20-11

drawcircle x y r [function with four arguments ] ::::::::::::::::::::::::::::::::::::: 20-11

drawcn x y cn [function with three arguments ] :::::::::::::::::::::::::::::::::::::::: 18-21

drawcn x y cn [function with three arguments ] :::::::::::::::::::::::::::::::::::::::: 20-13

drawcursor x y i [function with three arguments ] :::::::::::::::::::::::::::::::::::: 18-21

drawellipse x y rx ry [function with four arguments ] ::::::::::::::::::::::::::::::: 20-10

drawline x y x y [function with four arguments ] :::::::::::::::::::::::::::::::: 20-11

drawpoint x y [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::: 20-11

drawpolyline n vx vy [function with three arguments ] :::::::::::::::::::::::::::::::: 20-9

drawpolymarker n vx vy [function with three arguments ] ::::::::::::::::::::::::::::: 20-10

drawrectangles n vx vy vw vh [function with ve arguments ] :::::::::::::::::::::::: 20-12

drawrectangle x y w h [function with four arguments ] ::::::::::::::::::::::::::::::: 20-11

drawsegments n vx vy vx vy [function with ve arguments ] ::::::::::::::::::::: 20-11

drawstring x y s [function with three arguments ] :::::::::::::::::::::::::::::::::::: 18-21

drawstring x y s [function with three arguments ] :::::::::::::::::::::::::::::::::::: 20-13

drawsubstring x y s start length [function with ve arguments ] ::::::::::::::::::: 18-22

drawsubstring x y s start length [function with ve arguments ] ::::::::::::::::::: 20-10

ds symb type adr [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 3-20

duplstring n strg [function with two arguments ] ::::::::::::::::::::::::::::::::::::: 3-92

E [Complice error message ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: 13-20

E [Complice error message ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: 13-20

0-10

E [Complice error message ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: 13-20

E [Complice error message ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: 13-20

E [Complice error message ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: 13-21

E [Complice error message ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: 13-21

E [Complice error message ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: 13-21

edlin [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 17-1

edlin [feature ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::: 17-1

end returncode [function with an optional argument ] :::::::::::::::::::::::::::::::::: 7-17

enoughnamestring path default [function with one or two arguments ] :::::::::::::::: 6-71

enterwindowevent [event ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::: 19-3

eof chan [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::: 6-52

eof [programmable interrupt ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: 6-52

eol [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 6-46

eol [programmable interrupt ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: 6-45

eprogn l [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::: 3-3

eqn x y [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::: 4-14

eqstring str str [function with two arguments ] :::::::::::::::::::::::::::::::::::: 3-91

equalpathname path path [function with two arguments ] ::::::::::::::::::::::::::: 6-65

equal s s [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::: 3-47

eqvector vect vect [function with two arguments ] :::::::::::::::::::::::::::::::::: 3-101

eq s s [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::::: 3-46

error s s s [function with three arguments ] :::::::::::::::::::::::::::::::::::::::: 7-8

errset e i [macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::: 7-9

err s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::: 7-9

n

evalwhen moments expressions [function with a variable number of arguments ] ::::::: 13-13

eval s env [function with one or two arguments ] :::::::::::::::::::::::::::::::::::::::: 3-2

even z [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 10-4

evenp x [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 4-14

eventloop [feature ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::: 6-57

eventmode mode [function with an optional argument ] :::::::::::::::::::::::::::::::::: 19-5

eventp [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 19-6

event event [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::: 19-9

event [programmable interrupt ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::: 19-8

event [structure ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 19-2

0-11

every fn l ::: l [function with a variable number of arguments ] ::::::::::::::::::::::: 3-11

n

evexit s s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 3-38

n

evlis l [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 3-2

evlis l [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 3-61

evloopadddisplay display managefct [function with two arguments ] :::::::::::::: 6-60

evloopaddinput fd managefct argtouse [function with three arguments ] ::::::::: 6-58

evloopaddoutput fd managefct argtouse [function with three arguments ] :::::::: 6-59

evloopallowttyinput [function with no arguments ] :::::::::::::::::::::::::::::::: 6-58

evloopchangemanagefunction fd newmanagefct newargtouse [function

with three arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::: 6-58

evloopchangeoutputmanagefunction fd newmanagefct newargtouse

[function with three arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 6-60

evloopdisallowttyinput [function with no arguments ] :::::::::::::::::::::::::::: 6-58

evloopdisplaymanagedp display [function with one argument ] :::::::::::::::::::: 6-60

evloopinitializedp [function with no arguments ] :::::::::::::::::::::::::::::::::: 6-59

evloopinit [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::: 6-57

evloopinputmanagedp fd [function with one argument ] ::::::::::::::::::::::::::::: 6-59

evloopreadp fd [function with one argument ] :::::::::::::::::::::::::::::::::::::::: 6-59

evloopremovedisplay display [function with one argument ] :::::::::::::::::::::::: 6-60

evloopremoveinput fd [function with one argument ] :::::::::::::::::::::::::::::::: 6-58

evloopremoveoutput fd [function with one argument ] ::::::::::::::::::::::::::::::: 6-60

evlooprestart [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::: 6-58

evloopselect [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::: 6-58

evloopsettimeouthandler handler [function with one argument ] :::::::::::::::::: 6-59

evloopsettimeout secs millisecs [function with two arguments ] ::::::::::::::::::: 6-59

evloopstop [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::: 6-58

evloopwait [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::: 6-59

evtag s s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 3-38

n

ex x y z [function with three arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 4-21

ex x y [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::: 4-20

ex x [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 4-20

ex x y [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::: 4-21

ex x [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 4-20

exmod [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::: 4-7

0-12

exregret [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::: 4-20

ex x y [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::: 4-22

exchstring strg strg [function with two arguments ] :::::::::::::::::::::::::::::::: 3-88

exchvector vect vect [function with two arguments ] :::::::::::::::::::::::::::::::: 3-102

exit symb s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 3-38

n

expandpathname path [function with one argument ] :::::::::::::::::::::::::::::::::: 6-67

explodech s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::: 6-39

explode s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::: 6-39

exp x [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 4-11

fact n [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 10-4

fadd x y [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::::: 4-22

false e ::: e [function with a variable number of arguments ] :::::::::::::::::::::::::: 3-42

n

fdiv x y [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::::: 4-23

featurep symb [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::: 6-75

feqn x y [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::::: 4-23

fge x y [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::: 4-23

fgt x y [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::: 4-23

fib n [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 10-4

fieldlist symbol [function with one argument ] :::::::::::::::::::::::::::::::::::::: 5-17

filenamestring path [function with one argument ] :::::::::::::::::::::::::::::::::: 6-69

fillarc x y w h angle angle [function with six arguments ] :::::::::::::::::::::::: 20-12

fillarea n vx vy [function with three arguments ] :::::::::::::::::::::::::::::::::::: 20-10

fillcircle x y r [function with three arguments ] :::::::::::::::::::::::::::::::::::: 20-12

fillellipse x y rx ry [function with four arguments ] ::::::::::::::::::::::::::::::: 20-10

fillrectangles n vx vy vw vh [function with ve arguments ] :::::::::::::::::::::::: 20-12

fillrectangle x y w h [function with four arguments ] ::::::::::::::::::::::::::::::: 20-12

fillstring strg n cn n [function with three or four arguments ] :::::::::::::::::::::: 3-95

fillvector vect n e n [function with three or four arguments ] ::::::::::::::::::::::: 3-102

findwindow x y [function with two arguments ] :::::::::::::::::::::::::::::::::::::::: 18-19

findfn s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::: 3-79

firstn n l [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 3-57

fixp x [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 4-2

fix x [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 4-3

flambda l s ::: s [special form ] :::::::::::::::::::::::::::::::::::::::::::::::::: 3-6

n

0-13

flet l s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::: 3-23

n

fle x y [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::: 4-24

floatp x [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::: 4-3

float x [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 4-4

floor n [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 4-3

flt x y [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::: 4-24

flushevent [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::: 19-6

flush [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 6-46

flush [programmable interrupt ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::: 6-46

fmax x y [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::::: 4-24

fmin x y [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::::: 4-24

fmul x y [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::::: 4-22

fneqn x y [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::: 4-23

fontascent [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::: 18-25

fontheight [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::: 18-25

fontmax [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::: 20-2

fontname font [function with one argument ] :::::::::::::::::::::::::::::::::::::::::: 20-2

format dest cntrl e ::: e [function with two or more arguments ] :::::::::::::::::::: 9-1

n

format [feature ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 9-1

for var in ic ntl e ::: e s ::: s [special form ] ::::::::::::::::::::::::::::: 3-32

m n

freecons cons [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::: 7-22

freetree tree [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::: 7-23

fsub x y [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::::: 4-22

funcall fn s ::: s [function with a variable number of arguments ] :::::::::::::::::::: 3-7

n

function fn [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::: 3-5

gcbeforealarm [function with no arguments ] :::::::::::::::::::::::::::::::::::::::: 7-22

gcbeforealarm [programmable interrupt ] :::::::::::::::::::::::::::::::::::::::::::::: 7-22

gcalarm [function with no arguments ] :::::::::::::::::::::::::::::::::::::::::::::::::: 7-22

gcalarm [programmable interrupt ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::: 7-22

gcd z ::: z [function with a variable number of arguments ] ::::::::::::::::::::::::::::: 10-4

n

gcinfo i [function with an optional argument ] :::::::::::::::::::::::::::::::::::::::::: 7-20

gc i [function with an optional argument ] ::::::::::::::::::::::::::::::::::::::::::::::: 7-20

genarith [arithmetic interrupt ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 4-2

gensym [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 3-84

0-14

getabbrev symb [function with one argument ] :::::::::::::::::::::::::::::::::::::::: 5-14

getallmessages language [function with one argument ] ::::::::::::::::::::::::::::: 9-17

getmessagep message [function with one argument ] ::::::::::::::::::::::::::::::::: 9-16

getmessage message [function with one argument ] :::::::::::::::::::::::::::::::::::: 9-16

getrgbvalues pixel [function with one argument ] :::::::::::::::::::::::::::::::::: 20-3

getdefmodule defmod key [function with two arguments ] :::::::::::::::::::::::::::::: 13-16

getdef symb [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::: 3-80

getenv strg [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::: 7-24

getfn pkgc fn [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::: 5-7

getfn pkgc symb [function with two arguments ] ::::::::::::::::::::::::::::::::::::::: 3-82

getfn pkgc pkgc fn [function with three arguments ] :::::::::::::::::::::::::::::::: 5-8

getfn pkgc symb lastpkgc [function with two or three arguments ] ::::::::::::::::::::::: 3-82

getfn pkgc fn pkgc [function with two or three arguments ] ::::::::::::::::::::::::::: 5-8

getglobal strg [function with one argument ] :::::::::::::::::::::::::::::::::::::::::: 14-1

gethash key ht default [function with two or three arguments ] ::::::::::::::::::::::::: 3-105

getl pl l [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::: 3-76

getprop pl ind [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::: 3-75

get pl ind [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 3-75

ge x y [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::::::: 4-15

go symb [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::: 3-34

grabevent window [function with an optional argument ] ::::::::::::::::::::::::::::::: 19-7

greencomponent color value [function with one or two arguments ] :::::::::::::::::::: 20-4

gt x y [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::::::: 4-15

hanoiend [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::: 15-11

hanoi n [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 15-10

hasanabbrev symb [function with one argument ] ::::::::::::::::::::::::::::::::::::: 5-14

hashtablecount ht [function with one argument ] ::::::::::::::::::::::::::::::::::: 3-106

hashtablep obj [function with one argument ] ::::::::::::::::::::::::::::::::::::::: 3-105

hash strg [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::: 3-90

hash [feature ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::: 3-104

heightspace [function with no arguments ] :::::::::::::::::::::::::::::::::::::::::::: 18-24

heightsubstring string start length [function with three arguments ] :::::::::::::: 18-23

heightsubstring string start length [function with three arguments ] :::::::::::::: 20-13

herald [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 7-16

0-15

highlightrectangle x y w h [function with four arguments ] ::::::::::::::::::::::::: 20-13

hostnamestring path [function with one argument ] :::::::::::::::::::::::::::::::::: 6-70

ibase n [function with an optional argument ] ::::::::::::::::::::::::::::::::::::::::::: 6-12

identity s [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 3-5

ifn s s s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 3-27

n

if s s s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 3-26

n

imagerectanglewindowcurrentkeyboardfocuswindow w [function

with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::: 18-20

imagerectanglewindowcurrentwindow win [function with one argument ] :::::: 18-20

imagerectanglewindowkillwindow win [function with one argument ] :::::::::: 18-20

imagerectanglewindowmapwindow win x y symbx symby [function with

ve arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::: 18-20

imagerectanglewindowmodifywindow win left top w h ti hi vi [function

with eight arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::: 18-20

imagerectanglewindowmovebehindwindow win win [function with

two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::: 18-20

imagerectanglewindowpopwindow win [function with one argument ] ::::::::::: 18-20

imagerectanglewindowprop w v [function with one or two arguments ] :::::::::::: 18-15

imagerectanglewindowuncurrentwindow win [function with one argument ] :::: 18-20

imagerectanglewindow [structure ] :::::::::::::::::::::::::::::::::::::::::::::::: 18-11

imagpart c [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 10-8

imax x y [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::::: 4-16

imin x y [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::::: 4-15

implodech s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::: 6-40

implode ln [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 6-39

inbuf n cn [function with one or two optional arguments ] :::::::::::::::::::::::::::::::: 6-42

inchan chan [function with an optional argument ] ::::::::::::::::::::::::::::::::::::::: 6-49

incr symb n [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::: 3-74

index str str n [function with two or three arguments ] ::::::::::::::::::::::::::::::: 3-95

inibitmap symbol [function with an optional argument ] ::::::::::::::::::::::::::::::::: 18-1

initty symb [function with an optional argument ] ::::::::::::::::::::::::::::::::::::::: 15-1

inmax n [function with an optional argument ] ::::::::::::::::::::::::::::::::::::::::::: 6-42

inpos n [function with an optional argument ] ::::::::::::::::::::::::::::::::::::::::::: 6-42

input file [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 6-50

integerp z [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 10-3

0-16

intersection list list eqfunc [function with two or three arguments ] ::::::::::::: 3-107

itsoft symb larg [function with two arguments ] ::::::::::::::::::::::::::::::::::::::: 7-2

keyboardfocusevent [event ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 19-4

killbitmap bitmap [function with one argument ] ::::::::::::::::::::::::::::::::::::: 20-16

killcolor color [function with one argument ] ::::::::::::::::::::::::::::::::::::::: 20-4

killmenu menu [function with one argument ] :::::::::::::::::::::::::::::::::::::::::: 19-10

killwindowevent [event ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::: 19-3

killwindow win [function with one argument ] :::::::::::::::::::::::::::::::::::::::: 18-17

kwote s [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 3-54

lambda l s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 3-6

n

largeromanfont screen [function with an optional argument ] :::::::::::::::::::::::: 18-7

lastn n l [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::: 3-57

last s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 3-51

leavewindowevent [event ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::: 19-3

length s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::: 3-51

let lv s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 3-15

n

letn symb lv s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::: 3-16

n

lets lv s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 3-15

n

letterp cn [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 3-98

letvq lvar lval s ::: s [special form ] :::::::::::::::::::::::::::::::::::::::::::: 3-15

n

letv lvar lval s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::: 3-14

n

let lv s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::: 3-13

n

le x y [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::::::: 4-15

lhoblist strg [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::: 3-85

libautoload file sym ::: sym [special form ] :::::::::::::::::::::::::::::::::::::: 6-57

n

libcirpackageparano [variable ] :::::::::::::::::::::::::::::::::::::::::::::::::: 9-13

libcir [feature ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 9-12

libloadfile file i [function with two arguments ] :::::::::::::::::::::::::::::::::::: 6-56

libload file i [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 6-56

linestylemax [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::: 20-7

listfeatures [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::: 6-75

listp s [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 3-45

list s ::: s [function with a variable number of arguments ] ::::::::::::::::::::::::::: 3-53

n

llcpstd name [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::: 7-14

0-17

LLCFIX [Fonction C ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::: 14-13

LLCFLOAT [Fonction C ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::: 14-14

lmargin n [function with an optional argument ] ::::::::::::::::::::::::::::::::::::::::: 6-44

loadbytetest n np nl [function with three arguments ] :::::::::::::::::::::::::::::: 4-19

loadbyte n np nl [function with three arguments ] :::::::::::::::::::::::::::::::::::: 4-18

loadcpl im min ed env ld cmp [function with one to six arguments ] ::::::::::::::::::: 7-15

loadfont string [function with one argument ] ::::::::::::::::::::::::::::::::::::::: 20-2

loadstd im min ed env ld cmp [function with one to six arguments ] ::::::::::::::::::: 7-14

loadstm im min ed env ld cmp [function with one to six arguments ] ::::::::::::::::::: 7-14

loadfile file i [function with two arguments ] :::::::::::::::::::::::::::::::::::::::: 6-54

loadmodule module reloadp interpretedp [function with one two or three arguments ] 13-16

loadobjectfile file [function with one argument ] :::::::::::::::::::::::::::::::::::: 13-12

load file i [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::: 6-54

lock fn s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 3-39

n

log x [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 4-11

logand x y [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 4-16

lognot x [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::: 4-16

logor x y [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::: 4-17

logshift x y [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::: 4-17

logxor x y [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 4-17

log x [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 4-11

lowercase cn [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::: 3-98

lt x y [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::::::: 4-15

macroopenp name [function with one argument ] ::::::::::::::::::::::::::::::::::::::: 13-5

macroexpand s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::: 3-20

macroexpand s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::: 3-21

makecolor red green blue [function with three arguments ] ::::::::::::::::::::::::::: 20-3

makecursor b b x y [function with four arguments ] :::::::::::::::::::::::::::::::: 20-5

makehashtableequal [function with no arguments ] ::::::::::::::::::::::::::::::::: 3-105

makehashtableeq [function with no arguments ] :::::::::::::::::::::::::::::::::::: 3-105

makelinestyle width style [function with two arguments ] :::::::::::::::::::::::::: 20-7

makemacroopen name fval [function with two arguments ] :::::::::::::::::::::::::::: 13-5

makemutablecolor red green blue [function with three arguments ] :::::::::::::::::: 20-3

makenamedcolor name [function with one argument ] ::::::::::::::::::::::::::::::::: 20-3

0-18

makenamedcursor name [function with one argument ] :::::::::::::::::::::::::::::::: 20-5

makepathname element ::: element [function with a variable number of arguments ] ::: 6-69

n

makepattern bitmap [function with one argument ] :::::::::::::::::::::::::::::::::::: 20-7

makewindow win [function with one argument ] :::::::::::::::::::::::::::::::::::::::: 18-13

makearray a ::: a s [function with a variable number of arguments ] ::::::::::::::::::: 3-103

n

makecomplex c i [function with two arguments ] :::::::::::::::::::::::::::::::::::::::: 10-7

makedef symb ftyp fval [function with three arguments ] ::::::::::::::::::::::::::::::: 3-80

makelist n s [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::: 3-54

makestring n cn [function with two arguments ] :::::::::::::::::::::::::::::::::::::::: 3-92

makevector n s [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::: 3-99

makunbound symb [function with one argument ] :::::::::::::::::::::::::::::::::::::::: 3-71

mapwindow win x y symbx symby [function with ve arguments ] ::::::::::::::::::::::: 18-19

mapwindow [event ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::: 19-4

mapcan fn l ::: l [function with a variable number of arguments ] :::::::::::::::::::::: 3-10

n

mapcar fn l ::: l [function with a variable number of arguments ] :::::::::::::::::::::: 3-9

n

mapcoblist fn [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::: 3-12

mapcon fn l ::: l [function with a variable number of arguments ] :::::::::::::::::::::: 3-9

n

mapc fn l ::: l [function with a variable number of arguments ] :::::::::::::::::::::::: 3-8

n

maphash fnt ht [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::: 3-106

maplist fn l ::: l [function with a variable number of arguments ] :::::::::::::::::::: 3-9

n

maploblist fn [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::: 3-12

mapl fn l ::: l [function with a variable number of arguments ] :::::::::::::::::::::::: 3-8

n

mapoblist fn [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::: 3-12

mapvector fn vect [function with two arguments ] ::::::::::::::::::::::::::::::::::::: 3-11

map fn l ::: l [function with a variable number of arguments ] ::::::::::::::::::::::::: 3-8

n

maskfield n np nl [function with three arguments ] ::::::::::::::::::::::::::::::::::: 4-18

max x ::: x [function with a variable number of arguments ] ::::::::::::::::::::::::::::: 4-7

n

mcons s ::: s [function with a variable number of arguments ] :::::::::::::::::::::::::: 3-52

n

member s l [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 3-50

memq symb l [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::: 3-49

menudeleteitemlist menu choice [function with two arguments ] :::::::::::::::::: 19-11

menudeleteitem menu choice item [function with three arguments ] :::::::::::::::::: 19-11

menuinsertitemlist menu choice string active [function with four arguments ] :: 19-10

0-19

menuinsertitem menu choice item string active value [function with six

arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::: 19-11

menumodifyitemlist menu choice string active [function with four arguments ] :: 19-11

menumodifyitem menu choice item string active value [function with six

arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::: 19-11

mergepathnames path defaultpath [function with two arguments ] ::::::::::::::::::: 6-70

messagelanguages [function with no arguments ] :::::::::::::::::::::::::::::::::::::: 9-16

messages [feature ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::: 9-14

microceyx [feature ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::: 5-15

minusp x [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::: 4-10

min x ::: x [function with a variable number of arguments ] ::::::::::::::::::::::::::::: 4-7

n

mlambda l s ::: s [special form ] :::::::::::::::::::::::::::::::::::::::::::::::::: 3-6

n

modenot [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::: 20-8

modeor [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::: 20-8

modeset [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::: 20-8

modexor [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::: 20-8

modifywindowevent [event ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::: 19-3

modifywindow win x y w h ti hi vi [function with eight arguments ] ::::::::::::::::: 18-17

modulecompiledlist [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 13-17

moduleinterpretedlist [variable ] ::::::::::::::::::::::::::::::::::::::::::::::: 13-17

modulo x y [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 4-6

movebehindwindow win win [function with two arguments ] :::::::::::::::::::::::: 18-19

movecursor x y [function with two arguments ] :::::::::::::::::::::::::::::::::::::::: 20-6

moveevent [event ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::: 19-2

moveresizewindow win x y w h [function with ve arguments ] :::::::::::::::::::::: 18-18

movewindow win x y [function with three arguments ] :::::::::::::::::::::::::::::::::: 18-18

mul x y [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::: 4-13

M [sharp macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 9-16

m [sharp macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 9-16

n [macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 9-12

nametorgb name [function with one argument ] ::::::::::::::::::::::::::::::::::::::: 20-3

namestring path [function with one argument ] :::::::::::::::::::::::::::::::::::::::: 6-65

nconc l s [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 3-62

nconc l ::: l [function with a variable number of arguments ] :::::::::::::::::::::::::: 3-61

n

0-20

ncons s [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 3-52

neqn x y [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::::: 4-14

nequal s s [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::: 3-48

neq s s [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::: 3-47

newl symb s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::: 3-73

newr symb s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::: 3-73

new struct [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::: 5-2

nextl sym sym [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::: 3-73

nintersection list list eqfunc [function with two or three arguments ] :::::::::::: 3-108

nlistp s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::: 3-46

[macro character ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::: 6-32

[macro character ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::: 6-20

n m [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::::::: 10-5

x ::: x [function with a variable number of arguments ] ::::::::::::::::::::::::::::::: 4-5

n

x ::: x [function with a variable number of arguments ] ::::::::::::::::::::::::::::::: 4-4

n

x ::: x [function with a variable number of arguments ] ::::::::::::::::::::::::::::::: 4-5

n

x y [function with one or two arguments ] :::::::::::::::::::::::::::::::::::::::::::: 4-6

x y [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::::::: 4-8

x y [function with one or two arguments ] ::::::::::::::::::::::::::::::::::::::::::::: 4-6

x [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 4-5

x [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 4-5

n [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 4-17

x x ::: x [function with a variable number of arguments ] ::::::::::::::::::::::::::: 4-9

n

x y [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::::::: 4-8

x y [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::: 4-8

x x ::: x [function with a variable number of arguments ] :::::::::::::::::::::::::::: 4-9

n

x x ::: x [function with a variable number of arguments ] :::::::::::::::::::::::::::: 4-8

n

x x ::: x [function with a variable number of arguments ] ::::::::::::::::::::::::::: 4-8

n

x x ::: x [function with a variable number of arguments ] :::::::::::::::::::::::::::: 4-9

n

[macro character ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::: 6-21

[macro character ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::: 6-21

[macro character ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::: 6-21

[macro character ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::: 10-6

[macro character ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::: 6-20

0-21

[macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::: 6-26

<> [nonLisp pointer ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::: 6-37

[macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::: 6-26

[macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::: 6-27

[macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::: 20-15

[macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::: 6-27

[macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::: 6-27

[macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::: 6-26

[macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::: 6-24

[macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::: 6-26

[macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::: 6-27

[macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::: 6-25

[macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::: 6-27

[macro character ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::: 6-23

[macro character ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::: 6-20

[inside macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::: 6-26

not s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 3-43

nreconc l s [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::: 3-63

nreverse l [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 3-62

nsetdifference list list eqfunc [function with two or three arguments ] ::::::::: 3-108

nsetexclusiveor list list eqfunc [function with two or three arguments ] ::::::: 3-108

nsubst s s l [function with three arguments ] :::::::::::::::::::::::::::::::::::::::: 3-63

nthcdr n l [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 3-50

nth n l [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::: 3-51

null s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 3-42

numberp s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::: 3-44

numberp x [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::: 4-2

numerator f [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::: 10-5

nunion list list eqfunc [function with two or three arguments ] :::::::::::::::::::: 3-107

n [macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 9-12

obase n [function with an optional argument ] ::::::::::::::::::::::::::::::::::::::::::: 6-38

objval symb s [function with one or two arguments ] :::::::::::::::::::::::::::::::::::: 3-82

oblist pkgc symb [function with zero one or two arguments ] :::::::::::::::::::::::::::: 3-84

oddp x [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 4-14

0-22

ogetq tclassorrecord field obj [macro ] :::::::::::::::::::::::::::::::::::::::: 5-17

omakeq type field val ::: field val [macro ] ::::::::::::::::::::::::::::::::: 5-17

n n

omatchq tclass obj [macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::: 5-18

openab file [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::: 6-49

opena file [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 6-49

openib file [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::: 6-49

openi file [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 6-48

openob file [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::: 6-49

openo file [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 6-49

oputq tclassorrecord field obj val [macro ] :::::::::::::::::::::::::::::::::::: 5-18

or s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::: 3-28

n

outbuf n cn [function with one or two optional arguments ] ::::::::::::::::::::::::::::::: 6-45

outchan chan [function with an optional argument ] ::::::::::::::::::::::::::::::::::::: 6-50

outpos n [function with an optional argument ] :::::::::::::::::::::::::::::::::::::::::: 6-45

output file [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::: 6-51

packagecell symb pkgc [function with one or two arguments ] ::::::::::::::::::::::::::: 3-82

pairlis l l al [function with three arguments ] :::::::::::::::::::::::::::::::::::::: 3-65

parallelvalues e ::: e [special form ] :::::::::::::::::::::::::::::::::::::::::::: 7-5

n

parallel e ::: e [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 7-5

n

pathnamedevice path [function with one argument ] :::::::::::::::::::::::::::::::::: 6-67

pathnamedirectory path [function with one argument ] ::::::::::::::::::::::::::::::: 6-68

pathnamehost path [function with one argument ] ::::::::::::::::::::::::::::::::::::: 6-67

pathnamename path [function with one argument ] ::::::::::::::::::::::::::::::::::::: 6-68

pathnametype path [function with one argument ] ::::::::::::::::::::::::::::::::::::: 6-68

pathnameversion path [function with one argument ] ::::::::::::::::::::::::::::::::: 6-68

pathnamecurrent [indicator ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 6-66

pathnameprin path [function with one argument ] :::::::::::::::::::::::::::::::::: 6-65

pathnameup [indicator ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::: 6-66

pathnamewild [indicator ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::: 6-67

pathnamep s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::: 6-64

pathname string [function with one argument ] ::::::::::::::::::::::::::::::::::::::::: 6-64

pathname [feature ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::: 6-63

pathname [structure ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::: 6-63

patternmax [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::: 20-7

0-23

[unnameable number ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: 6-36

[macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::: 6-25

peekevent event [function with an optional argument ] ::::::::::::::::::::::::::::::::: 19-6

peekch [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 6-5

peekcn [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 6-5

pepefile f [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 16-2

pepend [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 16-2

pepe f [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::: 16-1

pepe [feature ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::: 16-1

pgcd z z [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 10-4

phase c [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 10-8

placdl l s [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 3-61

plength strg [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::: 3-89

plist pl l [function with one or two arguments ] ::::::::::::::::::::::::::::::::::::::: 3-75

plusp x [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 4-9

plus x ::: x [function with a variable number of arguments ] ::::::::::::::::::::::::::: 4-25

n

pname strg [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 3-89

popwindow win [function with one argument ] :::::::::::::::::::::::::::::::::::::::::: 18-19

portablepathname [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 6-74

portablepathnamep path [function with one argument ] :::::::::::::::::::::::::::::: 6-74

powerset set [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::: 3-108

power x y [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::: 4-11

pprint s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::: 8-2

pprin s [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 8-2

pratom atom [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::: 6-39

precision n [function with an optional argument ] :::::::::::::::::::::::::::::::::::::: 10-2

precompile exp result exp operand [special form ] ::::::::::::::::::::::::::::::: 13-3

prettyquotelength [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 8-3

prettyquotelevel [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 8-3

prettyend [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::: 8-2

prettyf file sym ::: sym [special form ] :::::::::::::::::::::::::::::::::::::::::: 8-2

n

pretty sym ::: sym [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::: 8-2

n

pretty [feature ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::: 8-2

princh ch n [function with one or two arguments ] :::::::::::::::::::::::::::::::::::::: 6-35

0-24

princn cn n [function with one or two arguments ] :::::::::::::::::::::::::::::::::::::: 6-34

prinflush s ::: s [function with a variable number of arguments ] :::::::::::::::::::::: 6-34

n

prinf cntrl e ::: eN [SUBRa or N arguments ] ::::::::::::::::::::::::::::: 9-2

printtostring s [function with one argument ] :::::::::::::::::::::::::::::::::::::: 6-41

printdefmodule defmod module [function with two arguments ] ::::::::::::::::::::::::: 13-16

printerror symb s s [function with three arguments ] :::::::::::::::::::::::::::::::: 7-8

printf cntrl e ::: eN [SUBRa or N arguments ] ::::::::::::::::::::::::::: 9-2

printlength n [function with an optional argument ] :::::::::::::::::::::::::::::::::::: 6-35

printlevel n [function with an optional argument ] ::::::::::::::::::::::::::::::::::::: 6-35

printline n [function with an optional argument ] :::::::::::::::::::::::::::::::::::::: 6-36

printstack n s [function with one or two optional arguments ] ::::::::::::::::::::::::::: 11-12

print s ::: s [function with a variable number of arguments ] :::::::::::::::::::::::::: 6-33

n

prin s ::: s [function with a variable number of arguments ] :::::::::::::::::::::::::::: 6-33

n

probefile file [function with one argument ] :::::::::::::::::::::::::::::::::::::::::: 6-53

probepathf file [function with one argument ] :::::::::::::::::::::::::::::::::::::::: 6-56

probepathm module [function with one argument ] :::::::::::::::::::::::::::::::::::::: 13-16

probepatho file [function with one argument ] :::::::::::::::::::::::::::::::::::::::: 13-12

prog l ec ::: ec [macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::: 3-35

n

prog s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 3-3

n

prog s s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 3-4

n

progn s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 3-4

n

prog l ec ::: ec [macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::: 3-34

n

prompt strg [function with an optional argument ] ::::::::::::::::::::::::::::::::::::::: 6-9

protect s s ::: s [special form ] :::::::::::::::::::::::::::::::::::::::::::::::::: 3-39

n

psetq sym s ::: sym s [special form ] :::::::::::::::::::::::::::::::::::::::::::: 3-71

n n

ptype symb n [function with one or two arguments ] ::::::::::::::::::::::::::::::::::::: 6-38

putabbrev sym sym [function with two arguments ] :::::::::::::::::::::::::::::::::: 5-13

putmessage message language string [function with three arguments ] :::::::::::::::: 9-17

puthash key ht value [function with three arguments ] ::::::::::::::::::::::::::::::::: 3-105

putprop pl pval ind [function with three arguments ] :::::::::::::::::::::::::::::::::: 3-77

p [macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::: 6-65

quomod x y [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 4-7

quote s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::: 3-5

quotient x y [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::: 4-6

0-25

quo x y [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::: 4-6

q [feature ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::::::::::: 10-1

random x y [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 4-19

rassoc s al [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::: 3-67

rassq symb al [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::: 3-66

rationalp q [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::: 10-3

ratio [feature ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::: 10-1

readdelimitedlist cn [function with one argument ] :::::::::::::::::::::::::::::::: 6-6

readevent event [function with an optional argument ] ::::::::::::::::::::::::::::::::: 19-6

readfromstring string [function with one argument ] ::::::::::::::::::::::::::::::: 6-40

readmouse event [function with an optional argument ] ::::::::::::::::::::::::::::::::: 19-9

readch [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 6-5

readcn [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 6-5

readdefmodule module [function with one argument ] ::::::::::::::::::::::::::::::::::: 13-16

readline [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::: 6-4

readstring [function with no arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 6-4

read [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 6-3

realpart c [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 10-8

realp r [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 10-6

recordlanguage language [function with one argument ] :::::::::::::::::::::::::::::: 9-15

recordnamep symbol [function with one argument ] :::::::::::::::::::::::::::::::::::: 5-17

redcomponent color value [function with one or two arguments ] :::::::::::::::::::::: 20-4

redisplayscreen sn so w h [function with four or twelve arguments ] ::::::::::::::::::: 15-9

remabbrev symb [function with one argument ] :::::::::::::::::::::::::::::::::::::::: 5-14

remfeature symb [function with one argument ] ::::::::::::::::::::::::::::::::::::::: 6-75

remfn symb [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 3-80

remhash key ht [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::: 3-106

remob symb [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 3-86

removelanguage language [function with one argument ] :::::::::::::::::::::::::::::: 9-15

removemacroopen name [function with one argument ] :::::::::::::::::::::::::::::::: 13-6

removemessage message language [function with two arguments ] ::::::::::::::::::::: 9-17

remove s l [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 3-58

remprop pl ind [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::: 3-77

remq symb l [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::: 3-58

0-26

rem x y [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::: 4-14

renamefile ofile nfile [function with two arguments ] :::::::::::::::::::::::::::::::: 6-53

repaintwindowevent [event ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 19-3

repeat m s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 3-32

n

reread lcn [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 6-5

resetfn symb ftype fval [function with three arguments ] :::::::::::::::::::::::::::::: 3-79

resizewindow win w h [function with three arguments ] :::::::::::::::::::::::::::::::: 18-18

restorecore file [function with one argument ] :::::::::::::::::::::::::::::::::::::: 7-12

resume env [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 7-5

returnfrom symb e [special form ] :::::::::::::::::::::::::::::::::::::::::::::::::: 3-33

return e [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::: 3-33

reverse s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::: 3-55

revert symb [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::: 3-81

rmargin n [function with an optional argument ] ::::::::::::::::::::::::::::::::::::::::: 6-45

rootwindow screen [function with an optional argument ] :::::::::::::::::::::::::::::: 18-5

round n d [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::: 4-4

rplaca l s [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 3-60

rplacd l s [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 3-60

rplac l s s [function with three arguments ] ::::::::::::::::::::::::::::::::::::::::: 3-60

runtime [function with no arguments ] :::::::::::::::::::::::::::::::::::::::::::::::::: 7-23

savecore file [function with one argument ] :::::::::::::::::::::::::::::::::::::::::: 7-12

savestd name msg fntsav fntrest [function of two three or four arguments ] :::::::: 7-16

scale x y z [function with three arguments ] ::::::::::::::::::::::::::::::::::::::::::: 4-14

scanstring str str n [function with two or three arguments ] :::::::::::::::::::::::: 3-96

schedule fnt e ::: e [special form ] ::::::::::::::::::::::::::::::::::::::::::::::: 7-5

n

searchinpath path file [function with two arguments ] ::::::::::::::::::::::::::::: 6-55

selectq s l ::: l [special form ] :::::::::::::::::::::::::::::::::::::::::::::::::: 3-29

n

senderror symb rest [function with two arguments ] :::::::::::::::::::::::::::::::::: 5-9

sendsuper type symb o p ::: p [function with a variable number of arguments ] ::::::: 5-10

n

send symb o o p ::: p [function with a variable number of arguments ] :::::::::::::: 5-11

n

sendfq message par ::: par [macro ] ::::::::::::::::::::::::::::::::::::::::::::: 5-19

n

sendf message par ::: par [macro ] ::::::::::::::::::::::::::::::::::::::::::::::: 5-19

n

sendq message object par ::: par [macro ] ::::::::::::::::::::::::::::::::::::::: 5-18

n

send message objet par ::: par [function with a variable number of arguments ] ::::::: 5-18

n

0-27

send symb o p ::: p [function with a variable number of arguments ] :::::::::::::::::::: 5-9

n

setdifference list list eqfunc [function with two or three arguments ] ::::::::::: 3-108

setequal list list eqfunc [function with two or three arguments ] ::::::::::::::::: 3-109

setexclusiveor list list eqfunc [function with two or three arguments ] :::::::: 3-108

setpathnamedevice path device [function with two arguments ] ::::::::::::::::::::: 6-68

setpathnamedirectory path dir [function with two arguments ] ::::::::::::::::::::: 6-68

setpathnamehost path host [function with two arguments ] :::::::::::::::::::::::::: 6-68

setpathnamename path name [function with two arguments ] :::::::::::::::::::::::::: 6-68

setpathnametype path type [function with two arguments ] :::::::::::::::::::::::::: 6-68

setpathnameversion path version [function with two arguments ] ::::::::::::::::::: 6-69

setdemodule defmod key value [function with three arguments ] :::::::::::::::::::::::: 13-16

setfn symb ftype fval [function with three arguments ] :::::::::::::::::::::::::::::::: 3-79

setf loc val ::: loc val [macro ] :::::::::::::::::::::::::::::::::::::::::::::: 3-24

n n

setqq sym e ::: sym e [special form ] :::::::::::::::::::::::::::::::::::::::::::: 3-71

n n

setq sym s ::: sym s [special form ] ::::::::::::::::::::::::::::::::::::::::::::: 3-71

n n

sets [feature ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::: 3-106

set symb s [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 3-71

sharpvalue [property ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::: 6-25

signum c [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::: 10-8

sinh z [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 10-9

sin x [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 4-10

sleep n [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 7-24

slength strg [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::: 3-89

slen strg [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::: 3-87

slet lv s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 3-15

n

smallromanfont screen [function with an optional argument ] :::::::::::::::::::::::: 18-7

sortl l [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 3-68

sortn l [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 3-69

sortp l [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 3-69

sort fn l [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::: 3-68

sort [feature ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::: 3-68

spanstring str str n [function with two or three arguments ] :::::::::::::::::::::::: 3-97

sqrt x [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 4-11

srandom x [function with an optional argument ] ::::::::::::::::::::::::::::::::::::::::: 4-19

0-28

sref strg n [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::: 3-87

sset strg n cn [function with three arguments ] :::::::::::::::::::::::::::::::::::::::: 3-88

standardbackgroundpattern screen [function with an optional argument ] ::::::::::: 18-8

standardbackground screen [function with an optional argument ] ::::::::::::::::::::: 18-8

standardbackground screen [function with an optional argument ] ::::::::::::::::::::: 18-9

standardboldfont screen [function with an optional argument ] :::::::::::::::::::::: 18-7

standardbusycursor screen [function with an optional argument ] ::::::::::::::::::: 18-8

standarddarkgraypattern screen [function with an optional argument ] :::::::::::: 18-8

standardforegroundpattern screen [function with an optional argument ] ::::::::::: 18-8

standardforeground screen [function with an optional argument ] ::::::::::::::::::::: 18-7

standardforeground screen [function with an optional argument ] ::::::::::::::::::::: 18-9

standardgccursor screen [function with an optional argument ] :::::::::::::::::::::: 18-8

standardlelispcursor screen [function with an optional argument ] ::::::::::::::::: 18-8

standardlightgraypattern screen [function with an optional argument ] ::::::::::: 18-8

standardmediumgraypattern screen [function with an optional argument ] :::::::::: 18-8

standardromanfont screen [function with an optional argument ] ::::::::::::::::::::: 18-7

stepeval e env [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::: 7-11

stepeval [programmable interrupt ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::: 7-10

step s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::: 11-13

stratom n strg i [function with three arguments ] :::::::::::::::::::::::::::::::::::::: 6-3

stringp s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::: 3-45

string s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::: 3-89

structfield o e [function with one or two arguments ] :::::::::::::::::::::::::::::: 5-3

structmake [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::: 5-2

structurep o [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::: 5-3

sub x [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 4-13

sublis al s [function with two arguments ] :::::::::::::::::::::::::::::::::::::::::::: 3-67

subsetp list list eqfunc [function with two or three arguments ] ::::::::::::::::::: 3-109

substcolors bytetmap l [function with two arguments ] :::::::::::::::::::::::::::::: 20-18

substitutecolor bytemap oldcol newcol [function with three arguments ] :::::::::::: 20-18

substringequal size strg pos strg pos [function with ve arguments ] ::::::::: 3-96

substring strg n n [function with two or three arguments ] ::::::::::::::::::::::::::: 3-92

subst s s s [function with three arguments ] ::::::::::::::::::::::::::::::::::::::::: 3-57

subtypep type type [function with two arguments ] :::::::::::::::::::::::::::::::::: 5-6

0-29

subversion [function with no arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 7-17

sub x y [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::: 4-13

superitsoft package symb larg [function with three arguments ] ::::::::::::::::::::: 7-2

suspend [function with no arguments ] :::::::::::::::::::::::::::::::::::::::::::::::::: 7-5

symbolp s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::: 3-44

symbol pkgc strg [function with two arguments ] ::::::::::::::::::::::::::::::::::::::: 3-83

fsymbg [macro character ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::: 5-14

symeval symb [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::: 3-70

synonymq sym sym [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 3-81

synonym sym sym [function with two arguments ] :::::::::::::::::::::::::::::::::::::: 3-81

syspackagecolon [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 6-30

syspackagegenarith [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 4-2

syspackageitsoft [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 7-1

syspackagesharp [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 6-23

syspackagetty [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::: 15-11

syserror symb s s [function with three arguments ] :::::::::::::::::::::::::::::::::: 7-8

syserror [programmable interrupt ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::: 7-7

systemcompressedicon [variable ] :::::::::::::::::::::::::::::::::::::::::::::::: 20-15

systemcoredirectory [variable ] :::::::::::::::::::::::::::::::::::::::::::::::::: 7-12

systemcoreextension [variable ] :::::::::::::::::::::::::::::::::::::::::::::::::: 7-12

systemdebugline [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 11-12

systemdefstructallaccessflag [variable ] :::::::::::::::::::::::::::::::::::: 5-2

systemeditor [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::: 6-31

systeminreadflag [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 6-7

systeminibitmapafterrestoreflag [variable ] ::::::::::::::::::::::::::::::::: 7-16

systeminittyafterrestoreflag [variable ] :::::::::::::::::::::::::::::::::::: 7-15

systemlelispextension [variable ] ::::::::::::::::::::::::::::::::::::::::::::::: 6-48

systemlinemodeflag [variable ] :::::::::::::::::::::::::::::::::::::::::::::::::: 6-9

systemllibdirectory [variable ] :::::::::::::::::::::::::::::::::::::::::::::::::: 6-48

systemllubdirectory [variable ] :::::::::::::::::::::::::::::::::::::::::::::::::: 6-48

systemloadedfromfile [property ] ::::::::::::::::::::::::::::::::::::::::::::::: 3-18

systemloadedfromfile [variable ] ::::::::::::::::::::::::::::::::::::::::::::::: 3-18

systemloadedfromfile [variable ] ::::::::::::::::::::::::::::::::::::::::::::::: 3-70

systemobjextension [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 13-12

0-30

systempath [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::: 6-55

systempreviousdefflag [variable ] :::::::::::::::::::::::::::::::::::::::::::::: 3-17

systempreviousdef [property ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 3-17

systemprintcaseflag [variable ] :::::::::::::::::::::::::::::::::::::::::::::::: 6-37

systemprintforread [variable ] :::::::::::::::::::::::::::::::::::::::::::::::::: 6-37

systemprintmsgs [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 6-48

systemprintpackageflag [variable ] ::::::::::::::::::::::::::::::::::::::::::::: 6-37

systemprintwithabbrevflag [variable ] :::::::::::::::::::::::::::::::::::::::: 5-14

systemreadcaseflag [variable ] :::::::::::::::::::::::::::::::::::::::::::::::::: 6-10

systemrealterminalflag [variable ] ::::::::::::::::::::::::::::::::::::::::::::: 6-9

systemredefflag [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 3-17

systemstackdepth [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 11-12

systemtermcapfile [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 15-2

systemterminfodirectory [variable ] ::::::::::::::::::::::::::::::::::::::::::::: 15-2

systemtopleveltag [escape ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 7-19

systemunixp [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::: 7-17

systemvirttydirectory [variable ] ::::::::::::::::::::::::::::::::::::::::::::::: 15-1

system [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 7-16

tagbody ec ::: ec [special form ] :::::::::::::::::::::::::::::::::::::::::::::::::: 3-33

n

tag symb s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 3-38

n

tailp s l [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::: 3-50

tanh z [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 10-9

tclassnamep symbol [function with one argument ] :::::::::::::::::::::::::::::::::::: 5-16

tconscl s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::: 3-59

tconsmk s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::: 3-59

tconsp s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::: 3-59

tcons s s [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::: 3-59

temporaryfilepathname name [function with one argument ] ::::::::::::::::::::::::: 6-73

teread [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 6-7

termcap [feature ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::: 15-2

terminfo [feature ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::::: 15-2

terpri n [function with an optional argument ] :::::::::::::::::::::::::::::::::::::::::: 6-34

times x ::: x [function with a variable number of arguments ] :::::::::::::::::::::::::: 4-25

n

time e [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 7-24

0-31

topleveleval [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::: 7-18

toplevelread [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::: 7-18

toplevelstatus [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::: 7-18

toplevel [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::: 7-18

toplevel [programmable interrupt ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::: 7-18

tracearg [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::: 11-3

tracearg [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::: 11-3

tracearg [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::: 11-3

tracenotintraceflag [variable ] ::::::::::::::::::::::::::::::::::::::::::::::: 11-4

tracetrace [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::: 11-5

tracevalue [variable ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::: 11-4

traceval e env [function with one or two arguments ] ::::::::::::::::::::::::::::::::::: 7-11

trace trace ::: trace [special form ] :::::::::::::::::::::::::::::::::::::::::::::: 11-2

n

transitiveclosure fn list eqfunc [function with two or three arguments ] :::::::::: 3-110

truepathname path [function with one argument ] ::::::::::::::::::::::::::::::::::::: 6-71

true e ::: e [function with a variable number of arguments ] ::::::::::::::::::::::::::: 3-42

n

truncate x [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 4-3

tryinparallel e ::: e [special form ] ::::::::::::::::::::::::::::::::::::::::::::: 7-5

n

tyattrib i [function with an optional argument ] :::::::::::::::::::::::::::::::::::::::: 15-8

tyback cn [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::: 15-4

tybeep [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 15-7

tybs cn [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 15-6

tycleol [function with no arguments ] :::::::::::::::::::::::::::::::::::::::::::::::::: 15-7

tycleos [function with no arguments ] :::::::::::::::::::::::::::::::::::::::::::::::::: 15-7

tycls [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 15-6

tycn cn [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 15-3

tycot x y cn ::: cn [function with a variable number of arguments ] :::::::::::::::::::: 15-9

n

tyco x y cn ::: cn [function with a variable number of arguments ] ::::::::::::::::::::: 15-8

n

tycr [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 15-6

tycursor x y [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::: 15-6

tydelch [function with no arguments ] :::::::::::::::::::::::::::::::::::::::::::::::::: 15-7

tydelcn cn [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 15-7

tydelln [function with no arguments ] :::::::::::::::::::::::::::::::::::::::::::::::::: 15-8

tydownkey [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::: 15-7

0-32

tyepilogue [function with no arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 15-5

tyerror list [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::: 15-3

tyflush [function with no arguments ] :::::::::::::::::::::::::::::::::::::::::::::::::: 15-5

tyinsch ch [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 15-7

tyinscn cn [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 15-7

tyinsln [function with no arguments ] :::::::::::::::::::::::::::::::::::::::::::::::::: 15-8

tyinstring string [function with one argument ] :::::::::::::::::::::::::::::::::::::: 15-3

tyi [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 15-3

tyleftkey [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::: 15-7

tynewline [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::: 15-4

tyod n nc [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::::: 15-5

tyo o ::: o [function with a variable number of arguments ] ::::::::::::::::::::::::::::: 15-4

n

typeof s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::: 5-5

typech ch symb [function with one or two arguments ] ::::::::::::::::::::::::::::::::::: 6-16

typecn cn symb [function with one or two arguments ] ::::::::::::::::::::::::::::::::::: 6-16

typefn symb [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::: 3-78

typep s type [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::: 5-6

typestring strg symb [function with one or two arguments ] :::::::::::::::::::::::::::: 3-88

typevector vect symb [function with one or two arguments ] :::::::::::::::::::::::::::: 3-101

typrologue [function with no arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 15-5

tyrightkey [function with no arguments ] :::::::::::::::::::::::::::::::::::::::::::::: 15-7

tyshowcursor i [function with an optional argument ] ::::::::::::::::::::::::::::::::::: 15-8

tystring string length [function with two arguments ] :::::::::::::::::::::::::::::::: 15-3

tys [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 15-3

tyupkey [function with no arguments ] :::::::::::::::::::::::::::::::::::::::::::::::::: 15-7

tyxmax [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 15-6

tyymax [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 15-6

unexit symb s ::: s [special form ] :::::::::::::::::::::::::::::::::::::::::::::::: 3-39

n

union list list eqfunc [function with two or three arguments ] :::::::::::::::::::::: 3-107

unless s s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 3-27

n

unmapwindow [event ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::: 19-4

unstep s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::: 11-13

n

untilexit symb e ::: e [special form ] ::::::::::::::::::::::::::::::::::::::::::::: 3-39

n

until s s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 3-31

n

0-33

untrace sym ::: sym [special form ] :::::::::::::::::::::::::::::::::::::::::::::::: 11-2

n

unwind n s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: : 3-40

n

upevent [event ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::: 19-2

uppercase cn [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::: 3-97

userhomedirpathname [function with no arguments ] ::::::::::::::::::::::::::::::::: 6-72

userinterrupt [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::: 7-4

userinterrupt [programmable interrupt ] ::::::::::::::::::::::::::::::::::::::::::::::: 7-4

u [macro ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::: 6-65

valfn symb [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::: 3-79

variablep s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::: 3-44

vdtend [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: 15-11

vdt [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::: 15-11

vectorp s [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::: 3-45

vector s ::: s [function with a variable number of arguments ] ::::::::::::::::::::::::: 3-99

n

version [function with no arguments ] :::::::::::::::::::::::::::::::::::::::::::::::::: 7-17

visibilitychange [event ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :::::::: 19-4

vlength vect [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::: 3-100

vref vect n [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::: 3-100

vset vect n e [function with three arguments ] ::::::::::::::::::::::::::::::::::::::::: 3-100

W [Complice warning message ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::: 13-22

W [Complice warning message ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::: 13-24

W [Complice warning message ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::: 13-25

W [Complice warning message ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::: 13-22

W [Complice warning message ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::: 13-22

W [Complice warning message ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::: 13-23

W [Complice warning message ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::: 13-23

W [Complice warning message ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::: 13-23

W [Complice warning message ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::: 13-23

W [Complice warning message ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::: 13-24

W [Complice warning message ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::: 13-24

whanoiend [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::::: 15-11

whanoi n [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::::::: 15-11

when s s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 3-27

n

while s s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: :: 3-31

n

0-34

widthspace [function with no arguments ] ::::::::::::::::::::::::::::::::::::::::::::: 18-24

widthsubstring string start length [function with three arguments ] :::::::::::::::: 18-23

widthsubstring string start length [function with three arguments ] :::::::::::::::: 20-13

wildcard path [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::: 6-67

windowbackground win color [function with one or two arguments ] ::::::::::::::::::: 18-18

windowbitmap window [function with one argument ] ::::::::::::::::::::::::::::::::::: 20-14

windowborder win border [function with one or two arguments ] ::::::::::::::::::::::: 18-18

windowclearregion win x y w h [function with ve arguments ] ::::::::::::::::::::: 18-18

windoweventslist win events [function with one or two arguments ] ::::::::::::::::: 18-18

windowstate win state [function with one or two arguments ] ::::::::::::::::::::::::: 18-18

windowtitle win title [function with one or two arguments ] ::::::::::::::::::::::::: 18-18

windowp win [function with one argument ] ::::::::::::::::::::::::::::::::::::::::::::: 18-18

withinputfromstring string body [macro ] :::::::::::::::::::::::::::::::::: 6-40

withoutputtostring string n body [macro ] ::::::::::::::::::::::::::::::::: 6-40

withoutinterrupts e ::: e [special form ] ::::::::::::::::::::::::::::::::::::::: 7-3

n

with l s ::: s [special form ] ::::::::::::::::::::::::::::::::::::::::::::::::::: ::: 3-25

n

xbasespace [function with no arguments ] :::::::::::::::::::::::::::::::::::::::::::: 18-24

xbasesubstring string start length [function with three arguments ] :::::::::::::: 18-24

xbasesubstring string start length [function with three arguments ] :::::::::::::: 20-13

xincsubstring string start length [function with three arguments ] :::::::::::::::: 18-24

xincsubstring string start length [function with three arguments ] :::::::::::::::: 20-13

xcons s s [function with two arguments ] ::::::::::::::::::::::::::::::::::::::::::::: 3-52

ybasespace [function with no arguments ] :::::::::::::::::::::::::::::::::::::::::::: 18-24

ybasesubstring string start length [function with three arguments ] :::::::::::::: 18-24

ybasesubstring string start length [function with three arguments ] :::::::::::::: 20-13

yincsubstring string start length [function with three arguments ] :::::::::::::::: 18-24

yincsubstring string start length [function with three arguments ] :::::::::::::::: 20-13

zerop x [function with one argument ] :::::::::::::::::::::::::::::::::::::::::::::::::: 4-9