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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <garrigue@k...>
Subject: Re: [Caml-list] Polymorphic methods and ellipsis
From: Alessandro Baretta <alex@baretta.com>
> At any rate, why does my technique not work?
> 
> class salutation : object
>    method greet : 'a. (#parent as 'a) -> string
> end = object
>    method greet obj -> obj # foo ^ obj # bar
> end

You can see the above (and it is more or less type the same way) as

class salutation0 = object
   method greet obj -> obj # foo ^ obj # bar
end

class salutation : object
   method greet : 'a. (#parent as 'a) -> string
end = salutation0

So you see that your constraint is applied too late: salutation0
itself is not typable.
I though at some time of attempting to make this work, since something
like that is already done for recursive functions for instance, but
that's not regular. In fact, you would probably end up wanting to
write the implementation in the .ml and the interface in the .mli, and
this would not work anyway.
So, there is a deep problem about which constraints apply
where. The examples in the tutorial give you the way to do that
without ambiguity.

        Jacques
-------------------
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