From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by c5ff346549e7 (Postfix) with ESMTPS id 735305D4 for ; Fri, 22 May 2020 05:51:28 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.73,420,1583190000"; d="scan'208";a="450865432" Received: from prod-listesu18.inria.fr (HELO sympa.inria.fr) ([128.93.162.160]) by mail2-relais-roc.national.inria.fr with ESMTP; 22 May 2020 07:51:27 +0200 Received: by sympa.inria.fr (Postfix, from userid 20132) id F1A1DE1E7D; Fri, 22 May 2020 07:51:26 +0200 (CEST) Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 3CCC4E1E7D for ; Fri, 22 May 2020 07:51:21 +0200 (CEST) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=asai@is.ocha.ac.jp; spf=Pass smtp.mailfrom=asai@is.ocha.ac.jp; spf=None smtp.helo=postmaster@web.is.ocha.ac.jp IronPort-PHdr: =?us-ascii?q?9a23=3AkmtPAB36rLsXjDOesmDT+DRfVm0co7zxezQtwd8Z?= =?us-ascii?q?seIVIvad9pjvdHbS+e9qxAeQG9mCtrQd0rCd4v6ocFdDyK7JiGoFfp1IWk1Nou?= =?us-ascii?q?QttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXdrXKo8DEdBAj0OxZr?= =?us-ascii?q?KeTpAI7SiNm82/yv95HJbAhEmTqwbalvIBmrswnduc0bjIp/Iast1xXFpWdFdf?= =?us-ascii?q?5Lzm1yP1KTmBj85sa0/JF99ilbpuws+c1dX6jkZqo0VbNXAigoPGAz/83rqALM?= =?us-ascii?q?TRCT6XsGU2UZiQRHDg7Y5xznRJjxsy/6tu1g2CmGOMD9UL45VSi+46ptVRTljj?= =?us-ascii?q?oMOTwk/2HNksF+gqJVrgy8qRJ8zY7bb52aO+d8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2e?= =?us-ascii?q?bJCjCDA1QMg2xoZTMUdmXdKpjhmF1iHsAadHzrE=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0BfAADeZ8debQpAQYVmGgEBAQEBAQEBA?= =?us-ascii?q?QEDAQEBARIBAQEBAgIBAQEBQIFHgixvVjEsjSWIB5tmAgkBAwEKAQElCAIEAQG?= =?us-ascii?q?ERAKCGhwHAQQ0EwIQAQEFAQEBAgECAwQBEw0VBxuFawyCOyKDFQEBAQECARIoR?= =?us-ascii?q?AsLGC40AQUBHDuDBYJcHwEPoVSBBD2KMnSBNIh+IYFWEoEmjFyCAIQhPoJnAgK?= =?us-ascii?q?FKoItBIstB4MciVmBUpkogl6CdIU1kCQMHYJjgRKHb4ROjUyaOoZYjRwCCgcGD?= =?us-ascii?q?yOBRoF4MxoIMIMkCUcYDZBMF4NPhCCGRTMyAgE0AgYIAQEDCVYmE4xzAQE?= X-IPAS-Result: =?us-ascii?q?A0BfAADeZ8debQpAQYVmGgEBAQEBAQEBAQEDAQEBARIBAQE?= =?us-ascii?q?BAgIBAQEBQIFHgixvVjEsjSWIB5tmAgkBAwEKAQElCAIEAQGERAKCGhwHAQQ0E?= =?us-ascii?q?wIQAQEFAQEBAgECAwQBEw0VBxuFawyCOyKDFQEBAQECARIoRAsLGC40AQUBHDu?= =?us-ascii?q?DBYJcHwEPoVSBBD2KMnSBNIh+IYFWEoEmjFyCAIQhPoJnAgKFKoItBIstB4Mci?= =?us-ascii?q?VmBUpkogl6CdIU1kCQMHYJjgRKHb4ROjUyaOoZYjRwCCgcGDyOBRoF4MxoIMIM?= =?us-ascii?q?kCUcYDZBMF4NPhCCGRTMyAgE0AgYIAQEDCVYmE4xzAQE?= X-IronPort-AV: E=Sophos;i="5.73,420,1583190000"; d="scan'208";a="349332357" X-MGA-submission: =?us-ascii?q?MDGn4KfaTKzvpANm3JEzBMRMRL10ndll+oTsqK?= =?us-ascii?q?GVLGR6Grpk87eI/OH+1bivAJS97TUQtcN+l+nIdExc4JFO94D9oFukL3?= =?us-ascii?q?n7Jb4uxH0J6w6aGTq/vLnneTcOMR+W2UeMvfh4UujRBUBAft3zP/3rjA?= =?us-ascii?q?6lSvUXcCdtoW2Y0/YPXWXReQ=3D=3D?= Received: from web.is.ocha.ac.jp ([133.65.64.10]) by mail3-smtp-sop.national.inria.fr with ESMTP; 22 May 2020 07:51:05 +0200 Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by web.is.ocha.ac.jp (Postfix) with ESMTP id 52D31200D06BD for ; Fri, 22 May 2020 14:51:02 +0900 (JST) Received: by mail-pl1-f199.google.com with SMTP id x4so7038064pll.19 for ; Thu, 21 May 2020 22:51:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=e0YoOd697U19oGZVAQOSiiTFJzlmrNWblNOHyslvNNc=; b=HFzC1+oWVf1gOoLtQZXb3wL/rjl6GD5kPT1pT50b3KAPLGP2kprz3ILZWMjN1w9J+c 5aTy2PvXWN/uWBEF0+PfUh+Fc1Al8rZdmr5FU7+vIJAgItd4Wso8Lgw61fqWBGPvDd8v CPnRWW01f0lAuSebs502rUFeosRHtPkGFqMsjprd9AZ4fjwe2TbmBvu8gLFymrfxOEn+ 7rnmNSs3YP0cL82s4w14tz/O/8/F3WwLh+uLuIfyR9dpfoz7u+DN0EE6YbCzL/fzURaP 2ue/qxhvRC609yRYG+HSHreBpfHzUqMzlX3FfomU1FXYvXZjHo9oNYGjVsVK93vOUJXg LUSw== X-Gm-Message-State: AOAM532TdbolXN2o83F7PoiZAdRTc3rGci1SqnRW/1Ii1Npj74VDXFKs H+JXf5H1xH8RcEbqPMtlS05//HSuzb0/QGSB1UcQjWz22Zc1IKOWdAvM6F37EuUxZueiu8ROdC/ TXWu7BljLpiwF X-Received: by 2002:a17:90a:1b68:: with SMTP id q95mr2533061pjq.15.1590126661554; Thu, 21 May 2020 22:51:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1HVQys0Vk7bPDVcrJC0ZRXt7YqdRnn7susM7foLCIYrolPxyCQVcP5Jlf6cqWPTHmVmtNEw== X-Received: by 2002:a17:90a:1b68:: with SMTP id q95mr2533028pjq.15.1590126660888; Thu, 21 May 2020 22:51:00 -0700 (PDT) Received: from localhost (61.245.19.237.eo.eaccess.ne.jp. [61.245.19.237]) by smtp.gmail.com with ESMTPSA id t14sm5182008pju.42.2020.05.21.22.50.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 22:50:59 -0700 (PDT) Date: Fri, 22 May 2020 14:50:46 +0900 From: Kenichi Asai To: caml-list@inria.fr Message-ID: <20200522055046.GA7203@pllab.is.ocha.ac.jp> References: <20200518113203.GA26442@pllab.is.ocha.ac.jp> <20200519093406.GA55524@pllab.is.ocha.ac.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200519093406.GA55524@pllab.is.ocha.ac.jp> Subject: Re: [Caml-list] expansion of #use? Reply-To: Kenichi Asai X-Loop: caml-list@inria.fr X-Sequence: 18151 Errors-To: caml-list-owner@inria.fr Precedence: list Precedence: bulk Sender: caml-list-request@inria.fr X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: My attempt succeeded! Here is what I did. In addition to the previous e-mail, - I copied topdirs.ml from toplevel/topdirs.ml and modified all the occurences of Toploop to My_toploop. This loads the function to handle #use into the (compiler-libs) toplevel environment. - I switched off (!) the check for the following error: > Fatal error: exception Invalid_argument("The ocamltoplevel.cma library from compiler-libs cannot be loaded inside the OCaml toplevel") (If this is too dangerous, please let me know.) - (Some more minor changes.) The resulting code can be installed via: opam pin add remove-sharpuse https://github.com/kenichi-asai/remove-sharpuse.git#4.11.0-alpha1 Note that the default branch is now changed to 4.04.0 (for which I wanted this tool originally). -- Kenichi Asai On Tue, May 19, 2020 at 06:34:06PM +0900, Kenichi Asai wrote: > I tried to implement it myself, using compiler-libs (based on OCaml > 4.11.0-alpha1 that I happen to install recently): > > https://github.com/kenichi-asai/remove-sharpuse > > It can be installed via: > > opam pin add remove-sharpuse https://github.com/kenichi-asai/remove-sharpuse.git > > However, if I execute (with attached a.ml and b.ml): > > $ remove-sharpuse -dsource b.ml > Fatal error: exception Invalid_argument("The ocamltoplevel.cma library from compiler-libs cannot be loaded inside the OCaml toplevel") > > What I did is as follows: > > - I copied topstart.ml from toplevel/topstart.ml and modified it so > that it calls My_topmain.main() instead of Topmain.main(). > - I copied my_topmain.ml from toplevel/topmain.ml and modified all the > occurences of Toploop to My_toploop. > - I copied my_toploop.ml from toplevel/toploop.ml and modified > execute_phrase so that it does not execute Ptop_def case. That is, > I inserted "if true then true else" at line 273: > > https://github.com/kenichi-asai/remove-sharpuse/blob/4.11.0-alpha1/my_toploop.ml#L273 > > so that Ptop_def case is ignored. > > If I insert the "if true then true else" line manually into the OCaml > source and compile it via "make world", I can expand #use by passing > "-dsource" to the resulting ocaml. Can I do the same using > compiler-libs without getting the above error? > > Thank you in advance. > > -- > Kenichi Asai > > > On Mon, May 18, 2020 at 08:32:03PM +0900, > Kenichi Asai wrote: > > > Is there any way to expand the use of #use? Suppose I have the > > following two files: > > > > a.ml: > > let a = 3 > > > > b.ml: > > #use "a.ml";; > > print_int a > > > > Given the file name b.ml, I want to obtain: > > > > let a = 3 ;; > > print_int a > > > > The -dsource option of ocaml almost does it, but it executes the > > program at the same time. In the above program, it prints 3, too. > > > > So far, I tweak into the OCaml implementation, turn off the execution > > in execute_phrase in toploop.ml, and re-compile whole the OCaml. I > > wonder if I can do the same thing simpler than this, possibly using > > compiler libs? > > > > Thank you in advance. > > > > PS. I know I should not use #use from the first place. > > > > -- > > Kenichi Asai