1. 24
  1.  

  2. 5

    This fun macro has been in Arc Lisp from the start under the name accum, and I find it extremely useful. For example, I recently added support for list comprehensions using it: http://akkartik.name/post/list-comprehensions-in-anarki

    One difference between the two: gathering uses a hardcoded function name gather, whereas accum takes a first arg that’s the function you call to ‘accumulate’ new item. Often we use acc, so calls begin (accum acc ...).

    1. 2

      Interesting posr about list comprehensions!

      It is commonly use collect or with-collector in Lisp. The named variant is also common.

      https://github.com/jscl-project/jscl/blob/master/src/utils.lisp

      There is even a variant to collect into multiple queues, in which case one has to provide a name for each collector.

      1. 3

        Serapeum has a version called collect too. I didn’t call it collect because that conflicts with iterate’s collect clause, and I tend to use iterate pretty heavily in my personal stuff..

        1. 2

          Thanks for that pointer! I wasn’t aware, but in my toy lisp I called the pair collect and yield. Glad I was on the right track!

      2. 4

        For those that have tried to wipe the piece of salad from their phone screen, that is an image of a fern of some sort below the menu, not food on your screen.

        1. 2

          Macros: The Gathering