5 ms·
Isn’t the tangle-untangle process fundamental in literate programming?
by nesarkvechnep 5y ago
Isn’t the tangle-untangle process fundamental in literate programming?
- kryptiskt 5y agoI wouldn't say it's absolutely needed in a language like Haskell, where functions and types can be defined in any order. So if you want to defer implementing something until later in the document you can just make it a function and get back to it later.
- daly 5y agoLisp has the same ability to define things in any order. Java wants specially named paths to files. The Makefile can create the directory structure and use the "tangle" program to extract the files to the correct place. That's what I did in the Clojure example.
- daly 5y agoThere is a trivial C program that is also in the document. It does the actual "chunk" extraction from the Latex. The Makefile uses it to extract named chunks. The program scans the Latex looking for named "chunk" blocks. Each named block is put in a hash table under the name. Once the scan is complete you use a provided command line argument to extract the named chunk to a file. Of course, the chunk can include other chunks and these get extracted and expanded inline. So tanglec myliteratefile.tex achunkname > myfile.lang This creates a hash table from "myliteratefile.tex" containing named chunks, then prints the chunk "achunkname" to stdout (recursively expanding chunks embedded in other chunks). The Makefile can extract Java files and put them in the proper directories. It really is a trivial C program. Make a hash, print a hash key. This would be a simple interview test question. (Actually I use Lisp, mostly because I always code in Lisp these days, but lets not start that war.)