I noticed that you can't put a concept in a generic.
    
    
    PluggableHashAlgorithmU64 = concept x
          x.open_default(self: var PluggableHashAlgorithmU64)
          # if you do this:
          # x.hash(self: PluggableHashAlgorithmU64; input: pointer; length: 
int): uint64
          # it will fail to build even though thats valid function syntax
          # XXX will have to bother upstream about this goofup
          x.hash(self: var PluggableHashAlgorithmU64, input: pointer, length: 
int) is uint64
          x.close(self: var PluggableHashAlgorithmU64)
       
       FakeHashMap[K,V:typedesc,H:PluggableHashAlgorithmU64] = object
          hash*: H
          
          dummy_key: K
          dummy_value: V
    
    
    Run

In version 2.0.0 you will get an error like this:
    
    
    Error: cannot instantiate FakeHashMap [type declared in 
/home/icedquinn/code/science-fusedhash/fused.nim(12, 4)]
    got: <typedesc[string], typedesc[int], typedesc[FakeBlake3]>
    but expected: <K, V, H: PluggableHashAlgorithmU64>
    
    
    Run

This is a little disappointing though I suppose not critical. Nim will 
thankfully let us call whatever on `H` and try to get away with it (especially 
with defensive `when compiles` to make those call hooks optional) but I thought 
I'd try out concepts.

(before anyone asks, what i was trying to do is fix the icedmaps module so it 
no longer relies on closures and lets you bake in the hash algorithm at compile 
time)

Reply via email to