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 BABC77F249 for ; Mon, 5 Nov 2012 03:31:03 +0100 (CET) Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of henry@pps.univ-paris-diderot.fr) identity=pra; client-ip=194.254.61.138; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="henry@pps.univ-paris-diderot.fr"; x-sender="henry@pps.univ-paris-diderot.fr"; x-conformance=sidf_compatible Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of henry@pps.univ-paris-diderot.fr) identity=mailfrom; client-ip=194.254.61.138; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="henry@pps.univ-paris-diderot.fr"; x-sender="henry@pps.univ-paris-diderot.fr"; x-conformance=sidf_compatible Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@korolev.univ-paris7.fr) identity=helo; client-ip=194.254.61.138; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="henry@pps.univ-paris-diderot.fr"; x-sender="postmaster@korolev.univ-paris7.fr"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvIDAF8kl1DC/j2KgWdsb2JhbABEi2u3TSMBARYmJ4IeAQEEAScLAUYFCwsOJgERPBsGiBcKuHeRXGEDjnuBIYVeAYEckhg X-IronPort-AV: E=Sophos;i="4.80,712,1344204000"; d="ml'?scan'208";a="161350178" Received: from korolev.univ-paris7.fr ([194.254.61.138]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 05 Nov 2012 03:31:02 +0100 Received: from mailhub.math.univ-paris-diderot.fr (mailhub.math.univ-paris-diderot.fr [81.194.30.253]) by korolev.univ-paris7.fr (8.14.4/8.14.4/relay1/38117) with ESMTP id qA52V1KX008172; Mon, 5 Nov 2012 03:31:01 +0100 Received: from mailhub.math.univ-paris-diderot.fr (localhost [127.0.0.1]) by mailhub.math.univ-paris-diderot.fr (Postfix) with ESMTP id C859A1A171C; Mon, 5 Nov 2012 03:31:01 +0100 (CET) X-Virus-Scanned: amavisd-new at math.univ-paris-diderot.fr Received: from mailhub.math.univ-paris-diderot.fr ([127.0.0.1]) by mailhub.math.univ-paris-diderot.fr (mailhub.math.univ-paris-diderot.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GkYU5ZK4nUxW; Mon, 5 Nov 2012 03:30:56 +0100 (CET) Received: from melquiades.local (abo-30-238-68.guy.modulonet.fr [85.68.238.30]) (Authenticated sender: henry) by mailhub.math.univ-paris-diderot.fr (Postfix) with ESMTPSA id 508EE1A170C; Mon, 5 Nov 2012 03:30:56 +0100 (CET) Received: from greg by melquiades.local with local (Exim 4.80) (envelope-from ) id 1TVCSl-00073g-8U; Mon, 05 Nov 2012 03:30:55 +0100 Date: Mon, 5 Nov 2012 03:30:55 +0100 From: =?iso-8859-1?Q?Gr=E9goire?= Henry To: Gerd Stolpmann Cc: Alain Coste , caml-list@inria.fr Message-ID: <20121105023055.GA26666@mlqds.hnr.gr> References: <720307009FD94454BF0EDC318177AA0D@Ganymede> <1351958190.8536.17@samsung> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="M9NhX3UHpAaciwkO" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1351958190.8536.17@samsung> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.7 (korolev.univ-paris7.fr [194.254.61.138]); Mon, 05 Nov 2012 03:31:01 +0100 (CET) X-Validation-by: henry@pps.univ-paris-diderot.fr Subject: Re: [Caml-list] Why are modules handled differently by the interpreter and the compiler --M9NhX3UHpAaciwkO Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit > What could be implemented as an extension is a #use_as_module > directive that adds the implicit module. This could be in deed > useful for debugging, especially when it overlooks the mli file if > present - if you #load, the definition hiding of the mli file takes > place, and you cannot see unexported definitions anymore. Of course, > this is sometimes in the way when you test things out. > > Now that compiler-libs is installed this extension could probably > even be implemented outside the compiler. Anyone up for it? Well, here it is: $ ocamlmktop -o myocaml mod_use.ml $ cat test.ml let x = 53 $ ./myocaml OCaml version 4.00.1 # #mod_use "test.ml";; module Test : sig val x : int end # Test.x;; - : int = 53 Regards, Grégoire --M9NhX3UHpAaciwkO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="mod_use.ml" open Parsetree let filter_out_directives lb = List.concat (List.map (function | Ptop_def s -> s | Ptop_dir _ -> []) lb) let parse_mod_use_file parse_use_file name lb = let modname = String.capitalize (Filename.chop_extension (Filename.basename name)) in let items = filter_out_directives (parse_use_file lb) in [ Ptop_def [{pstr_desc = Pstr_module ( Location.mknoloc modname , { pmod_desc = Pmod_structure items; pmod_loc = Location.none } ); pstr_loc = Location.none }] ] let dir_mod_use name = let parse_use_file = !Toploop.parse_use_file in Toploop.parse_use_file := parse_mod_use_file parse_use_file name; ignore (Toploop.use_file Format.std_formatter name); Toploop.parse_use_file := parse_use_file let () = Hashtbl.add Toploop.directive_table "mod_use" (Toploop.Directive_string dir_mod_use) --M9NhX3UHpAaciwkO--