Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] functors and objects
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Damien <Damien.Pous@e...>
Subject: Re: [Caml-list] functors and objects
On Wed, 04 Feb 2004 11:57:45 +0900 Jacques Garrigue wrote:

> The closest I can see to what you ask for is
> 
> module type O = sig
>   type t
>   val as_o : t -> o
> end
> ...
> 
> This isn't a problem of soundness.
> There is just no such thing as a "partially abstract" object type.
there is no such thing...
...in the type system or in the compiler ?

Sorry for mixing variants and objects again, 
but I have got the feeling that since the example I posted with variants
works, the first example with objects could/should work :
It seems quite natural and reasonable. So why should it be rejected...

I don't really see what can prevent the compiler to do it.
It looks like an additional check in the type checker,
and almost nothing in the compiler
(that's just a feeling, I never looked at ocamlc sources...)

> But as shown above, you can easily simulate it by coupling an abstract
> type with a coercion to an object type.
still curious : are such "coercion identity functions" eliminated by the
compiler ?
 
> Note however that it would be probably simpler to turn your functors
> into parameterized classes: then you can specify constraints on the
> parameters with #-types.
yes, the project is currently written with classes like
['reactor] obj 
['obj] reactor

I was just wondering whether the  class "reactor"
could be translated into a module, since it is instantiated only once.

cheers,
damien

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners