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 CF91E5D5 for ; Fri, 5 Mar 2021 17:12:06 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.81,225,1610406000"; d="scan'208,217";a="496402878" Received: from prod-listesu18.inria.fr (HELO sympa.inria.fr) ([128.93.162.160]) by mail2-relais-roc.national.inria.fr with ESMTP; 05 Mar 2021 18:12:03 +0100 Received: by sympa.inria.fr (Postfix, from userid 20132) id 9F908E1D3F; Fri, 5 Mar 2021 18:12:03 +0100 (CET) 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 D9595E0171 for ; Fri, 5 Mar 2021 18:11:58 +0100 (CET) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=jdimino@janestreet.com; spf=Pass smtp.mailfrom=jdimino@janestreet.com; spf=None smtp.helo=postmaster@mxout1.mail.janestreet.com IronPort-PHdr: =?us-ascii?q?9a23=3Ag/99Hxw6cJDwnsPXCy+O+j09IxM/srCxBDY+r6Qd?= =?us-ascii?q?2u4WIJqq85mqBkHD//Il1AaPAdyKrasc1aGG6OjJYi8p2d65qncMcZhBBVcuqP?= =?us-ascii?q?49uEgeOvODElDxN/XwbiY3T4xoXV5h+GynYwAOQJ6tL1LdrWev4jEMBx7xKRR6?= =?us-ascii?q?JvjvGo7Vks+7y/2+94fcbglVgDexe65+IAm3oAnetcQbj5ZpJ7osxBfOvnZGYf?= =?us-ascii?q?ldy3lyJVKUkRb858Ow84Bm/i9Npf8v9NNOXLvjcaggQrNWEDopM2Yu5M32rhbD?= =?us-ascii?q?VheA5mEdUmoNjBVFBRXO4QzgUZfwtiv6sfd92DWfMMbrQ704RSiu4qF2QxLzli?= =?us-ascii?q?wJKyA2/33WisxojaJUvhShpwBkw4XJZI2ZLedyc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-ascii?q?F431SQo6Scg8lppXOx4kSoeSyyvb1i/vOIc70rmCBZg66KXZhiajJc97xm3azq?= =?us-ascii?q?Qskx8tRc4dbDT61J46zBDaAsvyq2vcj7yjLPpO3ifL+Xyf12eDoAdTVwsiCfyY?= =?us-ascii?q?D0BaXVPfqJHC3m2HT7KqDu53YA5RztOec+1PY9zty1dPQvr4JM7Tbn73kGC1V0?= =?us-ascii?q?6F?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0CLBgDFZUJgfU7IaSZiDg4BAQE8AQEEB?= =?us-ascii?q?AEBAgEBBwEBgTkBASuBPAIBAYFfVzkxhEGBHpBAlDCIHQsBAwENBQIZFAQBAYR?= =?us-ascii?q?NAoF6Ah0HAQQ0EwIQAQEFAQEBAgEDAwQBEwEBDxQIhhENgjgpAYNjAQEDARIRB?= =?us-ascii?q?BkBATcBBAsLBAc3AgIiEgEFARwGExsHgk+CZiEDoR6BBD2KPnZ/M4MEAQEGhhO?= =?us-ascii?q?BPAkSgSUCAQEBAYZ4AQGGRCYcgUlCgUeCZD6HVIJfgnxKL4FtkSCpSIMIiUCSZ?= =?us-ascii?q?iKEbp5+hk2wVRAjgUiBejMaCBsVOzEGgjIJRxkNkg6EIIV4QUEyOAIGAQkBAQM?= =?us-ascii?q?JjyYBAQ?= X-IPAS-Result: =?us-ascii?q?A0CLBgDFZUJgfU7IaSZiDg4BAQE8AQEEBAEBAgEBBwEBgTk?= =?us-ascii?q?BASuBPAIBAYFfVzkxhEGBHpBAlDCIHQsBAwENBQIZFAQBAYRNAoF6Ah0HAQQ0E?= =?us-ascii?q?wIQAQEFAQEBAgEDAwQBEwEBDxQIhhENgjgpAYNjAQEDARIRBBkBATcBBAsLBAc?= =?us-ascii?q?3AgIiEgEFARwGExsHgk+CZiEDoR6BBD2KPnZ/M4MEAQEGhhOBPAkSgSUCAQEBA?= =?us-ascii?q?YZ4AQGGRCYcgUlCgUeCZD6HVIJfgnxKL4FtkSCpSIMIiUCSZiKEbp5+hk2wVRA?= =?us-ascii?q?jgUiBejMaCBsVOzEGgjIJRxkNkg6EIIV4QUEyOAIGAQkBAQMJjyYBAQ?= X-IronPort-AV: E=Sophos;i="5.81,225,1610406000"; d="scan'208,217";a="374918741" X-MGA-submission: =?us-ascii?q?MDFMLNIn6d7ZO0pnX4YmORssH4gKT6j+HQhXjh?= =?us-ascii?q?prasq4pRxPoX6pxgF6QQpGO0EiuTHkwaIz6OKwDxJo6OjpgBb6rLjIZx?= =?us-ascii?q?k1bjZ2y64kgSj+7mzDhp0zS0Y+hRUUgLwxAXl0MVTu2wT47yq29TedAK?= =?us-ascii?q?VjMLWv/4bFHuSA0rA/NTZzPg=3D=3D?= Received: from mxout1.mail.janestreet.com ([38.105.200.78]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Mar 2021 18:11:57 +0100 Received: from mail-ej1-f71.google.com ([209.85.218.71]) by mxgoog2.mail.janestreet.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.94) id 1lIDzW-0003gj-8X for caml-list@inria.fr; Fri, 05 Mar 2021 12:11:54 -0500 Received: by mail-ej1-f71.google.com with SMTP id mj6so1156969ejb.11 for ; Fri, 05 Mar 2021 09:11:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dtMobs9v0m8IZtf5AJbBQMoa1HzaYQvOdL8dlOdC4iw=; b=VDu8elxtuInthonrjXBXPebfSgdl/TJ+kCyCmlWFtkrxhRb4ZhfnNyuwTFLx5IowjD YmL29ZcaGYgJJSUyyfolxnWoU5n4dxfs7ILNJeIae+qRZDp/OCOT6pPpBRChZhbSBRg2 MYGW6MeP1bGdUy6sFRJuZo7IgsA9ygwcV4LUA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dtMobs9v0m8IZtf5AJbBQMoa1HzaYQvOdL8dlOdC4iw=; b=bU2mwRfMNV5U9jvUgxMV/3AeVS0oOTkdmLOWky2bslChcOyfNRPYxruWtkJrMcIT+N yMWVl2/vy0KL+x6FY75xTICAgD3Vy7kxBtV5xTvPLaNRZlbgJfngRa/1aJrv2kXdoPrJ LkJCHsqTafqUWfGT84c+4j2RNNRPkHr1cOSwXHUaKuQmgJH+9N3I1I0MMeSZRo8tz9L2 aqnQ2m2FgXpkOM/N5WGO7vYQpGZzjxIgDbB4CjU2yPXoiV+utF/jpgql+jmiyfTWO7E7 5/PDieHGjZxrtKUjJDrj+M4pM6XCOogIrI9r3GFAB9FtfV0OLHMOqo1oYaj0jgc2whcj M+qA== X-Gm-Message-State: AOAM532eXve9nhtGVHryw3noi74uqzUC9KJ7/LYVKho2aiinOBpylbSg +LBkv7Dednh5ZrSDLE5yox/+7XS7YZGDjyekOYyZAaphL0WLgnL228pdYmqi25k8bCI2qSP4wEG G2yuxx/NGdQILcZjgCVku9VuVXw== X-Received: by 2002:a17:906:40c7:: with SMTP id a7mr3127197ejk.109.1614964313223; Fri, 05 Mar 2021 09:11:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJw0KR204sHtprUzWPuSCKJ6Ak1vQNMXA2vWu2kPzVR1w4SjjckUKAnBtzr27vmmeuz6nlvquRloLgWdMuuzqVk= X-Received: by 2002:a17:906:40c7:: with SMTP id a7mr3127173ejk.109.1614964312996; Fri, 05 Mar 2021 09:11:52 -0800 (PST) MIME-Version: 1.0 References: <20210305050509.GA97697@pllab.is.ocha.ac.jp> <20210305140334.GA6750@pllab.is.ocha.ac.jp> In-Reply-To: <20210305140334.GA6750@pllab.is.ocha.ac.jp> From: Jeremie Dimino Date: Fri, 5 Mar 2021 17:11:42 +0000 Message-ID: To: Kenichi Asai Cc: caml users Content-Type: multipart/alternative; boundary="00000000000033994905bccd2e7d" Subject: Re: [Caml-list] a simple example of compiler-libs.toplevel? Reply-To: Jeremie Dimino X-Loop: caml-list@inria.fr X-Sequence: 18419 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: --00000000000033994905bccd2e7d Content-Type: text/plain; charset="UTF-8" On Fri, Mar 5, 2021 at 2:04 PM Kenichi Asai wrote: > A side question. How can I find what hooks are available? By looking > at the source and finding what functions are defined as refs? (I find > that parse_toplevel_phrase, parse_use_file, and toplevel_startup_hook > are defined as refs in toploop.ml, so they can be replaced?) > That's the idea. Only the refs exposed in the mli can be set from the outside though. > What if there is no such hook? For the type debugger, I want to call > a specific function whenever a type error occurs in the second > execute_phrase (right after "with exn ->") in toploop.ml. But there > is no hook there. Since the execute_phrase function is not defined as > a ref, I cannot replace it, either. What can I do then? > If there is no hook, I'm afraid there is no good solution at the moment; you need to patch the toplevel library, or copy some of its code and modify it. -- Jeremie --00000000000033994905bccd2e7d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Fri, Mar 5, 2021 at 2:04 PM Kenichi Asai <asai@is.ocha.ac.jp> wrote:
A side question.=C2=A0 How can I find what hooks are available?= =C2=A0 By looking
at the source and finding what functions are defined as refs?=C2=A0 (I find=
that parse_toplevel_phrase, parse_use_file, and toplevel_startup_hook
are defined as refs in toploop.ml, so they can be replaced?)

That's the idea. Only the refs exposed in the mli = can be set from the outside though.
=C2=A0
What if there is no such hook?=C2=A0 For the type debugger, I want to call<= br> a specific function whenever a type error occurs in the second
execute_phrase (right after "with exn ->") in toploop.ml.=C2=A0 Bu= t there
is no hook there.=C2=A0 Since the execute_phrase function is not defined as=
a ref, I cannot replace it, either.=C2=A0 What can I do then?

If there is no=C2=A0hook, I'm afraid there is no g= ood solution at the=C2=A0moment; you need to patch the toplevel library, or= copy some of its code and modify it.

--
Jeremie
--00000000000033994905bccd2e7d--