3 ms·
Fun with Macros: Gathering
- birthdaywizard 8y agoVery neat. It reminds me of the writer monad.
- lispm 8y ago'gathering' is also explained in CLtL2: https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node365.html https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node365.html
- norswap 8y agoNice, but how does it beat passing a writable collection around?
- reikonomusha 8y agoThis 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).
- yvdriess 8y agoIt beats it in the same way that procedures beat subroutines that use a stack.
- omaranto 8y agoAs 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.