Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

2. Creating Your First Lisp Program > Basic Lisp Etiquette

Basic Lisp Etiquette

The way commands are called and the way code is formatted in Lisp is somewhat strange compared with other languages. First of all, you need to surround the command (and its arguments) with parentheses, as with the defparameter function:

> (defparameter *small* 1)
*SMALL*

Without the parentheses, a command will not be called.

Also, spaces and line breaks are completely ignored when Lisp reads in your code. That means you could call this command in any crazy way, with the same result:

> (               defparameter
           *small* 1)
*SMALL*

Because Lisp code can be formatted in such flexible ways, Lispers have a lot of conventions for formatting commands, including when to use multiple lines and indentation. We’ll loosely follow some of the common indentation conventions in the code examples in this book. However, we’re more interested in writing games than in discussing source code indentation rules, so we’re not going to be spending too much time on code layout rules in this book.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint