Skip to content

Instantly share code, notes, and snippets.

@idlewan
Created January 15, 2014 19:12
Show Gist options
  • Save idlewan/7d84e797aef10fd14bd3 to your computer and use it in GitHub Desktop.
Save idlewan/7d84e797aef10fd14bd3 to your computer and use it in GitHub Desktop.
Can I get information on previously-declared types thanks to a macro?
type TBla = tuple[a: string, b: int]
macro inspect_tuple(node: expr): seq[string] =
# can I get to know that the tuple type has 'a' and 'b' as fields?
macro stuff(n: expr): stmt =
var fields = inspect_tuple(n)
stuff(TBla)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment