Hi, How to access table outside of the module? I have some module and I want create dictionary storing an object and access outside of the module. I'm using Nim 0.11.3.
# testmodule.nim
import tables,hashes
var gId: int
type
PNode* = ref TNode
TNodeTable* = Table[PNode,PNode]
TNode = object
id* : int
nodes* : TNodeTable
proc hash(node: PNode): Hash =
result = node.id.hash
proc newNode* (): PNode =
new(result)
result.id = gId
result.nodes = initTable[PNode, PNode]()
inc gId
import testmodule
var node = newNode()
echo "Count of nodes" & $node.nodes.len
But I'm getting following error message:
Error: type mismatch: got (TNodeTable)
but expected one of:
system.len(x: TOpenArray)
system.len(x: string)
system.len(x: seq[T])
system.len(x: cstring)
system.len(x: array[I, T])
macros.len(n: NimNode)
Can anyone help me?
Thanks. That does it!
export tables
Also working.