From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 7804FBB84 for ; Fri, 18 Jul 2008 04:27:53 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAJqcf0iCNhAB/2dsb2JhbACwAg X-IronPort-AV: E=Sophos;i="4.31,207,1215381600"; d="scan'208";a="27436626" Received: from unknown (HELO kurims.kurims.kyoto-u.ac.jp) ([130.54.16.1]) by mail4-smtp-sop.national.inria.fr with ESMTP; 18 Jul 2008 04:27:52 +0200 Received: from localhost (orion [130.54.16.5]) by kurims.kurims.kyoto-u.ac.jp (8.13.8/8.13.8) with ESMTP id m6I2RjTq012974; Fri, 18 Jul 2008 11:27:45 +0900 (JST) Date: Fri, 18 Jul 2008 11:27:50 +0900 (JST) Message-Id: <20080718.112750.233079116.garrigue@math.nagoya-u.ac.jp> To: darioteixeira@yahoo.com Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Troublesome nodes From: Jacques Garrigue In-Reply-To: <733448.29873.qm@web54602.mail.re2.yahoo.com> References: <20080717.094328.191385811.garrigue@math.nagoya-u.ac.jp> <733448.29873.qm@web54602.mail.re2.yahoo.com> X-Mailer: Mew version 5.2 on Emacs 22.1 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; nodes:01 node:01 node:01 ocaml:01 compiler:01 abbreviation:01 explicitely:01 abbreviation:01 semantics:01 semantics:01 12.:98 abstract:01 abstract:01 syntactic:01 caml-list:01 From: Dario Teixeira > Thanks for the clarification, Jacques. So I guess my initial interpretation > of 'private' was correct. But is 'private' also applicable when a type > is declared using a constraint? In my Node module, for example, type 't' > is declared abstract in the signature: > > type (+'a, 'b) t constraint 'a = [< super_node_t ] > > In the implementation, the type is declared as follows: > > type (+'a, 'b) t = 'a constraint 'a = [< super_node_t ] > > Is it possible in this case to make signature equal to the implementation > except for a 'private' declaration? (Being able to pattern-match on values > of type 't' would be very handy, that is why I would prefer to use 'private' > instead of making the type fully abstract). > > Note: I am running Ocaml 3.11+dev12. Jeremy just sent a message where > he reports that the compiler behaviour in this matter changed between > 3.10 and 3.11. This is indeed possible in 3.11, due to the addition of private abbreviations. Note however that the behaviour of private abbreviations is not as transparent as private types or rows: the only practical difference between an abstract type and a private abbreviation is that you can explicitely coerce from the private abbreviation to its definition. You cannot use pattern matching directly without coercion. So if you write type (+'a, 'b) t = private 'a constraint 'a = [< super_node_t ] then you must write (x : (_,_) t :> [> ]) if you want to use pattern matching on x. Another side-effect of the addition of private abbreviations is that now the distinction between private rows and private abbreviations is syntactic. In particular type (+'a, 'b) t = private 'a constraint 'a = [< super_node_t ] defined a private row in 3.10, but it is a private abbreviation in 3.11 (with of course a different semantics). If you need the private row semantics, you should now write it as type (+a, 'b) t = private [< super_node_t] as 'a which is more intuitive anyway. Jacques Garrigue