On Sat 13 Mar 2021 at 16:04, Alexander Burger <a...@software-lab.de> wrote: > I don't get your problem with side effects!
in your example: (de <div> (Col . Prg) (prin "<div class=\"" Col "\">") (run Prg) (prin "</div>") ) prin has side-effect. Col is not properly escaped! This example: (de <p> Prg (prin "<p>") (run Prg) (prin "</p>") ) These functions output the formatted html immediatelly, which is too early for reasons I wrote about already. <p> would be better written as: (de p @ (cons 'p (args))) This has no side-effects. It also allows me to postpone serialisation to a better point in time, when I call a function called html. Similar to xml function in picolisp, this html function serializes cons tree into a stream with html syntax. This way I never have to care about escaping and other issues. Separating p, div etc and html function opens new possibilities. > Why do you open new issues like like SVG and PDF generation, when the > task is to print a page to to a socket? Because cons trees can brilliantly represent pretty much anything, from lisp code to html, xml, svg, pdf, docx, odt, der, json etc. You can easily construct them, pretty-print them, trace them, transform them and serialize them. Picolisp way of implementing <p> has fundamental flaws which the cons tree approach solves elegantly. >> > If you want output with a pre-calculated width, you can still do it in the >> > FEXPR. >> >> Not pre-calculated. The bounding box is known after the thing is drawn. > > That's trivial. Just calculate while printing then. That does not work, because with and height are not known yet at that time! They are known after the printing is finished, which is too late. >> If my code outputs html to /tmp/a.html and I trace it, where would the >> arguments and return values be written to? Where would the side-effect >> be written to? > > I already explained that tracing goes to stderr. So will I see the generated html in stderr? If yes then /tmp/a.html is empty and tracing breaks my program. If no then stderr will not contain the generated html and tracing is useless. -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe