• 0 Posts
  • 1 Comment
Joined 1 year ago
cake
Cake day: October 21st, 2023

help-circle
  • tdrhq@alien.topBtoLispFighting with nested backquotes
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    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 ...))