Discussion about this post

User's avatar
Joe Blow's avatar

Lisp macro:

https://news.ycombinator.com/item?id=43838342

You give it a dummy variable, root expression, and expressions how to navigate left and right relative to dummy variable.

No iterator interfaces; the loop writes the code for walking the binary tree.

Expand full comment
Niklas Dewally's avatar

Haskell has a lot of ideas for this, e.g. Traversals, Prisms, Lenses, Uniplate, Scrap your Boilerplate.

Uniplate seems to be the most applicable to imperative languages, as it does not require any advanced type system features (just lists).

Some examples:

* In C#: https://github.com/benjamin-hodgson/Sawmill

* In Rust: https://lib.rs/crates/uniplate (shameless plug!)

The paper: https://ndmitchell.com/downloads/paper-uniform_boilerplate_and_list_processing-30_sep_2007.pdf

Expand full comment
6 more comments...

No posts