From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id E1624BC48 for ; Sat, 9 Apr 2005 12:44:23 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j39AiNUe004867 for ; Sat, 9 Apr 2005 12:44:23 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA02687 for ; Sat, 9 Apr 2005 12:44:23 +0200 (MET DST) Received: from smtp004.mail.ukl.yahoo.com (smtp004.mail.ukl.yahoo.com [217.12.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with SMTP id j39AiMXq017761 for ; Sat, 9 Apr 2005 12:44:22 +0200 Received: from unknown (HELO ?82.121.159.29?) (sejourne?kevin@82.121.159.29 with plain) by smtp004.mail.ukl.yahoo.com with SMTP; 9 Apr 2005 10:44:22 -0000 Message-ID: <4257D06E.4070505@yahoo.fr> Date: Sat, 09 Apr 2005 12:54:06 +0000 From: sejourne_kevin User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: fr, en MIME-Version: 1.0 To: =?ISO-8859-1?Q?S=E9bastien_Hinderer?= Cc: caml-list@inria.fr Subject: Re: [Caml-list] Syntactic inclusion of a.ml in b.ml ? References: <20050408174142.GA1804@galois> In-Reply-To: <20050408174142.GA1804@galois> X-Enigmail-Version: 0.90.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Miltered: at concorde with ID 4257B207.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4257B206.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 gcc:01 ocamlc:01 ocamlc:01 -pp:01 lib:01 cpp:01 printf:01 printf:01 kwd:01 syntactic:01 define:01 define:01 caml:02 seems:03 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: Sébastien Hinderer a écrit : > Dear all, > > (How) is it possible to include syntactically a file a.ml in a file > b.ml ? > > One method that seems to w)rk is to rename b.ml to b.ml.c, > and then have in b.ml.c a line saying > #include "a.ml" > And with this, gcc -E b.ml.c > b.ml > produces a file that ocamlc can apparently handle. > > But is this considered a good solution, or is some better solution > available ? > > Many thanks in advance, > Sébastien. If you want to use a pre-processor, you can do things like that: (* ocamlc -pp /lib/cpp test.ml *) #define P(x) (fst x) (snd x) (fst x) #define S(x) (snd x) let x = ("world","hello");; Printf.printf "%s %s %s %s\n" S(x) P(x);; or use camlp4 for the use of include : http://caml.inria.fr/pub/docs/manual-ocaml/manual019.html#@manual.kwd167