Quick actions

cmd+k|ctrl+k

Navigation

Languages

Untitled

Snippet info

Language

Nim

Visibility

unlisted

Author

legacy-anonymous

Created

2017-04-08T14:49:51Z

Updated

2017-04-08T14:49:51Z

import macros

#[
Compare to the expresion newSeq[int](10), which is represented by the AST:
  StmtList
    Call
      BracketExpr
        Ident !"newSeq"
        Ident !"int"
      IntLit 10
]#

macro dseq(len : int) : untyped = 
  let procTyped = newNimNode(nnkBracketExpr).add(ident("newSeq")).add(ident("int"))
  result = newCall(procTyped, [len])

let a = dseq(10)
INFO