I'm writing various macros that "wrap" objects with new methods and procedures.
aka
macro wrap_fancy*(n: typed): typed =
# blah blah put code here
# which creates:
# proc super_fancy_method(self: $1)
# proc other_thing_method(self: $1)
#...
type
Something = object of RootObj
a: string
b: string
wrap_fancy(Something)
var x = Something()
x.super_fancy_method()
It works great.
But, because these wrapping macros create lots of methods that might not be used later, the end users sees lots of:
lib/core/macros.nim(512, 6) Hint: example.other_thing_method(self: Something)[declared in lib/core/macros.nim(512, 5)]' is declared but not used [XDeclaredButNotUsed]
messages. I've tried wrapping the macro itself with {.hint[XDeclaredButNotUsed]: off.} pragmas, but that does not seem to work.
One could apply pragmas to each macro call, but that is a bit much to ask of the end-user programmer.
I could possibly try putting the macros in a outer macro so that the inner macro is automatically wrapped with pragmas. About to try that.
But before I start spelunking down that rabbit hole, I figured I'd ask: is there a best practice for this in general? Or should I just let the hints happen?