Interfaces with structs...?

Era Scarecrow rtcvb32 at yahoo.com
Thu Jul 5 11:17:24 PDT 2012


  Something that was coming to mind a while back was that classes 
can include interfaces while structs cannot. I can understand 
easily why this wouldn't work being much lower level compared to 
how classes are (And the vast varying of parameters and return 
types).

  But could the notation be allowed for more documentation 
purposes? Or more for contract debugging? Course it would only 
work with templates since that's how the constraints work...

  Example:

  struct something : isForwardRange
  {}

  I would think the equivalent would be a simple conversion to a 
unittest code:

  struct something{}

  unittest {
   assert(isForwardRange(something), "Fails to satisfy 
'isForwardRange' template!");
  }

  Now this is just a thrown out thought/idea, but curiously I 
don't think it would change much semantically... would it?


More information about the Digitalmars-d-learn mailing list