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 sympa.inria.fr (Postfix) with ESMTPS id E2E587EEBF for ; Wed, 5 Aug 2015 08:40:23 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of paurkedal@gmail.com) identity=pra; client-ip=209.85.218.52; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="paurkedal@gmail.com"; x-sender="paurkedal@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of paurkedal@gmail.com designates 209.85.218.52 as permitted sender) identity=mailfrom; client-ip=209.85.218.52; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="paurkedal@gmail.com"; x-sender="paurkedal@gmail.com"; 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@mail-oi0-f52.google.com) identity=helo; client-ip=209.85.218.52; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="paurkedal@gmail.com"; x-sender="postmaster@mail-oi0-f52.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BRAQBtrsFVmzTaVdFbhFgGsWmTKQKBPQdMAQEBAQEBEgEBAQEBBgsLCSEuhCQBAQQSER0BGx0BAwwGBQsNAgImAgIiAREBBQEcBhMih3YBAxKmJ4EuPjGLP4FsgnmLTwoZJw0VQoRWAQEBAQEFAgEZAQUOgRSKLYRVMweCaYFDBZR9AYxTgUeUNIIYEiOBFxeEDjwxgkwBAQE X-IPAS-Result: A0BRAQBtrsFVmzTaVdFbhFgGsWmTKQKBPQdMAQEBAQEBEgEBAQEBBgsLCSEuhCQBAQQSER0BGx0BAwwGBQsNAgImAgIiAREBBQEcBhMih3YBAxKmJ4EuPjGLP4FsgnmLTwoZJw0VQoRWAQEBAQEFAgEZAQUOgRSKLYRVMweCaYFDBZR9AYxTgUeUNIIYEiOBFxeEDjwxgkwBAQE X-IronPort-AV: E=Sophos;i="5.15,614,1432591200"; d="scan'208";a="172706323" Received: from mail-oi0-f52.google.com ([209.85.218.52]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 05 Aug 2015 08:40:23 +0200 Received: by oihn130 with SMTP id n130so17700630oih.2 for ; Tue, 04 Aug 2015 23:40:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=pp5C77I1F5vqZJApyuVlxAqHmnwT7lwEW9UtRTBEqdQ=; b=aN1S23Fnb4N4A7N4M6uqufYN3vx59vkoIQxaD+QgQa8JU11iiFGI4BVDhICiRA5KKi v+DuYpA5pb1viB2lEZ6BywjNFHwFvRs9Of/n2KUDOze6zMOS/XTXFykZ3GTnS6DiPBsv 0yQe3IdZm9CJzIZULzj5IgB6jWfGPUsJGIPAa9pwDdRcZnB9Vz82DUr05vNkmtb4UMCM MHNE5A2/lmMf7eiATZC7VhGou5vB3tmsJcPd5VV8IV1qeysjVfak7tXjFiu2rb5+vD0X w983pSZPlruRSAcWv9X0ZvyCA61JMiMK6OVdICCgobcD9STH5PbGz2BGUOfSoqHE1JP0 Wy4Q== MIME-Version: 1.0 X-Received: by 10.202.95.198 with SMTP id t189mr6378455oib.105.1438756821765; Tue, 04 Aug 2015 23:40:21 -0700 (PDT) Received: by 10.202.171.145 with HTTP; Tue, 4 Aug 2015 23:40:21 -0700 (PDT) In-Reply-To: <20150804093301.GD5689@frosties> References: <55BF6F1C.3050705@bioquant.uni-heidelberg.de> <55BF75F6.1040006@bioquant.uni-heidelberg.de> <8E1A640CE3374EB492981ADB0A2DA5C6@erratique.ch> <20150804065134.GA10576@dione.int.eideticdew.org> <20150804093301.GD5689@frosties> Date: Wed, 5 Aug 2015 08:40:21 +0200 Message-ID: From: "Petter A. Urkedal" To: Goswin von Brederlow Cc: caml users Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] destructive local opens 2015-08-04 11:33 GMT+02:00 Goswin von Brederlow : > On Tue, Aug 04, 2015 at 08:51:34AM +0200, Petter Urkedal wrote: >> On 2015-08-03, Daniel B=C3=BCnzli wrote: >> > Le lundi, 3 ao=C3=BBt 2015 =C3=A0 15:08, Nils Becker a =C3=A9crit : >> > > It's possible that people actually want M.() to mean let open! more >> > > often than let open. For me I think that's the case. >> > >> > If you are in the vector case, I don't think that's the case. With Gg = [1] I often had the following kind of subtly wrong code (can't remember the= exact details but something similar): >> > >> > let ox =3D V2.((dot v ox) * ox) in >> > V2.(3 * ox + oy) >> > >> > The reality is that M.() is inherently dangerous, especially from an A= PI evolution perspective where new identifiers with matching type may get i= ntroduced later leading to silent semantic changes in your code. So we shou= ld not encourage people to use M.!() as it's going to make the problem even= more acute. Besides we should have that 44 warning by default so that we s= ee the problems, but for now it's impossible to live with 44 and a Gg like = library. >> >> This suggests another option. If type information is available at the >> point this warning is emitted, then the warning could be issued only in >> the case when the type of the shadowing identifier matched that of the >> shadowed identifier. >> >> This assumes the common case for shadowing is to redefine operators or >> common functions at a custom type, the use of M.() being an alternative >> to overloading. Loosely the warning should be emitted if the chosen >> identifier is not the one which would have been chosen by some sensible >> overloading scheme, but instead we make a simple estimate. >> >> This could still go wrong, since the type required by the context may be >> general than the type of both the shadowed and shadowing terms, so a >> better rule might be to issue the warning if both are admissible in the >> given context, though my guess is that's harder to implement. > > I like the idea but how feasable is it? Most of the time I figure the > type being infered from the operator being used. The use of M.(*) > makes it the custom type while simple (*) would make it int. The type > system would have to track the ambiguity until some other use of the > arguments or result decide the proper type. And if it doesn't resolve > then emit the warning. Yes, it's probably not that easy to implement. Not familiar with the code base. At least it requires postponing the warning till type information is available, and maybe cluttering the parse tree with sub-nodes containing the types and locations of shadowed identifiers. The types at the point the check is made will have been analysed under the assumption that the right resolution was made. I originally assumed we had closed types, only type variables stemming from let-polymorphism. That may be the case for M-bound identifiers in M.(...), but the context may contain local identifiers or file-level identifiers with unresolved existentials. Nevertheless, I think the common case when we don't want to emit a warning is when M.(...) shadows a global binding whose type was already fixed.