Hacker News new | past | comments | ask | show | jobs | submit login
Fun with Macros: Gathering (stevelosh.com)
59 points by stevelosh on May 21, 2018 | hide | past | favorite | 6 comments



As a very minor point I think I like the names Mathematica uses a little better: instead of "gathering" and "gather", they are called "reap" and "sow", respectively.


'gathering' is also explained in CLtL2: https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node365.html


Very neat. It reminds me of the writer monad.


Nice, but how does it beat passing a writable collection around?


This is basically what it is, except the collection is made otherwise inaccessible through the closure. The closure exposes the minimum interface needed to adjoin elements to the collection, whereas passing the collection around allows all sorts of modification. I’d also say that if this was used a lot, the intent is more clearly specified and it’s easier to narrow down where a bug might be (precisely because rampant changes to the collection are not possible in the body of the macro).


It beats it in the same way that procedures beat subroutines that use a stack.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: