简体   繁体   中英

How is the order of execution of code chunks in a Literate Programming tool like noweb or Rmarkdown determined?

I am reading this and it says:

Because of the way notangle extracts and assembles its input, the program can be presented and explained in the best order for human understanding. notangle will make sure that the program chunks are in the right order for the compiler or interpreter.

My query is: How does the noweb compiler determine the order of code chunks?

This says that:

An R Markdown document will have often have many code chunks. They are evaluated in order, in a single R session, and the state of the various variables in one code chunk are preserved in future chunks.

Is'nt Rmarkdown based on noweb? Should it not automatically determine code chunk order like noweb?

Noweb chunks may be used as macros in other chunks so the order just boils down to what order notangle finds them in. For example if I tangled main.txt from this, the resulting text would be the letters A to E in alphabetical order.

<<main.txt>>=
<<A>>
<<D>>
<<D>>=
D
<<E>>
@
A text chunk that won't be in main.txt.
<<F>>=
Since this chunk is not referred to in any other chunk it will not appear in main.txt.
<<A>>=
A
<<B>>
<<C>>
<<E>>=
E
<<C>>=
C
<<B>>=
B

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM