Subject: Re: Can't figure out unreachable code error
From: rpw3@rpw3.org (Rob Warnock)
Date: Sat, 07 Jan 2006 04:40:59 -0600
Newsgroups: comp.lang.lisp
Message-ID: <z_ydnZpl-8ImByLenZ2dnUVZ_tOdnZ2d@speakeasy.net>
Jonathon McKitrick <j_mckitrick@bigfoot.com> wrote:
+---------------
| (defun test-web (&optional qname)
|   (let ((aq "SELECT lastname,firstname FROM members")
|         result stuff)
|     (if qname
|       (setf aq (concatenate 'string aq " WHERE lastname= '" qname "'")))
|     (connect '("localhost" "rlg" "root" "none") :database-type :mysql)
|     (setf result "<table><tr><th>Last</th><th>First</th></tr>")
|     (do-query ((lastname firstname) aq)
| ;   (let (lastname firstname)
|               (setf stuff (format nil "<tr><td>~a</td><td>~a</td></tr>"
|                               lastname firstname))
|               (setf result (concatenate 'string result stuff)))
|     (disconnect)
|     (setf result (concatenate 'string result "</table>"))
|     (format t "Result: ~A~%" result)
|     result))
| 
| It's supposed to output 2 fields of a database as an html table.  As it
| is here, it finds unreachable code in the format statement below the
| commented out statement.  If I uncomment the let, and comment the
| do-query, the error goes away but there is obviously no query done.
| What have I screwed up here?
+---------------

Instead of using ";" to "comment out" the LET, try using "#-(and)".
The semicolon doesn't comment out the entire LET form, it only
comments out the first *line* of the LET form. As a result, you've
messed up your parenthesis-matching.


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607