Hi Vladimir,

The main difference I have noticed is that you can have multiple blocks with the same :noweb-ref header argument, and they will be concatenated on tangle. I use this in some of my files to progressively build a block of code which is then referenced somewhere else. With #+name, you can have only one block with each name, the others are discarded (can't remember if it's the first or the last one that gets used).

I guess this is also why :noweb-ref tangling is slow, since all blocks need to be scanned and put together.

--Diego


On Thu, Jan 9, 2020 at 2:43 AM Vladimir Nikishkin <lockywolf@gmail.com> wrote:
Ouch, that was unexpected.

The manual for my version only includes four mentions if the noweb-ref header argument. Is it becoming deprecated?

What does "apparently don't need" actually mean? That is, when should I use the name, and when the header argument? What can the header argument do that the name cannot?


Nicolas Goaziou <mail@nicolasgoaziou.fr> 於 2020年1月9日 週四 01:23 寫道:
Hello,

Vladimir Nikishkin <lockywolf@gmail.com> writes:

> I am attaching the file in which tangling is still slow.
>
> The file is quite big, but that alone doesn't seem to be the reason
> for slowliness (I tried adding 1M-long words in the random places of
> the previous mwe).
>
> You can see the result by C-c C-v C-v'ing the code block at the
> "Ramanujan numbers" heading.
>
> Below is the profiler report for C-c C-v C-v'ing.with the heaviest
> blocks expanded:

This is because you're using :noweb-ref, which _is_ slow, although you
apparently don't need it in the document. Use name keyword instead,
e.g.,

    #+name: primetest
    #+begin_src scheme :exports both :results output
      (define (smallest-divisor n)
        (find-divisor n 2))
      (define (find-divisor n test-divisor)
        (cond ((> (square test-divisor) n) n)
          ((divides? test-divisor n) test-divisor)
          (else (find-divisor n (+ test-divisor 1)))))
      (define (divides? a b) (= (remainder b a) 0))

      (define (prime? n)
        (= n (smallest-divisor n)))
    #+end_src


Regards,

--
Nicolas Goaziou