From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id 641037F1BA for ; Sun, 18 Nov 2012 10:33:03 +0100 (CET) Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of gabriel.scherer@gmail.com) identity=pra; client-ip=209.85.223.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail4-smtp-sop.national.inria.fr: domain of gabriel.scherer@gmail.com designates 209.85.223.182 as permitted sender) identity=mailfrom; client-ip=209.85.223.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-ie0-f182.google.com) identity=helo; client-ip=209.85.223.182; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="postmaster@mail-ie0-f182.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqgBAHSqqFDRVd+2mGdsb2JhbABEsBuTDAgjAQEBAQEICQ0HFCeCHgEBBAFAARsSCwEDAQsGBQsNDSEiAREBBQEKEgYTEodoAQMJBguhR4wzgniDdAoZJwMKWYh1AQUMjCiFDQOVfIEcjUYWKYQS X-IronPort-AV: E=Sophos;i="4.83,273,1352070000"; d="scan'208,217";a="162883210" Received: from mail-ie0-f182.google.com ([209.85.223.182]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 18 Nov 2012 10:33:02 +0100 Received: by mail-ie0-f182.google.com with SMTP id k10so9714810iea.27 for ; Sun, 18 Nov 2012 01:33:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=igqCkQ5MvUQduTkXbenx/Q5Ya1M1Z1eEGs45nHLEaTo=; b=M6Xc6IXCfPY9bnVL7TuF2EzwU+C7rfNH8G2zyICaa5nk4BZWXjPPLvdjJRwJAHed9e qAvH2TgpRteV9NoSdexVG9Hs74/1AEewR6ziPt+ZoB1xhkwJZv6z9XNxXtwlh5+d79jo wGKnqT1LrtDbm1JDJMI5EyXr/G2w/ihNIGFOSuW0LEAiN5wTC5Iyyn9jmj7pWiQkUYFd PhJ3u21RyGUrZd4TB7D3t4/YraV1Cj+1nmEwnRKF/mwf2t9uEUYfG3tmRvwDKjM/gn8u pTgP9vrEaMxUP8qRjOc5rVewHjKKpGctfkn/lBWPzAJC7jbpyTKJqOy+71oYOepfgkf4 qL6w== Received: by 10.50.180.133 with SMTP id do5mr3829665igc.2.1353231180943; Sun, 18 Nov 2012 01:33:00 -0800 (PST) MIME-Version: 1.0 Received: by 10.50.184.199 with HTTP; Sun, 18 Nov 2012 01:32:20 -0800 (PST) In-Reply-To: <1353225703782@names.co.uk> References: <1353225703782@names.co.uk> From: Gabriel Scherer Date: Sun, 18 Nov 2012 10:32:20 +0100 Message-ID: To: "\"Mark\"" Cc: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Caml-list] Some questions about building OCaml programs Hi, The short answer is that you should compile your files and use #load "file.cmo";;, rather than directly #use "file.ml" which has a different, less modular semantics. The long answer is part of this discussion of two weeks ago, started by someone with essentially the same question: https://sympa.inria.fr/sympa/arc/caml-list/2012-11/msg00024.html On Sun, Nov 18, 2012 at 9:01 AM, "Mark" wrote: > Hi, > > I've got a series of interrelated questions about alternatives and > what appear to be limitations in building OCaml programs. I hope you > don't mind me packaging these together into one thread. > > I am writing a program that runs in the OCaml toplevel, implemented as > a series of modules. Each module has a .mli source code file for its > interface and a .ml source code file for its body. > > I would like to be able to do both of the following: > A. Process the program interactively in the toplevel (using #use > directives); > B. Build the program into an extended toplevel (using 'ocamlc' to > create .cmi and .cmo files, followed by 'ocamlmktop'). > > QUESTION 1 > > It seems that for A, each .mli file must have "outer module syntax", > e.g. something like: > "module type = sig end" > and each .ml file must have something like: > "module : = struct end". > > And it seems that for B, 'ocamlc' requires each .mli file not to have > the outer syntax, i.e. to be of the form: > "" > and similarly each .ml file to be of the form: > "". > > Am I correct? If so, why can't 'ocamlc' deal with the form for files > acceptable for A? Wouldn't it be better to have the option of > 'ocamlc' allowing the syntax required for A? > > QUESTION 2 > > This is just about A. I want to have a file "main.ml" which has #use > directives for all the module files, and to call "main.ml" itself > using a #use directive. It seems that a #use directive fails if there > is an error in the given source code file, but not if the source code > file itself contains #use directives (like my "main.ml") that fail. > Why is this? Wouldn't it be better all failures bubbled to the top? > > QUESTION 3 > > This is just about B. It seems the 'ocamlmktop' command will only > incorporate what are, ultimately, modules into the toplevel. Am I > correct? Why can't it also incorporate directives and top level > definitions? > > QUESTION 4 > > The 'ocaml' command can be called without a file argument, in which > case a toplevel interactive session is started. It can also be called > with a source code file argument, in which case the source code file > is processed through the toplevel and then the session is terminated. > Is there a way to process a file but then not terminate and instead > enter an interactive toplevel session (with the source code file > incorporated)? > > Mark. > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs