Skip to content

Instantly share code, notes, and snippets.

@mratsim
Created April 20, 2017 11:23
Show Gist options
  • Save mratsim/6df3846b88346877d3f8fb60ecdd579b to your computer and use it in GitHub Desktop.
Save mratsim/6df3846b88346877d3f8fb60ecdd579b to your computer and use it in GitHub Desktop.
Type checking a "Context" with Nim compiler
type
Context*[T] = ref object
nodes: seq[T]
Variable*[T; C: static[Context[T]]] = object
tape: Context[T]
index: int
value: T
proc newContext*[T]: Context[T] {.noSideEffect.} =
new result
result.nodes = newSeq[T]()
let a = newContext[float32]()
let b = newContext[float32]()
echo a == b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment