3 ms·
> Well, I've encountered this use case a few times in Lisp:... > ...where a callback is used to collect various items. This can be and is achieved by simple
by thesz 1y ago
> Well, I've encountered this use case a few times in Lisp:...
> ...where a callback is used to collect various items.
This can be and is achieved by simple SQL-like query. Filter (flat) set of nodes by integerness and you even do not need a push_back.
Despite that, I find article interesting. It shows that Tcl can truely be multiparadigm programming language.
Myself, I've implemented pattern matching [1] over algebraic-type-like values and used that here and there.
[1] https://wiki.tcl-lang.org/page/Algebraic+Types https://wiki.tcl-lang.org/page/Algebraic+Types
- BoingBoomTschak 1y agoThe 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.
- thesz 1y ago> modify the node in-place I consider this anti-pattern [1]. [1] https://web.archive.org/web/20070417190836/https://www.eecs.harvard.edu/~nr/pubs/zipcfg.pdf 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.