Arc Forumnew | comments | leaders | submitlogin
1 point by kennytilton 6128 days ago | link | parent

Right, but I think the different approach to the splicing was sound and simpler for noobs:

  (def report-result (result form)
    (prn)
    (prn form)
    (prs '-> result)(prn)
    (prn))

  (mac check args
    `(do ,@(do (map (fn (test)
                    `(report-result ,test ',test)) args))))
I think I transliterated to the _ form accurately, but this commented out bit gives me an error from CAR.

;;; so why doesn't this work? ;;;(mac check args ;;; `(do ,@(do (map [`(report-result ,_ ',_)] args))))

Anyway, this then produces the expected results:

  (check
   (is (* 6 9) 42)
   (is (* 6 9) (coerce "42" 'int 13)))
The above should fail the first, pass the second, tho Adams denied knowing that was what he was going on about.


3 points by almkglor 6127 days ago | link

  [`(report-result ,_) ',_]
becomes:

  (fn (_) (`(report-result ,_) ',_))
If you notice, whenever a macro in arc.arc wants to use `(), it avoids using the [... _ ...] syntax for it.

-----

2 points by kennytilton 6127 days ago | link

Oops, that extra "do" wrapping just the map was left over from debugging the macro and can be chopped. Note to noobs: this is also a macro-writing tip to remember, one can put debugging print statements that run as a macro gets expanded to help debug and even learn how to write macros.

-----