Version française
Home     About     Download     Resources     Contact us    
Browse thread
OO programming
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Julien Signoles <Julien.Signoles@l...>
Subject: Re: [Caml-list] OO programming

>> Hence my question: does anyone knows a way of combining the reusability
>> of sets of related classes with a more modular (type/consistency)-checking ?
>
> I'm not sure whether it helps, but I attach here the same example of
> observer pattern as in the tutorial, but without using type
> parameters. They are replaced by private row types.
>
> Ideally, one would like to check coherence too by writing
>  module rec Check : S' = Window(Check)
> Unfortunately, this doesn't seem to work currently. I'm not yet sure
> whether this is a bug or a limitation of recursive modules.

As far as I understand the Jacques' code, the following check seems to 
work

===
module rec Check : sig
   type event = private [> `Move]
   type subject = private <draw: unit; ..>
   type observer = private < notify : Check.subject -> Check.event -> unit; .. >
end = struct
   include Window(Check)
   type event = Check.event
end
===

I don't know exactly why one has to write "Check.subject" and 
"Check.event" in the signature. The consequence is that the following 
code just does not work.

===
module rec Check : S' = struct
   include Window(Check)
   type event = Check.event
end
===

As Jacques said, it is either a bug or a limitation of recursive modules.
I don't know.

--
Julien