> In conjunction with tables module having default hash function implementation 
> is a bad idea. For hash-table consistency keys should be immutable, so that 
> their hashes do not change over the lifespan of the key objects.

We already have this situation with the default hash implementations in the 
[hashes](https://nim-lang.org/docs/hashes.html) module: 
    
    
    import tables
    
    var t = Table[seq[int], int]()
    
    var key = @[1, 2, 3]
    t[key] = 3
    echo t[key]
    key.add(4)
    echo t[key]
    
    
    Run

<https://play.nim-lang.org/#ix=2xsB>

resulting in 
    
    
    3
    /usercode/in.nim(9)      in
    /playground/nim/lib/pure/collections/tables.nim(262) []
    Error: unhandled exception: key not found: @[1, 2, 3, 4] [KeyError]
    
    
    Run

Client code is responsible for not changing keys.

Reply via email to