Selftype: an idea from Scala for D2.0
Jari-Matti Mäkelä
jmjmak at utu.fi.invalid
Sat May 26 03:28:27 PDT 2007
eao197 wrote:
> On Sat, 26 May 2007 00:30:11 +0400, Jari-Matti Mäkelä
> <jmjmak at utu.fi.invalid> wrote:
>
>>> abstract class SubjectObserver {
>>> type S <: Subject;
>>> type O <: Observer;
>>> abstract class Subject requires S { /* (1) */
>>> private var observers: List[O] List();
>>> def subscribe(obs: O) /* (2) */
>>> observers obs :: observers;
>>> def publish for (val obs <observers)
>>> obs.notify(this); /* (3) */
>>> }
>>>
>>> abstract class Observer {
>>> def notify(sub: S): unit; /* (4) */
>>> }
>>> }
>> Can you show how this would work if there were multiple subclasses
>> of 'Subject' and 'Observer'? (for example multiple sensor types in the
>> SensorReader example) Does it require language support for multiple
>> dispatch then?
>
> Do you what [sic] to see Scala example?
Yes, please :)
More information about the Digitalmars-d
mailing list