Add `hash` function and equality operator `==` for custom key.
    
    
    import tables, hashes
    
    type
      Fn = proc (args: varargs[string]): int
      FnSignature = tuple
        name: string
        arity: int
        argTypes: seq[string]
    
    proc hash(fns: FnSignature): Hash = fns[0].hash
    proc `==`(a, b: FnSignature): bool = a[0] == b[0]
    
    var signatures = newTable[FnSignature, Fn]()
    
    signatures.add(("print", 1, @["any"])) do (args: varargs[string]) -> int:
      discard
    
    echo signatures[("print", 1, @["string"])]("whatev")
    
    
    Run

Reply via email to