Re: Evaluation misstep in tag function

2017-04-05 Thread Bruno Franco
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 , who only ever saw the atom 2.
Thanks Alex.

On Wed, Apr 5, 2017 at 1:36 AM, Alexander Burger 
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:
> >
> > : ( 'main
> >( NIL "Head")
> >( NIL
> >   ( "Line 1")
> >   "Line"
> >   ()
> >   (+ 1 1) ) )
> > Head
> > Line 1
> > Line
> > 
> >
> > 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.
>
>: ( NIL "Head")
>Head
>
> is nothing more than
>
>: (prinl "Head")
>Head
>
> just in a more convenient form.
>
> The nice thing is that these functions may be nested, as can be seen in
> your
> example ( 'main ( 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
>
>( 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
>


Re: Evaluation misstep in tag function

2017-04-05 Thread Alexander Burger
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:
> 
> : ( 'main
>( NIL "Head")
>( NIL
>   ( "Line 1")
>   "Line"
>   ()
>   (+ 1 1) ) )
> Head
> Line 1
> Line
> 
> 
> 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.

   : ( NIL "Head")
   Head

is nothing more than

   : (prinl "Head")
   Head

just in a more convenient form.

The nice thing is that these functions may be nested, as can be seen in your
example ( 'main ( 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

   ( 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


Evaluation misstep in tag function

2017-04-04 Thread Bruno Franco
Hi list,

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:

: ( 'main
   ( NIL "Head")
   ( NIL
  ( "Line 1")
  "Line"
  ()
  (+ 1 1) ) )
Head
Line 1
Line 2


the problem is that, when I run it, I get this:

: ( 'main
   ( NIL "Head")
   ( NIL
  ( "Line 1")
  "Line"
  ()
  (+ 1 1) ) )
Head
Line 1
Line


That is, the (+ 1 1) part is not evaluated.

I run it both as a file loaded from the terminal by pil in a session started as:
pil @lib/http.l @lib/xhtml.l @lib/form.l --server 8080 project.l

And in a modified version of psh, but still the (+ 1 1) is not evaluated.

The evaluation only happens if I add an accent to the (+ 1 1)
( 'main
  ( NIL "Head")
  ( NIL
 ( "Line 1")
 "Line"
 ()
 `(+ 1 1) ) )
Head
Line 1
Line2


It also works if I just put the number, and if I nest it in a print
statement, like
(prin (+ 1 1)).

Can someone help me figure why this happens?