Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2004-02-05 (08:55)
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... 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.


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: