Next: , Up: Common Lisp Conditions   [Contents][Index]


7.2.1 An Example

To get a sense of how this works, let’s suppose you’re writing an application that reads some sort of textual log file, such as a Web server’s log. Somewhere in your application you’ll have a function to parse the individual log entries. Let’s assume you’ll write a function, parse-log-entry, that will be passed a string containing the text of a single log entry and that is supposed to return a ‘log-entry’ object representing the entry. This function will be called from a function, parse-log-file, that reads a complete log file and returns a list of objects representing all the entries in the file.

To keep things simple, the parse-log-entry function will not be required to parse incorrectly formatted entries. It will, however, be able to detect when its input is malformed. But what should it do when it detects bad input? In C you’d return a special value to indicate there was a problem. In Java or Python you’d throw or raise an exception. In Common Lisp, you signal a condition.