From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p2SBX0aN028064 for ; Mon, 28 Mar 2011 13:33:00 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApMCANZwkE1RZ90vkWdsb2JhbAClSxQBAQEBCQsLBxQDIsJygn2CbASMdw X-IronPort-AV: E=Sophos;i="4.63,255,1299452400"; d="scan'208";a="95142719" Received: from mtaout01-winn.ispmail.ntl.com ([81.103.221.47]) by mail2-smtp-roc.national.inria.fr with ESMTP; 28 Mar 2011 13:32:54 +0200 Received: from aamtaout02-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout01-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20110328113254.KFWY18231.mtaout01-winn.ispmail.ntl.com@aamtaout02-winn.ispmail.ntl.com>; Mon, 28 Mar 2011 12:32:54 +0100 Received: from romulus.metastack.com ([81.102.132.77]) by aamtaout02-winn.ispmail.ntl.com (InterMail vG.3.00.04.00 201-2196-133-20080908) with ESMTP id <20110328113253.JAIK25842.aamtaout02-winn.ispmail.ntl.com@romulus.metastack.com>; Mon, 28 Mar 2011 12:32:53 +0100 Received: from remus.metastack.local ([172.16.0.1]) by romulus.metastack.com (8.14.2/8.14.2) with ESMTP id p2SBWn9s024692 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Mon, 28 Mar 2011 12:32:49 +0100 Received: from Remus.metastack.local ([fe80::547c:3c42:e1da:eda2]) by Remus.metastack.local ([fe80::547c:3c42:e1da:eda2%11]) with mapi; Mon, 28 Mar 2011 12:32:49 +0100 From: David Allsopp To: Alain Frisch , caml-list Thread-Topic: [Caml-list] Re: module typing issue Thread-Index: AQHL6sjgGT8J0i0YbEKMp09xW6WxSJQ+GUyAgAAY1ICAAA+egIAABMCAgAAiCICAA+uzAIAATSSA Date: Mon, 28 Mar 2011 11:32:48 +0000 Message-ID: References: <89643D7F-B0F9-4452-BBAF-0445D9D3CA4E@gmail.com> <639CCD2C-402F-4754-B942-B460FD908A95@gmail.com> <63968844-AD95-4359-80F0-E9E071CF6518@mpi-sws.org> <20110325164240.GT10028@localhost> <46B666E2-4575-4E79-ACF1-FE0789C0C76B@mpi-sws.org> <20110325190129.GU10028@localhost> <4D903E90.4080907@frisch.fr> In-Reply-To: <4D903E90.4080907@frisch.fr> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Organization: MetaStack Solutions Ltd. X-Scanned-By: MIMEDefang 2.65 on 81.102.132.77 X-Cloudmark-Analysis: v=1.1 cv=JvdXmxIgLJv2/GthKqHpGJEEHukvLcvELVXUanXFreg= c=1 sm=0 a=GIoHEcz2c30A:10 a=kj9zAlcOel0A:10 a=xqWC_Br6kY4A:10 a=9v6ylFnvZVjeTr1fipMA:9 a=Lm87Ck6Yrx84nQapp9UsfFY_4_UA:4 a=CjuIK1q_8ugA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p2SBX0aN028064 Subject: RE: [Caml-list] Re: module typing issue Alain Frisch wrote: > On 03/25/2011 08:01 PM, Guillaume Yziquel wrote: > > type error = private int > > > > external get_error : unit -> error = "zzz" > > > > You get some error level that you can pattern match as an int, and > > this also enforces that all values of type error come from a call to > > get_error. > > You need to coerce explicitly from type error to type int (... :> int), so > this is not really different from defining error as an abstract type and > exposing a function error->int. Except that calling an identity function like that requires an optimising compiler to spot that the call is irrelevant and can be removed whereas the coercion is handled (and stripped out) during type inference. So although they're roughly equivalent, the private int approach is "neater" by several orders of magnitude (and as long as you only need an abbreviated coercion, a similar amount of keyboard-typing)! David