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: Edgar Friendly <thelema314@g...>
Subject: Re: [Caml-list] OO programming
Andrej Bauer wrote:
> Keiko Nakata wrote:
>>>> As for extension, I'm fully satisfied. But the verbosity level is
>>>> annoying for scalability...
>>> Well, yes, that's always the problem with functors...
>>
>> Since there are some people (including me) who are interested in using
>> functors and recursive modules in the style of object-oriented
>> context, I thought that it could be useful to devise a (camlp4) syntax
>> extension which mitigates this a bit painful verbosity.
>> At the moment, I have no idea which syntax is general enough and
>> intuitive for us,
>> but as far as I understand we always follow similar encodings. 
> 
> I have three wishes related to the case when a functor accepts a
> structure that contains a single type or a single value:
> 
> 1) To be able to write
> 
>   module F(type t) = struct ...t... end
> 
> instead of
> 
>   module F(T : sig type t end) = struct ... T.t  ... end
> 
> and to write
> 
>   F(s)
> 
> instead of
> 
>   F(struct type t = s end)
> 
I wonder what use you would put this to where normal 'a polymorphism
wouldn't suffice.

> 2) Similarly for values, to be able to write
> 
>   module F(val x : t) = struct ... x ... end
> 
> instead of
> 
>   module F(T : sig val x : t end) = struct ... T.x ... end
> 
Similarly, an additional parameter on each of the contained functions
seems not too unreasonable.  I guess I can see more use for this than
#1, but a global ref inside F might also work, as long as you had a way
to set it and you had a good default.

E.