Arc Forumnew | comments | leaders | submitlogin
1 point by akkartik 5425 days ago | link | parent

Off-topic: I've found myself using (after (do ..)) a few times and always found it clumsy. I just got around to do something about it.

  (mac after* block
    (let (body finally) (split-by block ':do)
      `(after
         (do ,@body)
         (do ,@finally))))

  (def split-by(seq delim)
    (case type.seq
      cons    (split seq (or (pos delim seq) (len seq)))
      string  (split seq (or (posmatch delim seq) (len seq)))
              (err "bad type for split-by")))

  arc> (after* (prn "interrupted") (/ 3 0) (prn "completed") 34
  :do
    (prn "end") (prn "and again"))
  interrupted
  end
  and again
  Error: "/: division by zero"
Never again will do seem in the wrong place..