logoalt Hacker News

BoingBoomTschak05/03/20251 replyview on HN

The callback way is more generic and prevents consing when you don't need to store the resulting node list. You may want to simply print something or maybe modify the node in-place, for example.


Replies

thesz05/05/2025

  > modify the node in-place
I consider this anti-pattern [1].

[1] https://web.archive.org/web/20070417190836/https://www.eecs....

Authors found themselves fighting with control flow graph modifications and replaced mutable graph with immutable one, modified by zippers. They achieved speed up of 11% in optimizing transformations, some of which they were unable to implement in mutable version. E.g., more complex optimizations were working faster.