Hi,

Let me write some comments and suggestions. I added numbers, so you can refer 
to them easier. I understand that some of these requests are actually making 
the `concept` body a little bit longer. However, I believe that these will make 
Nim cleaner.

**1.**

_Suggestion:_ I think that the form `T = type(c[0])` should be used instead of 
the form `c[0] is T` when defining `T` inside concepts.

_Reasons_: My main reason is not to let `is` to modify its parameters, and let 
`c[0] is T` to be a pure type check with no side effects. (I'm not a big fan of 
`T = type(c[0])`, but I don't know a better solution.)

_Implementation_: I think that an extra check should be added to `semAsgn` proc 
in _semexpr.nim_ before it calls `localError` with `errXCannotBeAssignedTo` to 
enable `T = type(c[0])`.

**2.**

_Suggestion:_ I think that `put(m.bindings, p[1], p[0].typ)` should be replaced 
to something more careful and smarter logic at the end of `matchUserTypeClass`. 
Is it possible that we override an already matched generic parameter? Is the 
this example working now: `proc f[T](x: Container[seq[T]]): T = ...` (where `x` 
can be `seq[seq[int]]`)?

_Implementation_: `procParamTypeRel` calls `typeRel`, maybe we should copy that 
logic. The order of parameters of `typeRel` matters a lot :)

**3.**

_Suggestion:_ We should use `T` only for types, and not for default values. 
This code shouldn't work: `m.contains(K) is bool`.

_Reasons_: It might happen that `m.contains(...)` actually accepts a type (as 
well). Also it is not a valid code outside of a concept. I think that we should 
have functions to generate immutable instance (e.g., `default(T)`), and mutable 
instance (e.g., `defaultVar(T)`), so we won't need to wrtie `var k: K; 
m.contains(k) is bool`.

**4.**

I know that this is just an example. However in your `Map[K, V]` example `K` is 
not inferred, but why? Is it possible that an object is `Map[float, string]` 
and `Map[int, int]` as well? I would add `m.keysSeq()` (which is an important 
part of a map in my view), and it defines `K`.

Thanks,
    Peter

Reply via email to