[
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@m...> |
| Subject: | Re: [Caml-list] Recursive class+type definitions |
From: "Chris King" <colanderman@gmail.com>
> You can get the exact behavior you want using a pair of recursive
> modules (see the "Language Extensions" section of the manual), one for
> each of mypoint and mypointlist, but it's a lot more verbose (since
> recursive modules require you to explicity give their signatures).
I would think that one recursive module is sufficient.
Note also that, as this virtual class has no concrete methods, it
could just be defined as a class type (just means you can only use it
in interfaces and type annotations.) Then there is no code
duplication.
module rec Mypoint : sig
class type p =
object
method getx : float
method getlist : Mypoint.plist
end
type plist = Empty | Cons of (p * Mypoint.plist)
end = Mypoint
Jacques Garrigue