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 86F0B5D6 for ; Fri, 9 Aug 2019 14:27:52 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.64,364,1559512800"; d="scan'208";a="394968534" Received: from sympa.inria.fr ([193.51.193.213]) by mail2-relais-roc.national.inria.fr with ESMTP; 09 Aug 2019 16:27:51 +0200 Received: by sympa.inria.fr (Postfix, from userid 20132) id 423007EF0B; Fri, 9 Aug 2019 16:27:51 +0200 (CEST) Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 57D347ED21 for ; Fri, 9 Aug 2019 16:27:43 +0200 (CEST) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=rich@annexia.org; spf=Pass smtp.mailfrom=rich@annexia.org; spf=Pass smtp.helo=postmaster@annexia.org IronPort-PHdr: =?us-ascii?q?9a23=3A/Y4exx3+oet8O2TysmDT+DRfVm0co7zxezQtwd8Z?= =?us-ascii?q?seweLvad9pjvdHbS+e9qxAeQG9mCsbQd0rWd7PyocFdDyK7JiGoFfp1IWk1Nou?= =?us-ascii?q?QttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXdrXKo8DEdBAj0OxZr?= =?us-ascii?q?KeTpAI7SiNm82/yv95HJbAhEmSSxbalvIBmrrwjducsbjIR/Iast1xXFpWdFdf?= =?us-ascii?q?5Lzm1yP1KTmBj85sa0/JF99ilbpuws+c1dX6jkZqo0VbNXAigoPGAz/83rqALM?= =?us-ascii?q?TRCT6XsGU2UZiQRHDg7Y5xznRJjxsy/6tu1g2CmGOMD9UL45VSi+46ptVRTljj?= =?us-ascii?q?oMOTwk/2HNksF+gqJVrgy8qRJ8zIHbfJyaO/Rlc6PBYd8XX3ZNUtpLWiBfBI63?= =?us-ascii?q?cosBD/AGPeZdt4TxqUcArRqiCgmsHuzv0CJHjWL20qEg1OotCxzN0ggnH9IIrn?= =?us-ascii?q?vUt9v5P7oVXOCvzanH0TXDYuhM1jf77ojHbB8gofCWUr5qdsrR00YvGhrDg16N?= =?us-ascii?q?qoLlJyuY2+cRv2SB7udtVvijhmo6pw1rvzSixMYhh4/UjYwP0F/E7z92wIMtKN?= =?us-ascii?q?24VkF7ZdmkHYNKuCGcMYt5XMwjQ2Bytyogzb0Go5G7cDALyJQh2RHfd+SKfouU?= =?us-ascii?q?7h75VeucIi10iXZ4dL6lmhq/80mtxvX5Vsau0VZKqiRFksPLtnAIzxHT8MmHRe?= =?us-ascii?q?d9/kq6wzmP0QbT5f9LIEA1j6XXMZkhwqQ/lpYLq0TMAjf2mFnqjK+Rbkgr5vKn?= =?us-ascii?q?6+HjYrn/op+cNpR0ih3lP6Q1ms2/BPw4PRIUU2ia/+S8zrzj8lfjTLVElP1l2p?= =?us-ascii?q?Xe5ZvTIMBeoq+iHydU1Jwi4lCxFWSIytMdyDM9LVlFcQiLx7evHheGAvf+AOz1?= =?us-ascii?q?ywC2kTxr7/nAOLDxA5yLKWLMxuSyNY1h4lJRnVJghetU4IhZX+lYfKDDH3Tpvd?= =?us-ascii?q?mdNScXdhSuyr+8Wtx70I4OWGvJBbWWYvuL4A24o9k3KuzJX7c7/TP0Kvwr/fnr?= =?us-ascii?q?1CRrkFkbcLmo1N0Qcn/qR607cXXcWmLlh5I6KUlPvgc6S7Wx2lSEVzNDZn/0WL?= =?us-ascii?q?gztGg2?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0DvGQBWgk1dZLBbRFBmHQEBHwUBDAGBS?= =?us-ascii?q?oEvAmWBPjOTbE4BAQEBAQacQAkBAwEMLAECAQGHIhwGAQQ0EwEEAQEEAQEEAQM?= =?us-ascii?q?HAQRThUiCOiKDL3sTIS2FTRisYYVJhQOBMgIBAYtiEQZ4PkmJcoUWBKpYbQcCA?= =?us-ascii?q?oIdA5QgJ5g4pXiBZyCBWX0IO4JtghgBjm5BgTQBjgoBAQ?= X-IPAS-Result: =?us-ascii?q?A0DvGQBWgk1dZLBbRFBmHQEBHwUBDAGBSoEvAmWBPjOTbE4?= =?us-ascii?q?BAQEBAQacQAkBAwEMLAECAQGHIhwGAQQ0EwEEAQEEAQEEAQMHAQRThUiCOiKDL?= =?us-ascii?q?3sTIS2FTRisYYVJhQOBMgIBAYtiEQZ4PkmJcoUWBKpYbQcCAoIdA5QgJ5g4pXi?= =?us-ascii?q?BZyCBWX0IO4JtghgBjm5BgTQBjgoBAQ?= X-IronPort-AV: E=Sophos;i="5.64,364,1559512800"; d="scan'208";a="394968413" X-MGA-submission: =?us-ascii?q?MDEbtPmQN6sQ0lY4TjbG6E/1QBC33JtLAm6Xi+?= =?us-ascii?q?cjJLlWEadjFdFeBm7KuvvFiee8bJTOdOG2two7Wc/LIiIcBNtE2bImn2?= =?us-ascii?q?wmZZRL54UiPUh/TA599c+Nj2lXM9WTRoHY/v8JiqyMdmilMqa5D3txsE?= =?us-ascii?q?UYFYut1ln1kfTLIPWs02PG0A=3D=3D?= Received: from annexia.org ([80.68.91.176]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES256-GCM-SHA384; 09 Aug 2019 16:27:21 +0200 Received: from rich by annexia.org with local (Exim 4.89) (envelope-from ) id 1hw5rU-0008Nh-LO for caml-list@inria.fr; Fri, 09 Aug 2019 15:27:20 +0100 Date: Fri, 9 Aug 2019 15:27:20 +0100 From: "Richard W.M. Jones" To: caml-list@inria.fr Message-ID: <20190809142719.ff4kogz4fq6r7vfr@annexia.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Subject: [Caml-list] Syntax puzzle / suggestion Reply-To: "Richard W.M. Jones" X-Loop: caml-list@inria.fr X-Sequence: 17749 Errors-to: caml-list-owner@inria.fr Precedence: list Precedence: bulk Sender: caml-list-request@inria.fr X-no-archive: yes List-Id: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Let's imagine you have a list of named things, but you also want to collect them up into a single list. For example: let item1 = "hello" let item2 = "world" let all_items = [ item1; item2 ] let () = printf "item1 = %s\n" item1; printf "all_items = %s\n" (String.concat ", " all_items) This is fine, but there's a danger that a programmer could add item3 but forget to add it to the "all_items" list. (In the real world problem to which this applies, my items are complex and lengthy structures, and the "all-things-list" is well off the bottom of the page when you're viewing the top item). My idea to fix this was to write: let all_items = [ ("hello" as item1); ("world" as item2); ] Actually I was slightly surprised to find this doesn't compile. I guess because "as" can only be used like this in patterns, not expressions. Also the scoping is wrong because the "as item1" if it worked probably wouldn't apply outside the list. I haven't worked out if it's possible to write this in ordinary OCaml, although I suppose ppx could solve it. Any ideas if this is possible? Rich.