Try not to fight so much with macros. I see what you’re trying to do, but it might be better to just bind a list or array of ports, instead of binding port{1-n}.
If you agree to use an array for binding, then you can use https://github.com/tdrhq/easy-macros to write this macro without using any backquotes at all. The macro definition would look something like:
(def-easy-macro with-free-ports (start end &binding ports &fn fn)
(unwind-protect
(fn (... construct listor array of ports ...))
(cleanup #| this cleanup is probably the reason you're using macros in the first place |#)))
And you’ll call it as:
(with-free-ports (10002000 port)
(... do something with port ...))
Try not to fight so much with macros. I see what you’re trying to do, but it might be better to just bind a list or array of ports, instead of binding port{1-n}.
If you agree to use an array for binding, then you can use https://github.com/tdrhq/easy-macros to write this macro without using any backquotes at all. The macro definition would look something like:
(def-easy-macro with-free-ports (start end &binding ports &fn fn) (unwind-protect (fn (... construct list or array of ports ...)) (cleanup #| this cleanup is probably the reason you're using macros in the first place |#)))
And you’ll call it as:
(with-free-ports (1000 2000 port) (... do something with port ...))