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

Edi Weitz edi at agharta.de
Thu Dec 22 17:12:27 UTC 2011


In your example, LABEL is not a string.  It's a symbol that happens to
be bound to a string.  A string is something that starts and ends with
double quotes.

Note that, as the documentation says, WITH-OUTPUT-TO-STRING is a
macro.  It has no way to look into the future and to know what value
the variable LABEL will have at a specific point in time... :)

Cheers,
Edi.


On Thu, Dec 22, 2011 at 6:03 PM, Tyler Smith <tyler.smith at mail.mcgill.ca> wrote:
> 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
>
> _______________________________________________
> cl-who-devel site list
> cl-who-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/cl-who-devel
>




More information about the Cl-who-devel mailing list