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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id DFB18823C5 for ; Fri, 17 Nov 2017 15:02:07 +0100 (CET) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=octa@polychoron.fr; spf=Pass smtp.mailfrom=octa@polychoron.fr; spf=None smtp.helo=postmaster@relay6-d.mail.gandi.net Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of octa@polychoron.fr) identity=pra; client-ip=217.70.183.198; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="octa@polychoron.fr"; x-sender="octa@polychoron.fr"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of octa@polychoron.fr designates 217.70.183.198 as permitted sender) identity=mailfrom; client-ip=217.70.183.198; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="octa@polychoron.fr"; x-sender="octa@polychoron.fr"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@relay6-d.mail.gandi.net) identity=helo; client-ip=217.70.183.198; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="octa@polychoron.fr"; x-sender="postmaster@relay6-d.mail.gandi.net"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3A61ts2hKRchhwK40uQ9mcpTZWNBhigK39O0sv0rFi?= =?us-ascii?q?tYgXL/7xwZ3uMQTl6Ol3ixeRBMOAtKIC1rKempujcFJDyK7JiGoFfp1IWk1Nou?= =?us-ascii?q?QttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBWB6kG1uDUbHxG6MQtu?= =?us-ascii?q?Osz0HJTThoK5zbOc4ZrWNgJDmDO2Yal1Kl3iqg7Nv+EOho9zIaY20BzP5HVSLb?= =?us-ascii?q?cFjVh0LE6eyk6vrvy7+4Rupnxd?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0DRCABU6w5ahsa3RtlcHQEBBQELAYQgA?= =?us-ascii?q?2snB4N4mUSBV5kZCiWFFgKEZ0MUAQEBAQEBAQEBARIBAQEICwsIKC+COCKCRQM?= =?us-ascii?q?DIw8BBVEJAhoCJgICVxMIAQEXiX0RDIwYnWiCJ4szgQ+CJYIHgVSCEwuCd4Mkg?= =?us-ascii?q?kOCSYJjBZkiiRyBBYIahFOQEokMh0iMcolAgTo2ghZ+EUmCZQiCY4F0dgGJRAG?= =?us-ascii?q?BEAEBAQ?= X-IPAS-Result: =?us-ascii?q?A0DRCABU6w5ahsa3RtlcHQEBBQELAYQgA2snB4N4mUSBV5k?= =?us-ascii?q?ZCiWFFgKEZ0MUAQEBAQEBAQEBARIBAQEICwsIKC+COCKCRQMDIw8BBVEJAhoCJ?= =?us-ascii?q?gICVxMIAQEXiX0RDIwYnWiCJ4szgQ+CJYIHgVSCEwuCd4MkgkOCSYJjBZkiiRy?= =?us-ascii?q?BBYIahFOQEokMh0iMcolAgTo2ghZ+EUmCZQiCY4F0dgGJRAGBEAEBAQ?= X-IronPort-AV: E=Sophos;i="5.44,409,1505772000"; d="scan'208";a="301248828" Received: from relay6-d.mail.gandi.net ([217.70.183.198]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Nov 2017 14:01:10 +0100 X-Originating-IP: 86.203.185.106 Received: from [192.168.1.10] (AMarseille-655-1-37-106.w86-203.abo.wanadoo.fr [86.203.185.106]) (Authenticated sender: octa@polychoron.fr) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 4720CFB87D for ; Fri, 17 Nov 2017 14:01:09 +0100 (CET) To: caml-list@inria.fr References: From: octachron Message-ID: <41144c60-9090-7159-c870-08ca5eb5c09e@polychoron.fr> Date: Fri, 17 Nov 2017 14:01:08 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [Caml-list] Subtyping (or something like it) With OCaml 4.06, if what you really want is to have a nice syntax for array indexing, one solution would be to define your own indexing operators:   let (  .%{ } ) a k = a.{k}   let ( .%{ } <- ) a k x = a.{k} <- x These operators can be used like standard indexing operators     let x = a.%{ 0 } in     a.%{ 1 } <- x and exported with    val (  .%{ } ): …    val ( .%{ } <- ): … Nevertheless, contrarily to Bigarray, there is no implicit conversion for multidimensional array, in other words     a .%{0,1} will not work out of the box. However, if needed, it is possible to use qualified indexing operators to circumvent this difficulty:   module D1 = struct let ( .%{} ) a k = a.{k} end   module D2 = struct let ( .%{} ) a (k,l) = a.{k,l} end   let x_ij = mat.D2.%{i, j}   let x_0 = vector.D1.%{0} See also the manual for more details: http://caml.inria.fr/pub/docs/manual-ocaml/extn.html#s%3Aindex-operators . − octachron.