[rust-dev] Support for Literate Rust

Eduard Bopp eduard.bopp at aepsil0n.de
Mon Jun 30 01:35:55 PDT 2014

On 06/29/2014 09:30 PM, Nathan Typanski wrote:
> I'm wondering if anyone else here has had the thought of supporting
> literate programming in Rust. For those who don't know what this is
> about, a language with good support for the concept is Haskell [1],
> which normally uses bird-style (>) for code blocks. I would propose a
> file extension (.lrs, most likely) that's dedicated to literate
> usage.

Haven't thought about it in Rust yet but I like the idea. Although I've
never managed to actually use literate programming in a productive
environment (except for, well, TeX). However, I still think it might be
a good idea to force yourself to write good documentation for the
reasons you describe.

Regarding syntax I would prefer to use indentation to distinguish text
from code rather than ">". This is easier to write in common text
editors and does not clutter the file as much. Thus I find it strikes a
better balance between practical application and educational purposes.

As a first prototypical step, I would suggest to simply write a
preprocessor that does the conversion from literate to current Rust.
Even though you eventually want to have libsyntax to handle this
correctly, it makes imo sense to experiment with literate this way and
figure out some details like the relation between doc comments and
literate text blocks, code/text structure within a module, practicality
of syntax variants, etc.

In this context one could probably also think about the relation to
rustdoc's markdown, which imho is fairly limiting looking for comparison
at Python docutils, sphinx and reStructuredText, especially if you
really start writing text for it.


More information about the Rust-dev mailing list