Re: Nim macro help
In `createSlide`, you have 2 arguments with type varargs[string], because you put a comma after `title`. Also `body.sons` is not defined. import macros proc createSlide(title: string, body: varargs[string]): NimNode = result = newEmptyNode() echo "createSlide", title, body proc slideDslImpl(head, body: NimNode): NimNode = if body.kind == nnkIdent: var args: seq[string] for n in body: if n.kind == nnkStrLit: args.add n.strVal result = createSlide(body.strVal, args) macro slide*(head, body: untyped): untyped = result = slideDslImpl(head, body) echo result.treeRepr # let us inspect the result Run Documentation of the macros module: [https://nim-lang.org/docs/macros.html](https://nim-lang.org/docs/macros.html)
Re: Nim macro help
`import macros`
Nim macro help
Hi, I'm very noob with macros, I'm trying to learn, but I'm getting this error: undeclared field: 'kind' for type system.NimNode proc createSlide(title, body: varargs[string]) = echo "createSlide", title, body proc slideDslImpl(head, body: NimNode): NimNode = if body.kind == nnkIdent: var args: seq[string] for n in body.sons: if n.kind == nnkStrLit: args.add n.strVal result = createSlide(body.strVal, args) macro slide*(head, body: untyped): untyped = result = slideDslImpl(head, body) echo result.treeRepr # let us inspect the result Run