Comment made by: alexmiller
So (like most things), obvious things aren't. :)
There are several ways to call instrument:
- (instrument)
- (instrument sym)
- (instrument (link: syms))
- (instrument sym opts)
- (instrument (link: syms) opts)
The number there is variable. Similarly, a "body" is typically also variadic in other with-style macros. Parsing those two variadic things is ambiguous.
You mentioned the opts map, so I'm assuming you'd want that as an option. So you could narrow the args to: (link: sym-or-syms opts & body). Not sure whether you've then introduced things you don't need in common cases and ruined the usefulness of the macro.
(with-instrument `my-fun {my-opts ...} (test-something))
would expand to
`
(do
(instrument user/my-fun {my-opts ...})
(try
(test-something)
(finally
(unstrument user/my-fun))))
`
There are maybe interesting things to think about with how much you take into account what's already instrumented. Do you unstrument what you instrument, or do you try to return the instrumentation to what it was before (where some stuff may already have been instrumented)?