Browse thread
[Caml-list] Mutually recursive types and classes
-
Nick Name
- Olivier Andrieu
- brogoff@s...
- John Max Skaller
[
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: | Olivier Andrieu <andrieu@i...> |
| Subject: | Re: [Caml-list] Mutually recursive types and classes |
Nick Name [Thursday 19 June 2003] :
> Hi all,
>
> I wish to declare a type like
>
> type a = A of (b -> unit) | ...
>
> where b is a class like
>
> class b =
> object (this)
> method f : a -> unit =
> function
> A f -> f this
> | _ -> unit
> end
>
> or, alternatively:
>
> class b =
> object
> inherit [a] otherclass
> ...
> end
>
> How can I do such a thing, considering that I can't write an "and"
> keyword between a type declaration and a class (or class type)
> declaration?
You could add a type parameter in your definition of a :
type 'a a = A of ('a -> unit) | ...
and then
class b = object (this : 'a) method f : 'a a -> unit = ... end
or
class b = object method f : b a -> unit = ... end
and eventually redefine a :
type a = b a
--
Olivier
-------------------
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