Arc Forumnew | comments | leaders | submitlogin
1 point by almkglor 6046 days ago | link | parent

as far as I can tell, `(insert your macro code here ,@body) is the generalized solution form of that design pattern. Just template the code: insert this part here, insert that part there.

The nice thing about templating is that you reasonably arbitrarily insert various bits of code:

  (mac do body
    (w/uniq rv
      (let (desc . body) (if (isa (car body) 'string) body (cons (uniq) body))
        `(let ,rv nil
            (profile-enter ,desc)
            (after (= ,rv ((fn () ,@body)))
                   (profile-leave ,desc)
                   ,rv)))))
Of course, Arc does indeed try to provide specific, shorter solutions for the most common cases, such as single-argument functions ([... _ ... ] syntax), single-variable 'let (let syntax), and anaphoric macros.

Perhaps we can define mac-sym?

  (mac-sym foob
    '(insert your code here))

  (foob
    niaw
    woof
    arf)
  ==
  (insert your code here
    niaw
    woof
    arf)

  (mac mac-sym (name . body)
    (w/uniq m-body
      `(mac ,name .m-body
          (join (do ,@body) ,m-body))))
Or is what is bothering you something else entirely?