(I'm deleting an old topic, because my assumptions were wrong.) Can anyone 
point me to the latest guidance on using concepts? I believe the documentation 
in the manual is out of date. The best guidance I've found is in this RFC: 
<https://github.com/nim-lang/RFCs/issues/168>

However, I've having some issues implementing the ideas described there. For 
example, suppose I have these concepts:
    
    
    type
        Addable = concept
          proc `+`(x, y: Self): Self
        
        Coll[T] = concept
            iterator items(x: Self): T
        
        AddableColl[T] = concept
            iterator items(x: Self): T
            proc `+`(x, y: T): T
    
    
    Run

In this case, the following works:
    
    
    proc sum[T: Addable](nums: Coll[T]): T =
        for num in nums.items:
            result += num
    
    echo @[0, 1, 2].sum
    
    
    Run

But the following fails, and I'm not sure why:
    
    
    proc sum[T](nums: AddableColl[T]): T =
        for num in nums.items:
            result += num
    
    echo @[0, 1, 2].sum
    
    
    Run

Any help with understanding the second example, as well as the general state of 
concepts, would be much appreciated. Thanks.

Reply via email to