[cl-who-devel] loop and with-html-output

Tyler Smith tyler.smith at mail.mcgill.ca
Thu Dec 22 17:03:43 UTC 2011


On Thu, Dec 22, 2011 at 10:53 AM, Sebastian Tennant
<sebyte at smolny.plus.com> wrote:
> http://weitz.de/cl-who/#syntax
>
> Hope this helps.
>

Not really, that's the documentation that I'm confused about. It
starts out with the statement that strings will be printed verbatim.
My variables are strings, but they aren't printed. I understand from
Jens' response that I can get the function to work by wrapping my
variables in (str ...), but I don't understand why that's necessary.
The documentation of str suggests it's not necessary for strings:

  A form which is neither a string nor a keyword nor a list beginning
with a keyword will be left as is except for the following
substitutions:

My variables are already strings:

* (multiple-value-bind (records fields)
    (select [genus] [species] :from "specimens" :where [< [specimen_id] 4])
  (loop for rec in records do
       (loop for label in fields
          for val in rec do
            (fresh-line)
            (princ (stringp label))
            (princ (stringp val)))))


TT
TT
TT
TT
TT
TT
NIL
*

Can someone explain why my variables aren't being treated as strings
within with-html-output?

The definition of (str ...) continues:

  Forms that look like (str form1 form*) will be substituted with (let
((result form1)) (when result (princ result s))).

I'm new to Lisp (as must be clear by now!): what is the difference between

  (princ form1)

and

  (let ((result form1))
    (princ result))

Thanks for your help,

Tyler




More information about the Cl-who-devel mailing list