Ah, I see! So, its for convenience that the atoms are printed. And the
reason `(+ 1 1) was printed was that it was first evaluated to 2, *then*
passed to <p>, who only ever saw the atom 2.
Thanks Alex.

On Wed, Apr 5, 2017 at 1:36 AM, Alexander Burger <a...@software-lab.de>
wrote:

> Hi Bruno,
>
> > I'm going through the picolisp application development tutorial (
> > http://software-lab.de/doc/app.html#tags) and I'm trying this piece of
> code
> > at the tags section:
> >
> > : (<div> 'main
> >    (<h1> NIL "Head")
> >    (<p> NIL
> >       (<br> "Line 1")
> >       "Line"
> >       (<nbsp>)
> >       (+ 1 1) ) )
> > <div class="main"><h1>Head</h1>
> > <p>Line 1<br/>
> > Line&nbsp;</p>
> > </div>
> >
> > That is, the (+ 1 1) part is not evaluated.
>
> In fact it *is* evaluated, but it does not print anything.
>
> All those HTML functions are *print* front-ends, which send text to the
> current
> output channel.
>
>    : (<h1> NIL "Head")
>    <h1>Head</h1>
>
> is nothing more than
>
>    : (prinl "<h1>Head</h1>")
>    <h1>Head</h1>
>
> just in a more convenient form.
>
> The nice thing is that these functions may be nested, as can be seen in
> your
> example (<div> 'main (<h1> NIL "Head") ..). Still they must print
> somewhere at
> the bottom.
>
> So the answer to your question is to write
>
>    (ht:Prin (+ 1 1))
>
> or just
>
>    (prin (+ 1 1))
>
> ('ht:Prin' is recommended for textual data which may contain HTML meta
> characters
> to properly escape them)
>
>
> Note that - for convenience - *atomic* expressions (like "Head" or "Line"
> in
> your example) are printed directly, so that it is not necessary to write
>
>    (<h1> NIL (prin "Head"))  # Not needed
>
> This is also mentioned in doc/app.html as
>
>    • If an argument is an atom (a number or a symbol (string)), its value
> is
>      printed immediately.
>
>    • Otherwise (a list), it is evaluated as a Lisp function (typically
> some form
>      of print statement).
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>

Reply via email to