On Wed, Oct 22, 2008 at 05:52:14PM +0100, Tomas Hlavaty wrote:
> Well, I think this version has one important limitation: if Prg has a
> recursive call(s) to foo, the deeper foo won't see any values set by
> the foo above, or will it?
Yes, that's right. 'run' takes care to skip the corresponding f
On Wed, Oct 22, 2008 at 05:23:40PM +0100, Tomas Hlavaty wrote:
>
> > The hard-to-explain thing is, that here (up @ 2) is needed:
> >
> >(de foo "Prg"
> > (when (car "Prg")
> > (run (let @ (up @ 2) (cdr "Prg"))) ) )
>
> (up @ 2) is not right, it sets @ to 2 which makes the examp
Hi Alex and Jon,
>> Indenting is impossible to do well I think because the function does
>> not know what is going to happen in the body (the 'xml' function knows
>
> I think so, too. This is also the reason why the functions in
> "lib/xhtml.l" don't do any efforts to indent. And with this
> func
> Up until now, the simplest (and recommended, I think) version was:
>
>(de foo Prg
> (when (car Prg)
> (run (cdr Prg) 1) ) )
Well, I think this version has one important limitation: if Prg has a
recursive call(s) to foo, the deeper foo won't see any values set by
the foo above,
> For one thing, the quote in the call of 'up' is too much. But this
> is not the main problem.
Sorry, my mistake.
> The hard-to-explain thing is, that here (up @ 2) is needed:
>
>(de foo "Prg"
> (when (car "Prg")
> (run (let @ (up @ 2) (cdr "Prg"))) ) )
(up @ 2) is not right,
On Wed, Oct 22, 2008 at 04:47:36PM +0100, Tomas Hlavaty wrote:
> (de foo "Prg"
>(let "At" (up @)
> (when (car "Prg")
> (let @ "At"
> (run (cdr "Prg"))
>
> : (and 2 (foo T (+ 1 @ 3)))
> -> 6
Yep. In that case, you can even omit the 'up', as '@' is not modified
ye
On Wed, Oct 22, 2008 at 03:37:10PM +0100, Tomas Hlavaty wrote:
> (de foo "Prg"
>(when (car "Prg")
> (run (let @ (up '@) (cdr "Prg")) ) ) )
>
> Why this does not work?
Well, this is a hairy one ;-)
For one thing, the quote in the call of 'up' is too much. But this is
not the main probl
> If you use transient symbols
>
>(de foo "Prg"
> (when (car "Prg")
> (run (cdr "Prg")) ) )
>
> then it basically works
>
>: (foo T (+ 1 2 3))
>-> 6
>: (foo NIL (+ 1 2 3))
>-> NIL
>
> BUT if you want to use '@'
>
>: (and 2 (foo T (+ 1 @ 3)))
>!? (+ 1 @ 3)
>> it would be possible to do indenting if the body prg was not run in
>> the parent environment. Then we could pass some indenting state to
>> the recursive calls of and indent accordingly.
>
> Should be possible. If we had
>
>(de (Level . Lst)
> (default Level 0)
>
> Then we could do
> The disadvantage of gensym'd symbols is that the code is more difficult
> to understand when pretty printed, and cannot be written to some file
> and retrieved later.
True.
> The PicoLisp solution of transient symbols has an identical effect
> (especially if you surround the function definition
Hi Tomas,
> it would be possible to do indenting if the body prg was not run in
> the parent environment. Then we could pass some indenting state to
> the recursive calls of and indent accordingly.
Should be possible. If we had
(de (Level . Lst)
(default Level 0)
Then we could do
Hi Alex,
>> Indenting is impossible to do well I think because the function does
>> not know what is going to happen in the body (the 'xml' function knows
>
> I think so, too. This is also the reason why the functions in
> "lib/xhtml.l" don't do any efforts to indent. And with this
> function we
On Wed, Oct 22, 2008 at 01:22:50PM +0100, Tomas Hlavaty wrote:
> The trick with run/eval in parent environment is used quite often in
> picoLisp to avoid variable binding clashes. I was wandering whether
> it would not be better sometimes to do something like Common Lispers
> do with gensyms which
On Wed, Oct 22, 2008 at 10:43:32AM +0100, Tomas Hlavaty wrote:
> The body should be printed using ht:Prin to get good escaping.
Sorry, didn't read this before my previous post ...
> Actually, the more I think about it the less I like it. It just
> introduces some questions with application spec
Hi Tomas,
thanks for the analysis!
> Indenting is impossible to do well I think because the function does
> not know what is going to happen in the body (the 'xml' function knows
I think so, too. This is also the reason why the functions in
"lib/xhtml.l" don't do any efforts to indent. And with
> The only problem with this code is that the body is not run in the
> parent environment, which I don't know how to fix or what problems it
> could cause.
The trick with run/eval in parent environment is used quite often in
picoLisp to avoid variable binding clashes. I was wandering whether
it w
The escXml function could be like this:
(de escXml (X)
(for C (chop X)
(prin (case C
("\"" """)
("&" "&")
("<" "<")
(">" ">")
(T C) ) ) ) )
> It is probably best to automatically escape attributes but leave the
>
Hi Jon and Alex,
>> Since this is "pure" XML, it would seem natural to find a function like
>> this in lib/xml.l. I haven't studied the functions in that file
>
> Tomas also suggested this. I think it is a good idea. I would like to
> let Tomas make the final decision and/or design.
I take it
Hi Alex,
Hi Jon,
The test "(if (car Lst) ..." determines whether the current element is a
container ("hoy") or not ("inner").
Is the 'car' necessary? Otherwise a simple test of 'Lst' would suffice.
No, it seems to work quite well without the 'car'. ;-)
BTW, I always feel that a 'prog'
Hi Jon,
> The test "(if (car Lst) ..." determines whether the current element is a
> container ("hoy") or not ("inner").
Is the 'car' necessary? Otherwise a simple test of 'Lst' would suffice.
BTW, I always feel that a 'prog' is a kind of kludge, and avoid it
if possible by inverting the 'if'.
Hi Tomas,
> maybe it could become part of lib/xml.l? I would use it as it looks
> more convenient than building list for 'xml' function in some cases.
I'm not sure. It might be convenient, but it makes 'xml' asymmetrical.
Are you thinking of a separate '' function? It should be tried in
practica
On Mon, Oct 20, 2008 at 04:21:31PM +0100, Tomas Hlavaty wrote:
That's nice. It could even be:
(de Prg
(prin "<" (pop 'Prg))
(while (atom (car Prg))
(prin " " (pop 'Prg) "=\"" (eval (pop 'Prg) 1) "\"") )
(prin ">")
(run Prg) # the text, or other elements
(prin
Hi Alex,
maybe it could become part of lib/xml.l? I would use it as it looks
more convenient than building list for 'xml' function in some cases.
Thanks,
Tomas
--
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]
On Mon, Oct 20, 2008 at 04:21:31PM +0100, Tomas Hlavaty wrote:
> That's nice. It could even be:
>
> (de Prg
>(prin "<" (pop 'Prg))
>(while (atom (car Prg))
> (prin " " (pop 'Prg) "=\"" (eval (pop 'Prg) 1) "\"") )
>(prin ">")
>(run Prg) # the text, or other elements
>
> How about the following?
>
>(de Prg
> (prin " (while (atom (car Prg))
> (prin " " (pop 'Prg) "=\"" (eval (pop 'Prg) 1) "\"") )
> (prin ">")
> (run Prg) # the text, or other elements
> (prinl "") )
>
> Then you could write
>
>: ( id 123 dx (+
Hi Jon,
> then the calls would very often have a lot of NIL arguments, which looks
> rather ugly. Should I switch to property lists? Any suggestions?
How about the following?
(de Prg
(prin "")
(run Prg) # the text, or other elements
(prinl "") )
Then you could write
26 matches
Mail list logo