struct vs. class, int vs. char.
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Tue Apr 28 10:15:54 PDT 2009
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
More information about the Digitalmars-d
mailing list