> 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, or will it?

: (de foo Prg
   (when (car Prg)
      (print Foo)
      (let Foo (pack Foo "%")
         (run (cdr Prg) 1) ) ) )
-> foo
: (foo T (foo T (foo T)) (foo T))
NILNILNILNIL-> NIL
: (de foo Prg
   (when (car Prg)
      (print Foo)
      (let Foo (pack Foo "%")
         (run (cdr Prg)) ) ) )
# foo redefined
-> foo
: (foo T (foo T (foo T)) (foo T))
NIL"%""%%""%"-> NIL
: (de foo "Prg"
   (when (car "Prg")
      (print "Foo")
      (let "Foo" (pack "Foo" "%")
         (run (cdr "Prg")) ) ) )
-> foo
: (foo T (foo T (foo T)) (foo T))
"Foo""Foo%""Foo%%""Foo%"-> NIL
: 

So if I want to write recursive <xml> function, I cannot use (run ... 1).

So far, I have this:

(====)
(de <xml> "Lst"
   (let ("At" @
         "Tag" (pop '"Lst"))
      (if "Tag"
         (queue '"Xml"
            (make
               (link "Tag")
               (let "Att"
                  (make
                     (while (and "Lst" (atom (car "Lst")))
                        (link (cons (pop '"Lst") (eval (pop '"Lst") 1))) ) )
                  (let "Xml" NIL
                     (let @ "At"
                        (run "Lst") )
                     (ifn "Xml"
                        (when "Att"
                           (link "Att") )
                        (link "Att")
                        (chain "Xml") ) ) ) ) )
         (let ("Xml" NIL
               "Out" (when (and "Lst" (atom (car "Lst")))
                      (eval (pop '"Lst") 1) )
               xmlPrin '(@ (queue '"Xml" (pass pack))) )
            (let @ "At"
               (run "Lst") )
            (if (=T "Out")
               (car "Xml")
               (out "Out"
                  (xml (car "Xml")) ) ) ) ) ) )
(====)

This works well:

: (load '@lib/xml.l)
-> attr
: (and 4 (<xml> NIL (<xml> elt att @ (xmlPrin "hi"))))
<elt att="4">hi</elt>
-> ">"
: 

I don't think it could possibly work without me being esotheric:-)

Thank you,

Tomas
-- 
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]

Reply via email to