Difference Between Scala Features and C ++ Concepts

What is the difference between Scala features of a Haskell class type and C ++ 0x concepts?

Like in this example below, where the Observer declares the abstract members of receiveUpdate. The observer is actually an "anonymous" type or structural types.

package observer
trait Subject {
   type Observer = { def receiveUpdate(subject: Any) }
   private var observers = List[Observer]()
   def addObserver(observer:Observer) = observers ::= observer
   def notifyObservers = observers foreach (_.receiveUpdate(this))
}
+3
source share
1 answer
  • Concepts do not come to C ++ 0x, they were removed in the latest versions of the project specification.
  • , ( , "forall x , x ..." ) ad-hoc- ad-hoc.
  • , ++. ++.
  • - .

, - , , -. : ++ Haskell

+7

Source: https://habr.com/ru/post/1751460/


All Articles