4 ms·
Every language with block comments supports this, by starting the file with a comment and wrapping code in end-comment/start-comment pairs. It's not especially
by jmillikin 3y ago
Every language with block comments supports this, by starting the file with a comment and wrapping code in end-comment/start-comment pairs.
It's not especially useful. For literate programming you really need the ability to move blocks of code around without the ceremony of function signatures.
- mjw1007 3y agoIf I use block comments like that in most contemporary IDEs, I find that by default they show the main text in flat "this is a comment" styling, even though they're in principle capable of using different kinds of highlighting for different parts of the file. Similarly, if I preview such a file on github I get syntax highlighting for the code but I don't get rendering for the markdown. So I think the advantage of an 'official' way of saying you're using this arrangement would be communicating intent to more-or-less generic tools.
- jmillikin 3y agoThat's an IDE configuration problem. Most of them support mixed-mode syntax highlighting nowadays, so you just need to configure your theme to treat block comments as Markdown (or LaTeX, HTML, whatever). You could probably even do it with Markdown directly, using fenced code blocks as part of your begin/end lines. I think you'll find that this approach offers very little benefit over either traditional commentary or linear notebook-style inline code blocks.
- Joker_vD 3y agoHaskell actually supports literate programming [0]. Oleg Kiselyov regularly writes examples of his ideas using it, e.g. [1], [2]. [0] https://wiki.haskell.org/Literate_programming#Haskell_and_literate_programming https://wiki.haskell.org/Literate_programming#Haskell_and_li... [1] https://okmij.org/ftp/Haskell/class-based-dispatch.lhs https://okmij.org/ftp/Haskell/class-based-dispatch.lhs [2] https://okmij.org/ftp/Computation/lightweight-guarantees/eliminating-mult-array-bound-check.lhs https://okmij.org/ftp/Computation/lightweight-guarantees/eli...
- jmillikin 3y agoHaskell does not natively support literate programming -- it only allows the comment/code default to be swapped. The format named "literate Haskell" is basically just syntactic sugar for {- comment blocks -}. Literate programming requires the ability to decouple the ordering of code relative to the commentary. I wrote more about this at <https://news.ycombinator.com/item?id=35985835 https://news.ycombinator.com/item?id=35985835> and <https://john-millikin.com/software/anansi#history https://john-millikin.com/software/anansi#history>.