From: Jacques GARRIGUE <garrigue@math.nagoya-u.ac.jp>
To: colanderman@gmail.com
Cc: rajb@rice.edu, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Recursive class+type definitions
Date: Mon, 16 Jul 2007 18:00:46 +0900 (JST) [thread overview]
Message-ID: <20070716.180046.194240538.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <875c7e070707151927t529c3e2anb2dc9a5c5bf634fe@mail.gmail.com>
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
prev parent reply other threads:[~2007-07-16 9:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-16 1:29 Raj B
2007-07-16 2:00 ` [Caml-list] " Jon Harrop
2007-07-16 2:27 ` Chris King
2007-07-16 9:00 ` Jacques GARRIGUE [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070716.180046.194240538.garrigue@math.nagoya-u.ac.jp \
--to=garrigue@math.nagoya-u.ac.jp \
--cc=caml-list@yquem.inria.fr \
--cc=colanderman@gmail.com \
--cc=rajb@rice.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).