Skip to Content
Land of Lisp
book

Land of Lisp

by Conrad Barski M.D.
November 2010
Intermediate to advanced
504 pages
12h 45m
English
No Starch Press
Content preview from Land of Lisp

Defining Global Variables in Lisp

As the player calls the functions that make up our game, the program will need to track the small and big limits. In order to do this, we’ll need to create two global variables called *small* and *big*.

Defining the small and big Variables

A variable that is defined globally in Lisp is called a top-level definition. We can create new top-level definitions with the defparameter function:

> (defparameter *small* 1)
*SMALL*
> (defparameter *big* 100)
*BIG*

The function name defparameter is a bit confusing, since it doesn’t really have anything to do with parameters. What it does is let you define a global variable.

The first argument we send to defparameter is the name of the new variable. The asterisks surrounding the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Practical Common Lisp

Practical Common Lisp

Peter Seibel
The Rust Programming Language, 2nd Edition

The Rust Programming Language, 2nd Edition

Steve Klabnik, Carol Nichols
Programming Rust, 2nd Edition

Programming Rust, 2nd Edition

Jim Blandy, Jason Orendorff, Leonora F. S. Tindall
The Go Programming Language

The Go Programming Language

Alan A. A. Donovan, Brian W. Kernighan

Publisher Resources

ISBN: 9781593272814Errata Page