Skip to content

Instantly share code, notes, and snippets.

@apriori
Created December 10, 2012 21:05
Show Gist options
  • Save apriori/4253422 to your computer and use it in GitHub Desktop.
Save apriori/4253422 to your computer and use it in GitHub Desktop.
type
SMatrixNM*[M, N, T] = object
aij*: array[M, array[N, T]]
TMatrixNM*[M, N, T] = ref SMatrixNM[M, N, T]
TVector3*[T] = TVectorN[range[0..2], T]
proc newObj[T](): T =
result.new()
macro newBlub(e: expr): stmt =
let cs = callsite()
var slist = newNimNode(nnkStmtList)
var node = newNimNode(nnkCall)
var bracket = newNimNode(nnkBracketExpr)
bracket.add(newIdentNode("newObj"))
#Error: undeclared identifier: 'AnonType'
bracket.add(newIdentNode($cs[1].symbol))
node.add(bracket)
slist.add(node)
return slist
var
v1 = TVector3[float].newBlub()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment