Arc Forumnew | comments | leaders | submitlogin
1 point by fallintothis 5599 days ago | link | parent

Interesting. Arc has essentially that, but implements it directly with each:

  (mac noisy-each (n var val . body)
    (w/uniq (gn gc)
      `(with (,gn ,n ,gc 0)
         (each ,var ,val
           (when (multiple (++ ,gc) ,gn)
             (pr ".") 
             (flushout)
             )
           ,@body)
         (prn)
         (flushout))))
I suppose it depends on if you want index to be captured. Since on is used in your version, index is bound within the macro call. So if

  (everyp 2 c "abcd"
    (prn c)
    (++ index))
expands to

  (on c "abcd"
    (when (multiple index 2)
      (prn "heartbeat"))
    (prn c)
    (++ index))
it prints

  heartbeat
  a
  heartbeat
  c
because on captures index. This might be unexpected if you just want heartbeats in an otherwise normal each.


1 point by akkartik 5599 days ago | link

Ah, thanks for the reminder about noisy-each.

-----