mu/tangle
Kartik Agaram 4a943d4ed3 5001 - drop the :(scenario) DSL
I've been saying for a while[1][2][3] that adding extra abstractions makes
things harder for newcomers, and adding new notations doubly so. And then
I notice this DSL in my own backyard. Makes me feel like a hypocrite.

[1] https://news.ycombinator.com/item?id=13565743#13570092
[2] https://lobste.rs/s/to8wpr/configuration_files_are_canary_warning
[3] https://lobste.rs/s/mdmcdi/little_languages_by_jon_bentley_1986#c_3miuf2

The implementation of the DSL was also highly hacky:

a) It was happening in the tangle/ tool, but was utterly unrelated to tangling
layers.

b) There were several persnickety constraints on the different kinds of
lines and the specific order they were expected in. I kept finding bugs
where the translator would silently do the wrong thing. Or the error messages
sucked, and readers may be stuck looking at the generated code to figure
out what happened. Fixing error messages would require a lot more code,
which is one of my arguments against DSLs in the first place: they may
be easy to implement, but they're hard to design to go with the grain of
the underlying platform. They require lots of iteration. Is that effort
worth prioritizing in this project?

On the other hand, the DSL did make at least some readers' life easier,
the ones who weren't immediately put off by having to learn a strange syntax.
There were fewer quotes to parse, fewer backslash escapes.

Anyway, since there are also people who dislike having to put up with strange
syntaxes, we'll call that consideration a wash and tear this DSL out.

---

This commit was sheer drudgery. Hopefully it won't need to be redone with
a new DSL because I grow sick of backslashes.
2019-03-12 19:14:12 -07:00
..
000test.cc 4403 2018-07-25 13:07:01 -07:00
001trace.cc 5001 - drop the :(scenario) DSL 2019-03-12 19:14:12 -07:00
001trace.test.cc 5001 - drop the :(scenario) DSL 2019-03-12 19:14:12 -07:00
002main.cc 4403 2018-07-25 13:07:01 -07:00
003tangle.cc 5001 - drop the :(scenario) DSL 2019-03-12 19:14:12 -07:00
003tangle.test.cc 5001 - drop the :(scenario) DSL 2019-03-12 19:14:12 -07:00
Readme.md 4980 2019-02-18 20:31:44 -08:00
boot.cc 3711 2016-12-26 15:57:13 -08:00

Readme.md

Literate Programming tool to convert Mu's layers into compilable form.

Mu's tangling directives differ from Knuth's classic implementation. The classical approach starts out with labeled subsystems that are initially empty, and adds code to them using two major directives:

<name> ≡
<code>
<name> +≡
<code>

(<code> can span multiple lines.)

This approach is best suited for top-down exposition.

On the other hand, Mu's tangling directives are better suited for a cleaned-up history of a codebase. Subsystems start out with a simple skeleton of the core of the program. Later versions then tell a story of the evolution of the program, with each version colocating all the code related to new features.

Read more:

directives

Add code to a project:

:(code)
<code>

Insert code before a specific line:

:(before <waypoint>)
<code>

Here <waypoint> is a substring matching a single line in the codebase. (We never use regular expressions.) Surround the substring in " quotes if it spans multiple words.

Insert code after a specific line:

:(after <waypoint>)
<code>

Delete a specific previously-added line (because it's not needed in a newer version).

:(delete <line>)

Delete a block of code starting with a given header and surrounded by { and }:

:(delete{} <header>)

(Caveat: doesn't directly support C's do..while loops.)

Replace a specific line with new code:

:(replace <line>)
<code>

This is identical to:

:(before <line>)
<code>
:(delete <line>)

(Assuming <code> did not insert a new line matching the substring <line>.)

Replace a block of code with another:

:(replace{} <header>)
<code>

Insert code before or after a substring pattern that isn't quite a unique waypoint in the whole codebase:

:(before <line> following <waypoint>)
<code>
:(after <line> following <waypoint>)
<code>
:(before <waypoint> then <line>)
<code>
:(after <waypoint> then <line>)
<code>