logoalt Hacker News

theszyesterday at 5:31 PM1 replyview on HN

  > 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


Replies

BoingBoomTschakyesterday at 7:17 PM

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.