Browse thread
[Caml-list] Polymorphic method problem
-
szegedy@t...
- Alex Baretta
- Olivier Andrieu
- Jacques GARRIGUE
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jacques GARRIGUE <garrigue@k...> |
| Subject: | Re: [Caml-list] Polymorphic method problem |
From: szegedy@t-online.de (Christian Szegedy)
> Can anyone tell me, why does the following piece of
> code fail to compile, and how can I achieve
> equivalent effect in the most convenient way?
>
> class a () =
> object(self)
> method f : 'a. ((< f : unit; .. > as 'a) -> unit) = fun other ->
> other#f
> method g = (self :> a)
> end
There was a bug in the subtyping algorithm.
Hopefully, it's now fixed in CVS.
A workaround at the source level is to define your type in advance:
class type ta = object
method f : <f : unit; ..> -> unit
method g : ta
end
class a () =
object(self : #ta)
method f other = other#f
method g = (self :> ta)
end
Jacques Garrigue
-------------------
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