Recently, a thread starting with a simple question went OT and became a 
different exchange starting [here](https://forum.nim-lang.org/t/3128/2#19739). 
The short version:

"Methods (inheritance based dispatch) and concepts (user defined type classes 
with VTable based dispatch) are two solutions to the same problem and we don't 
really need both."

"But wait, there's a difference between the two: with inheritance, the author 
of a derived type explicitly refers to the base type. That's probably a 
conscious commitment to a contract of some kind. With a concept, the definition 
of a matching type doesn't even mention the concept. So the match could be 
coincidence and there's no commitment to a behavioral contract."

Two questions about this:

  * Is this difference important enough to care about it?
  * If it is (as I think), could there be a kind of concept which provides such 
a contract commitment by the matching type?



The latter could look something like this: 
    
    
    type
      MyConcept = explicit concept m
      # the optional "explicit" means: only concrete types defined with 
"satisfies"
      # match.
        ...
      
      MyType = object of BaseType satisfies MyConcept
      # the optional "satisfies" means: I am consciously claiming to be a 
MyConcept
      # and I satisfy its contract.
        ...
    

If this makes any sense: should it be part of the language spec or implemented 
as a macro?

Reply via email to