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 B81F45D4 for ; Tue, 19 May 2020 09:34:29 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.73,409,1583190000"; d="ml'?scan'208";a="450359041" Received: from prod-listesu18.inria.fr (HELO sympa.inria.fr) ([128.93.162.160]) by mail2-relais-roc.national.inria.fr with ESMTP; 19 May 2020 11:34:28 +0200 Received: by sympa.inria.fr (Postfix, from userid 20132) id 3F85DE1E79; Tue, 19 May 2020 11:34:28 +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 B180CE1E74 for ; Tue, 19 May 2020 11:34:22 +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=3AnT7XQx0vT96JwiZSsmDT+DRfVm0co7zxezQtwd8Z?= =?us-ascii?q?seIVIvad9pjvdHbS+e9qxAeQG9mCtrQd07Wd6v2ocFdDyK7JiGoFfp1IWk1Nou?= =?us-ascii?q?QttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXdrXKo8DEdBAj0OxZr?= =?us-ascii?q?KeTpAI7SiNm82/yv95HJbAhEmTqwbalvIBmqrwjdudQajIt/Iast1xXFpWdFdf?= =?us-ascii?q?5Lzm1yP1KTmBj85sa0/JF99ilbpuws+c1dX6jkZqo0VbNXAigoPGAz/83rqALM?= =?us-ascii?q?TRCT6XsGU2UZiQRHDg7Y5xznRJjxsy/6tu1g2CmGOMD9UL45VSi+46ptVRTljj?= =?us-ascii?q?oMOTwk/2HNksF+gqJVrgy8qRJ8zY7bb52aO+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zt6MDW2e?= =?us-ascii?q?bJCjCDA1QMg2xoZTMUdmXdKpjhmF1iHsAadHzrE=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0BrBADIpsNebQpAQYVmHQEBAQEJARIBB?= =?us-ascii?q?QUBQIFHgixvVjEsjSWICptkAgkBAwEKAQElCAIEAQGERAKCDRwHAQQ0EwIQAQE?= =?us-ascii?q?FAQEBAgECAwQBEw0VBxuFawyCOyKDFQEBAQIBEmwLC0Y0AQUBHDuDBYJcHwEPp?= =?us-ascii?q?DWBBD2LJoE0iFMhgUYQEoEmjFyCAIQhPoJnAgKCMIJ6gi0EiyoHjHGBFTuJA5A?= =?us-ascii?q?bglqCdIElglGBPJAVDB2Da4wqjUGaLoZTjRUCCgcGDyOBRoF4MxoIMIMkCUcYD?= =?us-ascii?q?ZBMF4NPhCCGRTMyAgE0AgYIAQEDCVYmE44IAQE?= X-IPAS-Result: =?us-ascii?q?A0BrBADIpsNebQpAQYVmHQEBAQEJARIBBQUBQIFHgixvVjE?= =?us-ascii?q?sjSWICptkAgkBAwEKAQElCAIEAQGERAKCDRwHAQQ0EwIQAQEFAQEBAgECAwQBE?= =?us-ascii?q?w0VBxuFawyCOyKDFQEBAQIBEmwLC0Y0AQUBHDuDBYJcHwEPpDWBBD2LJoE0iFM?= =?us-ascii?q?hgUYQEoEmjFyCAIQhPoJnAgKCMIJ6gi0EiyoHjHGBFTuJA5AbglqCdIElglGBP?= =?us-ascii?q?JAVDB2Da4wqjUGaLoZTjRUCCgcGDyOBRoF4MxoIMIMkCUcYDZBMF4NPhCCGRTM?= =?us-ascii?q?yAgE0AgYIAQEDCVYmE44IAQE?= X-IronPort-AV: E=Sophos;i="5.73,409,1583190000"; d="ml'?scan'208";a="349040429" X-MGA-submission: =?us-ascii?q?MDHP8dNontHZNdRrS2PICkKxrcj1jclPV/Uodp?= =?us-ascii?q?ZDexhJOq64QIN6Q/MRFxsroRYr9fTkIOLoNW2unrWXLJWeyGSeKPXg4x?= =?us-ascii?q?Zq2aU3PLKEyb5D5F+r0hYi2t4pTYx9HVW06FYKg7hc4Nbsg4NN4/6YoT?= =?us-ascii?q?n+Fq/ayf03qKbC0Witpz/jag=3D=3D?= Received: from web.is.ocha.ac.jp ([133.65.64.10]) by mail3-smtp-sop.national.inria.fr with ESMTP; 19 May 2020 11:34:19 +0200 Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by web.is.ocha.ac.jp (Postfix) with ESMTP id 53771200C6423 for ; Tue, 19 May 2020 18:34:17 +0900 (JST) Received: by mail-pg1-f197.google.com with SMTP id r2so10239515pgd.23 for ; Tue, 19 May 2020 02:34:17 -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=cC2kL0kxXzfyYoh7k/88ht4paFpE1TwwgbvRT/M+6xA=; b=YLy6DD8cyppxZiKGcdge4XNlB42iFsKWhCD2JnHrrKpEsN+i2iPow2kMfobR4IJw9K heak5YSEpXYPZdZb+Q7DsaF+VrBP+YPcwO7JvGY+CIfOeUnbCiwF5PGxhqoTKr7jMpNW 8WPIhaIiN7IXrllLBK+LTebjFxewazsFz5VU/UsT9pzTvEuWiKAezALrWpLnzkA9qIf6 AQB8yHzcRdYGtGwmNZDA8pUdq7aJ2Y5rA7mdsnjW7C60g3ZC3VtJnINSwLSx0coKdyLD NdLWAYKoCgxrOdeAxxYXTz2UNAgTUza8epGWYeYhHj0Me5lKNPdN+Lgh0WH4ecSBjixd kvTg== X-Gm-Message-State: AOAM531RkziyXHyU+QkvebppHBV2E2tydkJdny9LqenK3Zf9EqCEC8sJ GKs4nJtvjmWZeMAgz+IWUFAgwUTlFeTfWmFXCIfogEpPisqF5M9SxjQoo/737fT/Bv/zyiI0YNW 2TQCb34/bvdlJ X-Received: by 2002:a17:90b:1104:: with SMTP id gi4mr3733323pjb.115.1589880856552; Tue, 19 May 2020 02:34:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQ0ECrgjU4ZPOPAwg/R2CbMp2AkPFZBKCYewjjv5WSjoEX0Elb7Jy2M0d008njy1Lx+YxuJQ== X-Received: by 2002:a17:90b:1104:: with SMTP id gi4mr3733294pjb.115.1589880856273; Tue, 19 May 2020 02:34:16 -0700 (PDT) Received: from localhost (61.245.19.237.eo.eaccess.ne.jp. [61.245.19.237]) by smtp.gmail.com with ESMTPSA id mg9sm1684854pjb.10.2020.05.19.02.34.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 02:34:14 -0700 (PDT) Date: Tue, 19 May 2020 18:34:06 +0900 From: Kenichi Asai To: caml-list@inria.fr Message-ID: <20200519093406.GA55524@pllab.is.ocha.ac.jp> References: <20200518113203.GA26442@pllab.is.ocha.ac.jp> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="3V7upXqbjpZ4EhLz" Content-Disposition: inline In-Reply-To: <20200518113203.GA26442@pllab.is.ocha.ac.jp> Subject: Re: [Caml-list] expansion of #use? Reply-To: Kenichi Asai X-Loop: caml-list@inria.fr X-Sequence: 18147 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: --3V7upXqbjpZ4EhLz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --3V7upXqbjpZ4EhLz Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="a.ml" let a = 1 + 2 --3V7upXqbjpZ4EhLz Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="b.ml" let b = 5;; #use "a.ml";; let _ = print_int (a + b) --3V7upXqbjpZ4EhLz--