From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id VAA17989; Sun, 23 Mar 2003 21:01:18 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id VAA18212 for ; Sun, 23 Mar 2003 21:01:17 +0100 (MET) Received: from mx12.arcor-online.net (mx12.arcor-online.net [151.189.8.88]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h2NK1Gf19709 for ; Sun, 23 Mar 2003 21:01:16 +0100 (MET) Received: from lindig.dyndns.org (dialin-145-254-151-075.arcor-ip.net [145.254.151.75]) by mx12.arcor-online.net (Postfix) with ESMTP id 9237E10B129 for ; Sun, 23 Mar 2003 21:01:12 +0100 (CET) Received: by lindig.dyndns.org (Postfix, from userid 1002) id 31CD04991; Sun, 23 Mar 2003 10:58:41 +0100 (CET) Date: Sun, 23 Mar 2003 10:58:41 +0100 From: Christian Lindig To: Caml Mailing List Subject: Re: [Caml-list] code duplication when abstracting using explicit signatures Message-ID: <20030323095841.GA709@eecs.harvard.edu> Mail-Followup-To: Christian Lindig , Caml Mailing List References: <20030322120710.GA16956@roke.freak> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="BOKacYhQ+x31HxR3" Content-Disposition: inline In-Reply-To: X-No-Archive: yes X-URL: http://www.eecs.harvard.edu/~lindig/ User-Agent: Mutt/1.5.3i X-Spam: no; 0.00; lindig:01 caml-list:01 brogoff:01 michal:01 moskal:01 mli:01 afair:01 noweb:01 foo:01 chunks:01 speakeasy:01 literate:01 referenced:02 signatures:02 concrete:02 X-Attachments: type="application/pgp-signature" Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk --BOKacYhQ+x31HxR3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Mar 22, 2003 at 04:52:13PM -0800, brogoff@speakeasy.net wrote: > On Sat, 22 Mar 2003, Michal Moskal wrote: > > Use example_types.mli and example.ml/mli. AFAIR you can only put types > > in example_types, not even exceptions. >=20 > And making that example_types.ml instead of .mli will allow exceptions (a= nd=20 > values!), but I'd prefer having a pure .mli file as you suggest, and just= =20 > creating a fourth file example_exns.ml for any example exceptions.=20 Just for completeness, here is another trick: when you are using a literate programming tool like NoWEB you can let it do the code duplication: the file foo.nw contains both interface and implementation as named chunks, plus some documentation. A named chunk <> that contains code shared between interface and implementation can be referenced from both. When foo.mli and foo.ml are extracted from foo.nw for compilation, all references are resolved and the shared code shows up in both. <>=3D type foo =3D (* large, shared concrete type *) <>=3D <> (* other abstract types, function signatures *) <>=3D <> (* rest of implementation *) @ In comparison, this approach goes the opposite way: instead of having more source files, have just one *.nw file that allows internal references for code chunks. -- Christian --=20 Christian Lindig http://www.eecs.harvard.edu/~lindig/ --BOKacYhQ+x31HxR3 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (GNU/Linux) iD8DBQE+fYVQlBiMgzy5BH0RAj2qAJ46cdqF3w3rbaI/clJK+XmqvXmsnQCeLjl7 mRZ3+9RdaoWXMr0gsQ294tg= =bBiJ -----END PGP SIGNATURE----- --BOKacYhQ+x31HxR3-- ------------------- 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