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 KAA06510; Mon, 15 Jul 2002 10:44:45 +0200 (MET DST) 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 KAA06443 for ; Mon, 15 Jul 2002 10:44:45 +0200 (MET DST) Received: from fichte.ai.univie.ac.at (fichte.ai.univie.ac.at [131.130.174.156]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g6F8iij02530 for ; Mon, 15 Jul 2002 10:44:44 +0200 (MET DST) Received: (from markus@localhost) by fichte.ai.univie.ac.at (8.9.3/8.9.3/Debian 8.9.3-21) id KAA31729; Mon, 15 Jul 2002 10:44:35 +0200 Date: Mon, 15 Jul 2002 10:44:35 +0200 From: Markus Mottl To: Nicolas FRANCOIS Cc: Caml List Subject: Re: [Caml-list] About modules again Message-ID: <20020715084435.GA31562@fichte.ai.univie.ac.at> Mail-Followup-To: Nicolas FRANCOIS , Caml List References: <20020715023542.56e961fa.nicolas.francois@free.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020715023542.56e961fa.nicolas.francois@free.fr> User-Agent: Mutt/1.4i Organization: Austrian Research Institute for Artificial Intelligence Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Mon, 15 Jul 2002, Nicolas FRANCOIS wrote: > (it's an Euclidian Ring, but that's not the point). So you see my problem > : I have to define a concrete method in an abstract module, just not to > have to fill the definition for every new Ring I define. > > Is there a way to do this ? Or is this specific to objects ? This is the point where higher-order modules (functors) enter the game. If you have some common functionality that is shared across all rings, you can factor it out in a functor body. E.g.: module MakeRing (Spec : RING_SPEC) : RING = struct include Spec (* All common stuff follows here *) end Module "Spec" should adhere to a signature "RING_SPEC", the latter specifying what is different or at least parameterizable for each ring. Applying the functor to such a specification yields a module that implements the signature RING, e.g.: module Ring_Z = MakeRing (Ring_Z_Spec) The specification of rings over Z (Ring_Z_Spec) may itself be the result of a functor application. This way you can highly modularize the creation of algebraic structures. Btw., you'd surely get into troubles using OO here. It is not very suitable for such purposes, because it lacks expressiveness if you want to specify interaction of several types (sorts) at an abstract level. Regards, Markus Mottl -- Markus Mottl markus@oefai.at Austrian Research Institute for Artificial Intelligence http://www.oefai.at/~markus ------------------- 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