Thanks for the feedback (corrected `get(c,0)` and yes, no equality for 
typedescs).

This doesn't look like an easy task (summary: concepts are not working, the 
documentation is outdated, and it is likely the most misunderstood language 
feature). Currently I'm working on a tool which will make the debugging easier.

By the way, a couple of quick questions. If `get(c,int)` is not valid, then is 
there a way to ask for a variable with the given type and with the default 
value inline? This is the best I have: `get(c, newSeq[int](1)[0])` (in this 
form you can replace `int` with `T`).

My other question: should the following code work? (However, it is not a good 
practice) 
    
    
    type Container[T] = concept c
      get(c, 0) is T
    
    # We create this "get" function for seq[T],
    # therefore seq[int] is a Container
    proc get[T](c: seq[T], i: int): T = c[i]
    
    # Sum the elements
    proc sum[T](x: Container[T]): T =
      for i in 0..<x.len:
        result += get(i, 0)
    
    # Use "sum" on a seq[int]
    echo sum(@[10,11,12])
    

Here nobody guarantees that `x.len` is implemented and `T+T` is valid (and `+` 
would fail for `seq[string]`). However, it should work, right? This feels like 
python's duck typing, and Rust wouldn't allow this (there you need to specify 
everything which you want to do with the template).

Reply via email to