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 XAA14729; Wed, 12 Jun 2002 23:31:11 +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 XAA14672 for ; Wed, 12 Jun 2002 23:31:10 +0200 (MET DST) Received: from web13407.mail.yahoo.com (web13407.mail.yahoo.com [216.136.175.65]) by concorde.inria.fr (8.11.1/8.11.1) with SMTP id g5CLV9b19249 for ; Wed, 12 Jun 2002 23:31:09 +0200 (MET DST) Message-ID: <20020612213108.88273.qmail@web13407.mail.yahoo.com> Received: from [63.195.80.23] by web13407.mail.yahoo.com via HTTP; Wed, 12 Jun 2002 14:31:08 PDT Date: Wed, 12 Jun 2002 14:31:08 -0700 (PDT) From: Brian Naylor Subject: [Caml-list] double-functors for types and values To: caml-list@inria.fr MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk It frequently happens that I have a module/functor A parameterized by module B, but B depends on types that are part of A. Those types of A in turn depend on the types of B. Wow, I've confused myself already. Let me try to make this clearer: let A.avalue = ... B.bvalue ... val B.bvalue : ... A.atype ... type A.atype = ... B.btype ... This results in the following kind of double-functor, one functor for the types and the second internal functor for the values: module A = struct module Types (B_types : sig type btype end) = struct type atype = ... B_types.btype ... module Values (B_values : sig val bvalue : ... atype ... end) = struct let avalue = ... B_values.bvalue ... end end end module B = struct type btype = ... module A_types = A.Types (struct type btype = B.btype end) let bvalue = ... module A_values = A_types.Values (struct let bvalue = B.bvalue end) let _ = ... A_values.avalue ... end So, my questions are: (1) is this a normal way of structuring this kind of thing? I know I could use polymorphic types instead of trying to make it work in the module system, but I like the idea that all my types are made explicit. (2) do I pay a run-time cost for functor applications that only contain types? In other words, does A_values.avalue suffer a double indirection since it is buried two functors deep? Or do you only pay the indirection cost for values that are passed across functorial boundaries? __________________________________________________ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com ------------------- 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