bearophile wrote:
Yes, this is a problem of D2. Scala language shows that there are
better ways to design types, as you say.
Could you please give a little more detail?
And speaking of Scala, after having watched a presentation, I was left
with the impression that traits are nothing but classes with
parameterized base.
I mean this:
abstract class Person {
def schedule:Schedule
}
trait Student extends Person {
private var classSchedule:Schedule = ...
override def schedule = classSchedule
def learn() = {...}
}
trait Worker extends Person {
private var workSchedule:Schedule = ...
override def schedule = workSchedule
def work() = {...}
}
class CollegeStudent(school:School, company:Company) extends Student
with Worker {
// ...
}
is really this (in Scala-D made-up language):
abstract class Person {
def schedule:Schedule
}
class Student(Base) extends Person {
private var classSchedule:Schedule = ...
override def schedule = classSchedule
def learn() = {...}
}
class Worker(Base) extends Person {
private var workSchedule:Schedule = ...
override def schedule = workSchedule
def work() = {...}
}
class CollegeStudent(school:School, company:Company) extends
Worker!(Student!(CollegeStudent)) {
// ...
}
Is that correct?
Andrei