Here's a simple concept and a function that makes use of the concept methods, which doesn't compile: type Eq* = concept x, y eq(x, y) is bool ne(x, y) is bool func is_symmetric*(x, y: Eq): bool = eq(x, y) == eq(y, x) func eq*(x, y: int): bool = x == y func ne*(x, y: int): bool = x != y assert int is Eq assert eq(3, 3) assert is_symmetric(3, 4) Run
Changing the order to this does allow it to compile: type Eq* = concept x, y eq(x, y) is bool ne(x, y) is bool func eq*(x, y: int): bool = x == y func ne*(x, y: int): bool = x != y func is_symmetric*(x, y: Eq): bool = eq(x, y) == eq(y, x) assert int is Eq assert eq(3, 3) assert is_symmetric(3, 4) Run I think this prevents me from placing the `eq/ne` implementations for various types into separate files that import the file defining the concept? Do all types that implement the concept have to be in the same file as the concept, defined before any generic functions that use the concept methods in a type independent way?