From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q2UCGOQC007796 for ; Fri, 30 Mar 2012 14:16:27 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkYDALWjdU/ZSMD3jWdsb2JhbAAqEQm4ZyIBAQEBCQkUEgUkggkBAQQBMgFLCwsYCSUPAQQoNIgECQcpujeKd4J1gyQElnSETI06 X-IronPort-AV: E=Sophos;i="4.75,344,1330902000"; d="scan'208";a="138373847" Received: from fmmailgate06.web.de ([217.72.192.247]) by mail4-smtp-sop.national.inria.fr with ESMTP; 30 Mar 2012 14:16:27 +0200 Received: from moweb001.kundenserver.de (moweb001.kundenserver.de [172.19.20.114]) by fmmailgate06.web.de (Postfix) with ESMTP id B7CFB1067FC6 for ; Fri, 30 Mar 2012 14:16:26 +0200 (CEST) Received: from frosties.localnet ([95.208.118.96]) by smtp.web.de (mrweb001) with ESMTPA (Nemesis) id 0Lilcj-1SnU072Mof-00cmWV; Fri, 30 Mar 2012 14:16:26 +0200 Received: from mrvn by frosties.localnet with local (Exim 4.77) (envelope-from ) id 1SDakk-0000DP-1n for caml-list@inria.fr; Fri, 30 Mar 2012 14:16:26 +0200 From: Goswin von Brederlow To: caml-list@inria.fr In-Reply-To: <4F74E647.1040603@lri.fr> ("Francois Bobot"'s message of "Thu, 29 Mar 2012 17:46:31 -0500") References: <87fwcx6ejm.fsf@frosties.localnet> <4F74E647.1040603@lri.fr> User-Agent: Gnus/5.110009 (No Gnus v0.9) XEmacs/21.4.22 (linux, no MULE) Date: Fri, 30 Mar 2012 14:16:25 +0200 Message-ID: <87k4229td1.fsf@frosties.localnet> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:xvV0hwlYRqP63YWeyKKdawIwizaNdHJWeEpF0XTGVLZ bPOauDkNFFHs4HsZ4UUO+11OK1Va4KxCayyTzL3A0+ItW5q/jq zVhJz8+O10LtgcyR8ZXC2mslcxRg1xvm7E5RAVbSWlyLDOoJt/ 4ZJkYW3dxOnZhKZajgeMQaIBMrzn/b7AtQJFtvNaUmH/Gi4hSf JYNeNdaLx1ralZcGtKPMQ== Subject: Re: [Caml-list] Wish: mutable variant types, equivalence with records François Bobot writes: > On 24/03/2012 13:45, Wojciech Meyer wrote: >> Please see [1], Alain Frisch has been working recently on implementing >> in-line records for constructor arguments. >> >> It's more implementation/design implications than people might think. >> >> [1] http://caml.inria.fr/mantis/view.php?id=5528 > > In the thread of this proposed feature, there is a remark that inlined > record and normal record can become competing features. There is also > the burden that inlined record as proposed can be modified only in > pattern matching. > > But can't we consider that, for a semantic, syntax and typing perspective: > > type t = > | A of string > | B of ({msg: string; mutable foo:int} as t2) > | C > > is exactly the same thing than: > > type t = > | A of string > | B of t2 > | C > > and t2 = {msg: string; mutable foo:int} That would change existing code because B of t2 currently is a Block of size 1 with tag B and pointer to a record of type t2. > The only difference is that when you create a record of type t2 the > tag is directly the one of B in the first case and is the default tag > for record (the first tag if I remember well) in the second case. So > in the first case applying the constructor B is just the identity. Maybe the type of a record could be altered to, at least internally, include a tag value: type t = A of string | B of ({msg: string; mutable foo:int} as t2) | C type t2 = {[B] x : int; } The inline record would be identical to the external record with tag value and (t2 :> t) would work even implicitly. MfG Goswin