Hi,

Ihor Radchenko writes:
Can you provide more concrete examples?

Some drawbacks:
  + doesn't work for all languages (does work for LaTeX)
Which languages do not work?
Most languages do not work. Using your proposed solution, what I'm
trying to do is

#+name:javascript-header
#+begin_src javascript :tangle no
some javascript, with \ and " to be escaped
#+end_src

#+name: string-escape
#+begin_src emacs-lisp :var str="" :tangle no
(prin1-to-string (string-trim-right str))
#+end_src

#+begin_src emacs-lisp :noweb yes :tangle yes
(setq javascript-header <<string-escape(str=javascript-header)>>)
#+end_src

If you replace javascript with latex, it happens to work, because when
org executes a latex block, it prints its content.

The goal is to tangle to some lisp code whose purpose is to generate
LaTeX/javascript code. Quite niche admittedly, though as you showed,
it could also be used to string-escape documentation.

  + the tangle gets very noisy: not only are the result of execution
    printed in the echo buffer, but emacs visits the tangling buffer
    and moves the point to each block.
    Perhaps this is a bug that can be fixed.
Did you try to play with :results header argument to disable messages?
What exactly went unexpected?

I did. I might have missed something, but no combination of :results
argument to both the latex block and the string-escape block silences
the tangle (except for :results none, which doesn't tangle the content
of the block). During tangle, the contents of the latex block are
displayed (shortly) in the echo buffer (check *Messages*), and the
point very briefly moves to the latex block. This isn't very
noticeable with a single block.

  + src block execution also resets the noweb cache, slowing down
    tangle, though I have not tried to measure the effect.
I am not sure what you are referring to here. Can you elaborate?

Lines 2892-2893 of (my) ob-core.el, in org-babel-expand-noweb-references:

             ;; Evaluation can potentially modify the buffer
             ;; and invalidate the cache: reset it.

Regards,

-- 
Sébastien Miquel