> Now I'm stuck at a language design question, how to find out T in concept[T]

Congratulations. you're definitely on the right track! :) That's the tough nut. 
I have the following proposal, but I'm not sure it answers every one of your 
questions. The idea is that `concept[T, ...]` is always used for containers and 
thus the `T` should always be the container's element type. This means that 
concepts like `Comparable` cannot have a `T` since `int` is Comparable, but not 
a container.

Let's assume these definitions:
    
    
    type
      One[T] = concept
        ...
      Two[S, T] = concept
        ...
    

The body is not relevant, since the body is not used to infer `S` and `T`.

# Inferences rules

  1. A generic type `G[U]` matches `One[T]` and infers the `T`: `T <- U`
  2. A generic type `G[U, V]` matches `Two[S, T]` and infers the `T <- U` and 
`S <- V`.
  3. A generic type `G[U, ...]` matches `One[T]` with `T <- U`. The other 
generic parameters are ignored.
  4. `array` is a special case. `array[I, T]` matches `One[T]` ignoring the 
index type. (It matches a container of T)
  5. However, `array[I, U]` matches `Two[S, T]` with `S <- I` and `T <- U`. (It 
matches a container with key, value pairs)



After the inference rules, the concept body is checked and if that matches too, 
we have a match, otherwise we don't. 

Reply via email to