Yes, the second example should work. This is just a generic proc accepting any 
kind of stack. Just like a regular generic proc, it will be instantiated once 
per every unique concrete type matching the `Stack` concept and within each 
instantiation the `T` parameter will be bound to the respective inferred type.

The ability to write generic procs over generic concepts is essential. Consider 
the possible collection of `Matrix` algorithms which I have outlined in the 
manual. Most of these algorithms work over any `Matrix` type.

You seem to have a slight misconception about the inference/matching process, 
but I'm not sure exactly where it lies. Why are you saying that a single type 
could implement both `Stack[int]` and `Stack[float]`? Let's consider a concrete 
type such as `seq[int]`. It does include the overload `x.push(int)`, but it 
doesn't include `x.push(string)`, so it can be adapted to match only the 
`Stack[int]` concept.

Perhaps careful study of this example from the suite may help:

[https://github.com/nim-lang/Nim/blob/generic-concepts/tests/concepts/tmapconcept.nim](https://github.com/nim-lang/Nim/blob/generic-concepts/tests/concepts/tmapconcept.nim)

Try to grok why `JudyArray` is `Map` and also `Map[int, int]`, but it's not 
`Map[string, int]`.

[https://en.wikipedia.org/wiki/Judy_array](https://en.wikipedia.org/wiki/Judy_array)

Reply via email to