Hi Christophe,

> If I sum up (efficiently) my problem, I need a program like:
> (Display "hello")
> to have two interpretations.
> In the first context it would (surprise surprise) «println "hello"».
> In the second context it should be reprogramed to generate some XML.
> No problem for Display, but "hello" should spontaneously have its value
> changed to some XML containing the string "hello".

picolisp has dynamic bindings so what you want is trivial:

1st case:

(let Display println
   (Display "hello") )

2nd case:

(let Display (Msg (prinl "<greeting>" Msg "</greeting>"))
   (Display "hello") )

Another, more traditional approach is using methods, which would
dispatch on some kind of context:

(de display (Msg)
   (display> *Ctx Msg) )

(class +Case1 ...)

(dm display> (Msg)
   (println Msg) )

(class +Case2 ...)

(dm display> (Msg)
   (prinl "<greeting>" Msg "</greeting>") )

(display (new +Case1) "hello")
(display (new +Case2) "hello")

Hope it helps,

UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to